mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Clear notifications before adding new ones
closes #783 - I think there's probably a nicer solution than putting clearEverything() everywhere, but that would also probably involve significant refactoring.
This commit is contained in:
parent
60bb02ad6a
commit
00b60a7a74
4 changed files with 17 additions and 19 deletions
|
@ -44,6 +44,7 @@
|
|||
};
|
||||
|
||||
Ghost.Validate.handleErrors = function () {
|
||||
Ghost.notifications.clearEverything();
|
||||
_.each(Ghost.Validate._errors, function (errorObj) {
|
||||
|
||||
Ghost.notifications.addItem({
|
||||
|
|
|
@ -193,15 +193,7 @@
|
|||
this.renderItem(item);
|
||||
},
|
||||
clearEverything: function () {
|
||||
var height = this.$('.js-notification').outerHeight(true),
|
||||
self = this;
|
||||
this.$el.css({height: height});
|
||||
this.$el.find('.js-notification.notification-passive').fadeOut(250, function () {
|
||||
$(this).remove();
|
||||
self.$el.slideUp(250, function () {
|
||||
$(this).show().css({height: "auto"});
|
||||
});
|
||||
});
|
||||
this.$el.find('.js-notification.notification-passive').remove();
|
||||
},
|
||||
removeItem: function (e) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -120,11 +120,7 @@
|
|||
this.savePost({
|
||||
status: keys[newIndex]
|
||||
}).then(function () {
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
message: self.notificationMap[status],
|
||||
status: 'passive'
|
||||
});
|
||||
self.reportSaveSuccess(status);
|
||||
}, function (xhr) {
|
||||
// Show a notification about the error
|
||||
self.reportSaveError(xhr, model, status);
|
||||
|
@ -188,11 +184,7 @@
|
|||
this.savePost({
|
||||
status: status
|
||||
}).then(function () {
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
message: self.notificationMap[status],
|
||||
status: 'passive'
|
||||
});
|
||||
self.reportSaveSuccess(status);
|
||||
// Refresh publish button and all relevant controls with updated status.
|
||||
self.render();
|
||||
}, function (xhr) {
|
||||
|
@ -224,6 +216,15 @@
|
|||
return $.Deferred().reject();
|
||||
},
|
||||
|
||||
reportSaveSuccess: function (status) {
|
||||
Ghost.notifications.clearEverything();
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
message: this.notificationMap[status],
|
||||
status: 'passive'
|
||||
});
|
||||
},
|
||||
|
||||
reportSaveError: function (response, model, status) {
|
||||
var message = this.errorMap[status];
|
||||
|
||||
|
@ -235,6 +236,7 @@
|
|||
message += " " + model.validationError;
|
||||
}
|
||||
|
||||
Ghost.notifications.clearEverything();
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: message,
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
});
|
||||
},
|
||||
saveSuccess: function (model, response, options) {
|
||||
Ghost.notifications.clearEverything();
|
||||
// TODO: better messaging here?
|
||||
Ghost.notifications.addItem({
|
||||
type: 'success',
|
||||
|
@ -124,6 +125,7 @@
|
|||
});
|
||||
},
|
||||
saveError: function (model, xhr) {
|
||||
Ghost.notifications.clearEverything();
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
|
||||
|
@ -131,6 +133,7 @@
|
|||
});
|
||||
},
|
||||
validationError: function (message) {
|
||||
Ghost.notifications.clearEverything();
|
||||
Ghost.notifications.addItem({
|
||||
type: 'error',
|
||||
message: message,
|
||||
|
|
Loading…
Add table
Reference in a new issue