1"use strict"; 2 3//This file only controls flow header, as its named 4(function($) { 5 6 $(document).ready(function () { 7 stm_default_header_height(); 8 stm_default_header(); 9 10 stm_fixed_transparent_header(); 11 }); 12 13 $(window).on('load',function () { 14 stm_default_header_height(); 15 stm_default_header(); 16 17 stm_fixed_transparent_header(); 18 }); 19 20 $(window).on('resize',function () { 21 stm_default_header_height(); 22 stm_default_header(); 23 24 stm_fixed_transparent_header(); 25 }); 26 27 $(window).on('scroll', function () { 28 stm_default_header(); 29 stm_fixed_transparent_header(); 30 }); 31 32 //Default header 33 function stm_default_header_height(){ 34 if($('#header-nav-holder').length > 0 && $('.header-nav').length > 0 && $('.header-nav').hasClass('header-nav-default')) { 35 var height = $('.header-nav').outerHeight(); 36 $('#header-nav-holder').css({ 37 'min-height': height + 'px' 38 }); 39 } 40 } 41 42 function stm_default_header(){ 43 if($('#header-nav-holder').length > 0 && $('.header-nav').length > 0 && $('.header-nav').hasClass('header-nav-default')) { 44 var currentScrollPos = $(window).scrollTop(); 45 var headerPos = $('#header-nav-holder').offset().top; 46 if(currentScrollPos >= headerPos) { 47 $('.header-nav-default').addClass('header-nav-sticky'); 48 } else { 49 $('.header-nav-default').removeClass('header-nav-sticky'); 50 } 51 } 52 } 53 54 //Transparent header 55 function stm_fixed_transparent_header() { 56 if($('#header-nav-holder').length > 0 && $('.header-nav').length > 0 && $('.header-nav').hasClass('header-nav-transparent')) { 57 var currentScrollPos = $(window).scrollTop(); 58 var headerPos = $('#header-nav-holder').offset().top; 59 if(currentScrollPos >= headerPos) { 60 $('.header-nav-transparent').addClass('header-nav-sticky'); 61 } else { 62 $('.header-nav-transparent').removeClass('header-nav-sticky'); 63 } 64 } 65 } 66 67 68})(jQuery); 69 70// car service scripts 71var $ = jQuery; 72if($('.header-service').length > 0) { 73 74 var sections = []; 75 76 var headerOffset = 48; 77 78 var currentVisibleSection = ''; 79 80 var hasVisible = false; 81 82 $(document).ready(function () { 83 stm_sticky_service_header(); 84 85 $('.header-service .header-menu li a, .header-service .header-service-right .service-header-appointment, .stm-slider-button').on('click', function(e){ 86 87 var name = $(this).attr('href'); 88
89 var hash = name.split('#'); 90 91 var pageHasDiv = false; 92 93 if(typeof hash[1] !== 'undefined') { 94 if($('#' + hash[1]).length) { 95 pageHasDiv = true; 96 } 97 } 98 99 if(pageHasDiv){ 100 if(typeof($('div#' + hash[1]).offset()) != 'undefined') { 101 e.preventDefault(); 102 $('html, body').stop().animate({ 103 scrollTop: $('div#' + hash[1]).offset().top - headerOffset 104 }, 700); 105 } 106 } 107 }); 108 }); 109 110 $(window).on('load',function () { 111 stm_sticky_service_header(); 112 113 stm_getSections(); 114 }); 115 116 $(window).on('resize',function () { 117 stm_sticky_service_header(); 118 }); 119 120 $(window).on('scroll', function () { 121 stm_sticky_service_header(); 122 stm_getSections(); 123 }); 124} 125 126// electric vehicle dealership scripts 127if($('.header-main-ev_dealer.header-listing-fixed').length > 0) { 128 129 var $this = $('.header-main-ev_dealer.header-listing-fixed'); 130 var isAbsolute = $this.css('position') == 'absolute'; 131 132 $(document).ready(function () { 133 stm_listing_fixed_header(); 134 }); 135 136 $(window).on('load',function () { 137 stm_listing_fixed_header(); 138 }); 139 140 $(window).on('resize',function () { 141 stm_listing_fixed_header(); 142 }); 143 144 $(window).on('scroll', function () { 145 stm_listing_fixed_header(); 146 }); 147} 148 149// Listing scripts 150if($('.header-listing.header-listing-fixed').length > 0) { 151 152 var $this = $('.header-listing.header-listing-fixed'); 153 var isAbsolute = $this.css('position') == 'absolute'; 154 155 $(document).ready(function () { 156 stm_listing_fixed_header(); 157 }); 158 159 $(window).on('load',function () { 160 stm_listing_fixed_header(); 161 }); 162 163 $(window).on('resize',function () { 164 stm_listing_fixed_header(); 165 }); 166 167 $(window).on('scroll', function () { 168 stm_listing_fixed_header(); 169 }); 170} 171 172// magazine scripts 173if($('.header-magazine.header-magazine-fixed').length > 0) { 174 175 var $this = $('.header-magazine.header-magazine-fixed'); 176 var isAbsolute = $this.css('position') == 'absolute'; 177 178 $(document).ready(function () { 179 stm_listing_fixed_header(); 180 }); 181 182 $(window).load(function () { 183 stm_listing_fixed_header(); 184 }); 185 186 $(window).resize(function () { 187 stm_listing_fixed_header(); 188 }); 189 190 $(window).scroll(function () { 191 stm_listing_fixed_header(); 192 }); 193} 194 195// motorcycle scripts 196if($('.stm_motorcycle-header.header-listing-fixed').length > 0) { 197 198 var $this = $('.stm_motorcycle-header.header-listing-fixed'); 199 var isAbsolute = $this.css('position') == 'absolute'; 200 201 $(document).ready(function () { 202 stm_motocycle_fixed_header(); 203 }); 204 205 $(window).on('load',function () { 206 stm_motocycle_fixed_header(); 207 }); 208 209 $(window).on('resize',function () { 210 stm_motocycle_fixed_header(); 211 }); 212 213 $(window).on('scroll', function () { 214 stm_motocycle_fixed_header(); 215 }); 216} 217 218function stm_sticky_service_header() { 219 var currentScrollPos = $(window).scrollTop(); 220 var headerPos = $('#header').offset().top; 221 if(currentScrollPos >= headerPos) { 222 $('.header-service-fixed').addClass('header-service-sticky'); 223 } else { 224 $('.header-service-fixed').removeClass('header-service-sticky'); 225 } 226 227 if(sections) { 228 hasVisible = false; 229 sections.forEach(function(sectionObj){ 230 231 if(currentScrollPos < sectionObj.height && (currentScrollPos + headerOffset + 1) > sectionObj.offset) { 232 233 currentVisibleSection = sectionObj.id; 234 235 $('.header-service .header-menu li').removeClass('active'); 236 $('a[href="' + sectionObj.id + '"]').closest('li').addClass('active'); 237 238 if(!hasVisible) { 239 hasVisible = true; 240 } 241 242 } 243 244 }); 245 246 if(!hasVisible) { 247 $('.header-service .header-menu li').removeClass('active'); 248 } 249 } 250} 251 252function stm_getSections() { 253 sections = []; 254 255 $('.header-menu li').each(function(){ 256 257 var currentId = $(this).find('a').attr('href'); 258 259 if(currentId.charAt(0) == '#') { 260 261 var currentIdOffset = $('div'+currentId).offset(); 262 263 if(typeof currentIdOffset != 'undefined') { 264 currentIdOffset = currentIdOffset.top; 265 var currenIdHeight = $('div' + currentId).outerHeight() + currentIdOffset; 266 sections.push({ 267 id:currentId, 268 offset: currentIdOffset, 269 height: currenIdHeight 270 }); 271 } 272 } 273 }); 274} 275 276function stm_listing_fixed_header() { 277 278 if( $('.header-listing').hasClass('header-listing-fixed') || $('.header-magazine').hasClass('header-magazine-fixed') || $('.header-main-ev_dealer').hasClass('header-listing-fixed')) { 279 var currentScrollPos = $(window).scrollTop(); 280 var headerPos = $('#header').offset().top; 281 var $headerHeight = 0; 282
283 if ($this.hasClass('listing-nontransparent-header')) { 284 $('#header').css('min-height', $headerHeight = $this.outerHeight() + 'px'); 285 } 286 287 if (currentScrollPos > headerPos) { 288 $this.addClass('stm-fixed-invisible-mobile'); 289 290 } else { 291 $this.removeClass('stm-fixed-invisible-mobile'); 292 } 293 294 if (currentScrollPos > headerPos + 200) { 295 if( !isAbsolute ) $('#header').attr('style', 'min-height: ' + $this.outerHeight() + 'px;'); 296 $this.addClass('stm-fixed-invisible'); 297 } else { 298 $('#header').removeAttr('style'); 299 $this.removeClass('stm-fixed-invisible'); 300 } 301 302 if (currentScrollPos > headerPos + 400) { 303 var width = $("#main").width(); 304 var bg = $this.find(".header-inner-content").attr("data-bg"); 305 $this.addClass('stm-fixed'); 306 if($(".stm-boxed").width() != null) { 307 $this.find(".header-inner-content").attr("style", "background-color: " + bg + "; width: " + width + "px; max-width: " + width + "px;"); 308 $('#header').addClass('stm-header-was-fixed'); 309 } 310 } else { 311 $this.removeClass('stm-fixed'); 312 $('#header').removeClass('stm-header-was-fixed'); 313 $this.find(".header-inner-content").removeAttr("style"); 314 } 315 } 316} 317 318function stm_motocycle_fixed_header() { 319 320 if($('.stm_motorcycle-header').hasClass('header-listing-fixed')) { 321 var currentScrollPos = $(window).scrollTop(); 322 var headerPos = $('#header').offset().top; 323 var $headerHeight = 0; 324 325 if ($this.hasClass('listing-nontransparent-header')) { 326 327 $('#header').css('min-height', $headerHeight = $this.outerHeight() + 'px'); 328 329 } 330 331 if (currentScrollPos > headerPos + 200) { 332 $this.addClass('stm-fixed-invisible'); 333 } else { 334 $this.removeClass('stm-fixed-invisible'); 335 } 336 337 if (currentScrollPos > headerPos + 400) { 338 $this.addClass('stm-fixed'); 339 $('#header').addClass('stm-header-was-fixed'); 340 } else { 341 $this.removeClass('stm-fixed'); 342 $('#header').removeClass('stm-header-was-fixed'); 343 } 344 } 345}
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.