Index: trunk/phase3/resources/jquery/jquery.checkboxShiftClick.js |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +/** |
| 3 | + * jQuery checkboxShiftClick |
| 4 | + * |
| 5 | + * This will enable checkboxes to be checked or unchecked in a row by clicking one, holding shift and clicking another one |
| 6 | + * |
| 7 | + * @author Krinkle <krinklemail@gmail.com> |
| 8 | + * @license GPL v2 |
| 9 | + */ |
| 10 | + |
| 11 | +jQuery.fn.checkboxShiftClick = function( text ) { |
| 12 | + var prevCheckbox = null; |
| 13 | + var $box = this; |
| 14 | + // When our boxes are clicked.. |
| 15 | + $box.click(function (e) { |
| 16 | + // And one has been clicked before... |
| 17 | + if (prevCheckbox !== null && e.shiftKey) { |
| 18 | + // Check or uncheck this one and all in-between checkboxes |
| 19 | + $box.slice( |
| 20 | + Math.min($box.index(prevCheckbox), $box.index(e.target)), |
| 21 | + Math.max($box.index(prevCheckbox), $box.index(e.target)) + 1 |
| 22 | + ).attr({checked: e.target.checked ? 'checked' : ''}); |
| 23 | + } |
| 24 | + // Either way, update the prevCheckbox variable to the one clicked now |
| 25 | + prevCheckbox = e.target; |
| 26 | + }); |
| 27 | + return $box; |
| 28 | +}; |
\ No newline at end of file |
Property changes on: trunk/phase3/resources/jquery/jquery.checkboxShiftClick.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 29 | + native |
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -26,22 +26,6 @@ |
27 | 27 | this.tooltipAccessKeyPrefix = 'alt-shift-'; |
28 | 28 | } |
29 | 29 | |
30 | | - // Setup CheckboxShiftClick |
31 | | - $.fn.enableCheckboxShiftClick = function () { |
32 | | - var prevCheckbox = null; |
33 | | - var $box = this; |
34 | | - $box.click(function (e) { |
35 | | - if (prevCheckbox !== null && e.shiftKey) { |
36 | | - $box.slice( |
37 | | - Math.min($box.index(prevCheckbox), $box.index(e.target)), |
38 | | - Math.max($box.index(prevCheckbox), $box.index(e.target)) + 1 |
39 | | - ).attr({checked: e.target.checked ? 'checked' : ''}); |
40 | | - } |
41 | | - prevCheckbox = e.target; |
42 | | - }); |
43 | | - return $box; |
44 | | - }; |
45 | | - |
46 | 30 | // Prototype enhancements |
47 | 31 | if (typeof String.prototype.ucFirst === 'undefined') { |
48 | 32 | String.prototype.ucFirst = function () { |
— | — | @@ -53,7 +37,7 @@ |
54 | 38 | $(function () { |
55 | 39 | |
56 | 40 | // Enable CheckboxShiftClick |
57 | | - $('input[type=checkbox]:not(.noshiftselect)').enableCheckboxShiftClick(); |
| 41 | + $('input[type=checkbox]:not(.noshiftselect)').checkboxShiftClick(); |
58 | 42 | |
59 | 43 | // Fill bodyContant var |
60 | 44 | if ($('#bodyContent').length) { |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -35,6 +35,9 @@ |
36 | 36 | 'jquery.autoEllipsis' => new ResourceLoaderFileModule( |
37 | 37 | array( 'scripts' => 'resources/jquery/jquery.autoEllipsis.js' ) |
38 | 38 | ), |
| 39 | + 'jquery.checkboxShiftClick' => new ResourceLoaderFileModule( |
| 40 | + array( 'scripts' => 'resources/jquery/jquery.checkboxShiftClick.js' ) |
| 41 | + ), |
39 | 42 | 'jquery.client' => new ResourceLoaderFileModule( |
40 | 43 | array( 'scripts' => 'resources/jquery/jquery.client.js' ) |
41 | 44 | ), |
— | — | @@ -378,6 +381,7 @@ |
379 | 382 | ) ), |
380 | 383 | 'mediawiki.util' => new ResourceLoaderFileModule( array( |
381 | 384 | 'scripts' => 'resources/mediawiki.util/mediawiki.util.js', |
| 385 | + 'dependencies' => 'jquery.checkboxShiftClick', |
382 | 386 | 'debugScripts' => 'resources/mediawiki.util/mediawiki.util.test.js', |
383 | 387 | ) ), |
384 | 388 | |