Skip to content

Commit

Permalink
Close password demo on second click. Fixes #336
Browse files Browse the repository at this point in the history
Also save last eventTime on visible, in case the stayOpen option is true
  • Loading branch information
Mottie committed Mar 11, 2015
1 parent b2bf0af commit adae055
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion docs/js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ jQuery(function($) {
layout : 'qwerty'
});
$('#passwd').click(function(){
$('.qwerty:eq(1)').getkeyboard().reveal();
var kb = $('.qwerty:eq(1)').getkeyboard();
// close the keyboard if the keyboard is visible and the button is clicked a second time
if ( kb.isOpen ) {
kb.close();
} else {
kb.reveal();
}
});
// since IE adds an overlay behind the input to prevent clicking in other inputs (the keyboard may not automatically open on focus... silly IE bug)
// We can remove the overlay (transparent) if desired using this code:
Expand Down
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ <h4>Script</h4>
.addTyping();

$('#passwd').click(function(){
$('.qwerty:eq(1)').getkeyboard().reveal();
var kb = $('.qwerty:eq(1)').getkeyboard();
// close the keyboard if the keyboard is visible and the button is clicked a second time
if ( kb.isOpen ) {
kb.close();
} else {
kb.reveal();
}
});</pre>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions js/jquery.keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ var $keyboard = $.keyboard = function(el, options){
if (o.initialFocus) {
$keyboard.caret( base.$preview, base.last );
}
// save event time for keyboards with stayOpen: true
base.last.eventTime = new Date().getTime();
base.$el.trigger( $keyboard.events.kbVisible, [ base, base.el ] );
base.timer = setTimeout(function(){
// get updated caret information after visible event - fixes #331
Expand Down

0 comments on commit adae055

Please sign in to comment.