'; $(this).html($(".ui-article-title", this).html()); }).addClass("cs-tab"); // ADD THE PANELS TO THE DOM $(".cs-tab-panels", this).html(panels); } else { $(this).addClass("no-events"); } }); $(".hp-content.one .ui-widget.app.upcomingevents .cs-tab, .hp-content.two .ui-widget.app.upcomingevents .cs-tab, .hp-content.three .ui-widget.app.upcomingevents .cs-tab").each(function() { // MOVE DAY TO TAB $(this).find(".joel-day").prependTo(this); }); // REMOVE THE EXTRA LI'S $(".ui-widget.app.upcomingevents .ui-articles.cs-tab-list > li:nth-child(n+9), .ui-widget.app.upcomingevents .ui-articles.cs-tab-panels > li:nth-child(n+9)").remove(); // TAB CLICK $(document).on("hover", ".cs-tab", function(e) { e.preventDefault(); var app = $(this).closest(".ui-widget.app"); // SWITCH THE TABS switchTabs({ "currentTab": $(".cs-tab.active", app), "nextTab": $(this), "app": app }); }); // TAB KEYDOWN $(document).on("hover keydown", ".cs-tab", function(e) { var app = $(this).closest(".ui-widget.app"); handleTabEvent({ "event": e, "clickedTab": $(this), "app": app }); }); function handleTabEvent(props) { var lastIndex = $(".cs-tab:visible:last", props.app).attr("data-index"); // ONLY CONSUME IF NOT USING ALT KEY if (!props.event.altKey) { switch(props.event.keyCode) { // MOVE ONE STEP BACKWARDS case _this.KeyCodes.left: case _this.KeyCodes.up: if (!props.event.ctrlKey) { // CTRL+ARROW MOVES FOCUS FROM PANEL TO OPEN TAB - MAKE SURE THAT IS NOT BEING PRESSED TOO props.event.preventDefault(); props.event.stopPropagation(); // GET THE PREVIOUS TAB var prevTab; if (parseInt(props.clickedTab.attr("data-index")) == 0) { prevTab = $(".cs-tab[data-index='" + lastIndex + "']", props.app); // LAST TAB } else { prevTab = $(".cs-tab[data-index='" + (parseInt(props.clickedTab.attr("data-index")) - 1) + "']", props.app); // PREVIOUS TAB } // SWITCH THE TABS switchTabs({ "currentTab": props.clickedTab, "nextTab": prevTab, "app": props.app }); } break; // MOVE ONE STEP FORWARDS case _this.KeyCodes.right: case _this.KeyCodes.down: if (!props.event.ctrlKey) { // CTRL+ARROW MOVES FOCUS FROM PANEL TO OPEN TAB - MAKE SURE THAT IS NOT BEING PRESSED TOO props.event.preventDefault(); props.event.stopPropagation(); // GET THE NEXT TAB var nextTab; if (parseInt(props.clickedTab.attr("data-index")) == lastIndex) { nextTab = $(".cs-tab[data-index='0']", props.app); // FIRST TAB } else { nextTab = $(".cs-tab[data-index='" + (parseInt(props.clickedTab.attr("data-index")) + 1) + "']", props.app); // PREVIOUS TAB } // SWITCH THE TABS switchTabs({ "currentTab": props.clickedTab, "nextTab": nextTab, "app": props.app }); } break; // JUMP TO FIRST TAB case _this.KeyCodes.home: props.event.preventDefault(); props.event.stopPropagation(); // SWITCH THE TABS switchTabs({ "currentTab": props.clickedTab, "nextTab": $(".cs-tab[data-index='0']", props.app), "app": props.app }); break; // JUMP TO LAST TAB case _this.KeyCodes.end: props.event.preventDefault(); props.event.stopPropagation(); // SWITCH THE TABS switchTabs({ "currentTab": props.clickedTab, "nextTab": $(".cs-tab[data-index='" + lastIndex + "']", props.app), "app": props.app }); break; } } } function switchTabs(props) { // SWITCH TAB $(props.currentTab).removeClass("active").attr("aria-selected", "false").attr("tabindex", "-1"); $(props.nextTab).addClass("active").attr("aria-selected", "true").attr("tabindex", "0").focus(); // SWITCH PANEL var nextIndex = parseInt(props.nextTab.attr("data-index")); $(".cs-panel", props.app).removeClass("active").attr("aria-hidden", "true"); $(".cs-panel[data-index='" + nextIndex + "']", props.app).addClass("active").attr("aria-hidden", "false"); } $(window).resize(function() { // RESET TAB $(".ui-widget.app.upcomingevents .ui-articles.cs-tab-list > li").removeClass("active").attr("aria-selected", "false").attr("tabindex", "-1"); $(".ui-widget.app.upcomingevents .ui-articles.cs-tab-list > li:first-child").addClass("active").attr("aria-selected", "true").attr("tabindex", "0"); // RESET PANEL $(".ui-widget.app.upcomingevents .ui-articles.cs-tab-panels > li").removeClass("active").attr("aria-hidden", "true"); $(".ui-widget.app.upcomingevents .ui-articles.cs-tab-panels > li:first-child").addClass("active").attr("aria-hidden", "false"); }); //TAB SLIDER var element; var leftPos; var newWidth; var mainNav = $(".cs-tab-list"); $("