Skip to content

Commit

Permalink
Merge pull request #279 from friend8/master
Browse files Browse the repository at this point in the history
resolves #241: treat number input fields separately, because Chrome does...
  • Loading branch information
Mottie committed Jun 13, 2014
2 parents bd3436d + b9f682a commit e402138
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 e402138

Please sign in to comment.