Sonarr/src/UI/Activity/ActivityLayout.js

84 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-02-03 01:18:45 +00:00
var Marionette = require('marionette');
var Backbone = require('backbone');
var Backgrid = require('backgrid');
var HistoryLayout = require('./History/HistoryLayout');
var BlacklistLayout = require('./Blacklist/BlacklistLayout');
var QueueLayout = require('./Queue/QueueLayout');
2013-05-03 06:53:32 +00:00
2015-02-03 01:18:45 +00:00
module.exports = Marionette.Layout.extend({
2015-02-13 21:03:50 +00:00
template : 'Activity/ActivityLayoutTemplate',
regions : {
2015-02-03 01:18:45 +00:00
queueRegion : '#queue',
history : '#history',
blacklist : '#blacklist'
},
2015-02-13 21:03:50 +00:00
ui : {
2015-02-03 01:18:45 +00:00
queueTab : '.x-queue-tab',
historyTab : '.x-history-tab',
blacklistTab : '.x-blacklist-tab'
},
2015-02-13 21:03:50 +00:00
events : {
'click .x-queue-tab' : '_showQueue',
'click .x-history-tab' : '_showHistory',
'click .x-blacklist-tab' : '_showBlacklist'
2015-02-03 01:18:45 +00:00
},
2015-02-13 21:03:50 +00:00
initialize : function(options) {
if (options.action) {
2015-02-03 01:18:45 +00:00
this.action = options.action.toLowerCase();
}
},
2015-02-13 21:03:50 +00:00
onShow : function() {
2015-02-03 01:18:45 +00:00
switch (this.action) {
case 'history':
this._showHistory();
break;
case 'blacklist':
this._showBlacklist();
break;
default:
this._showQueue();
}
},
2015-02-13 21:03:50 +00:00
_navigate : function(route) {
2015-02-03 01:18:45 +00:00
Backbone.history.navigate(route, {
trigger : false,
replace : true
});
2015-02-03 01:18:45 +00:00
},
2015-02-13 21:03:50 +00:00
_showHistory : function(e) {
if (e) {
2015-02-03 01:18:45 +00:00
e.preventDefault();
}
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.history.show(new HistoryLayout());
this.ui.historyTab.tab('show');
this._navigate('/activity/history');
},
2015-02-13 21:03:50 +00:00
_showBlacklist : function(e) {
if (e) {
2015-02-03 01:18:45 +00:00
e.preventDefault();
}
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.blacklist.show(new BlacklistLayout());
this.ui.blacklistTab.tab('show');
this._navigate('/activity/blacklist');
},
2015-02-13 21:03:50 +00:00
_showQueue : function(e) {
if (e) {
2015-02-03 01:18:45 +00:00
e.preventDefault();
}
2015-02-13 21:03:50 +00:00
2015-02-03 01:18:45 +00:00
this.queueRegion.show(new QueueLayout());
this.ui.queueTab.tab('show');
this._navigate('/activity/queue');
}
});