fixed modal dialog.

This commit is contained in:
kay.one 2013-02-15 16:49:25 -08:00
parent 6a7e346bf2
commit 90332b8f01
7 changed files with 41 additions and 13 deletions

1
.gitignore vendored
View File

@ -131,3 +131,4 @@ NzbDrone.Web/cassette-cache/*
*.eq *.eq
NzbDrone.Web/_backboneApp/.idea/workspace.xml NzbDrone.Web/_backboneApp/.idea/workspace.xml
*/.idea/workspace.xml */.idea/workspace.xml
*workspace.xml

View File

@ -1,4 +1,4 @@
define(['app', 'AddSeries/AddSeriesLayout','Series/SeriesCollectionView'], function () { define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout','Series/SeriesCollectionView', 'Shared/NotificationView'], function (app, modalRegion) {
var controller = Backbone.Marionette.Controller.extend({ var controller = Backbone.Marionette.Controller.extend({
@ -32,6 +32,23 @@
} }
}); });
NzbDrone.addInitializer(function () {
NzbDrone.addRegions({modalRegion: modalRegion});
NzbDrone.vent.on(NzbDrone.Events.OpenModalDialog, function (options) {
console.log('opening modal dialog ' + options.view.template );
NzbDrone.modalRegion.show(options.view);
});
NzbDrone.vent.on(NzbDrone.Events.CloseModalDialog, function () {
console.log('closing modal dialog');
NzbDrone.modalRegion.close();
});
});
return new controller(); return new controller();
}); });

View File

@ -33,13 +33,17 @@ define([
editSeries: function () { editSeries: function () {
var view = new NzbDrone.Series.EditSeriesView({ model: this.model}); var view = new NzbDrone.Series.EditSeriesView({ model: this.model});
view.on('saved', this.render, this);
NzbDrone.modalRegion.show(view); NzbDrone.vent.trigger(NzbDrone.Events.OpenModalDialog, {
view: view
});
}, },
removeSeries: function () { removeSeries: function () {
var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model }); var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view); NzbDrone.vent.trigger(NzbDrone.Events.OpenModalDialog, {
view: view
});
} }
}); });
}); });

View File

@ -1,5 +1,5 @@
define('modalRegion', ['Marionette'], function (Marionette) { define(['app'], function () {
return Marionette.Region.extend({ return Backbone.Marionette.Region.extend({
el: "#modal-region", el: "#modal-region",
constructor: function () { constructor: function () {

View File

@ -6,6 +6,13 @@
initialize: function () { initialize: function () {
/* var model = new NzbDrone.Shared.NotificationModel();
model.set('title','test notification');
model.set('message','test message');
model.set('level', 'error');
this.push(model);
*/
var self = this; var self = this;
window.onerror = function (msg, url, line) { window.onerror = function (msg, url, line) {

View File

@ -29,6 +29,7 @@
}); });
NzbDrone.addInitializer(function () { NzbDrone.addInitializer(function () {
console.log('initializing notification view');
NzbDrone.notificationRegion.show(new collectionView()); NzbDrone.notificationRegion.show(new collectionView());
}); });

View File

@ -27,12 +27,6 @@
}); });
define('app', function () { define('app', function () {
//window.$ = jquery;
//window.jquery = jquery;
//window.Backbone.ModelBinder = modelBinder;
//window.Backbone.Marionette = marionette;
//window.Handlebars = handlebars;
window.NzbDrone = new Backbone.Marionette.Application(); window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Series = {}; window.NzbDrone.Series = {};
@ -45,6 +39,11 @@ define('app', function () {
window.NzbDrone.Quality = {}; window.NzbDrone.Quality = {};
window.NzbDrone.Shared = {}; window.NzbDrone.Shared = {};
window.NzbDrone.Events = {
OpenModalDialog :'openModal',
CloseModalDialog : 'closeModal'
},
window.NzbDrone.Constants = { window.NzbDrone.Constants = {
ApiRoot: '/api' ApiRoot: '/api'
}; };
@ -68,7 +67,6 @@ define('app', function () {
titleRegion: '#title-region', titleRegion: '#title-region',
mainRegion: '#main-region', mainRegion: '#main-region',
notificationRegion: '#notification-region', notificationRegion: '#notification-region',
modalRegion: '#modal-region'
}); });
}); });