'); $(".ui-article-inner",this).css("width",imgWidth + 14); }	$(".hp.column.four .ui-widget.app.headlines .ui-widget-detail .ui-articles .ui-article h1.ui-article-title").show(); $(".hp.column.four .ui-widget.app.headlines .ui-widget-detail .ui-articles .ui-article p.ui-article-description").show(); }); } function buildStyleSheet(){ var photoBGColor60 = "rgba(" + hexToRgb('#000000') + ", .8)"; var regionFGBGColor60 = "rgba(" + hexToRgb('#f79900') + ", .8)"; var BGphotoOverlayColor50 = "rgba(" + hexToRgb('#FFFFFF') + ", .5)"; var dynStyleSheet = document.createElement('style'); if(dynStyleSheet) { dynStyleSheet.setAttribute('type', 'text/css'); var head = document.getElementsByTagName('head')[0]; if(head) { head.insertBefore(dynStyleSheet, head.childNodes[0]); } var dynStyles =	'#gb-page-inner.background-photo-overlay-true {' + '	background: ' + BGphotoOverlayColor50 + ';' + '}' + '#hp-slideshow:hover .rs-photo-gallery-container .rs-photo-gallery-overlay, #hp-slideshow .mmg-description-outer {' + '	background: ' + photoBGColor60 + ';' + '}' + '.hp.column.four .ui-widget.app.headlines .ui-article-container {' + '	background: ' + regionFGBGColor60 + ';' + '}'; var rules = document.createTextNode(dynStyles); if(dynStyleSheet.styleSheet){ // IE dynStyleSheet.styleSheet.cssText = dynStyles; } else { dynStyleSheet.appendChild(rules); } } } function hexToRgb(h){ var r = parseInt((cutHex(h)).substring(0,2),16); var g = parseInt((cutHex(h)).substring(2,4),16); var b = parseInt((cutHex(h)).substring(4,6),16); return r + ', ' + g + ', ' + b; } function cutHex(h) { return (h.charAt(0)=="#") ? h.substring(1,7):h; } var parallaxScroll = function(){ var getWidth = $(window).width(); var gbSearchHeight = ($("#gb-search-outer").height()); var gbHeaderHeight = ($("#gb-header-outer").height()); var scrollHeight = gbSearchHeight + gbHeaderHeight + 26; var channelHeight = $("#gb-channel-list-outer").height() + 20; if($(window).scrollTop() >= scrollHeight && $("#gb-search-outer.open").length) { $("#gb-channel-list-outer").addClass("fixed"); $("#hp-content-outer").css("margin-top", channelHeight); $("#sp-content").css("margin-top", channelHeight); $("#spn-content").css("margin-top", channelHeight); } else if($(window).scrollTop() >= gbHeaderHeight && !$("#gb-search-outer.open").length) { $("#gb-channel-list-outer").addClass("fixed"); $("#hp-content-outer").css("margin-top", channelHeight); $("#sp-content").css("margin-top", channelHeight); $("#spn-content").css("margin-top", channelHeight); } else { $("#gb-channel-list-outer").removeClass("fixed"); $("#hp-content-outer").css("margin-top", "auto"); $("#sp-content").css("margin-top", "auto"); $("#spn-content").css("margin-top", "auto"); } if($(".spn").length || $(".sp").length && $(".ui-widget.app.calendar").length) { if($(".wcm-controls").hasClass("wcm-stuck")) { $(".wcm-controls").css("margin-top", $("#gb-channel-list-outer").outerHeight(true)); } } } function accessibility() { var csKeyCodes = { "tab": 9, "enter": 13, "esc": 27, "space": 32, "end": 35, "home": 36, "left": 37, "up": 38, "right": 39, "down": 40 }; /*$(".sw-mystart-dropdown").each(function(i) { // SET ATTRIBUTES $(this).attr("tabindex","0"); $(".selector", this).attr("id", "mystart-dropdown-" + (i + 1)); $(".sw-dropdown-list", this).attr("role", "menu").attr("aria-labelledby", $(".selector", this).attr("id")); $(".sw-dropdown", this).attr("aria-hidden", "true"); $(".sw-dropdown-list li", this).attr("role", "menuitem"); $(".sw-dropdown-list li a", this).attr("tabindex", "0"); });*/ /*$(".sw-mystart-dropdown.schoollist").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME DOWN ARROW case csKeyCodes.enter: e.preventDefault(); case csKeyCodes.space: e.preventDefault(); if(!$(this).hasClass("open")){ $(".sw-dropdown", this).slideDown("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).addClass("open"); // FOCUS FIRST ITEM $(".sw-dropdown-list li:first-child a", this).focus(); $(".sw-dropdown-list li a", this).attr("tabindex","0"); } else { $(".sw-dropdown", this).slideUp("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).removeClass("open"); $(this).focus(); $(".sw-dropdown-list li a", this).attr("tabindex","-1"); } break; } });*/ /*$(".sw-mystart-dropdown.translate").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME DOWN ARROW case csKeyCodes.enter: case csKeyCodes.space: e.preventDefault(); if(!$(this).hasClass("open")){ $(".sw-dropdown", this).slideDown("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).addClass("open"); // FOCUS FIRST ITEM $(".sw-dropdown-list li:first-child a", this).focus(); $(".sw-dropdown-list li a", this).attr("tabindex","0"); } else { $(".sw-dropdown", this).slideUp("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).removeClass("open"); $(this).focus(); $(".sw-dropdown-list li a", this).attr("tabindex","-1"); } break; } });*/ /*$(".sw-mystart-dropdown .sw-dropdown-list li a").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME HOME KEY case csKeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest(".sw-dropdown-list").find("li:first-child > a").focus(); break; // CONSUME END KEY case csKeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest(".sw-dropdown-list").find("li:last-child > a").focus(); break; } });*/ $(".sw-mystart-dropdown .sw-dropdown-list li a").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case csKeyCodes.left: case csKeyCodes.up: e.preventDefault(); // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest(".sw-dropdown-list").find("li:last-child > a").focus(); } else { // FOCUS PREVIOUS ITEM $(this).parent().prev("li").find("> a").focus(); } break; // CONSUME RIGHT AND DOWN ARROWS case csKeyCodes.right: case csKeyCodes.down: e.preventDefault(); // IS LAST ITEM if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest(".sw-dropdown-list").find("li:first-child > a").focus(); } else { // FOCUS NEXT ITEM $(this).parent().next("li").find("> a").focus(); } break; // CONSUME HOME KEY case csKeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest(".sw-dropdown-list").find("li:first-child > a").focus(); break; // CONSUME END KEY case csKeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest(".sw-dropdown-list").find("li:last-child > a").focus(); break; // CONSUME TAB KEY case csKeyCodes.tab: e.preventDefault(); $(this).parent().parent().parent().slideUp("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).parent().parent().parent().parent().removeClass("open"); $(this).parent().parent().parent().parent().next().focus(); break; } }); $("#sw-myaccount-list li a").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case csKeyCodes.left: case csKeyCodes.up: e.preventDefault(); // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest("#sw-myaccount-list").find("li:last-child > a").focus(); } else { // FOCUS PREVIOUS ITEM $(this).parent().prev("li").find("> a").focus(); } break; // CONSUME RIGHT AND DOWN ARROWS case csKeyCodes.right: case csKeyCodes.down: e.preventDefault(); // IS LAST ITEM if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest("#sw-myaccount-list").find("li:first-child > a").focus(); } else { // FOCUS NEXT ITEM $(this).parent().next("li").find("> a").focus(); } break; // CONSUME HOME KEY case csKeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest("#sw-myaccount-list").find("li:first-child > a").focus(); break; // CONSUME END KEY case csKeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest("#sw-myaccount-list").find("li:last-child > a").focus(); break; // CONSUME TAB KEY case csKeyCodes.tab: e.preventDefault(); $(this).parent().parent().slideUp("slow", "swing").attr("aria-hidden", ($("#sw-myaccount-list", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).parent().parent().parent().removeClass("open"); $("ul.sw-channel-list li.sw-channel-item").first().focus(); $("#sw-mystart-account .icon-font").text("+"); break; } }); /*$("#gb-header-links").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME DOWN ARROW case csKeyCodes.enter: case csKeyCodes.space: e.preventDefault(); if(!$(this).hasClass("open")){ $(".links-body", this).slideDown("slow", "swing").attr("aria-hidden", ($(".links-body", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).addClass("open"); // FOCUS FIRST ITEM $(".links-body li:first-child a", this).focus(); $(".links-body li a", this).attr("tabindex","0"); } else { $(".links-body", this).slideUp("slow", "swing").attr("aria-hidden", ($(".links-body", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).removeClass("open"); $(this).focus(); $(".links-body li a", this).attr("tabindex","-1"); } break; } });*/ /*$("#gb-header-links").focus(function() { if(!$(this).hasClass("open")){ $(".links-body", this).slideDown("slow", "swing").show().attr("aria-hidden", ($(".links-body", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).addClass("open"); // FOCUS FIRST ITEM $(".links-body li:first-child a", this).focus(); $(".links-body li a", this).attr("tabindex","0"); } else { $(".links-body", this).slideUp("slow", "swing").attr("aria-hidden", ($(".links-body", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).removeClass("open"); $(this).focus(); $(".links-body li a", this).attr("tabindex","-1"); } });*/ /*$("#gb-header-links .links-body li a").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case csKeyCodes.left: case csKeyCodes.up: e.preventDefault(); // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(".sw-mystart-dropdown.schoollist .selector").focus(); } else { // FOCUS PREVIOUS ITEM $(this).parent().prev("li").find("> a").focus(); } break; // CONSUME RIGHT AND DOWN ARROWS case csKeyCodes.right: case csKeyCodes.down: e.preventDefault(); // IS LAST ITEM if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $("#gb-header-links .links-body li:first-child > a").focus(); } else { // FOCUS NEXT ITEM $(this).parent().next("li").find("> a").focus(); } break; // CONSUME HOME KEY case csKeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $("#gb-header-links .links-body li:first-child > a").focus(); break; // CONSUME END KEY case csKeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $("#gb-header-links .links-body li:last-child > a").focus(); break; // CONSUME TAB KEY case csKeyCodes.tab: e.preventDefault(); $(this).parent().parent().slideUp("slow", "swing").attr("aria-hidden", ($(".sw-dropdown", this).attr("aria-hidden") == "true") ? "false" : "true"); $(this).parent().parent().parent().removeClass("open"); $(this).parent().parent().parent().next().focus(); break; } }); $("#gb-header-links.sw-mystart-dropdown.true .links-body li a").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME HOME KEY case csKeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest(".links-body").find("li:first-child > a").focus(); break; // CONSUME END KEY case csKeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest(".links-body").find("li:last-child > a").focus(); break; } });*/ $("#gb-search-icon").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME DOWN ARROW case csKeyCodes.enter: case csKeyCodes.space: e.preventDefault(); $("#gb-search-outer").slideToggle("slow").toggleClass("open"); if($("#gb-search-outer").hasClass("open")) { setTimeout(function() { $("#sw-search-input").focus(); }, 300); } else { $("#gb-search-icon").focus(); } break; } }); $("#sw-search-button").keydown(function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME DOWN ARROW case csKeyCodes.tab: e.preventDefault(); $("#gb-search-outer").slideUp("slow").removeClass("open"); $("#gb-search-icon").focus(); break; } }); $(".hp.column.four div.ui-widget.app.headlines .ui-articles li a").focus(function() { var photoBGColor60 = "rgba(" + hexToRgb('#000000') + ", .8)"; if($("#hp-slideshow .ui-widget.app.gallery").find(":focus").length) { $(".rs-photo-gallery-desc", this).css("opacity","1").css("display","block"); $(".rs-photo-gallery-overlay", this).css("background", photoBGColor60); } else { $(".rs-photo-gallery-desc", this).css("opacity","0").css("display","none"); $(".rs-photo-gallery-overlay", this).css("background", "none"); } }); $(".hp.column.four div.ui-widget.app.headlines .ui-articles li a").focus(function() { $(".hp.column.four div.ui-widget.app.headlines .ui-articles li").each(function() { if($(this).find(":focus").length) { $(".ui-article-inner.has-thumb .ui-article-container", this).css("opacity","1"); } else { $(".ui-article-inner.has-thumb .ui-article-container", this).css("opacity","0"); } }); }); } function MyStartDropdownActions(params) { var KeyCodes = { "tab": 9, "enter": 13, "esc": 27, "space": 32, "end": 35, "home": 36, "left": 37, "up": 38, "right": 39, "down": 40 }; var dropdownParent = params.dropdownParent; var dropdownSelector = params.dropdownSelector; var dropdown = params.dropdown; var dropdownList = params.dropdownList; // MYSTART DROPDOWN SELECTOR CLICK EVENT $(document).on("click", dropdownParent + " " + dropdownSelector, function(e) { e.preventDefault(); if($(this).parent().hasClass("open")){ $("+ " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } else { $(this).attr({"aria-expanded": "true"}).parent().addClass("open").find(dropdown).attr("aria-hidden","false").slideDown(300, "swing"); } }); // MYSTART DROPDOWN SELECTOR KEYDOWN EVENTS $(document).on("keydown", dropdownParent + " " + dropdownSelector, function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case KeyCodes.enter: case KeyCodes.space: e.preventDefault(); // IF THE DROPDOWN IS OPEN, CLOSE IT if($(dropdownParent).hasClass("open")){ $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } else { $(this).attr({"aria-expanded": "true"}).parent().addClass("open").find(dropdown).attr("aria-hidden", "false").slideDown(300, "swing", function(){ $(dropdownList + " li:first-child a", this).attr("tabindex", "0").focus(); }); } break; // CONSUME TAB KEY case KeyCodes.tab: $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr("aria-expanded", "false").parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); break; // CONSUME RIGHT AND DOWN ARROWS case KeyCodes.down: case KeyCodes.right: e.preventDefault(); $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $("+ " + dropdown + " " + dropdownList + " li:first-child > a", this).attr("tabindex", "0").focus(); break; } }); // MYSTART DROPDOWN LINK KEYDOWN EVENTS $(document).on("keydown", dropdownParent + " " + dropdownList + " li a", function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case KeyCodes.left: case KeyCodes.up: e.preventDefault(); // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownParent).find(dropdownSelector).focus(); } else { // FOCUS PREVIOUS ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().prev("li").find("> a").attr("tabindex", "0").focus(); } break; // CONSUME RIGHT AND DOWN ARROWS case KeyCodes.right: case KeyCodes.down: e.preventDefault(); // IS LAST ITEM if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); } else { // FOCUS NEXT ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().next("li").find("> a").attr("tabindex", "0").focus(); } break; // CONSUME TAB KEY case KeyCodes.tab: e.preventDefault(); if(e.shiftKey) { // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownParent).find(dropdownSelector).focus(); } else { // FOCUS PREVIOUS ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().prev("li").find("> a").attr("tabindex", "0").focus(); } } else { // IS LAST ITEM /*if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); } else { // FOCUS NEXT ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().next("li").find("> a").attr("tabindex", "0").focus(); }*/ //$(dropdownParent).next().find(dropdownSelector).focus(); } break; // CONSUME HOME KEY case KeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); break; // CONSUME END KEY case KeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:last-child > a").attr("tabindex", "0").focus(); break; } }); $(dropdownParent).mouseleave(function() { var _this = this; setTimeout(function () { if(!$(_this).find(":hover").length) { $("+ " + dropdownList + " a", this).attr("tabindex", "-1"); $(dropdownSelector, _this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } }, 500); }).focusout(function() { var thisDropdown = this; setTimeout(function () { if(!$(thisDropdown).find(":focus").length) { $(dropdownSelector, thisDropdown).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } }, 500); }); $(".sw-mystart-dropdown.header-links .sw-dropdown li a").keydown(function(e) { switch(e.keyCode){ // CONSUME LEFT AND UP ARROWS case csKeyCodes.tab: e.preventDefault(); $(".sw-mystart-dropdown.header-links .sw-dropdown").slideUp().attr("aria-hidden","true"); $("#gb-search-icon").focus(); break; } }); $(".sw-mystart-dropdown.translate .sw-dropdown li a").keydown(function(e) { switch(e.keyCode){ // CONSUME LEFT AND UP ARROWS case csKeyCodes.tab: e.preventDefault(); $(".sw-mystart-dropdown.translate .sw-dropdown").slideUp().attr("aria-hidden","true"); if($(".sw-mystart-dropdown.header-links").length) { $(".sw-mystart-dropdown.header-links .selector").focus(); } else { $("#gb-search-icon").focus(); } break; } }); $(".sw-mystart-dropdown.schoollist .sw-dropdown li a").keydown(function(e) { switch(e.keyCode){ // CONSUME LEFT AND UP ARROWS case csKeyCodes.tab: e.preventDefault(); $(".sw-mystart-dropdown.schoollist .sw-dropdown").slideUp().attr("aria-hidden","true"); if(!$(".sw-mystart-dropdown.translate").length && !$(".sw-mystart-dropdown.header-links").length) { $("#gb-search-icon").focus(); } else if(!$(".sw-mystart-dropdown.translate").length && $(".sw-mystart-dropdown.header-links").length) { $(".sw-mystart-dropdown.header-links .selector").focus(); } else { $(".sw-mystart-dropdown.translate .selector").focus(); } break; } }); } function MyStartDropdownActionsUserOptions(params) { var KeyCodes = { "tab": 9, "enter": 13, "esc": 27, "space": 32, "end": 35, "home": 36, "left": 37, "up": 38, "right": 39, "down": 40 }; var dropdownParent = params.dropdownParent; var dropdownSelector = params.dropdownSelector; var dropdown = params.dropdown; var dropdownList = params.dropdownList; // MYSTART DROPDOWN SELECTOR CLICK EVENT $(document).on("click", dropdownParent + " " + dropdownSelector, function(e) { e.preventDefault(); if($(this).parent().hasClass("open")){ $("+ " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } else { $(this).attr({"aria-expanded": "true"}).parent().addClass("open").find(dropdown).attr("aria-hidden","false").slideDown(300, "swing"); } }); // MYSTART DROPDOWN SELECTOR KEYDOWN EVENTS $(document).on("keydown", dropdownParent + " " + dropdownSelector, function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case KeyCodes.enter: case KeyCodes.space: e.preventDefault(); // IF THE DROPDOWN IS OPEN, CLOSE IT if($(dropdownParent).hasClass("open")){ $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } else { $(this).attr({"aria-expanded": "true"}).parent().addClass("open").find(dropdown).attr("aria-hidden", "false").slideDown(300, "swing", function(){ $(dropdownList + " li:first-child a", this).attr("tabindex", "0").focus(); }); } break; // CONSUME TAB KEY case KeyCodes.tab: $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $(this).attr("aria-expanded", "false").parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); break; // CONSUME RIGHT AND DOWN ARROWS case KeyCodes.down: case KeyCodes.right: e.preventDefault(); $("+ " + dropdown + " " + dropdownList + " a").attr("tabindex", "-1"); $("+ " + dropdown + " " + dropdownList + " li:first-child > a", this).attr("tabindex", "0").focus(); break; } }); // MYSTART DROPDOWN LINK KEYDOWN EVENTS $(document).on("keydown", dropdownParent + " " + dropdownList + " li a", function(e) { // CAPTURE KEY CODE switch(e.keyCode) { // CONSUME LEFT AND UP ARROWS case KeyCodes.left: case KeyCodes.up: e.preventDefault(); // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownParent).find(dropdownSelector).focus(); } else { // FOCUS PREVIOUS ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().prev("li").find("> a").attr("tabindex", "0").focus(); } break; // CONSUME RIGHT AND DOWN ARROWS case KeyCodes.right: case KeyCodes.down: e.preventDefault(); // IS LAST ITEM if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); } else { // FOCUS NEXT ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().next("li").find("> a").attr("tabindex", "0").focus(); } break; // CONSUME TAB KEY case KeyCodes.tab: e.preventDefault(); if(e.shiftKey) { // IS FIRST ITEM if($(this).parent().is(":first-child")) { // FOCUS DROPDOWN BUTTON $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownParent).find(dropdownSelector).focus(); } else { // FOCUS PREVIOUS ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().prev("li").find("> a").attr("tabindex", "0").focus(); } } else { // IS LAST ITEM /*if($(this).parent().is(":last-child")) { // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); } else { // FOCUS NEXT ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).parent().next("li").find("> a").attr("tabindex", "0").focus(); }*/ $(".sw-channel-item:eq(0) > a").focus(); } break; // CONSUME HOME KEY case KeyCodes.home: e.preventDefault(); // FOCUS FIRST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:first-child > a").attr("tabindex", "0").focus(); break; // CONSUME END KEY case KeyCodes.end: e.preventDefault(); // FOCUS LAST ITEM $(this).closest(dropdownList).find("a").attr("tabindex", "-1"); $(this).closest(dropdownList).find("li:last-child > a").attr("tabindex", "0").focus(); break; } }); $(dropdownParent).mouseleave(function() { $("+ " + dropdownList + " a", this).attr("tabindex", "-1"); $(dropdownSelector, this).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); }).focusout(function() { var thisDropdown = this; setTimeout(function () { if(!$(thisDropdown).find(":focus").length) { $(dropdownSelector, thisDropdown).attr({"aria-expanded": "false"}).parent().removeClass("open").find(dropdown).attr("aria-hidden", "true").slideUp(300, "swing"); } }, 500); }); }