fix tab navigation issue in web_decimal_numpad_dot

pull/1933/head
Jordi Ballester Alomar 2018-05-25 13:36:26 +02:00 committed by João Marques
parent 5a5cedce01
commit b5fe81f23f
3 changed files with 22 additions and 8 deletions

View File

@ -8,7 +8,7 @@
{ {
"name": "Web - Numpad Dot as decimal separator", "name": "Web - Numpad Dot as decimal separator",
"version": "11.0.1.0.1", "version": "11.0.1.0.2",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Allows using numpad dot to enter period decimal separator", "summary": "Allows using numpad dot to enter period decimal separator",
"depends": [ "depends": [

View File

@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@ -9,7 +9,7 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
var NumpadDotReplaceMixin = { var NumpadDotReplaceMixin = {
init: function () { init: function () {
this.events = $.extend({}, this.events, { this.events = $.extend({}, this.events, {
"keydown": "numpad_dot_replace", "keyup": "numpad_dot_replace",
}); });
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
}, },
@ -20,7 +20,11 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
}, },
numpad_dot_replace: function (event) { 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 // Only act on numpad dot key
event.stopPropagation()
if (event.keyCode != 110) { if (event.keyCode != 110) {
return; return;
} }
@ -29,12 +33,8 @@ odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
to = this.$input.prop("selectionEnd"), to = this.$input.prop("selectionEnd"),
cur_val = this.$input.val(), cur_val = this.$input.val(),
point = this.l10n_decimal_point(); point = this.l10n_decimal_point();
// Replace selected text by proper character var new_val = cur_val.replaceAt(from-1, point)
this.$input.val( this.$input.val(new_val);
cur_val.substring(0, from) +
point +
cur_val.substring(to)
);
// Put user caret in place // Put user caret in place
to = from + point.length to = from + point.length
this.$input.prop("selectionStart", to).prop("selectionEnd", to); this.$input.prop("selectionStart", to).prop("selectionEnd", to);