From e9f2edea75cbca334cb88c99e2d1e2e75f931982 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 27 Sep 2019 17:24:44 +0200 Subject: [PATCH] Optimize the initial state of the barcode scanner start button if the input element is disabled and make sure it does nothing, if the button is enabled however but the input element is disabled --- public/viewjs/components/barcodescanner.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/public/viewjs/components/barcodescanner.js b/public/viewjs/components/barcodescanner.js index 45a9203e..82d3973e 100644 --- a/public/viewjs/components/barcodescanner.js +++ b/public/viewjs/components/barcodescanner.js @@ -136,6 +136,14 @@ $(document).on("click", "#barcodescanner-start-button", function(e) { e.preventDefault(); + var inputElement = $(e.currentTarget).prev(); + if (inputElement.hasAttr("disabled")) + { + // Do nothing and disable the barcode scanner start button + $(e.currentTarget).addClass("disabled"); + return; + } + bootbox.dialog({ message: '
', title: __t('Scan a barcode'), @@ -164,5 +172,15 @@ $(document).on("click", "#barcodescanner-start-button", function(e) setTimeout(function() { - $(".barcodescanner-input:visible").after(''); + $(".barcodescanner-input:visible").each(function() + { + if ($(this).hasAttr("disabled")) + { + $(this).after(''); + } + else + { + $(this).after(''); + } + }); }, 50);