Factor showNotificationBar out into ValidatingView.

When all settings require an explicit save, this functionality will be
shared between each view (with slight changes, e.g. click handlers.)
This commit is contained in:
Peter Fogg
2013-06-24 13:07:09 -04:00
parent 4b59a85dae
commit 164a469e9d
2 changed files with 42 additions and 34 deletions

View File

@@ -67,5 +67,39 @@ CMS.Views.ValidatingView = Backbone.View.extend({
// put error on the contained inputs
return $(ele).find(inputElements);
}
},
showNotificationBar: function(message, primaryClick, secondaryClick) {
if(this.notificationBarShowing) {
return;
}
var self = this;
this.confirmation = new CMS.Views.Notification.Warning({
title: gettext("You've made some changes"),
message: message,
actions: {
primary: {
"text": gettext("Save Changes"),
"class": "action-save",
"click": function() {
primaryClick();
self.confirmation.hide();
self.notificationBarShowing = false;
}
},
secondary: [{
"text": gettext("Cancel"),
"class": "action-cancel",
"click": function() {
if(secondaryClick) {
secondaryClick();
}
self.confirmation.hide();
self.notificationBarShowing = false;
}
}]
}});
this.notificationBarShowing = true;
this.confirmation.show();
}
});