Make setupCheckboxShiftClick() process all checkboxes, not just those in ULs. This...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Mon, 15 Jan 2007 04:28:07 +0000 (04:28 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Mon, 15 Jan 2007 04:28:07 +0000 (04:28 +0000)
includes/DefaultSettings.php
skins/common/wikibits.js

index 46f9ce6..2587413 100644 (file)
@@ -1105,7 +1105,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '47';
+$wgStyleVersion = '48';
 
 
 # Server-side caching:
index 06a07d1..c6c8fc7 100644 (file)
@@ -689,48 +689,35 @@ function addRightClickEditHandler(el) {
        }
 }
 
+var checkboxes;
+var lastCheckbox;
+
 function setupCheckboxShiftClick() {
-       if (document.getElementsByTagName) {
-               var uls = document.getElementsByTagName('ul');
-               var len = uls.length;
-               for (var i = 0; i < len; ++i) {
-                       addCheckboxClickHandlers(uls[i]);
-               }
-       }
+       checkboxes = [];
+       lastCheckbox = null;
+       var inputs = document.getElementsByTagName('input');
+       addCheckboxClickHandlers(inputs);
 }
 
-function addCheckboxClickHandlers(ul, start, finish) {
-       if (ul.checkboxHandlersTimer) {
-               clearInterval(ul.checkboxHandlersTimer);
-       }
-       if ( !ul.childNodes ) {
-               return;
-       }
-       var len = ul.childNodes.length;
-       if (len < 2) {
-               return;
-       }
-       start = start || 0;
-       finish = finish || start + 250;
-       if ( finish > len ) { finish = len; }
-       ul.checkboxes = ul.checkboxes || [];
-       ul.lastCheckbox = ul.lastCheckbox || null;
-       for (var i = start; i<finish; ++i) {
-               var child = ul.childNodes[i];
-               if ( child && child.childNodes && child.childNodes[0] ) {
-                       var cb = child.childNodes[0];
-                       if ( !cb.nodeName || cb.nodeName.toLowerCase() != 'input' ||
-                            !cb.type || cb.type.toLowerCase() != 'checkbox' ) {
-                               return;
-                       }
-                       cb.index = ul.checkboxes.push(cb) - 1;
-                       cb.container = ul;
-                       cb.onmouseup = checkboxMouseupHandler;
-               }
+function addCheckboxClickHandlers(inputs, start) {
+       if ( !start) start = 0;
+
+       var finish = start + 250;
+       if ( finish > inputs.length )
+               finish = inputs.length;
+
+       for ( var i = start; i < finish; i++ ) {
+               var cb = inputs[i];
+               if ( !cb.type || cb.type.toLowerCase() != 'checkbox' )
+                       continue;
+               cb.index = checkboxes.push(cb) - 1;
+               cb.onmouseup = checkboxMouseupHandler;
        }
-       if (finish < len) {
-         var f=function(){ addCheckboxClickHandlers(ul, finish, finish+250); };
-         ul.checkboxHandlersTimer=setInterval(f, 200);
+
+       if ( finish < inputs.length ) {
+               setTimeout( function () {
+                       addCheckboxClickHandlers(inputs, finish);
+               }, 200 );
        }
 }
 
@@ -738,8 +725,8 @@ function checkboxMouseupHandler(e) {
        if (typeof e == 'undefined') {
                e = window.event;
        }
-       if ( !e.shiftKey || this.container.lastCheckbox === null ) {
-               this.container.lastCheckbox = this.index;
+       if ( !e.shiftKey || lastCheckbox === null ) {
+               lastCheckbox = this.index;
                return true;
        }
        var endState = !this.checked;
@@ -747,17 +734,17 @@ function checkboxMouseupHandler(e) {
                endState = !endState;
        }
        var start, finish;
-       if ( this.index < this.container.lastCheckbox ) {
+       if ( this.index < lastCheckbox ) {
                start = this.index + 1;
-               finish = this.container.lastCheckbox;
+               finish = lastCheckbox;
        } else {
-               start = this.container.lastCheckbox;
+               start = lastCheckbox;
                finish = this.index - 1;
        }
        for (var i = start; i <= finish; ++i ) {
-               this.container.checkboxes[i].checked = endState;
+               checkboxes[i].checked = endState;
        }
-       this.container.lastCheckbox = this.index;
+       lastCheckbox = this.index;
        return true;
 }