1 2//---------------------------------------------------------------------------------------------// 3 4$(window).on('load',function(){ 5 if($(window).width()>1200){ 6 $('.top_panel').css('position','relative'); 7 } 8 }) 9 10(function($) { 11 $.fn.stellarNav = function(options, width, breakpoint) { 12 13 var $nav, $width, $breakpoint, $parentItems; 14 nav = $(this); 15 width = $(window).width(); 16 17 // default settings 18 var settings = $.extend( { 19 theme: 'plain', // adds default color to nav. (light, dark) 20 breakpoint: 1080, // number in pixels to determine when the nav should turn mobile friendly 21 //menuLabel: 'Menu', // label for the mobile nav 22 sticky: false, // makes nav sticky on scroll (desktop only) 23 position: 'static', // 'static', 'top', 'left', 'right' - when set to 'top', this forces the mobile nav to be placed absolutely on the very top of page 24 openingSpeed: 250, // how fast the dropdown should open in milliseconds 25 closingDelay: 250, // controls how long the dropdowns stay open for in milliseconds 26 showArrows: true, // shows dropdown arrows next to the items that have sub menus 27 phoneBtn: '', // adds a click-to-call phone link to the top of menu - i.e.: "18009084500" 28 phoneLabel: 'Call Us', // label for the phone button 29 locationBtn: '', // adds a location link to the top of menu - i.e.: "/location/", "http://site.com/contact-us/" 30 locationLabel: 'Location', // label for the location button 31 closeBtn: false, // adds a close button to the end of nav 32 closeLabel: 'Close', // label for the close button 33 mobileMode: false, 34 scrollbarFix: false // fixes horizontal scrollbar issue on very long navs 35 }, options ); 36 37 return this.each( function() { 38 39 // defines black or white themes 40 if (settings.theme == 'light' || settings.theme == 'dark') { 41 nav.addClass(settings.theme); 42 } 43 44 if (settings.breakpoint) { 45 breakpoint = settings.breakpoint; 46 } 47 48 if (settings.menuLabel) { 49 menuLabel = settings.menuLabel; 50 } else { 51 menuLabel = ''; 52 } 53 54 if (settings.phoneLabel) { 55 phoneLabel = settings.phoneLabel; 56 } else { 57 phoneLabel = ''; 58 } 59 60 if (settings.locationLabel) { 61 locationLabel = settings.locationLabel; 62 } else { 63 locationLabel = ''; 64 } 65 66 if (settings.closeLabel) { 67 closeLabel = settings.closeLabel; 68 } else { 69 closeLabel = ''; 70 } 71 72 // css classes for main menu mobile buttons 73 if( settings.phoneBtn && settings.locationBtn ) { 74 var cssClass = 'third'; 75 } else if( settings.phoneBtn || settings.locationBtn ) { 76 var cssClass = 'half'; 77 } else { 78 var cssClass = 'full'; 79 } 80 81 // adds the toggle button to open and close nav 82 if ( settings.position == 'right' || settings.position == 'left' ) { 83 nav.prepend('<a href="#" class="menu-toggle"><span class="bars"><span></span><span></span><span></span></span> ' + menuLabel + '</a>'); 84 } else { 85 nav.prepend('<a href="#" class="menu-toggle ' + cssClass + '"><span class="bars"><span></span><span></span><span></span></span> ' + menuLabel + '</a>'); 86 } 87 88 // adds a click-to-call link 89 if (settings.phoneBtn && !(settings.position == 'right' || settings.position == 'left')) { 90 var btn = '<a href="tel:'+ settings.phoneBtn +'" class="call-btn-mobile ' + cssClass + '"><svg id="icon-phone"></svg> <span>' + phoneLabel + '</span></a>'; 91 nav.find('a.menu-toggle').after(btn); 92 } 93 94 // adds a location page link to the beginning of nav 95 if (settings.locationBtn && !(settings.position == 'right' || settings.position == 'left')) { 96 var btn = '<a href="'+ settings.locationBtn +'" class="location-btn-mobile ' + cssClass + '" target="_blank"><svg id="icon-location"></svg> <span>' + locationLabel + '</span></a>'; 97 nav.find('a.menu-toggle').after(btn); 98 } 99 100 // Makes nav sticky on scroll 101 if (settings.sticky) { 102 navPos = nav.offset().top; 103 if(width >= breakpoint) { 104 $(window).on('scroll', function() { 105 if ($(window).scrollTop() > navPos) { 106 nav.addClass('fixed'); 107 } 108 else { 109 nav.removeClass('fixed'); 110 } 111 }); 112 } 113 } 114 115 if (settings.position == 'top') { 116 nav.addClass('top'); 117 } 118 119 if (settings.position == 'left' || settings.position == 'right') { 120 var closeBtn = '<a href="#" class="close-menu ' + cssClass + '"><span class="icon-close"></span>' + closeLabel + '</a>'; 121 var phoneBtn = '<a href="tel:'+ settings.phoneBtn +'" class="call-btn-mobile ' + cssClass + '"><svg id="icon-phone"></svg></a>'; 122 var locationBtn = '<a href="'+ settings.locationBtn +'" class="location-btn-mobile ' + cssClass + '" target="_blank"><svg id="icon-location"></svg></i></a>'; 123 124 nav.find('ul:first').prepend(closeBtn); 125 126 if (settings.locationBtn) { 127 nav.find('ul:first').prepend(locationBtn); 128 } 129 if (settings.phoneBtn) { 130 nav.find('ul:first').prepend(phoneBtn); 131 } 132 } 133 134 if (settings.position == 'right') { 135 nav.addClass('right'); 136 } 137 138 if (settings.position == 'left') { 139 nav.addClass('left'); 140 } 141 142 if (!settings.showArrows) { 143 nav.addClass('hide-arrows'); 144 } 145 146 if (settings.closeBtn && !(settings.position == 'right' || settings.position == 'left')) { 147 // adds a link to end of nav to close it 148 nav.find('ul:first').append('<li><a href="#" class="close-menu"><span class="icon-close"></span> ' + closeLabel + '</a></li>'); 149 } 150 151 if (settings.scrollbarFix) { 152 $('body').addClass('nav-noscroll-x'); 153 } 154 155 156 157 158 // opens and closes menu 159 $('.menu-toggle, .nav-open').on('click', function(e) { 160 $('.nav.mobile ul').find('.demo1').remove(); 161 $('.topLinks > li.demo1').clone().appendTo('.nav.mobile > ul'); 162 $(this).toggleClass("nav_close"); 163 164 $("body, html").toggleClass("hidden") 165 $(".nav.mobile > ul").height($(window).height()-66); 166 e.preventDefault(); 167 168 // if nav position is left or right, uses fadeToggle instead of slideToggle 169 if (settings.position == 'left' || settings.position == 'right') { 170 nav.find('ul:first').stop(true, true).fadeToggle(settings.openingSpeed); 171 nav.toggleClass('active'); 172 173 if(nav.hasClass('active') && nav.hasClass('mobile')) { 174 // closes the menu when clicked outside of it 175 $(document).on('click', function(event) { 176 // ensures menu hides only on mobile nav 177 if(nav.hasClass('mobile')) { 178 if (!$(event.target).closest(nav).length) { 179 nav.find('ul:first').stop(true, true).fadeOut(settings.openingSpeed); 180 nav.removeClass('active'); 181 } 182 } 183 });
184 } 185 186 } else { 187 // static position - normal open and close animation 188 nav.find('ul:first').stop(true, true).slideToggle(settings.openingSpeed); 189 nav.toggleClass('active'); 190 $("#demo").height($(window).height()); 191 } 192 193 194 }); 195 196 // activates the close button 197 $('.close-menu, .nav-close').on('click', function() { 198 199 nav.removeClass('active'); 200 201 if (settings.position == 'left' || settings.position == 'right') { 202 nav.find('ul:first').stop(true, true).fadeToggle(settings.openingSpeed); 203 } else { 204 nav.find('ul:first').stop(true, true).slideUp(settings.openingSpeed).toggleClass('active'); 205 } 206 }); 207 208 209 // adds toggle button to li items that have children 210 nav.find('li a').each(function() { 211 if($(window).width()<1080){ 212 if ($(this).next().length > 0) { 213 $(this).parent('li').addClass('has-sub').append('<a class="dd-toggle" href="#"><span class="icon-plus"></span></a>'); 214 } 215 } 216 }); 217 218 // expands the dropdown menu on each click 219 //nav.find('li .dd-toggle').on('click', function(e) { 220 nav.find('li.has-sub > a').on('click', function(e) { 221 e.preventDefault(); 222 $(this).parent('li').children('ul').stop(true, true).slideToggle(settings.openingSpeed); 223 $(this).parent('li').toggleClass('open'); 224 }); 225 226 //nav.find('li .dd-toggle').on('click', function(e) { 227 nav.find('li.has-sub > a').on('click', function(e) { 228 e.preventDefault(); 229 $(this).parent('li').children('.mega_block').stop(true, true).slideToggle(settings.openingSpeed); 230 //$(this).parent('li').toggleClass('open'); 231 }); 232 233 234 235 236 237 238 var resetTriggers = function() { 239 nav.find('li').off('mouseenter'); 240 nav.find('li').off('mouseleave'); 241 } 242 243 // defines top level items 244 parentItems = nav.find('> ul > li'); 245 246 var setTriggers = function() { 247 $(parentItems).each(function() { 248 if( $(this).hasClass('mega') ) { 249 // mega dropdown 250 $(this).on('mouseenter', function(){ 251 $(this).find('ul').first().stop(true, true).slideDown(settings.openingSpeed); 252 }); 253 $(this).on('mouseleave', function(){ 254 $(this).find('ul').first().stop(true, true).slideUp(settings.openingSpeed); 255 }); 256 } else { 257 // normal dropdown 258 // first-level 259 $(this).on('mouseenter', function(){ 260 $(this).children('ul').stop(true, true).slideDown(settings.openingSpeed); 261 }); 262 $(this).on('mouseleave', function(){ 263 $(this).children('ul').stop(true, true).delay(settings.closingDelay).slideUp(settings.openingSpeed); 264 }); 265 266 // second level and below 267 $(this).find('li.has-sub').on('mouseenter', function(){ 268 $(this).children('ul').stop(true, true).slideDown(settings.openingSpeed); 269 }); 270 $(this).find('li.has-sub').on('mouseleave', function(){ 271 $(this).children('ul').stop(true, true).delay(settings.closingDelay).slideUp(settings.openingSpeed); 272 }); 273 } 274 }); 275 } 276 277 278 var setTriggers_mega = function() { 279 $(parentItems).each(function() { 280 if( $(this).hasClass('mega') ) { 281 // mega dropdown 282 $(this).on('mouseenter', function(){ 283 $(this).find('.mega_block').first().stop(true, true).slideDown(settings.openingSpeed); 284 }); 285 $(this).on('mouseleave', function(){ 286 $(this).find('.mega_block').first().stop(true, true).slideUp(settings.openingSpeed); 287 }); 288 } else { 289 // normal dropdown 290 // first-level 291 $(this).on('mouseenter', function(){ 292 $(this).find('.mega_block').stop(true, true).slideDown(settings.openingSpeed); 293 }); 294 $(this).on('mouseleave', function(){ 295 $(this).find('.mega_block').stop(true, true).delay(settings.closingDelay).slideUp(settings.openingSpeed); 296 }); 297 298 // second level and below 299 $(this).find('li.has-sub').on('mouseenter', function(){ 300 $(this).children('ul').stop(true, true).slideDown(settings.openingSpeed); 301 }); 302 $(this).find('li.has-sub').on('mouseleave', function(){ 303 $(this).children('ul').stop(true, true).delay(settings.closingDelay).slideUp(settings.openingSpeed); 304 });
305 } 306 }); 307 } 308 309 310 311 windowCheck(); 312 313 // check browser width in real-time 314 function windowCheck() { 315 var browserWidth = window.innerWidth; 316 317 if(browserWidth <= breakpoint || settings.mobileMode) { 318 // mobile/tablet nav 319 320 resetTriggers(); 321 nav.addClass('mobile'); 322 nav.removeClass('desktop'); 323 324 // closes the menu when resizing window back to desktop 325 if( !nav.hasClass('active') && nav.find('ul:first').is(':visible') ) { 326 nav.find('ul:first').hide(); 327 } 328 329 // resets all the styles back to normal that are added on the desktop for the mega dropdown 330 nav.find('li.mega').each(function() { 331 $(this).find('ul').first().removeAttr('style'); 332 $(this).find('ul').first().children().removeAttr('style'); 333 }); 334 335 } else { 336 // desktop nav 337 nav.addClass('desktop'); 338 nav.removeClass('mobile'); 339 340 if(nav.hasClass('active')) { 341 nav.removeClass('active'); 342 } 343 344 // ensures stellarnav is visible after resizing window 345 if( !nav.hasClass('active') && nav.find('ul:first').is(':hidden') ) { 346 nav.find('ul:first').show(); 347 } 348 349 // hides items that were open on mobile 350 $('li.open').removeClass('open').find('ul:visible').hide(); 351 352 resetTriggers(); 353 setTriggers(); 354 setTriggers_mega(); 355 356 // mega dropdown 357 navWidth = 0; 358 359 $(parentItems).each(function() { 360 // calculates the nav width based on the sum of all top-level items 361 navWidth += $(this)[0].getBoundingClientRect().width; 362 navWidth = Math.round(navWidth); 363 364 if($(this).hasClass('mega')) { 365 // left aligns mega dropdown with nav 366 $(this).find('ul').first().css({'left': 0, 'right': 0, 'margin': '0px auto'}); 367 368 // gets the data-column attribute and divides the columns equally 369 numCols = $(this).attr('data-columns'); 370 if(numCols==2) { 371 $(this).find('li.has-sub').width('50%'); 372 } else if (numCols==3) { 373 $(this).find('ul').first().children().width('33.33%'); 374 } else if (numCols==4) { 375 $(this).find('ul').first().children().width('25%'); 376 } else if (numCols==5) { 377 $(this).find('ul').first().children().width('20%'); 378 } else if (numCols==6) { 379 $(this).find('ul').first().children().width('16.66%'); 380 } else if (numCols==7) { 381 $(this).find('ul').first().children().width('14.28%'); 382 } else if (numCols==8) { 383 $(this).find('ul').first().children().width('12.5%'); 384 } else { 385 // defaults to 4 column 386 $(this).find('ul').first().children().width('25%'); 387 } 388 } 389 390 }); 391 392 // defines the mega dropdown width to be the same as nav width 393 if(parentItems.hasClass('mega')) { 394 nav.find('li.mega > ul').css({'max-width':navWidth}); 395 } 396 // end mega dropdown 397 398 } // end desktop nav 399 } // windowCheck() 400 401 $(window).on('resize', function() { 402 windowCheck(); 403 }); 404 }); 405 } 406}(jQuery));
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.