From a030988baab15e2e3c654d2e5b97e989374fcb7a Mon Sep 17 00:00:00 2001 From: Marian Pollzien Date: Thu, 5 Jun 2014 11:25:12 +0200 Subject: [PATCH] resolves #241: treat number input fields separately, because Chrome doesn't support selectionStart and selectionEnd for them any longer --- js/jquery.keyboard.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/jquery.keyboard.js b/js/jquery.keyboard.js index 0fdd1f33..1fe98394 100644 --- a/js/jquery.keyboard.js +++ b/js/jquery.keyboard.js @@ -170,7 +170,10 @@ $.keyboard = function(el, options){ // save caret position in the input to transfer it to the preview // add delay to get correct caret position setTimeout(function(){ - base.lastCaret = base.$el.caret(); + // Number inputs don't support selectionStart and selectionEnd + if (base.$el.attr('type') != 'number') { + base.lastCaret = base.$el.caret(); + } }, 20); } if (!base.isVisible()) { @@ -329,6 +332,10 @@ $.keyboard = function(el, options){ .addClass('ui-keyboard-preview ' + o.css.input) .attr('tabindex', '-1') .show(); // for hidden inputs + // Switch the number input fields to text so the caret positioning will work again + if (base.$preview.attr('type') == 'number') { + base.$preview.attr('type', 'text'); + } // build preview container and append preview display $('
') .addClass('ui-keyboard-preview-wrapper')