mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-06 16:55:49 +00:00
Moved source code under src folder - massive change
This commit is contained in:
48
src/UI/Shared/Modal/Controller.js
Normal file
48
src/UI/Shared/Modal/Controller.js
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Series/Edit/EditSeriesView',
|
||||
'Series/Delete/DeleteSeriesView',
|
||||
'Episode/EpisodeDetailsLayout',
|
||||
'History/Details/HistoryDetailsView'
|
||||
], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) {
|
||||
|
||||
var router = Marionette.AppRouter.extend({
|
||||
|
||||
initialize: function () {
|
||||
App.vent.on(App.Commands.CloseModalCommand, this._closeModal, this);
|
||||
App.vent.on(App.Commands.EditSeriesCommand, this._editSeries, this);
|
||||
App.vent.on(App.Commands.DeleteSeriesCommand, this._deleteSeries, this);
|
||||
App.vent.on(App.Commands.ShowEpisodeDetails, this._showEpisode, this);
|
||||
App.vent.on(App.Commands.ShowHistoryDetails, this._showHistory, this);
|
||||
},
|
||||
|
||||
_closeModal: function () {
|
||||
App.modalRegion.closeModal();
|
||||
},
|
||||
|
||||
_editSeries: function (options) {
|
||||
var view = new EditSeriesView({ model: options.series });
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_deleteSeries: function (options) {
|
||||
var view = new DeleteSeriesView({ model: options.series });
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_showEpisode: function (options) {
|
||||
var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab });
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_showHistory: function (options) {
|
||||
var view = new HistoryDetailsView({ model: options.history });
|
||||
App.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
|
||||
return new router();
|
||||
});
|
||||
55
src/UI/Shared/Modal/Region.js
Normal file
55
src/UI/Shared/Modal/Region.js
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'$',
|
||||
'marionette',
|
||||
'bootstrap'
|
||||
], function (app, $, Marionette) {
|
||||
var region = Marionette.Region.extend({
|
||||
el: '#modal-region',
|
||||
|
||||
constructor: function () {
|
||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||
this.on('show', this.showModal, this);
|
||||
},
|
||||
|
||||
getEl: function (selector) {
|
||||
var $el = $(selector);
|
||||
$el.on('hidden', this.close);
|
||||
return $el;
|
||||
},
|
||||
|
||||
showModal: function () {
|
||||
this.$el.addClass('modal hide fade');
|
||||
|
||||
//need tab index so close on escape works
|
||||
//https://github.com/twitter/bootstrap/issues/4663
|
||||
this.$el.attr('tabindex', '-1');
|
||||
this.$el.modal({
|
||||
'show' : true,
|
||||
'keyboard': true,
|
||||
'backdrop': 'static'});
|
||||
},
|
||||
|
||||
closeModal: function () {
|
||||
$(this.el).modal('hide');
|
||||
this.reset();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
require(
|
||||
[
|
||||
'Shared/Modal/Controller'
|
||||
], function () {
|
||||
|
||||
app.addInitializer(function () {
|
||||
app.addRegions({
|
||||
modalRegion: region
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return region;
|
||||
});
|
||||
Reference in New Issue
Block a user