Move notification dismissal events to Backbone

Also removes stray notification alert comments
This commit is contained in:
Matthew Harrison-Jones 2013-07-22 11:46:23 +01:00 committed by ErisDS
parent 2e0d2c73d6
commit 3a8b01dbcb
3 changed files with 13 additions and 14 deletions

View File

@ -56,11 +56,6 @@
});
});
$(document).on('animationend', '.js-notification', function () {
$(this).hide();
});
/**
* Example of how to add a persistent notification.
*/

View File

@ -93,23 +93,28 @@
template: function (data) {
return JST[this.templateName](data);
},
render: function() {
render: function () {
var html = this.template(this.model);
this.$el.html(html);
return this;
}
});
/**
* This handles Notification groups
*/
Ghost.Views.NotificationCollection = Ghost.View.extend({
el: '#flashbar',
initialize: function() {
initialize: function () {
this.render();
},
render: function() {
events: {
'animationend .js-notification': 'removeItem',
'webkitAnimationEnd .js-notification': 'removeItem',
'oanimationend .js-notification': 'removeItem',
'MSAnimationEnd .js-notification': 'removeItem'
},
render: function () {
_.each(this.model, function (item) {
this.renderItem(item);
}, this);
@ -117,6 +122,10 @@
renderItem: function (item) {
var itemView = new Ghost.Views.Notification({ model: item });
this.$el.html(itemView.render().el);
},
removeItem: function (e) {
e.preventDefault();
$(e.currentTarget).remove();
}
});

View File

@ -125,7 +125,6 @@
status: 'passive'
}]
}));
// return window.alert('Scheduled publishing not supported yet.');
}
if (status === 'queue') {
this.addSubview(new Ghost.Views.NotificationCollection({
@ -135,7 +134,6 @@
status: 'passive'
}]
}));
// return window.alert('Scheduled publishing not supported yet.');
}
this.savePost({
@ -148,7 +146,6 @@
status: 'passive'
}]
}));
// window.alert('Your post: ' + model.get('title') + ' has been ' + status);
}, function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
@ -174,7 +171,6 @@
status: 'passive'
}]
}));
// window.alert('Your post was saved as ' + model.get('status'));
}, function () {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
@ -183,7 +179,6 @@
status: 'passive'
}]
}));
// window.alert(model.validationError);
});
},