You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/UI/History/HistoryLayout.js

75 lines
2.0 KiB

'use strict';
define(
[
'app',
'marionette',
'backgrid',
'History/Table/HistoryTableLayout',
'History/Queue/QueueLayout'
], function (App,
Marionette,
Backgrid,
HistoryTableLayout,
QueueLayout) {
return Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate',
regions: {
history: '#history',
queueRegion : '#queue'
},
ui: {
historyTab: '.x-history-tab',
queueTab : '.x-queue-tab'
},
events: {
'click .x-history-tab' : '_showHistory',
'click .x-queue-tab' : '_showQueue'
},
initialize: function (options) {
if (options.action) {
this.action = options.action.toLowerCase();
}
},
onShow: function () {
switch (this.action) {
case 'queue':
this._showQueue();
break;
default:
this._showHistory();
}
},
_navigate:function(route){
require(['Router'], function(){
App.Router.navigate(route);
});
},
_showHistory: function (e) {
if (e) {
e.preventDefault();
}
this.history.show(new HistoryTableLayout());
this.ui.historyTab.tab('show');
this._navigate('/history');
},
_showQueue: function (e) {
if (e) {
e.preventDefault();
}
this.queueRegion.show(new QueueLayout());
this.ui.queueTab.tab('show');
this._navigate('/history/queue');
}
});
});