Permalink
Browse files

Work on async for confirmation callback

  • Loading branch information...
1 parent c18b882 commit 0e57ec8903596f2534df7ec52fb805a5a2030d73 @hyphyphyph committed Jun 4, 2012
Showing with 20 additions and 8 deletions.
  1. +10 −4 build/ui.js
  2. +9 −3 lib/components/confirmation/confirmation.js
  3. +1 −1 lib/components/dialog/dialog.js
View
14 build/ui.js
@@ -117,7 +117,7 @@ var active;
exports.Dialog = Dialog;
/**
- * Return a new `Dialog` with the given
+ * Return a new `Dialog` with the given
* (optional) `title` and `msg`.
*
* @param {String} title or msg
@@ -529,10 +529,11 @@ Confirmation.prototype.ok = function(text){
* @api public
*/
-Confirmation.prototype.show = function(fn){
+Confirmation.prototype.show = function(fn, async){
ui.Dialog.prototype.show.call(this);
this.el.find('.ok').focus();
this.callback = fn || function(){};
+ this.async = async || false;
return this;
};
@@ -569,8 +570,13 @@ Confirmation.prototype.render = function(options){
actions.find('.ok').click(function(e){
e.preventDefault();
self.emit('ok');
- if (self.callback(true) !== false) {
- self.hide();
+ if(self.async){
+ self.callback(true, function(){
+ self.hide();
+ });
+ }
+ else{
+ self.callback(true) !== false && self.hide();
}
});
};
View
12 lib/components/confirmation/confirmation.js
@@ -87,10 +87,11 @@ Confirmation.prototype.ok = function(text){
* @api public
*/
-Confirmation.prototype.show = function(fn){
+Confirmation.prototype.show = function(fn, async){
ui.Dialog.prototype.show.call(this);
this.el.find('.ok').focus();
this.callback = fn || function(){};
+ this.async = async || false;
return this;
};
@@ -127,8 +128,13 @@ Confirmation.prototype.render = function(options){
actions.find('.ok').click(function(e){
e.preventDefault();
self.emit('ok');
- if (self.callback(true) !== false) {
- self.hide();
+ if(self.async){
+ self.callback(true, function(){
+ self.hide();
+ });
+ }
+ else{
+ self.callback(true) !== false && self.hide();
}
});
};
View
2 lib/components/dialog/dialog.js
@@ -12,7 +12,7 @@ var active;
exports.Dialog = Dialog;
/**
- * Return a new `Dialog` with the given
+ * Return a new `Dialog` with the given
* (optional) `title` and `msg`.
*
* @param {String} title or msg

0 comments on commit 0e57ec8

Please sign in to comment.