1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-21 01:49:57 +02:00
Sonarr/UI/Shared/Modal/Region.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
define(
[
2013-07-20 02:08:41 +03:00
'app',
2013-06-27 02:45:05 +03:00
'$',
'marionette',
'bootstrap'
2013-07-20 02:08:41 +03:00
], function (app, $, Marionette) {
var region = Marionette.Region.extend({
2013-06-22 09:24:24 +03:00
el: '#modal-region',
2013-05-27 04:19:26 +03:00
constructor: function () {
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
2013-06-22 09:24:24 +03:00
this.on('show', this.showModal, this);
},
getEl: function (selector) {
var $el = $(selector);
2013-06-22 09:24:24 +03:00
$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 () {
2013-06-27 02:45:05 +03:00
$(this.el).modal('hide');
this.reset();
}
});
2013-07-20 02:08:41 +03:00
2013-07-24 04:15:58 +03:00
require(
[
'Shared/Modal/Controller'
], function () {
app.addInitializer(function () {
app.addRegions({
modalRegion: region
});
});
2013-07-20 02:08:41 +03:00
});
return region;
});