diff --git a/share/static/css/elevator-light/misc.css b/share/static/css/elevator-light/misc.css index 6ed4dd5eb1f..ec10f7ab379 100644 --- a/share/static/css/elevator-light/misc.css +++ b/share/static/css/elevator-light/misc.css @@ -183,3 +183,8 @@ ul.ui-autocomplete { .modal.search-results-filter .modal-dialog { margin: 0; } + +/* Enable checkboxes to be selected holding shift key */ +input[type="checkbox"] { + z-index: 1; +} diff --git a/share/static/js/util.js b/share/static/js/util.js index 4fa5bae7ae9..78c3349f764 100644 --- a/share/static/js/util.js +++ b/share/static/js/util.js @@ -237,6 +237,30 @@ function checkboxesToInput(target,checkboxes) { tar.val(emails.join(', ')).change(); } +// Enable multiple checkbox selection holding shift key +jQuery(function () { + var lastCheckedByName = {}; + jQuery('input[type=checkbox]').click(function (event) { + var name = jQuery(this).attr('name'); + if (name) { + // Remove text after "-" from name for better compatibility + name = name.replace(/-.*/, ''); + var lastChecked = lastCheckedByName[name]; + if (event.shiftKey && name) { + if (lastChecked) { + var checkboxes = jQuery('input[type=checkbox][name^=' + name + ']'); + var start = checkboxes.index(this); + var end = checkboxes.index(lastChecked); + checkboxes.slice(Math.min(start, end), + Math.max(start, end) + 1).prop('checked', + this.checked); + } + } + lastCheckedByName[name] = this; + } + }); +}); + // ahah for back compatibility as plugins may still use it function ahah( url, id ) { jQuery('#'+id).load(url);