diff --git a/core/misc/form.js b/core/misc/form.js index b1d1fff..c5e511e 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -10,6 +10,29 @@ return (this[0] && callback) ? $.trim(callback(this[0])) : ''; }; +/**** JS for checkbox ****/ + $.fn.shiftClick = function () { + var lastSelected; // Firefox error: LastSelected is undefined + var checkBoxes = $(this); + this.each(function () { + $(this).click(function (ev) { + if (ev.shiftKey) { + var last = checkBoxes.index(lastSelected); + var first = checkBoxes.index(this); + var start = Math.min(first, last); + var end = Math.max(first, last); + var chk = lastSelected.checked; + for (var i = start; i <= end; i++) { + checkBoxes[i].checked = chk; + } + } else { + lastSelected = this; + } + }) + }); +}; +$('.checkbox .form-checkbox').shiftClick(); + /** * Sets the summary for all matched elements. *