-
-
Save islaytitans/21a9c2e1bb9e5a2958af to your computer and use it in GitHub Desktop.
Script to move between the subtabs of a Sitecore Item Layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["sitecore", "/-/speak/v1/experienceprofile/CintelUtl.js"], function (sc, cintelUtil) { | |
var selectedTabProperty = "selectedTab"; | |
var textProperty = "text"; | |
var app = sc.Definitions.App.extend({ | |
initialized: function () { | |
this.processTabs(); | |
}, | |
loadPanel: function () { | |
var panelId = $("[data-sc-id='InteractionsTabControl'] > .tab-content > .active .sc-load-on-demand-panel").data("sc-id"); | |
var panel = this[panelId]; | |
if (panel && !panel.get("isLoaded")) { | |
panel.on("change:isLoaded", function () { | |
panel.set("isBusy", false); | |
}); | |
panel.set("isBusy", true); | |
panel.load(); | |
} | |
}, | |
showDefaultTab: function () { | |
var firstTabId = this.InteractionsTabControl.get(selectedTabProperty); | |
var urlTabId = this.getTabIdFromUrl(); | |
if (urlTabId && urlTabId != firstTabId) { | |
this.InteractionsTabControl.set(selectedTabProperty, urlTabId); | |
} else { | |
this.loadPanel(); | |
} | |
}, | |
processTabs: function () { | |
this.InteractionsTabControl.on("change:" + selectedTabProperty, function (tabControl, selectedTab) { | |
this.loadPanel(); | |
}, this); | |
this.showDefaultTab(); | |
}, | |
getTabIdFromUrl: function () { | |
var tabName = cintelUtil.getQueryParam("subtab"); | |
if (!tabName) return null; | |
var tabIdControlId = tabName[0].toUpperCase() + tabName.toLowerCase().substring(1) + "TabId"; | |
var tabIdControl = this[tabIdControlId]; | |
if (!tabIdControl) return null; | |
return tabIdControl.get(textProperty); | |
} | |
}); | |
return app; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment