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 id="show_builder" class="sb-content content-pane wide-panel">
<div class="panel-header"> <div class="panel-header">
<ul class="nav nav-tabs"> <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") ?>"> <a href="javascript:void(0)" class="tab-name" title="<?php echo _("Scheduled Shows") ?>">
<?php echo _("Scheduled Shows") ?> <?php echo _("Scheduled Shows") ?>
<span href='#' class='lib_pl_close icon-remove'></span>
</a> </a>
</li> </li>
</ul> </ul>

View File

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

View File

@ -855,17 +855,20 @@ var AIRTIME = (function(AIRTIME){
tab.close(); tab.close();
$.ajax( { // save settings if we are not closing the "Scheduled Shows" tab
url : baseUrl+"usersettings/set-library-screen-settings", if (tabId != "0") {
type : "POST", $.ajax( {
data : { url : baseUrl+"usersettings/set-library-screen-settings",
settings : { type : "POST",
playlist : false data : {
settings : {
playlist : false
},
format : "json"
}, },
format : "json" dataType : "json"
}, });
dataType : "json" }
});
}); });
$pl.find("#save_button").unbind().on("click", function(event) { $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. //Highlight the media type selector we're currently on.
highlightMediaTypeSelector(); 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. * 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 delete $tabMap[self.id]; // Remove this tab from the internal tab mapping
// Remove the relevant DOM elements (the tab and its contents) // Remove the relevant DOM elements (the tab and its contents)
self.tab.remove(); if (self.uid !== 0) {
self.contents.remove(); 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(); toTab.switchTo();
} else { } else {
mod.onResize(); mod.onResize();
} }
if (Object.keys($openTabs).length < 1) {
$('#show_builder').hide();
}
self._destroy(); self._destroy();
}; };
@ -259,6 +270,7 @@ var AIRTIME = (function(AIRTIME){
pane = $("#show_builder"), pane = $("#show_builder"),
contents = pane.find(".outer-datatable-wrapper"); contents = pane.find(".outer-datatable-wrapper");
self.id = 0; self.id = 0;
self.uid = uid;
tab.data("tab-id", self.id); tab.data("tab-id", self.id);
@ -266,12 +278,16 @@ var AIRTIME = (function(AIRTIME){
self.contents = contents; self.contents = contents;
self.tab = tab; self.tab = tab;
tab.on("click", function() { self.assignTabClickHandler(function(e) {
if (!$(this).hasClass('active')) { if (!self.isActive()) {
self.switchTo(); self.switchTo();
} }
}); });
self.assignTabCloseClickHandler(function(e) {
self.close();
});
$openTabs[uid] = self; $openTabs[uid] = self;
$tabMap[self.id] = uid; $tabMap[self.id] = uid;
}; };
@ -305,11 +321,29 @@ var AIRTIME = (function(AIRTIME){
* @returns {Tab} the created Tab object * @returns {Tab} the created Tab object
*/ */
mod.openTab = function(html, uid, callback) { mod.openTab = function(html, uid, callback) {
$('#show_builder').show();
var newTab = new Tab(html, uid); var newTab = new Tab(html, uid);
if (callback) callback(newTab); if (callback) callback(newTab);
return 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 * Updates the currently active tab
* *