/[drupal]/contributions/modules/blockbar/blockbar.js
ViewVC logotype

Diff of /contributions/modules/blockbar/blockbar.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Fri Nov 4 18:05:28 2005 UTC revision 1.2, Tue Jan 30 20:56:49 2007 UTC
# Line 17  function blockbar_toggle( targetId, bloc Line 17  function blockbar_toggle( targetId, bloc
17          if (document.getElementById(block_id) && (block_id != targetId )){          if (document.getElementById(block_id) && (block_id != targetId )){
18            if (document.getElementById(block_id).style.display!="none") {            if (document.getElementById(block_id).style.display!="none") {
19              var head2= document.getElementById("blockbarhead_"+block_id);              var head2= document.getElementById("blockbarhead_"+block_id);
20              toggleClass(head2, 'collapse');              blockbar_toggleClass(head2, 'collapse');
21              document.getElementById(block_id).style.display="none"              document.getElementById(block_id).style.display="none"
22            }            }
23          }          }
24        }        }
25      }      }
26      toggleClass(head, 'collapse');      blockbar_toggleClass(head, 'collapse');
27      if ( target.style.display == "none" ) {      if ( target.style.display == "none" ) {
28        target.style.display = "";        target.style.display = "";
29      } else {      } else {
# Line 93  function blockbar_save_state(){ Line 93  function blockbar_save_state(){
93    }    }
94  }  }
95    
96  if (isJsEnabled()) {  // Global Killswitch
97    addLoadEvent(blockbar_onload);  if (Drupal.jsEnabled) {
98      $(document).ready(blockbar_onload);
99    if (document.getElementById)    if (document.getElementById)
100      window.onunload=blockbar_save_state      window.onunload=blockbar_save_state
101  }  }
102    
103    function blockbar_toggleClass(node, className) {
104      if (!blockbar_removeClass(node, className) && !blockbar_addClass(node, className)) {
105        return false;
106      }
107      return true;
108    }
109    
110    function blockbar_addClass(node, className) {
111      if (blockbar_hasClass(node, className)) {
112        return false;
113      }
114      node.className += ' '+ className;
115      return true;
116    }
117    
118    function blockbar_removeClass(node, className) {
119      if (!blockbar_hasClass(node, className)) {
120        return false;
121      }
122      // Replaces words surrounded with whitespace or at a string border with a space. Prevents multiple class names from being glued together.
123      node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
124      return true;
125    }
126    
127    function blockbar_hasClass(node, className) {
128      if (node.className == className) {
129        return true;
130      }
131      var reg = new RegExp('(^| )'+ className +'($| )')
132      if (reg.test(node.className)) {
133        return true;
134      }
135      return false;
136    }
137    
138    function eregReplace(search, replace, subject) {
139      return subject.replace(new RegExp(search,'g'), replace);
140    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2