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

@ -23,9 +23,10 @@
<div id="show_builder" class="sb-content content-pane wide-panel">
<div class="panel-header">
<ul class="nav nav-tabs">
<li id="schedule-tab" role="presentation" class="active">
<li id="schedule-tab" data-tab-id="0" role="presentation" class="active">
<a href="javascript:void(0)" class="tab-name" title="<?php echo _("Scheduled Shows") ?>">
<?php echo _("Scheduled Shows") ?>
<span href='#' class='lib_pl_close icon-remove'></span>
</a>
</li>
</ul>

View File

@ -509,7 +509,7 @@ li.ui-state-default {
.tab-name {
float: left;
max-width: 120px;
max-width: 140px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

View File

@ -855,17 +855,20 @@ var AIRTIME = (function(AIRTIME){
tab.close();
$.ajax( {
url : baseUrl+"usersettings/set-library-screen-settings",
type : "POST",
data : {
settings : {
playlist : false
// save settings if we are not closing the "Scheduled Shows" tab
if (tabId != "0") {
$.ajax( {
url : baseUrl+"usersettings/set-library-screen-settings",
type : "POST",
data : {
settings : {
playlist : false
},
format : "json"
},
format : "json"
},
dataType : "json"
});
dataType : "json"
});
}
});
$pl.find("#save_button").unbind().on("click", function(event) {

View File

@ -187,6 +187,12 @@ AIRTIME = (function(AIRTIME) {
//Highlight the media type selector we're currently on.
highlightMediaTypeSelector();
// always re-show builder if dashboard button was clicked
$('.media_type_selector:first').on('click', function() {
$builder.show();
AIRTIME.tabs.openScheduleTab();
});
/*
* Icon hover states for search.
*/

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
*