Radarr/UI/Settings/Notifications/CollectionView.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-05-20 04:19:54 +00:00
'use strict';
2013-06-19 01:02:23 +00:00
define([
'app',
'marionette',
'Settings/Notifications/ItemView',
2013-06-28 01:55:45 +00:00
'Settings/Notifications/SchemaModal'
], function (App, Marionette, NotificationItemView, SchemaModal) {
2013-06-19 01:02:23 +00:00
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
2013-06-26 00:34:33 +00:00
itemViewContainer: '.notifications',
2013-06-19 01:02:23 +00:00
template : 'Settings/Notifications/CollectionTemplate',
2013-05-25 06:38:43 +00:00
2013-07-26 06:53:37 +00:00
ui: {
'addCard': '.x-add-card'
},
2013-05-25 06:38:43 +00:00
events: {
2013-07-26 06:53:37 +00:00
'click .x-add': '_openSchemaModal',
'click .x-add-card': '_openSchemaModal'
},
onBeforeItemAdded: function () {
this.ui.addCard.remove();
},
onAfterItemAdded: function () {
this._appendAddCard();
2013-05-26 00:36:12 +00:00
},
2013-05-25 06:38:43 +00:00
2013-06-26 00:34:33 +00:00
_openSchemaModal: function () {
2013-06-28 01:55:45 +00:00
SchemaModal.open(this.collection);
2013-07-26 06:53:37 +00: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 06:38:43 +00:00
}
2013-05-20 04:19:54 +00:00
});
});