Pop up info about a resource, coodrinates are coming from Manifold (hardcoded or...
[unfold.git] / portal / static / js / institution.js
index 1ddb3e3..173021f 100644 (file)
@@ -1,26 +1,21 @@
 $(document).ready(function() {
-       $('li#nav-institution').addClass("active");
+       loadedTabs = [];
+       
+       $('.nav-tabs a').click(function (e) {
+               e.preventDefault();
+               $(this).tab('show');
+               id = $(this).attr('href').substr(1);
+               if (!(id in loadedTabs)) {
+                       switch(id) {
+                               case 'users':
+                                       //loadUsers();
+                                       loadedTabs[id] = true;
+                               break;
+                       }
+               }
+               
+       });
 
-    $('a.home-tab').click(function() {
-        $('ul.nav-tabs li').removeClass('active');
-        $(this).parent().addClass('active');
-        $('div.home-panel').hide();
-        $('div#'+$(this).data('panel')).show();
-    });
-    var url = window.location;
-    if(url.hash) {
-        // Fragment exists 
-        tab = url.href.split("#")[1];
-        tab_exists = $('div#'+tab).length;
-        if (tab_exists) {
-           $('ul.nav-tabs li').removeClass('active');
-           $('li#'+tab+'-tab').addClass('active');
-           $('div.home-panel').hide();            
-           $('div#'+tab).show();
-        }
-    }
-
-    /* TODO: factorize into functions */
     $('button#deleteusers').click(function() {
         $('input:checkbox.user').each(function (index) {
             if(this.checked){
@@ -29,14 +24,17 @@ $(document).ready(function() {
                     if(data.success){
                         $('tr[id="'+record_id+'"]').fadeOut("slow");
                         $('tr[id="'+record_id+'"]').remove();
+                        mysliceAlert('Success: user deleted','success', true);
                     }else{
-                        alert("Rest Error for "+record_id+": "+data.error);
-                    }
-                });
-                
-            }
+                        mysliceAlert('Rest Error for: '+data.error,'warning', true);
+                        //alert("Rest Error for "+record_id+": "+data.error);
+                    }   
+                });     
+            } 
         });
     });
+
+    /* TODO: factorize into functions */
     $('button#deleteslices').click(function() {
         $('input:checkbox.slice').each(function (index) {
             if(this.checked){
@@ -45,11 +43,12 @@ $(document).ready(function() {
                     if(data.success){
                         $('tr[id="'+record_id+'"]').fadeOut("slow");
                         $('tr[id="'+record_id+'"]').remove();
+                        mysliceAlert('Success: slice deleted','success', true);
                     }else{
-                        alert("Rest Error for "+record_id+": "+data.error);
+                        mysliceAlert('Rest Error for: '+data.error,'warning', true);
+                        //alert("Rest Error for "+record_id+": "+data.error);
                     }
                 });
-                
             }
         });
     });
@@ -66,8 +65,10 @@ $(document).ready(function() {
                     if(data.success){
                         // TODO: highlight row after success
                         //$('tr[id="'+record_id+'"]').highlight();
+                        mysliceAlert('Success: slice renewed','success', true);
                     }else{
-                        alert("Rest Error for "+record_id+": "+data.error);
+                        mysliceAlert('Rest Error for: '+data.error,'warning', true);
+                        //alert("Rest Error for "+record_id+": "+data.error);
                     }
                 });
                 
@@ -86,3 +87,13 @@ $(document).ready(function() {
         */
     });
 });
+
+/*function loadUsers() {
+       $('div#users table').load('/table/user/',
+               {
+                       'fields'  : [ 'user_hrn', 'user_first_name', 'user_last_name', 'user_email', 'user_phone' ],
+                       'filters' : { 'parent_authority' : $('div#users').data('authority') },
+                       'options' : [ 'checkbox' ]
+               }
+       );
+}*/