Add global key handler for mobile receiving, for scanner wedge input
this way we don't have to focus the UPC search box, since that seems to always popup the device keyboard.
This commit is contained in:
parent
bf3d7b9143
commit
48f5da4511
|
@ -102,11 +102,31 @@ $(document).on('click', '#datasync-restart', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// handle global keypress on receiving "row" page, for sake of scanner wedge
|
||||||
// handle Enter press for receiving UPC lookup
|
$(document).on('keypress', function(event) {
|
||||||
$(document).on('keydown', '.receiving-upc-search', function(event) {
|
if ($('.ui-page-active [role="main"]').data('route') == 'mobile.receiving.view') {
|
||||||
|
var upc = $('#upc-search');
|
||||||
|
if (upc.length) {
|
||||||
|
if (upc.is(':focus')) {
|
||||||
if (event.which == 13) {
|
if (event.which == 13) {
|
||||||
$.mobile.navigate($(this).data('url') + '?upc=' + $(this).val());
|
if (upc.val()) {
|
||||||
|
$.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (event.which >= 48 && event.which <= 57) { // numeric (qwerty)
|
||||||
|
upc.val(upc.val() + event.key);
|
||||||
|
// TODO: these codes are correct for 'keydown' but apparently not 'keypress' ?
|
||||||
|
// } else if (event.which >= 96 && event.which <= 105) { // numeric (10-key)
|
||||||
|
// upc.val(upc.val() + event.key);
|
||||||
|
} else if (event.which == 13) {
|
||||||
|
if (upc.val()) {
|
||||||
|
$.mobile.navigate(upc.data('url') + '?upc=' + upc.val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="mobile_page_body()">
|
<%def name="mobile_page_body()">
|
||||||
<div role="main" class="ui-content">
|
<div role="main" class="ui-content" data-route="${request.matched_route.name}">
|
||||||
|
|
||||||
% if request.session.peek_flash('error'):
|
% if request.session.peek_flash('error'):
|
||||||
% for error in request.session.pop_flash('error'):
|
% for error in request.session.pop_flash('error'):
|
||||||
|
|
Loading…
Reference in a new issue