diff options
author | Trent Richardson <trentdrichardson@gmail.com> | 2013-08-27 16:14:50 -0400 |
---|---|---|
committer | Trent Richardson <trentdrichardson@gmail.com> | 2013-08-27 16:14:50 -0400 |
commit | 2d2574248b9bdc16df03dc7bdb423a6e290605cf (patch) | |
tree | 28a90e7a74deb4b1c68e64ebe16b53b5cc0fa26b | |
parent | dc663077c11421a4d173497f854afc62b1a37643 (diff) | |
download | jQuery-Impromptu-2d2574248b9bdc16df03dc7bdb423a6e290605cf.zip jQuery-Impromptu-2d2574248b9bdc16df03dc7bdb423a6e290605cf.tar.gz jQuery-Impromptu-2d2574248b9bdc16df03dc7bdb423a6e290605cf.tar.bz2 |
Fix issue #11 timeout doesnt call close event, timeouts overlap prompts
-rw-r--r-- | jquery-impromptu.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/jquery-impromptu.js b/jquery-impromptu.js index 014ba90..2532977 100644 --- a/jquery-impromptu.js +++ b/jquery-impromptu.js @@ -27,6 +27,12 @@ $.prompt.options = $.extend({},$.prompt.defaults,options);
$.prompt.currentPrefix = $.prompt.options.prefix;
+
+ // Be sure any previous timeouts are destroyed
+ if($.prompt.timeout){
+ clearTimeout($.prompt.timeout);
+ }
+ $.prompt.timeout = false;
var opts = $.prompt.options,
$body = $(document.body),
@@ -184,14 +190,16 @@ .on('impromptu:statechanging', opts.statechanging)
.on('impromptu:statechanged', opts.statechanged);
- //Show it
+ // Show it
$.prompt.jqif[opts.show](opts.overlayspeed);
$.prompt.jqi[opts.show](opts.promptspeed, function(){
$.prompt.jqib.trigger('impromptu:loaded');
});
- if(opts.timeout > 0)
- setTimeout($.prompt.close,opts.timeout);
+ // Timeout
+ if(opts.timeout > 0){
+ $.prompt.timeout = setTimeout(function(){ $.prompt.close(true); },opts.timeout);
+ }
return $.prompt.jqib;
};
@@ -624,6 +632,11 @@ * @return jQuery - the newly active state
*/
$.prompt.close = function(callCallback, clicked, msg, formvals){
+ if($.prompt.timeout){
+ clearTimeout($.prompt.timeout);
+ $.prompt.timeout = false;
+ }
+
$.prompt.jqib.fadeOut('fast',function(){
if(callCallback) {
|