Skip to content

Commit

Permalink
resolves Mottie#241: treat number input fields separately, because Ch…
Browse files Browse the repository at this point in the history
…rome doesn't support selectionStart and selectionEnd for them any longer
  • Loading branch information
Marian Pollzien committed Jun 5, 2014
1 parent bd3436d commit a030988
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/jquery.keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
$('<div />')
.addClass('ui-keyboard-preview-wrapper')
Expand Down

0 comments on commit a030988

Please sign in to comment.