From 90332b8f015b1928bdbedcee937ff3b4f270d27f Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Fri, 15 Feb 2013 16:49:25 -0800 Subject: [PATCH] fixed modal dialog. --- .gitignore | 1 + NzbDrone.Web/_backboneApp/Controller.js | 19 ++++++++++++++++++- .../_backboneApp/Series/SeriesItemView.js | 10 +++++++--- .../_backboneApp/Shared/ModalRegion.js | 4 ++-- .../Shared/NotificationCollection.js | 7 +++++++ .../_backboneApp/Shared/NotificationView.js | 1 + NzbDrone.Web/_backboneApp/app.js | 12 +++++------- 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 052177bef..db2a602c6 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,4 @@ NzbDrone.Web/cassette-cache/* *.eq NzbDrone.Web/_backboneApp/.idea/workspace.xml */.idea/workspace.xml +*workspace.xml diff --git a/NzbDrone.Web/_backboneApp/Controller.js b/NzbDrone.Web/_backboneApp/Controller.js index f13c4f661..aad45516d 100644 --- a/NzbDrone.Web/_backboneApp/Controller.js +++ b/NzbDrone.Web/_backboneApp/Controller.js @@ -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({ @@ -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(); }); diff --git a/NzbDrone.Web/_backboneApp/Series/SeriesItemView.js b/NzbDrone.Web/_backboneApp/Series/SeriesItemView.js index 7a1392965..2a38d9470 100644 --- a/NzbDrone.Web/_backboneApp/Series/SeriesItemView.js +++ b/NzbDrone.Web/_backboneApp/Series/SeriesItemView.js @@ -33,13 +33,17 @@ define([ editSeries: function () { 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 () { var view = new NzbDrone.Series.DeleteSeriesView({ model: this.model }); - NzbDrone.modalRegion.show(view); + NzbDrone.vent.trigger(NzbDrone.Events.OpenModalDialog, { + view: view + }); } }); }); diff --git a/NzbDrone.Web/_backboneApp/Shared/ModalRegion.js b/NzbDrone.Web/_backboneApp/Shared/ModalRegion.js index deb666175..7afbbc02c 100644 --- a/NzbDrone.Web/_backboneApp/Shared/ModalRegion.js +++ b/NzbDrone.Web/_backboneApp/Shared/ModalRegion.js @@ -1,5 +1,5 @@ -define('modalRegion', ['Marionette'], function (Marionette) { - return Marionette.Region.extend({ +define(['app'], function () { + return Backbone.Marionette.Region.extend({ el: "#modal-region", constructor: function () { diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationCollection.js b/NzbDrone.Web/_backboneApp/Shared/NotificationCollection.js index f2685590c..df91da6bc 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationCollection.js +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationCollection.js @@ -6,6 +6,13 @@ 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; window.onerror = function (msg, url, line) { diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationView.js b/NzbDrone.Web/_backboneApp/Shared/NotificationView.js index 4a9c90761..8c6f470c5 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationView.js +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationView.js @@ -29,6 +29,7 @@ }); NzbDrone.addInitializer(function () { + console.log('initializing notification view'); NzbDrone.notificationRegion.show(new collectionView()); }); diff --git a/NzbDrone.Web/_backboneApp/app.js b/NzbDrone.Web/_backboneApp/app.js index 3318272a2..dd83d795d 100644 --- a/NzbDrone.Web/_backboneApp/app.js +++ b/NzbDrone.Web/_backboneApp/app.js @@ -27,12 +27,6 @@ }); 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.Series = {}; @@ -45,6 +39,11 @@ define('app', function () { window.NzbDrone.Quality = {}; window.NzbDrone.Shared = {}; + window.NzbDrone.Events = { + OpenModalDialog :'openModal', + CloseModalDialog : 'closeModal' + }, + window.NzbDrone.Constants = { ApiRoot: '/api' }; @@ -68,7 +67,6 @@ define('app', function () { titleRegion: '#title-region', mainRegion: '#main-region', notificationRegion: '#notification-region', - modalRegion: '#modal-region' }); });