diff --git a/tailbone/static/js/tailbone.mobile.js b/tailbone/static/js/tailbone.mobile.js index d603643f..4bcb54db 100644 --- a/tailbone/static/js/tailbone.mobile.js +++ b/tailbone/static/js/tailbone.mobile.js @@ -102,11 +102,31 @@ $(document).on('click', '#datasync-restart', function() { }); - -// handle Enter press for receiving UPC lookup -$(document).on('keydown', '.receiving-upc-search', function(event) { - if (event.which == 13) { - $.mobile.navigate($(this).data('url') + '?upc=' + $(this).val()); +// handle global keypress on receiving "row" page, for sake of scanner wedge +$(document).on('keypress', 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 (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; + } + } } }); diff --git a/tailbone/templates/mobile/base.mako b/tailbone/templates/mobile/base.mako index 9fb83942..dd5cfa11 100644 --- a/tailbone/templates/mobile/base.mako +++ b/tailbone/templates/mobile/base.mako @@ -94,7 +94,7 @@ <%def name="mobile_page_body()"> -
+
% if request.session.peek_flash('error'): % for error in request.session.pop_flash('error'):