Skip to content

Commit

Permalink
fix tab navigation issue in web_decimal_numpad_dot
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiBForgeFlow committed May 25, 2018
1 parent 6ce6961 commit fb07cf2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion web_decimal_numpad_dot/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{
"name": "Web - Numpad Dot as decimal separator",
"version": "11.0.1.0.1",
"version": "11.0.1.0.2",
"license": "AGPL-3",
"summary": "Allows using numpad dot to enter period decimal separator",
"depends": [
Expand Down
14 changes: 7 additions & 7 deletions web_decimal_numpad_dot/static/src/js/numpad_dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
var NumpadDotReplaceMixin = {
init: function () {
this.events = $.extend({}, this.events, {
"keydown": "numpad_dot_replace",
"keyup": "numpad_dot_replace",
});
return this._super.apply(this, arguments);
},
Expand All @@ -20,7 +20,11 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
},

numpad_dot_replace: function (event) {
String.prototype.replaceAt=function(index, replacement) {
return this.substr(0, index) + replacement + this.substr(index + replacement.length);
}
// Only act on numpad dot key
event.stopPropagation()
if (event.keyCode != 110) {
return;
}
Expand All @@ -29,12 +33,8 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
to = this.$input.prop("selectionEnd"),
cur_val = this.$input.val(),
point = this.l10n_decimal_point();
// Replace selected text by proper character
this.$input.val(
cur_val.substring(0, from) +
point +
cur_val.substring(to)
);
var new_val = cur_val.replaceAt(from-1, point)
this.$input.val(new_val);
// Put user caret in place
to = from + point.length
this.$input.prop("selectionStart", to).prop("selectionEnd", to);
Expand Down

0 comments on commit fb07cf2

Please sign in to comment.