1/* NAVIGATION SUPPORT */ 2 3function basename(path) { 4 return path.split('/').reverse()[0]; // last part of url 5} 6 7 8$(document).ready( function() { 9 //$("#debug").prepend("<p style='color:red;'>debug works</p>"); 10 11 // GLOBAL 12 window.weSeeMobileMenu = ( $('#mobileMenu').is(':visible') ); 13 14 //drive silo navigation 15 // however, leave the logic for .topSubA.withArrow for laters, it is more complex 16 $("span.topSubA:not(.withArrow), span.topGchildA, span.sideA, span.sideSubA").on("click", function() { 17 if(typeof $(this).attr('target') === 'undefined'){ 18 location.replace($(this).attr("href")); 19 } 20 else 21 { 22 window.open($(this).attr("href"), $(this).attr('target')) 23 } 24 }); 25 26 27 // reset sidemenu 28 closeSideAll(); 29 30 // FUNCTIONS CLOSE ALL 31 // close all topSub & topGchild, reset arrows 32 function closeTopAll(){ 33 $('.topArrow').each(function(){ 34 $(this).parent('.topRowLI').removeClass('arrowClicked'); 35 $(this).html( arrow('topPlus') ); 36 $(this).next('.topSubUL').removeClass('rightAlign'); 37 $(this).next('.topSubUL').hide(); 38 }); 39 // special treatment for dynamically created content 40 $('body').find('.subArrow').html( arrow('subPlus') ); 41 $('body').find('.topGchildUL').hide(); 42 } 43 44 // close all side 45 function closeSideAll(){ 46 $('.sideArrow').each(function(){ 47 $(this).html( arrow('sidePlus') ); 48 $(this).next('.sideSubUL').hide(); 49 }); 50 // unless... 51 $('.sideArrow.showSideSub').each(function(){ 52 $(this).addClass('arrowClicked'); 53 $(this).html( arrow('sideMinus') ); 54 $(this).next('.sideSubUL').show(); 55 }); 56 } 57 58 59 // IF RESIZED 60 $(window).resize( function() { 61 var NOWweSeeMobileMenu = ( $('#mobileMenu').is(':visible') ); 62 // if swap mobile|desktop, set to default states 63 if(NOWweSeeMobileMenu != weSeeMobileMenu){ 64 if(NOWweSeeMobileMenu) $('#topMenu').hide(); 65 else $('#topMenu').show(); 66 67 window.weSeeMobileMenu = NOWweSeeMobileMenu; // set m 68 closeTopAll(); 69 closeSideAll(); 70 } 71 window.weSeeMobileMenu = NOWweSeeMobileMenu; 72 }); 73 74 // FUNCTION TOPMENU RIGHTALIGN SUBMENU 75 // if menu too far to the right, switch it to the left 76 function rightAlign(topSubUL){ 77 if( $(topSubUL).length ){ // if this topSubUL exist 78 $(topSubUL).removeClass('rightAlign'); // default 79 // no need to rightalign mobileMenu 80 if (weSeeMobileMenu==false) { 81 var topRowLI_leftPos = $(topSubUL).parent('.topRowLI').offset().left; 82 var topSubUL_width = $(topSubUL).outerWidth(); 83 84 var topSubUL_rightPos = $(window).width() - topRowLI_leftPos - topSubUL_width; // if negative then it overflowed browser right edge 85 86 if(topSubUL_rightPos<0){ 87 $(topSubUL).addClass('rightAlign'); // right:0; 88 //$(topSubUL).css('margin-left',topSubUL_rightPos+'px'); // alternative right browser side 89 } 90 } 91 } 92 } 93 94 // TOPMENU HOVER : DESKTOP RIGHTALIGN SUBMENU & SUBARROW FIX 95 $('.notMobile .topRowLI').hover( function() { // hover inFunction 96 if (weSeeMobileMenu==false) { 97 var topSubUL = $(this).children('.topSubUL'); 98 $(topSubUL).show(); 99 rightAlign(topSubUL); 100 } 101 }, function() { // hover outFunction 102 if (weSeeMobileMenu==false) { 103 closeTopAll(); // close all topSub & topGchild, reset arrows 104 } 105 }); 106 107 108 // TOPARROW CLICK : TABLET & MOBILE TOGGLE, TABLET RIGHTALIGN SUBMENU 109 $('body').on('click','.topArrow', function() { 110 topMenuToggle($(this)); 111 }); 112 // SUBARROW CLICK : ALL PLATFORMS 113 $('body').on('click', '.subArrow', function () { 114 subMenuToggle($(this)) 115 }); 116 117 // some sites prefer arrow and name click to open child menus, instead of only arrow 118 // if first child has the same href as parent, clicking the parent name opens the child menu 119 // do this for top menus 120 $('body').on('click','.topRowA.withArrow', function(e) { 121 // if the hamburger is hidden, this is a fullwidth desktop presentation of the menu, follow the link as normal 122 if($("#topMenu.notMobile").length) 123 { 124 if(!$("#mobileMenu").is(":visible")) return; 125 } 126 127 // this link and its child point to the same page? 128 if($(this).attr('href') == $(this).siblings('ul').find('.topSubA').first().attr('href')) 129 { 130 // prevent navigation to the page and open/close the child menu 131 e.preventDefault(); 132 topMenuToggle($(this).next('.topArrow')); 133 } 134 // otherwise, allow normal behaviour: navigate to link 135 }); 136 // same for sub-menus 137 // NOTE: submenus are NOT <a>nchors. They are js driven divs 138 $('body').on('click','.topSubA.withArrow', function(e) { 139 // this link and its child point to the same page? 140 if($(this).attr('href') == $(this).siblings('ul').find('.topGchildA').first().attr('href')) 141 {
142 // open/close the child menu and disable the anchor href 143 e.preventDefault(); 144 subMenuToggle($(this).next('.subArrow')); 145 } 146 147 }); 148 149 function topMenuToggle($topArrow) 150 { 151 // change arrow html 152 $topArrow.html(function(i,h){ 153 return ( $(this).next('.topSubUL').is(':visible') ? arrow('topPlus') : arrow('topMinus') ); 154 }); 155 156 var topSubUL = $topArrow.attr('data-child'); // "#{$link}-child" 157 if (weSeeMobileMenu) $(topSubUL).slideToggle(); // mobile sub slides up/down 158 else $(topSubUL).toggle(); 159 160 $topArrow.parent('.topRowLI').toggleClass('arrowClicked'); 161 162 // TABLET ONLY clean up previously clicked 163 if (weSeeMobileMenu==false) { 164 $('.topArrow').each(function() { 165 var other_topSubUL = $(this).attr('data-child'); 166 if(other_topSubUL != topSubUL) { 167 $(other_topSubUL).css('display','none'); 168 $(this).parent('.topRowLI').removeClass('arrowClicked'); 169 $(this).html( arrow('topPlus') ); 170 } 171 }); 172 } 173 rightAlign(topSubUL); 174 } 175 176 function subMenuToggle($subArrow) 177 { 178 // change arrow html 179 $subArrow.html(function(i,h){ 180 return ( $(this).next('.topGchildUL').is(':visible') ? arrow('subPlus') : arrow('subMinus') ); 181 }); 182 $subArrow.next('.topGchildUL').slideToggle(); 183 $subArrow.parent('.topSubLI').toggleClass('arrowClicked'); 184 } 185 186 187 function arrow(a){ 188 if(a=='topPlus') r = (weSeeMobileMenu) ? jqMobTopPlus : jqTopPlus; 189 else if(a=='topMinus') r = (weSeeMobileMenu) ? jqMobTopMinus : jqTopMinus; 190 else if(a=='subPlus') r = (weSeeMobileMenu) ? jqMobSubPlus : jqSubPlus; 191 else if(a=='subMinus') r = (weSeeMobileMenu) ? jqMobSubMinus : jqSubMinus; 192 else if(a=='sidePlus') r = (weSeeMobileMenu) ? jqMobSidePlus : jqSidePlus; 193 else if(a=='sideMinus') r = (weSeeMobileMenu) ? jqMobSideMinus : jqSideMinus; 194 return r; 195 } 196 197 198 // MOBILE MENU CLICK : TOGGLE 199 $('#mobileMenu').click( function() { 200 // if the btf css hasn't come in yet, the hamburger shouldn't works 201 //if(!$('.topSubLI').filter(function(){return $(this).css('display') == 'inline-block';}).length) return; 202 203 closeTopAll(); // close all topSub & topGchild, reset arrows 204 $('#topMenu').toggle(); 205 }); 206 207 208 // SIDE MENU 209 $('.sideArrow').click( function() { 210 // change arrow html 211 $(this).html(function(i,h){ 212 return ( $(this).next('.sideSubUL').is(':visible') ? arrow('sidePlus') : arrow('sideMinus') ); 213 }); 214 215 $(this).next('.sideSubUL').slideToggle('MenuBarSubmenuVisible'); 216 217 // change arrow html 218 $(this).toggleClass('arrowClicked'); 219 }); 220 221 /**/ 222});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.