From 3d097e9d54132f96d36b55d63c6ead8bbfb1f0b4 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Sun, 17 Jun 2012 17:34:09 -0500 Subject: [PATCH] Clicking accept in IE will now close the keyboard. Fixes #72 --- js/jquery.keyboard.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/jquery.keyboard.js b/js/jquery.keyboard.js index 1e67defb..0b25f82c 100644 --- a/js/jquery.keyboard.js +++ b/js/jquery.keyboard.js @@ -736,12 +736,16 @@ $.keyboard = function(el, options){ .trigger( (o.alwaysOpen) ? '' : 'beforeClose.keyboard', [ base, base.el, (accepted || false) ] ) .val( val ) .scrollTop( base.el.scrollHeight ) - .blur() .trigger( ((accepted || false) ? 'accepted.keyboard' : 'canceled.keyboard'), [ base, base.el ] ) - .trigger( (o.alwaysOpen) ? 'inactive.keyboard' : 'hidden.keyboard', [ base, base.el ] ); + .trigger( (o.alwaysOpen) ? 'inactive.keyboard' : 'hidden.keyboard', [ base, base.el ] ) + .blur(); if (o.openOn) { - // rebind input focus - base.$el.bind( o.openOn + '.keyboard', function(){ base.focusOn(); }); + // rebind input focus - delayed to fix IE issue #72 + base.timer = setTimeout(function(){ + base.$el.bind( o.openOn + '.keyboard', function(){ base.focusOn(); }); + // remove focus from element (needed for IE since blur doesn't seem to work) + if ($(':focus')[0] === base.el) { base.$el.blur(); } + }, 100); } if (!o.alwaysOpen) { base.$keyboard.hide(); @@ -1002,7 +1006,7 @@ $.keyboard = function(el, options){ base.destroy = function() { $(document).unbind('mousedown.keyboard keyup.keyboard'); if (base.$keyboard) { base.$keyboard.remove(); } - var unb = $.trim(o.openOn + ' accepted beforeClose blur canceled change contextmenu hidden initialized keydown keypress keyup visible').split(' ').join('.keyboard '); + var unb = $.trim(o.openOn + ' accepted beforeClose canceled change contextmenu hidden initialized keydown keypress keyup visible').split(' ').join('.keyboard '); base.$el .removeClass('ui-keyboard-input ui-keyboard-lockedinput ui-keyboard-placeholder ui-keyboard-notallowed ui-keyboard-always-open ' + o.css.input) .removeAttr('aria-haspopup')