2018-06-19 18:48:14 -04:00
|
|
|
const Mn = require('backbone.marionette');
|
|
|
|
const template = require('./main.ejs');
|
|
|
|
const HeaderView = require('./header/main');
|
|
|
|
const MenuView = require('./menu/main');
|
|
|
|
const FooterView = require('./footer/main');
|
|
|
|
const Cache = require('../cache');
|
|
|
|
|
|
|
|
module.exports = Mn.View.extend({
|
2018-06-20 02:51:18 -04:00
|
|
|
id: 'app',
|
|
|
|
className: 'page',
|
|
|
|
template: template,
|
|
|
|
modal_setup: false,
|
|
|
|
|
|
|
|
modal: null,
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
modal: '#modal-dialog'
|
|
|
|
},
|
2018-06-19 18:48:14 -04:00
|
|
|
|
|
|
|
regions: {
|
|
|
|
header_region: {
|
|
|
|
el: '#header',
|
|
|
|
replaceElement: true
|
|
|
|
},
|
|
|
|
menu_region: {
|
|
|
|
el: '#menu',
|
|
|
|
replaceElement: true
|
|
|
|
},
|
|
|
|
footer_region: '.footer',
|
2018-06-20 02:51:18 -04:00
|
|
|
app_content_region: '#app-content',
|
|
|
|
modal_region: '#modal-dialog'
|
2018-06-19 18:48:14 -04:00
|
|
|
},
|
|
|
|
|
2018-06-20 02:51:18 -04:00
|
|
|
/**
|
|
|
|
* @param {Object} view
|
|
|
|
*/
|
2018-06-19 18:48:14 -04:00
|
|
|
showAppContent: function (view) {
|
|
|
|
this.showChildView('app_content_region', view);
|
|
|
|
},
|
|
|
|
|
2018-06-20 02:51:18 -04:00
|
|
|
/**
|
|
|
|
* @param {Object} view
|
|
|
|
* @param {Function} [show_callback]
|
|
|
|
* @param {Function} [shown_callback]
|
|
|
|
*/
|
|
|
|
showModalDialog: function (view, show_callback, shown_callback) {
|
|
|
|
this.showChildView('modal_region', view);
|
|
|
|
let modal = this.getRegion('modal_region').$el.modal('show');
|
|
|
|
|
|
|
|
modal.on('hidden.bs.modal', function (/*e*/) {
|
|
|
|
if (show_callback) {
|
|
|
|
modal.off('show.bs.modal', show_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shown_callback) {
|
|
|
|
modal.off('shown.bs.modal', shown_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
modal.off('hidden.bs.modal');
|
|
|
|
view.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (show_callback) {
|
|
|
|
modal.on('show.bs.modal', show_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shown_callback) {
|
|
|
|
modal.on('shown.bs.modal', shown_callback);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {Function} [hidden_callback]
|
|
|
|
*/
|
|
|
|
closeModal: function (hidden_callback) {
|
|
|
|
let modal = this.getRegion('modal_region').$el.modal('hide');
|
|
|
|
|
|
|
|
if (hidden_callback) {
|
|
|
|
modal.on('hidden.bs.modal', hidden_callback);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-19 18:48:14 -04:00
|
|
|
onRender: function () {
|
|
|
|
this.showChildView('header_region', new HeaderView({
|
|
|
|
model: Cache.User
|
|
|
|
}));
|
|
|
|
|
|
|
|
this.showChildView('menu_region', new MenuView());
|
|
|
|
this.showChildView('footer_region', new FooterView());
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function () {
|
|
|
|
this.getRegion('header_region').reset();
|
|
|
|
this.getRegion('footer_region').reset();
|
2018-06-20 02:51:18 -04:00
|
|
|
this.getRegion('modal_region').reset();
|
2018-06-19 18:48:14 -04:00
|
|
|
}
|
|
|
|
});
|