wikibits: Replace checkboxShiftClick globals with dummies
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 22 Apr 2013 13:05:31 +0000 (15:05 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 28 May 2013 23:19:17 +0000 (00:19 +0100)
They have been deprecated in favour of jquery.checkboxShiftClick for
many releases now (since MediaWiki 1.17) and aren't used anywhere in
MediaWiki core (or extensions that I know of).

Though removal is justified, given the slow pace at which the tour[1]
is progressing and the amount of garbage I still find on a daily basis,
I'm replacing them with dummies instead and marking the dummies as
deprecated for easier tracking.

[1] https://meta.wikimedia.org/wiki/User:Krinkle/Le_Tour_de_Wik%C3%AD/2011_Resource_Walker

Change-Id: I72aac6111b9be974f160fecad8312c49c9460c5b

skins/common/wikibits.js

index 1c409d8..1a9aabc 100644 (file)
@@ -296,71 +296,21 @@ window.getInnerText = function( el ) {
        return str;
 };
 
-window.checkboxes = undefined;
-window.lastCheckbox = undefined;
-
-window.setupCheckboxShiftClick = function() {
-       checkboxes = [];
-       lastCheckbox = null;
-       var inputs = document.getElementsByTagName( 'input' );
-       addCheckboxClickHandlers( inputs );
-};
-
-window.addCheckboxClickHandlers = function( 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' || ( ' ' + cb.className + ' ' ).indexOf( ' noshiftselect ' )  != -1 ) {
-                       continue;
-               }
-               var end = checkboxes.length;
-               checkboxes[end] = cb;
-               cb.index = end;
-               addClickHandler( cb, checkboxClickHandler );
-       }
-
-       if ( finish < inputs.length ) {
-               setTimeout( function() {
-                       addCheckboxClickHandlers( inputs, finish );
-               }, 200 );
-       }
-};
-
-window.checkboxClickHandler = function( e ) {
-       if ( typeof e == 'undefined' ) {
-               e = window.event;
-       }
-       if ( !e.shiftKey || lastCheckbox === null ) {
-               lastCheckbox = this.index;
-               return true;
-       }
-       var endState = this.checked;
-       var start, finish;
-       if ( this.index < lastCheckbox ) {
-               start = this.index + 1;
-               finish = lastCheckbox;
-       } else {
-               start = lastCheckbox;
-               finish = this.index - 1;
-       }
-       for ( var i = start; i <= finish; ++i ) {
-               checkboxes[i].checked = endState;
-               if( i > start && typeof checkboxes[i].onchange == 'function' ) {
-                       checkboxes[i].onchange(); // fire triggers
-               }
-       }
-       lastCheckbox = this.index;
-       return true;
-};
-
+/**
+ * Toggle checkboxes with shift selection.
+ * To be removed in MediaWiki 1.23.
+ *
+ * @deprecated since 1.17 Use jquery.checkboxShiftClick instead.
+ */
+$.each({
+       checkboxes: [],
+       lastCheckbox: null,
+       setupCheckboxShiftClick: $.noop,
+       addCheckboxClickHandlers: $.noop,
+       checkboxClickHandler: $.noop
+}, function ( key, val ) {
+       mw.log.deprecate( window, key, val, 'Use jquery.checkboxShiftClick instead.' );
+} );
 
 /*
        Written by Jonathan Snook, http://www.snook.ca/jonathan