From 070771c077d19a5ebce320041360f83234680ccd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 8 Jun 2022 10:16:15 +0200 Subject: [PATCH] select with shift chromium --- ereuse_devicehub/static/js/main_inventory.js | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index f59bf588..55b6900a 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -13,7 +13,8 @@ $(document).ready(() => { newTrade(show_trade_form); } else { $(".deviceSelect").on("change", deviceSelect); - } + }; + select_shift(); // $('#selectLot').selectpicker(); }) @@ -229,6 +230,27 @@ function addTag() { $("#addTagAlertModal").click(); } +function select_shift() { + const chkboxes = $('.deviceSelect'); + lastChecked = null; + chkboxes.click(function(e) { + if (!lastChecked) { + lastChecked = this; + return; + } + + if (e.shiftKey) { + var start = chkboxes.index(this); + var end = chkboxes.index(lastChecked); + + chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', lastChecked.checked); + } + + lastChecked = this; + }); + selectorController("softInit"); +} + function newTrade(action) { let title = "Trade " const user_to = $("#user_to").data("email");