Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created December 21, 2017 11:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/00f3c78c2f1e6a51345e72a0810198e8 to your computer and use it in GitHub Desktop.
Save bjoerntx/00f3c78c2f1e6a51345e72a0810198e8 to your computer and use it in GitHub Desktop.
// ribbon can be manipulated when complete ribbon has been loaded
TXTextControl.addEventListener("ribbonTabsLoaded", function (e) {
// get the new tab container and add it after the existing last tab
$.get("/RibbonExtensions/NewTab/NewTab.html", function (data) {
$("ul.tabs:first li:last").after(data);
// attach the click event to switch tabs on a click
$("#tabNew").click(function () {
switchTabs($(this));
});
});
// get the ribbon tab content and add it to the content container
$.get("/RibbonExtensions/NewTab/NewTabContent.html", function (data) {
$("#txRibbonTabContentContainer div:last").after(data);
});
});
// enables the clicked tab and disables other tabs
function switchTabs(tabObject) {
$('#txRibbonTabContentContainer div.tab-content').css("display", "none");
$('#ribbonbar ul.tabs a').removeClass("selected");
var id = tabObject.attr("rel");
$('#' + id).css("display", "inline-block");
tabObject.addClass("selected");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment