summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/barcodes/static/src')
-rw-r--r--addons/barcodes/static/src/js/barcode_events.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/addons/barcodes/static/src/js/barcode_events.js b/addons/barcodes/static/src/js/barcode_events.js
index a2e5808f8be..2d602a36b97 100644
--- a/addons/barcodes/static/src/js/barcode_events.js
+++ b/addons/barcodes/static/src/js/barcode_events.js
@@ -64,12 +64,14 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
'position': 'fixed',
'top': '50%',
'transform': 'translateY(-50%)',
- 'opacity': 0,
+ 'z-index': '-1',
},
});
+ // Avoid to show autocomplete for a non appearing input
+ this.$barcodeInput.attr('autocomplete', 'off');
}
- this.__removeBarcodeField = _.debounce(this._removeBarcodeField, this.inputTimeOut);
+ this.__blurBarcodeInput = _.debounce(this._blurBarcodeInput, this.inputTimeOut);
},
handle_buffered_keys: function() {
@@ -232,7 +234,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
this.max_time_between_keys_in_ms);
}
// if the barcode input doesn't receive keydown for a while, remove it.
- this.__removeBarcodeField();
+ this.__blurBarcodeInput();
}
},
@@ -247,21 +249,22 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
var barcodeValue = this.$barcodeInput.val();
if (barcodeValue.match(this.regexp)) {
core.bus.trigger('barcode_scanned', barcodeValue, $(e.target).parent()[0]);
- this.$barcodeInput.val('');
+ this._blurBarcodeInput();
}
},
/**
- * Remove the temporary input created to store the barcode value.
- * If nothing happens, this input will be removed, so the focus will be lost
- * and the virtual keyboard on mobile devices will be closed.
+ * Removes the value and focus from the barcode input.
+ * If nothing happens, the focus will be lost and
+ * the virtual keyboard on mobile devices will be closed.
*
* @private
*/
- _removeBarcodeField: function () {
+ _blurBarcodeInput: function () {
if (this.$barcodeInput) {
- // Reset the value and remove from the DOM.
- this.$barcodeInput.val('').remove();
+ // Close the virtual keyboard on mobile browsers
+ // FIXME: actually we can't prevent keyboard from opening
+ this.$barcodeInput.val('').blur();
}
},