mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 11:27:03 +00:00
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
This commit is contained in:
@@ -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: '<div id="barcodescanner-container" class="col"><div id="barcodescanner-livestream"></div></div>',
|
||||
title: __t('Scan a barcode'),
|
||||
@@ -164,5 +172,15 @@ $(document).on("click", "#barcodescanner-start-button", function(e)
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
$(".barcodescanner-input:visible").after('<a id="barcodescanner-start-button" class="btn btn-sm btn-primary text-white"><i class="fas fa-camera"></i></a>');
|
||||
$(".barcodescanner-input:visible").each(function()
|
||||
{
|
||||
if ($(this).hasAttr("disabled"))
|
||||
{
|
||||
$(this).after('<a id="barcodescanner-start-button" class="btn btn-sm btn-primary text-white disabled"><i class="fas fa-camera"></i></a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).after('<a id="barcodescanner-start-button" class="btn btn-sm btn-primary text-white"><i class="fas fa-camera"></i></a>');
|
||||
}
|
||||
});
|
||||
}, 50);
|
||||
|
Reference in New Issue
Block a user