2013-05-20 07:19:54 +03:00
|
|
|
'use strict';
|
2013-06-19 04:02:23 +03:00
|
|
|
define([
|
|
|
|
'app',
|
|
|
|
'marionette',
|
|
|
|
'Settings/Notifications/ItemView',
|
2013-06-28 04:55:45 +03:00
|
|
|
'Settings/Notifications/SchemaModal'
|
|
|
|
], function (App, Marionette, NotificationItemView, SchemaModal) {
|
2013-06-19 04:02:23 +03:00
|
|
|
return Marionette.CompositeView.extend({
|
|
|
|
itemView : NotificationItemView,
|
2013-06-26 03:34:33 +03:00
|
|
|
itemViewContainer: '.notifications',
|
2013-06-19 04:02:23 +03:00
|
|
|
template : 'Settings/Notifications/CollectionTemplate',
|
2013-05-25 09:38:43 +03:00
|
|
|
|
2013-07-26 09:53:37 +03:00
|
|
|
ui: {
|
|
|
|
'addCard': '.x-add-card'
|
|
|
|
},
|
|
|
|
|
2013-05-25 09:38:43 +03:00
|
|
|
events: {
|
2013-07-26 09:53:37 +03:00
|
|
|
'click .x-add': '_openSchemaModal',
|
|
|
|
'click .x-add-card': '_openSchemaModal'
|
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeItemAdded: function () {
|
|
|
|
this.ui.addCard.remove();
|
|
|
|
},
|
|
|
|
|
|
|
|
onAfterItemAdded: function () {
|
|
|
|
this._appendAddCard();
|
2013-05-26 03:36:12 +03:00
|
|
|
},
|
2013-05-25 09:38:43 +03:00
|
|
|
|
2013-06-26 03:34:33 +03:00
|
|
|
_openSchemaModal: function () {
|
2013-06-28 04:55:45 +03:00
|
|
|
SchemaModal.open(this.collection);
|
2013-07-26 09:53:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
_appendAddCard: function () {
|
|
|
|
this.$itemViewContainer.find('.x-add-card').remove();
|
|
|
|
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get('Settings/Notifications/AddCardTemplate');
|
|
|
|
var html = this.templateFunction();
|
|
|
|
|
|
|
|
this.$itemViewContainer.append(html);
|
2013-05-25 09:38:43 +03:00
|
|
|
}
|
2013-05-20 07:19:54 +03:00
|
|
|
});
|
|
|
|
});
|