From: Timo Tijhof Date: Mon, 22 Apr 2013 13:05:31 +0000 (+0200) Subject: wikibits: Replace checkboxShiftClick globals with dummies X-Git-Tag: 1.31.0-rc.0~19560 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=08a42651334c434fe87a44d3b25d27f93ff47635;p=lhc%2Fweb%2Fwiklou.git wikibits: Replace checkboxShiftClick globals with dummies 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 --- diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 1c409d8bc0..1a9aabc776 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -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