Skip to content

Commit

Permalink
Return false from ui.Confirmation callback will avoid closing the dia…
Browse files Browse the repository at this point in the history
…log.
  • Loading branch information
hyphyphyph committed Jun 4, 2012
1 parent c1737db commit c18b882
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
19 changes: 10 additions & 9 deletions build/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ Dialog.prototype.hide = function(ms){
// hide / remove
this.el.addClass('hide');
if (this._effect) {
setTimeout(function(self){
setTimeout(function(){
self.remove();
}, 500, this);
}, 500);
} else {
self.remove();
}
Expand Down Expand Up @@ -448,7 +448,7 @@ Overlay.prototype.hide = function(){
exports.Confirmation = Confirmation;

/**
* Return a new `Confirmation` dialog with the given
* Return a new `Confirmation` dialog with the given
* `title` and `msg`.
*
* @param {String} title or msg
Expand Down Expand Up @@ -562,15 +562,16 @@ Confirmation.prototype.render = function(options){
actions.find('.cancel').click(function(e){
e.preventDefault();
self.emit('cancel');
self.callback(false);
self.callback(false)
self.hide();
});

actions.find('.ok').click(function(e){
e.preventDefault();
self.emit('ok');
self.callback(true);
self.hide();
if (self.callback(true) !== false) {
self.hide();
}
});
};

Expand Down Expand Up @@ -1148,9 +1149,9 @@ Notification.prototype.hide = function(ms){
// hide / remove
this.el.addClass('hide');
if (this._effect) {
setTimeout(function(self){
setTimeout(function(){
self.remove();
}, 500, this);
}, 500);
} else {
self.remove();
}
Expand Down Expand Up @@ -1297,7 +1298,7 @@ exports.Menu = Menu;
*/

exports.menu = function(){
return new Menu();
return new Menu;
};

/**
Expand Down
9 changes: 5 additions & 4 deletions lib/components/confirmation/confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exports.Confirmation = Confirmation;

/**
* Return a new `Confirmation` dialog with the given
* Return a new `Confirmation` dialog with the given
* `title` and `msg`.
*
* @param {String} title or msg
Expand Down Expand Up @@ -120,14 +120,15 @@ Confirmation.prototype.render = function(options){
actions.find('.cancel').click(function(e){
e.preventDefault();
self.emit('cancel');
self.callback(false);
self.callback(false)
self.hide();
});

actions.find('.ok').click(function(e){
e.preventDefault();
self.emit('ok');
self.callback(true);
self.hide();
if (self.callback(true) !== false) {
self.hide();
}
});
};

0 comments on commit c18b882

Please sign in to comment.