Fix: autofocus is done only on dekstop.

This commit is contained in:
Laurent Destailleur 2019-03-28 19:33:22 +01:00
parent 8d9a07de09
commit 2996965c50
2 changed files with 25 additions and 9 deletions

View File

@ -205,11 +205,13 @@ $action_buttons = array(
"function" =>"reset()", "function" =>"reset()",
"span" => "style='font-size: 150%;'", "span" => "style='font-size: 150%;'",
"text" => "C", "text" => "C",
"class" => "poscolorblue"
), ),
array( array(
"function" => "parent.$.colorbox.close();", "function" => "parent.$.colorbox.close();",
"span" => "id='printtext'", "span" => "id='printtext'",
"text" => $langs->trans("Cancel"), "text" => $langs->trans("Cancel"),
"class" => "poscolordelete"
), ),
); );
$numpad=$conf->global->TAKEPOS_NUMPAD; $numpad=$conf->global->TAKEPOS_NUMPAD;
@ -271,8 +273,9 @@ while($i < count($paiements)){
} }
$class=($i==3)?"calcbutton3":"calcbutton2"; $class=($i==3)?"calcbutton3":"calcbutton2";
foreach($action_buttons as $button){ foreach($action_buttons as $button){
$newclass = $class.($button["class"]?" ".$button["class"]:"");
?> ?>
<button type="button" class="<?php echo $class;?>" onclick="<?php echo $button["function"];?>"><span <?php echo $button["span"];?>><?php echo $button["text"];?></span></button> <button type="button" class="<?php echo $newclass;?>" onclick="<?php echo $button["function"];?>"><span <?php echo $button["span"];?>><?php echo $button["text"];?></span></button>
<?php <?php
} }
?> ?>

View File

@ -135,6 +135,13 @@ function PrintCategories(first) {
} }
} }
// Set the focus on search field but only on desktop. On tablet or smartphone, we don't to avoid to have the keyboard open automatically
function setFocusOnSearchField() {
<?php if ($conf->browser->layout == 'classic') { ?>
$("#search").focus();
<?php } ?>
}
function MoreCategories(moreorless) { function MoreCategories(moreorless) {
console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories); console.log("MoreCategories moreorless="+moreorless+" pagecategories="+pagecategories);
if (moreorless=="more") { if (moreorless=="more") {
@ -165,7 +172,7 @@ function MoreCategories(moreorless) {
$("#catwatermark"+i).show(); $("#catwatermark"+i).show();
} }
$("#search").focus(); setFocusOnSearchField();
} }
function LoadProducts(position, issubcat=false) { function LoadProducts(position, issubcat=false) {
@ -218,7 +225,7 @@ function LoadProducts(position, issubcat=false) {
} }
}); });
$("#search").focus(); setFocusOnSearchField();
} }
function MoreProducts(moreorless) { function MoreProducts(moreorless) {
@ -266,7 +273,7 @@ function MoreProducts(moreorless) {
} }
}); });
$("#search").focus(); setFocusOnSearchField();
} }
function ClickProduct(position) { function ClickProduct(position) {
@ -286,7 +293,8 @@ function ClickProduct(position) {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
}); });
} }
$("#search").focus();
setFocusOnSearchField();
} }
function deleteline() { function deleteline() {
@ -331,7 +339,9 @@ function Refresh() {
function ClearSearch() { function ClearSearch() {
console.log("ClearSearch"); console.log("ClearSearch");
$("#search").val('').focus(); $("#search").val('');
setFocusOnSearchField();
} }
function Search2() { function Search2() {
@ -372,7 +382,8 @@ function Edit(number) {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#qty").html("<?php echo $langs->trans("Qty"); ?>"); $("#qty").html("<?php echo $langs->trans("Qty"); ?>");
}); });
$("#search").focus();
setFocusOnSearchField();
return; return;
} }
else { else {
@ -387,7 +398,8 @@ function Edit(number) {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#price").html("<?php echo $langs->trans("Price"); ?>"); $("#price").html("<?php echo $langs->trans("Price"); ?>");
}); });
$("#search").focus();
setFocusOnSearchField();
return; return;
} }
else { else {
@ -402,7 +414,8 @@ function Edit(number) {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight); //$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
$("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>"); $("#reduction").html("<?php echo $langs->trans("ReductionShort"); ?>");
}); });
$("#search").focus();
setFocusOnSearchField();
return; return;
} }
else { else {