Hideable Scheduled Shows tab

Makes the first tab remoeable and the tracks page be full width after removing the last tab. You can press the "Dashboard" link to open it back up again.
This commit is contained in:
Lucas Bickel 2017-03-21 00:18:22 +01:00
parent 81d3c3e2b8
commit 6e712b4b82
5 changed files with 61 additions and 17 deletions

View file

@ -213,15 +213,26 @@ var AIRTIME = (function(AIRTIME){
delete $tabMap[self.id]; // Remove this tab from the internal tab mapping
// Remove the relevant DOM elements (the tab and its contents)
self.tab.remove();
self.contents.remove();
if (self.uid !== 0) {
self.tab.remove();
self.contents.remove();
} else {
// only hide scheduled shows tab so we can still interact with it.
self.tab.hide();
self.contents.hide();
}
if (self.isActive()) { // Closing the current tab, otherwise we don't need to switch tabs
if (self.isActive() && toTab) { // Closing the current tab, otherwise we don't need to switch tabs
toTab.switchTo();
} else {
mod.onResize();
}
if (Object.keys($openTabs).length < 1) {
$('#show_builder').hide();
}
self._destroy();
};
@ -259,6 +270,7 @@ var AIRTIME = (function(AIRTIME){
pane = $("#show_builder"),
contents = pane.find(".outer-datatable-wrapper");
self.id = 0;
self.uid = uid;
tab.data("tab-id", self.id);
@ -266,12 +278,16 @@ var AIRTIME = (function(AIRTIME){
self.contents = contents;
self.tab = tab;
tab.on("click", function() {
if (!$(this).hasClass('active')) {
self.assignTabClickHandler(function(e) {
if (!self.isActive()) {
self.switchTo();
}
});
self.assignTabCloseClickHandler(function(e) {
self.close();
});
$openTabs[uid] = self;
$tabMap[self.id] = uid;
};
@ -305,11 +321,29 @@ var AIRTIME = (function(AIRTIME){
* @returns {Tab} the created Tab object
*/
mod.openTab = function(html, uid, callback) {
$('#show_builder').show();
var newTab = new Tab(html, uid);
if (callback) callback(newTab);
return newTab;
};
/**
* open the schedule tab if if was closed
*
* @returns {Tab}
*/
mod.openScheduleTab = function() {
var $scheduleTab = this.getScheduleTab();
$('#show_builder').show();
$openTabs[0] = $scheduleTab;
$scheduleTab.tab.show();
$scheduleTab.contents.show();
$scheduleTab.switchTo();
$scheduleTab.assignTabCloseClickHandler(function(e) {
$scheduleTab.close();
});
};
/**
* Updates the currently active tab
*