From 3a8b01dbcbb578ee6f617c7e2b9c89ebce4717b8 Mon Sep 17 00:00:00 2001 From: Matthew Harrison-Jones Date: Mon, 22 Jul 2013 11:46:23 +0100 Subject: [PATCH] Move notification dismissal events to Backbone Also removes stray notification alert comments --- core/client/admin-ui-temp.js | 5 ----- core/client/views/base.js | 17 +++++++++++++---- core/client/views/editor.js | 5 ----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/client/admin-ui-temp.js b/core/client/admin-ui-temp.js index f8ab33f338..85bdf797d7 100644 --- a/core/client/admin-ui-temp.js +++ b/core/client/admin-ui-temp.js @@ -56,11 +56,6 @@ }); }); - $(document).on('animationend', '.js-notification', function () { - $(this).hide(); - }); - - /** * Example of how to add a persistent notification. */ diff --git a/core/client/views/base.js b/core/client/views/base.js index e4abf234ba..a991ad4ae8 100644 --- a/core/client/views/base.js +++ b/core/client/views/base.js @@ -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(); } }); diff --git a/core/client/views/editor.js b/core/client/views/editor.js index 4cbb37e084..3a269c1916 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -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); }); },