SAAS-948 - update tab functionality
This commit is contained in:
parent
c931b81b35
commit
32e1e70418
1 changed files with 27 additions and 18 deletions
|
@ -477,7 +477,9 @@ var AIRTIME = (function(AIRTIME){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newTab.tab.on("click", function() {
|
newTab.tab.on("click", function() {
|
||||||
AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
|
if (!$(this).hasClass('active')) {
|
||||||
|
AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
newTab.wrapper.find(".md-cancel").on("click", function() {
|
newTab.wrapper.find(".md-cancel").on("click", function() {
|
||||||
closeTab();
|
closeTab();
|
||||||
|
@ -491,9 +493,11 @@ var AIRTIME = (function(AIRTIME){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newTab.tab.on("click", function() {
|
newTab.tab.on("click", function() {
|
||||||
AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
|
if (!$(this).hasClass('active')) {
|
||||||
$.post(baseUrl+'new-playlist/edit',
|
AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
|
||||||
{format: "json", id: newTab.pane.find(".obj_id").val(), type: newTab.pane.find(".obj_type").val()});
|
$.post(baseUrl+'new-playlist/edit',
|
||||||
|
{format: "json", id: newTab.pane.find(".obj_id").val(), type: newTab.pane.find(".obj_type").val()});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
AIRTIME.playlist.init();
|
AIRTIME.playlist.init();
|
||||||
|
|
||||||
|
@ -515,16 +519,22 @@ var AIRTIME = (function(AIRTIME){
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeTab(id) {
|
function closeTab(id) {
|
||||||
var pane = id ? $(".pl-content[tab-id='" + id + "']") : $(".active-tab"),
|
var curr = $(".active-tab"),
|
||||||
|
pane = id ? $(".pl-content[tab-id='" + id + "']") : curr,
|
||||||
tab = id ? $(".nav.nav-tabs [tab-id='" + id + "']") : $(".nav.nav-tabs .active"),
|
tab = id ? $(".nav.nav-tabs [tab-id='" + id + "']") : $(".nav.nav-tabs .active"),
|
||||||
toPane = pane.next().length > 0 ? pane.next() : pane.prev(),
|
toPane = pane.next().length > 0 ? pane.next() : pane.prev(),
|
||||||
toTab = tab.next().length > 0 ? tab.next() : tab.prev(),
|
toTab = tab.next().length > 0 ? tab.next() : tab.prev(),
|
||||||
objId = id ? id : pane.find(".obj_id").val();
|
objId = pane.find(".obj_id").val(),
|
||||||
delete $openTabs[tab.attr("tab-type") + objId];
|
pl = id ? pane : $pl;
|
||||||
|
delete $openTabs[tab.attr("tab-type") + objId]; // Remove the closed tab from our open tabs array
|
||||||
|
|
||||||
|
// Remove the relevant DOM elements (the tab and the tab content)
|
||||||
tab.remove();
|
tab.remove();
|
||||||
$pl.remove();
|
pl.remove();
|
||||||
AIRTIME.showbuilder.switchTab(toPane, toTab);
|
|
||||||
|
if (pane.get(0) == curr.get(0)) { // Closing the current tab, otherwise we don't need to switch tabs
|
||||||
|
AIRTIME.showbuilder.switchTab(toPane, toTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.closeTab = function(id) {
|
mod.closeTab = function(id) {
|
||||||
|
@ -917,9 +927,9 @@ var AIRTIME = (function(AIRTIME){
|
||||||
$(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
|
$(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
|
||||||
|
|
||||||
var tabId = $(this).closest("li").attr("tab-id");
|
var tabId = $(this).closest("li").attr("tab-id");
|
||||||
AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
|
//AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
|
||||||
|
//$pl.hide();
|
||||||
|
|
||||||
$pl.hide();
|
|
||||||
// We need to update the text on the add button
|
// We need to update the text on the add button
|
||||||
AIRTIME.library.checkAddButton();
|
AIRTIME.library.checkAddButton();
|
||||||
// We also need to run the draw callback to update how dragged items are drawn
|
// We also need to run the draw callback to update how dragged items are drawn
|
||||||
|
@ -930,9 +940,9 @@ var AIRTIME = (function(AIRTIME){
|
||||||
if ((name == "Untitled Playlist"
|
if ((name == "Untitled Playlist"
|
||||||
|| name == "Untitled Smart Block")
|
|| name == "Untitled Smart Block")
|
||||||
&& $pl.find(".spl_sortable .spl_empty").length == 1) {
|
&& $pl.find(".spl_sortable .spl_empty").length == 1) {
|
||||||
mod.fnDelete();
|
mod.fnDelete(undefined, tabId);
|
||||||
} else {
|
} else {
|
||||||
closeTab();
|
closeTab(tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
|
@ -1143,20 +1153,19 @@ var AIRTIME = (function(AIRTIME){
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mod.fnDelete = function(plid) {
|
mod.fnDelete = function(plid, tabId) {
|
||||||
var url, id, lastMod;
|
var url, id, lastMod, type, pl = (tabId === undefined) ? $pl : $('#pl-tab-content' + tabId);
|
||||||
|
|
||||||
stopAudioPreview();
|
stopAudioPreview();
|
||||||
id = (plid === undefined) ? getId() : plid;
|
id = (plid === undefined) ? getId() : plid;
|
||||||
lastMod = getModified();
|
lastMod = getModified();
|
||||||
type = $pl.find('.obj_type').val();
|
type = pl.find('.obj_type').val();
|
||||||
url = baseUrl+'new-playlist/delete';
|
url = baseUrl+'new-playlist/delete';
|
||||||
|
|
||||||
$.post(url,
|
$.post(url,
|
||||||
{format: "json", ids: id, modified: lastMod, type: type},
|
{format: "json", ids: id, modified: lastMod, type: type},
|
||||||
function(json) {
|
function(json) {
|
||||||
closeTab();
|
closeTab(tabId);
|
||||||
// openPlaylist(json);
|
|
||||||
redrawLib();
|
redrawLib();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue