1/*! ET custom.js */ 2(function($){ 3 window.et_calculating_scroll_position = false; 4 window.et_side_nav_links_initialized = false; 5 6 var $et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ), 7 et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ), 8 et_is_ipad = navigator.userAgent.match( /iPad/ ), 9 $et_container = $( '.container' ), 10 et_container_width = $et_container.width(), 11 et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ) || $( 'body' ).hasClass( 'et_vertical_fixed' ), 12 et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ), 13 et_is_rtl = $( 'body' ).hasClass( 'rtl' ), 14 et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ), 15 et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ), 16 $top_header = $('#top-header'), 17 $main_header = $('#main-header'), 18 $main_container_wrapper = $( '#page-container' ), 19 $et_main_content_first_row = $( '#main-content .container:first-child' ), 20 $et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'), 21 $et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1.entry-title' ), 22 $et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'), 23 $et_single_post = $( 'body.single' ), 24 $et_window = $(window), 25 etRecalculateOffset = false, 26 et_header_height, 27 et_header_modifier, 28 et_header_offset, 29 et_primary_header_top, 30 $et_header_style_split = $('.et_header_style_split'), 31 $et_top_navigation = $('#et-top-navigation'), 32 $logo = $('#logo'), 33 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:visible:first' ), 34 et_is_touch_device = 'ontouchstart' in window || navigator.maxTouchPoints, 35 $et_top_cart = $('#et-secondary-menu a.et-cart-info'); 36 37 function et_preload_image( src, callback ) { 38 var img = new Image(); 39 img.onLoad = callback; 40 img.onload = callback; 41 img.src = src; 42 } 43 44 // We need to check first to see if we are on a woocommerce single product. 45 if ( $(".woocommerce .woocommerce-product-gallery").length > 0 ) { 46 // get the gallery container. 47 var gal = $(".woocommerce-product-gallery")[0]; 48 49 // let's replace the data attribute since Salvatorre reconfigures 50 // data-columns on the resize event. 51 var newstr = gal.outerHTML.replace( 'data-columns', 'data-cols' ); 52 53 // finally we re-insert. 54 gal.outerHTML = newstr; 55 } 56 57 // update the cart item on the secondary menu. 58 if ( $et_top_cart.length > 0 && $('.shop_table.cart').length > 0 ) { 59 $( document.body ).on( 'updated_wc_div', function(){ 60 var new_total = 0; 61 var new_text; 62 $('.shop_table.cart').find('.product-quantity input').each(function(){ 63 new_total = new_total + parseInt( $(this).val() ); 64 }); 65 66 if ( new_total === 1 ) { 67 new_text = DIVI.item_count; 68 } else { 69 new_text = DIVI.items_count; 70 } 71 72 new_text = new_text.replace('%d', new_total); 73 74 $et_top_cart.find('span').text(new_text); 75 }); 76 } 77 78 $(document).ready( function(){ 79 var $et_top_menu = $( 'ul.nav, ul.menu' ), 80 $et_search_icon = $( '#et_search_icon' ), 81 et_parent_menu_longpress_limit = 300, 82 et_parent_menu_longpress_start, 83 et_parent_menu_click = true, 84 is_customize_preview = $('body').hasClass('et_is_customize_preview'); 85 86 window.et_pb_init_nav_menu( $et_top_menu ); 87 88 function et_header_menu_split(){ 89 var $logo_container = $( '#main-header > .container > .logo_container' ), 90 $logo_container_splitted = $('.centered-inline-logo-wrap > .logo_container'), 91 et_top_navigation_li_size = $et_top_navigation.children('nav').children('ul').children('li').size(), 92 et_top_navigation_li_break_index = Math.round( et_top_navigation_li_size / 2 ) - 1, 93 window_width = window.innerWidth || $et_window.width(); 94 95 if ( window_width > 980 && $logo_container.length && $('body').hasClass('et_header_style_split') ) { 96 $('<li class="centered-inline-logo-wrap"></li>').insertAfter($et_top_navigation.find('nav > ul >li:nth('+et_top_navigation_li_break_index+')') ); 97 $logo_container.appendTo( $et_top_navigation.find('.centered-inline-logo-wrap') ); 98 } 99 100 if ( window_width <= 980 && $logo_container_splitted.length ) { 101 $logo_container_splitted.prependTo('#main-header > .container'); 102 $('#main-header .centered-inline-logo-wrap').remove(); 103 } 104 } 105
106 function et_set_right_vertical_menu() { 107 var $body = $( 'body' ); 108 if ( $body.hasClass( 'et_boxed_layout' ) && $body.hasClass( 'et_vertical_fixed' ) && $body.hasClass( 'et_vertical_right' ) ) { 109 var header_offset = parseFloat( $( '#page-container' ).css( 'margin-right' ) ); 110 header_offset += ( parseFloat( $( '#et-main-area' ).css( 'margin-right' ) ) - 225 ); 111 header_offset = 0 > header_offset ? 0 : header_offset; 112 113 $( '#main-header' ).addClass( 'et_vertical_menu_set' ).css( { 'left': '', 'right': header_offset } ); 114 } 115 } 116 117 if ( ( $et_header_style_split.length && ! window.et_is_vertical_nav ) || is_customize_preview ) { 118 et_header_menu_split(); 119 120 $(window).resize(function(){ 121 et_header_menu_split(); 122 }); 123 } 124 125 if ( window.et_is_vertical_nav ) { 126 if ( $( '#main-header' ).height() < $( '#et-top-navigation' ).height() ) { 127 $( '#main-header' ).height( $( '#et-top-navigation' ).height() + $( '#logo' ).height() + 100 ); 128 } 129 et_set_right_vertical_menu(); 130 } 131 132 window.et_calculate_header_values = function() { 133 var $top_header = $( '#top-header' ), 134 secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? parseInt( $top_header.innerHeight() ) : 0, 135 admin_bar_height = $( '#wpadminbar' ).length ? parseInt( $( '#wpadminbar' ).innerHeight() ) : 0, 136 $slide_menu_container = $( '.et_header_style_slide .et_slide_in_menu_container' ); 137 138 et_header_height = parseInt( $( '#main-header' ).innerHeight() ) + secondary_nav_height; 139 et_header_modifier = et_header_height <= 90 ? et_header_height - 29 : et_header_height - 56; 140 et_header_offset = et_header_modifier + admin_bar_height; 141 142 et_primary_header_top = secondary_nav_height + admin_bar_height; 143 144 if ( $slide_menu_container.length && ! $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 145 $slide_menu_container.css( { right: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px', 'display' : 'none' } ); 146 147 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) ) { 148 var page_container_margin = $main_container_wrapper.css( 'margin-left' ); 149 $main_header.css( { left : page_container_margin } ); 150 } 151 } 152 }; 153 154 var $comment_form = $('#commentform'); 155 156 et_pb_form_placeholders_init( $comment_form ); 157 158 $comment_form.submit(function(){ 159 et_pb_remove_placeholder_text( $comment_form ); 160 }); 161 162 et_duplicate_menu( $('#et-top-navigation ul.nav'), $('#et-top-navigation .mobile_nav'), 'mobile_menu', 'et_mobile_menu' ); 163 et_duplicate_menu( '', $('.et_pb_fullscreen_nav_container'), 'mobile_menu_slide', 'et_mobile_menu', 'no_click_event' ); 164 165 // Handle `Disable top tier dropdown menu links` Theme Option. 166 if ($('ul.et_disable_top_tier').length) { 167 $disbaled_top_tier_links = $("ul.et_disable_top_tier > li > ul").prev('a'); 168 169 $disbaled_top_tier_links.attr('href', '#'); 170 $disbaled_top_tier_links.on('click', function(e) { 171 e.preventDefault(); 172 }); 173 174 // Handle top tier links in cloned mobile menu 175 $disbaled_top_tier_links_mobile = $("ul#mobile_menu > li > ul").prev('a'); 176 177 $disbaled_top_tier_links_mobile.attr('href', '#'); 178 $disbaled_top_tier_links_mobile.on('click', function(e) { 179 e.preventDefault(); 180 }); 181 } 182 183 if ( $( '#et-secondary-nav' ).length ) { 184 $('#et-top-navigation #mobile_menu').append( $( '#et-secondary-nav' ).clone().html() ); 185 } 186 187 // adding arrows for the slide/fullscreen menus 188 if ( $( '.et_slide_in_menu_container' ).length ) { 189 var $item_with_sub = $( '.et_slide_in_menu_container' ).find( '.menu-item-has-children > a' ); 190 // add arrows for each menu item which has submenu 191 if ( $item_with_sub.length ) { 192 $item_with_sub.append( '<span class="et_mobile_menu_arrow"></span>' ); 193 } 194 } 195 196 function et_change_primary_nav_position( delay ) { 197 setTimeout( function() { 198 var $body = $('body'), 199 $wpadminbar = 'undefined' !== typeof window.top ? window.top.jQuery('#wpadminbar') : $('#wpadminbar'), 200 $top_header = $( '#top-header' ), 201 et_primary_header_top = 0; 202 203 if ( $wpadminbar.length ) { 204 var adminbarHeight = $wpadminbar.innerHeight(); 205 206 // Adjust admin bar height for builder's preview mode zoom since admin bar is rendered on top window 207 if ('undefined' !== typeof window.top && window.top.jQuery('html').is('.et-fb-preview--zoom:not(.et-fb-preview--desktop)')) { 208 adminbarHeight = adminbarHeight * 2; 209 } 210 211 et_primary_header_top += adminbarHeight; 212 } 213 214 if ( $top_header.length && $top_header.is(':visible') ) {
215 et_primary_header_top += $top_header.innerHeight(); 216 } 217 218 if ( ! window.et_is_vertical_nav && ( $body.hasClass( 'et_fixed_nav' ) ) ) { 219 $('#main-header').css( 'top', et_primary_header_top ); 220 } 221 }, delay ); 222 } 223 224 window.et_change_primary_nav_position = et_change_primary_nav_position; 225 226 function et_hide_nav_transform( ) { 227 var $body = $( 'body' ), 228 $body_height = $( document ).height(), 229 $viewport_height = $( window ).height() + et_header_height + 200; 230 231 // Do nothing when Vertical Navigation is Enabled 232 if ($body.hasClass('et_vertical_nav')) { 233 return; 234 } 235 236 if ($body.hasClass('et_hide_nav') || $body.hasClass('et_hide_nav_disabled') && ($body.hasClass('et_fixed_nav'))) { 237 if ($body_height > $viewport_height) { 238 if ($body.hasClass('et_hide_nav_disabled')) { 239 $body.addClass('et_hide_nav'); 240 $body.removeClass('et_hide_nav_disabled'); 241 } 242 $('#main-header').css('transform', 'translateY(-' + et_header_height + 'px)'); 243 $('#top-header').css('transform', 'translateY(-' + et_header_height + 'px)'); 244 } else { 245 $('#main-header').css({ 'transform': 'translateY(0)', 'opacity': '1' }); 246 $('#top-header').css({ 'transform': 'translateY(0)', 'opacity': '1' }); 247 $body.removeClass('et_hide_nav'); 248 $body.addClass('et_hide_nav_disabled'); 249 } 250 251 // Run fix page container again, needed when body height is not tall enough and 252 // adjustment has been aded 253 et_fix_page_container_position(); 254 } 255 } 256 257 // Saving current styling for the next resize cycle 258 function et_save_initial_page_container_style( $selector, property ) { 259 var styling = {}; 260 261 styling[property] = $selector.css( property ); 262 263 $selector.attr({ 264 'data-fix-page-container' : 'on' 265 }).data({ 266 'fix_page_container_style' : styling 267 }); 268 } 269 270 function et_page_load_scroll_to_anchor() { 271 var location_hash = window.et_location_hash.replace(/(\|)/g, "\\$1"); 272 273 if ($(location_hash).length === 0) { 274 return; 275 } 276 277 var $map_container = $(location_hash + ' .et_pb_map_container'); 278 var $map = $map_container.children('.et_pb_map'); 279 var $target = $(location_hash); 280 281 // Make the target element visible again 282 $target.css('display', window.et_location_hash_style); 283 284 var distance = ('undefined' !== typeof($target.offset().top)) ? $target.offset().top : 0; 285 var speed = (distance > 4000) ? 1600 : 800; 286 287 if ($map_container.length) { 288 google.maps.event.trigger($map[0], 'resize'); 289 } 290 291 // Allow the header sizing functions enough time to finish before scrolling the page 292 setTimeout(function() { 293 et_pb_smooth_scroll($target, false, speed, 'swing'); 294 295 // During the page scroll animation, the header's height might change. 296 // Do the scroll animation again to ensure its accuracy. 297 setTimeout(function() { 298 et_pb_smooth_scroll($target, false, 150, 'linear'); 299 }, speed + 25); 300 301 }, 700); 302 } 303 304 // Retrieving padding/margin value based on formatted saved padding/margin strings 305 function et_get_saved_padding_margin_value( saved_value, order ) { 306 if ( typeof saved_value === 'undefined' ) { 307 return false; 308 } 309 310 var values = saved_value.split('|'); 311 312 return typeof values[order] !== 'undefined' ? values[order] : false; 313 } 314 315 function et_fix_page_container_position(){ 316 var et_window_width = parseInt( $et_window.width() ), 317 $top_header = $( '#top-header' ), 318 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:visible:first' ), 319 secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? parseInt( $top_header.innerHeight() ) : 0, 320 main_header_fixed_height = 0, 321 header_height, 322 et_pb_first_row_padding_top; 323 324 var $mainHeaderClone = $main_header 325 .clone() 326 .addClass('et-disabled-animations main-header-clone') 327 .css({ 328 opacity: 0, 329 position: 'fixed', 330 top: 'auto', 331 right: 0, 332 bottom: 0, 333 left: 0, 334 }) 335 .appendTo($('body')); 336 337 // Replace previous resize cycle's adjustment 338 if (!$('body').hasClass('et-bfb')) { 339 $('*[data-fix-page-container="on"]').each(function(){ 340 var $adjusted_element = $(this), 341 styling = $adjusted_element.data(); 342 343 if (styling && styling.fix_page_container_style) { 344 // Reapply previous styling 345 $adjusted_element.css( styling.fix_page_container_style ); 346 } 347 348 }); 349 } 350 351 // Set data-height-onload for header if the page is loaded on large screen 352 // If the page is loaded from small screen, rely on data-height-onload printed on the markup, 353 // prevent window resizing issue from small to large 354 // ignore data-height-loaded in VB to make sure it calculated correctly. 355 if (et_window_width > 980 && (! $main_header.attr('data-height-loaded') || $('body').is('.et-fb'))) { 356 var mainHeaderHeight = 0; 357 if ($main_header.hasClass('et-fixed-header')) { 358 $mainHeaderClone.removeClass('et-fixed-header'); 359 mainHeaderHeight = $mainHeaderClone.height(); 360 $mainHeaderClone.addClass('et-fixed-header'); 361 } else { 362 mainHeaderHeight = $main_header.height(); 363 } 364 $main_header.attr({ 'data-height-onload' : parseInt(mainHeaderHeight), 'data-height-loaded' : true }); 365 } 366 367 // Use on page load calculation for large screen. Use on the fly calculation for small screen (980px below) 368 if ( et_window_width <= 980 ) {
369 header_height = parseInt( $main_header.innerHeight() ) + secondary_nav_height - ($('body').hasClass('et-fb') ? 0 : 1); 370 371 // If transparent is detected, #main-content .container's padding-top needs to be added to header_height 372 // And NOT a pagebuilder page 373 if ( window.et_is_transparent_nav && ! $et_pb_first_row.length ) { 374 header_height += 58; 375 } 376 } else { 377 378 // Get header height from header attribute 379 header_height = parseInt( $main_header.attr( 'data-height-onload' ) ) + secondary_nav_height; 380 381 // Non page builder page needs to be added by #main-content .container's fixed height 382 if ( window.et_is_transparent_nav && ! window.et_is_vertical_nav && $et_main_content_first_row.length ) { 383 header_height += 58; 384 } 385 386 // Calculate fixed header height by cloning, emulating, and calculating its height 387 main_header_fixed_height = $mainHeaderClone.height(); 388 } 389 390 // Saved fixed main header height calculation 391 $main_header.attr({ 392 'data-fixed-height-onload': main_header_fixed_height 393 }); 394 395 // Specific adjustment required for transparent nav + not vertical nav 396 if (window.et_is_transparent_nav && !window.et_is_vertical_nav) { 397 398 if (!$('body').hasClass('et-bfb')) { 399 // Add class for first row for custom section padding purpose 400 $et_pb_first_row.addClass( 'et_pb_section_first' ); 401 } 402 403 // List of conditionals 404 var is_pb = $et_pb_first_row.length, 405 is_post_pb = is_pb && $et_single_post.length, 406 is_post_pb_full_layout_has_title = $et_pb_post_fullwidth.length && $et_main_content_first_row_meta_wrapper_title.length, 407 is_post_pb_full_layout_no_title = $et_pb_post_fullwidth.length && 0 === $et_main_content_first_row_meta_wrapper_title.length, 408 is_pb_fullwidth_section_first = $et_pb_first_row.is( '.et_pb_fullwidth_section' ), 409 is_no_pb_mobile = et_window_width <= 980 && $et_main_content_first_row.length, 410 isProject = $( 'body' ).hasClass( 'single-project' ); 411 412 if ( is_post_pb && ! ( is_post_pb_full_layout_no_title && is_pb_fullwidth_section_first ) && !isProject ) { 413 414 /* Desktop / Mobile + Single Post */ 415 416 /* 417 * EXCEPT for fullwidth layout + fullwidth section ( at the first row ). 418 * It is basically the same as page + fullwidth section with few quirk. 419 * Instead of duplicating the conditional for each module, it'll be simpler to negate 420 * fullwidth layout + fullwidth section in is_post_pb and rely it to is_pb_fullwidth_section_first 421 */ 422 423 // Remove main content's inline padding to styling to prevent looping padding-top calculation 424 $et_main_content_first_row.css({ 'paddingTop' : '' }); 425 426 if ( et_window_width < 980 ) { 427 header_height += 40; 428 } 429 430 if ( is_pb_fullwidth_section_first ) { 431 // If the first section is fullwidth, restore the padding-top modified area at first section 432 $et_pb_first_row.css({ 433 'paddingTop' : '0' 434 }); 435 } 436 437 if ( is_post_pb_full_layout_has_title ) { 438 439 // Add header height to post meta wrapper as padding top 440 $et_main_content_first_row_meta_wrapper.css({ 441 'paddingTop' : header_height 442 }); 443 444 } else if ( is_post_pb_full_layout_no_title ) { 445 446 // Save current styling for the next resize cycle 447 et_save_initial_page_container_style( 448 $et_pb_first_row, 449 'paddingTop' 450 ); 451 452 // Reset any inline padding-top. 453 $et_pb_first_row.css({ 454 paddingTop: '' 455 }); 456 457 $et_pb_first_row.css({ 458 // Ignore the extra 58px added to header height previously. 459 'paddingTop' : 'calc(' + (header_height - 58) + 'px + ' + $et_pb_first_row.css('paddingTop') + ')' 460 }); 461 462 } else { 463 464 // Save current styling for the next resize cycle 465 et_save_initial_page_container_style( 466 $et_main_content_first_row, 467 'paddingTop' 468 ); 469 470 // Add header height to first row content as padding top 471 $et_main_content_first_row.css({ 472 'paddingTop' : header_height 473 }); 474 475 } 476 477 } else if ( is_pb_fullwidth_section_first ){ 478 479 /* Desktop / Mobile + Pagebuilder + Fullwidth Section */ 480 481 var $et_pb_first_row_first_module = $et_pb_first_row.children( '.et_pb_module:visible:first' ); 482 483 // Quirks: If this is post with fullwidth layout + no title + fullwidth section at first row, 484 // Remove the added height at line 2656 485 if ( is_post_pb_full_layout_no_title && is_pb_fullwidth_section_first && et_window_width > 980 ) { 486 header_height = header_height - 58; 487 } 488 489 if ( $et_pb_first_row_first_module.is( '.et_pb_slider' ) ) { 490 491 /* Desktop / Mobile + Pagebuilder + Fullwidth slider */ 492 493 var $et_pb_first_row_first_module_slide_image = $et_pb_first_row_first_module.find( '.et_pb_slide_image' ), 494 $et_pb_first_row_first_module_slide = $et_pb_first_row_first_module.find( '.et_pb_slide' ), 495 $et_pb_first_row_first_module_slide_container = $et_pb_first_row_first_module.find( '.et_pb_slide .et_pb_container' ), 496 et_pb_slide_image_margin_top = 0 - ( parseInt( $et_pb_first_row_first_module_slide_image.height() ) / 2 ), 497 et_pb_slide_container_height = 0, 498 $et_pb_first_row_first_module_slider_arrow = $et_pb_first_row_first_module.find( '.et-pb-slider-arrows a'), 499 et_pb_first_row_slider_arrow_height = $et_pb_first_row_first_module_slider_arrow.height(); 500 501 // Save current styling for the next resize cycle 502 et_save_initial_page_container_style( 503 $et_pb_first_row_first_module_slide, 504 'paddingTop' 505 ); 506 507 // Adding padding top to each slide so the transparency become useful 508 $et_pb_first_row_first_module_slide.css({ 509 'paddingTop' : header_height 510 }); 511 512 // delete container's min-height 513 $et_pb_first_row_first_module_slide_container.css({ 514 'min-height' : '' 515 }); 516 517 518 // Save current styling for the next resize cycle 519 et_save_initial_page_container_style( 520 $et_pb_first_row_first_module_slide_image, 521 'marginTop' 522 ); 523 524 // Adjusting slider's image, considering additional top padding of slideshow 525 $et_pb_first_row_first_module_slide_image.css({ 526 'marginTop' : et_pb_slide_image_margin_top 527 }); 528 529 // Save current styling for the next resize cycle 530 et_save_initial_page_container_style( 531 $et_pb_first_row_first_module_slider_arrow, 532 'marginTop' 533 ); 534 535 // Adjusting slider's arrow, considering additional top padding of slideshow 536 $et_pb_first_row_first_module_slider_arrow.css({ 537 'marginTop' : ( ( header_height / 2 ) - ( et_pb_first_row_slider_arrow_height / 2 ) ) 538 }); 539 540 // Looping the slide and get the highest height of slide 541 var et_pb_first_row_slide_container_height_new = 0; 542 543 $et_pb_first_row_first_module.find( '.et_pb_slide' ).each( function(){ 544 var $et_pb_first_row_first_module_slide_item = $(this), 545 $et_pb_first_row_first_module_slide_container = $et_pb_first_row_first_module_slide_item.find( '.et_pb_container' ); 546 547 // Make sure that the slide is visible to calculate correct height 548 $et_pb_first_row_first_module_slide_item.show(); 549 550 // Remove existing inline css to make sure that it calculates the height 551 $et_pb_first_row_first_module_slide_container.css({ 'min-height' : '' }); 552 553 var et_pb_first_row_slide_container_height = $et_pb_first_row_first_module_slide_container.innerHe
553ight(); 554 555 if ( et_pb_first_row_slide_container_height_new < et_pb_first_row_slide_container_height ){ 556 et_pb_first_row_slide_container_height_new = et_pb_first_row_slide_container_height; 557 } 558 559 // Hide the slide back if it isn't active slide 560 if ( $et_pb_first_row_first_module_slide_item.is( ':not(".et-pb-active-slide")' ) ){ 561 $et_pb_first_row_first_module_slide_item.hide(); 562 } 563 }); 564 565 // Save current styling for the next resize cycle 566 et_save_initial_page_container_style( 567 $et_pb_first_row_first_module_slide_container, 568 'min-height' 569 ); 570 571 // Setting appropriate min-height, considering additional top padding of slideshow 572 $et_pb_first_row_first_module_slide_container.css({ 573 'min-height' : et_pb_first_row_slide_container_height_new 574 }); 575 576 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_header' ) ) { 577 578 /* Desktop / Mobile + Pagebuilder + Fullwidth header */ 579 580 // Remove existing inline stylesheet to prevent looping padding 581 $et_pb_first_row_first_module.removeAttr( 'style' ); 582 583 // Get paddingTop from stylesheet 584 var et_pb_first_row_first_module_fullwidth_header_padding_top = parseInt( $et_pb_first_row_first_module.css( 'paddingTop' ) ); 585 586 // Save current styling for the next resize cycle 587 et_save_initial_page_container_style( 588 $et_pb_first_row_first_module, 589 'paddingTop' 590 ); 591 592 // Implement stylesheet's padding-top + header_height 593 $et_pb_first_row_first_module.css({ 594 'paddingTop' : ( header_height + et_pb_first_row_first_module_fullwidth_header_padding_top ) 595 } ); 596 597 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_portfolio' ) ) { 598 599 /* Desktop / Mobile + Pagebuilder + Fullwidth Portfolio */ 600 601 // Save current styling for the next resize cycle 602 et_save_initial_page_container_style( 603 $et_pb_first_row_first_module, 604 'paddingTop' 605 ); 606 607 $et_pb_first_row_first_module.css({ 'paddingTop' : header_height }); 608 609 } else if ( $et_pb_first_row_first_module.is( '.et_pb_map_container' ) ) { 610 611 /* Desktop / Mobile + Pagebuilder + Fullwidth Map */ 612 613 var $et_pb_first_row_map = $et_pb_first_row_first_module.find( '.et_pb_map' ); 614 615 // Remove existing inline height to prevent looping height calculation 616 $et_pb_first_row_map.css({ 'height' : '' }); 617 618 // Implement map height + header height 619 $et_pb_first_row_first_module.find('.et_pb_map').css({ 620 'height' : header_height + parseInt( $et_pb_first_row_map.css( 'height' ) ) 621 }); 622 623 // Adding specific class to mark the map as first row section element 624 $et_pb_first_row_first_module.addClass( 'et_beneath_transparent_nav' ); 625 626 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_menu' ) ) { 627 628 /* Desktop / Mobile + Pagebuilder + Fullwidth Menu */ 629 630 // Save current styling for the next resize cycle 631 et_save_initial_page_container_style( 632 $et_pb_first_row_first_module, 633 'marginTop' 634 ); 635 636 $et_pb_first_row_first_module.css({ 'marginTop' : header_height }); 637 638 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_code' ) ) { 639 640 /* Desktop / Mobile + Pagebuilder + Fullwidth code */ 641 642 var $et_pb_first_row_first_module_code = $et_pb_first_row_first_module; 643 644 $et_pb_first_row_first_module_code.css({ 'paddingTop' : '' }); 645 646 var et_pb_first_row_first_module_code_padding_top = parseInt( $et_pb_first_row_first_module_code.css( 'paddingTop' ) ); 647 648 // Save current styling for the next resize cycle 649 et_save_initial_page_container_style( 650 $et_pb_first_row_first_module_code, 651 'paddingTop' 652 ); 653 654 $et_pb_first_row_first_module_code.css({ 655 'paddingTop' : header_height + et_pb_first_row_first_module_code_padding_top 656 }); 657 658 } else if ( $et_pb_first_row_first_module.is( '.et_pb_post_title' ) ) { 659 660 /* Desktop / Mobile + Pagebuilder + Fullwidth Post Title */ 661 var $et_pb_first_row_first_module_title = $et_pb_first_row_first_module; 662 663 // Save current styling for the next resize cycle 664 et_save_initial_page_container_style( 665 $et_pb_first_row_first_module_title, 666 'paddingTop' 667 ); 668 669 $et_pb_first_row_first_module.css({ 670 'paddingTop' : header_height + 50 671 }); 672 } else if ( ! $et_pb_first_row_first_module.length ) { 673 // Get current padding top 674 et_pb_first_row_padding_top = parseFloat($et_pb_first_row.css('paddingTop')); 675 676 // Save current styling for the next resize cycle 677 et_save_initial_page_container_style( 678 $et_pb_first_row, 679 'paddingTop' 680 ); 681 682 // Keep the state of previous cycle. The padding top is reset to the first 683 // cycle by default (padding-top: 0px) so if previous cycle didn't hide the 684 // nav, automatically add the additional padding top 685 if ( ! $et_pb_first_row.data( 'is_hide_nav' ) ) { 686 $et_pb_first_row.css({ 687 'paddingTop' : et_pb_first_row_padding_top + header_height 688 }); 689 } 690 691 // Use timeout to avoid flickering padding top when window is resized vertically
692 // and hidden nav is transitioned to visible nav, vice versa. 693 clearTimeout(window.et_fallback_transparent_adjustment_timeout); 694 window.et_fallback_transparent_adjustment_timeout = setTimeout(function() { 695 // Hidden nav can be decided by the existance of et_hide_nav class AND 696 // the css transform attribute value because the visibility of nav is 697 // modified by CSS transition 698 var is_hide_nav = $('body').hasClass('et_hide_nav') && $('#main-header').css('transform') !== 'matrix(1, 0, 0, 1, 0, 0)'; 699 700 // Add / remove additional top padding accordingly 701 if ( is_hide_nav ) { 702 $et_pb_first_row.css({ 703 'paddingTop' : '' 704 }); 705 } else { 706 $et_pb_first_row.css({ 707 'paddingTop' : et_pb_first_row_padding_top + header_height 708 }); 709 } 710 711 // Save current nav state for next cycle assessment 712 $et_pb_first_row.data( 'is_hide_nav', is_hide_nav ); 713 }, 300) 714 } 715 716 } else if ( is_pb ) { 717 718 /* Desktop / Mobile + Pagebuilder + Regular section */ 719 720 // Remove first row's inline padding top styling to prevent looping padding-top calculation 721 $et_pb_first_row.css({ 'paddingTop' : '' }); 722 723 // Get saved custom padding from data-* attributes. Builder automatically adds 724 // saved custom paddings to data-* attributes on first section 725 var saved_custom_padding = $et_pb_first_row.attr('data-padding'), 726 saved_custom_padding_top = et_get_saved_padding_margin_value( saved_custom_padding, 0 ), 727 saved_custom_padding_tablet = $et_pb_first_row.attr('data-padding-tablet'), 728 saved_custom_padding_tablet_top = et_get_saved_padding_margin_value( saved_custom_padding_tablet, 0 ), 729 saved_custom_padding_phone = $et_pb_first_row.attr('data-padding-phone'), 730 saved_custom_padding_phone_top = et_get_saved_padding_margin_value( saved_custom_padding_phone, 0 ), 731 applied_saved_custom_padding; 732 733 if ( saved_custom_padding_top || saved_custom_padding_tablet_top || saved_custom_padding_phone_top ) { 734 // Applies padding top to first section to automatically convert saved unit into px 735 if ( et_window_width > 980 && saved_custom_padding_top ) { 736 $et_pb_first_row.css({ 737 paddingTop: saved_custom_padding_top 738 }); 739 } else if ( et_window_width > 767 && saved_custom_padding_tablet_top ) { 740 $et_pb_first_row.css({ 741 paddingTop: saved_custom_padding_tablet_top 742 }); 743 } else if ( saved_custom_padding_phone_top ) { 744 $et_pb_first_row.css({ 745 paddingTop: saved_custom_padding_phone_top 746 }); 747 } 748 749 // Get converted custom padding top value 750 applied_saved_custom_padding = parseInt( $et_pb_first_row.css( 'paddingTop' ) ); 751 752 // Implemented saved & converted padding top + header height 753 $et_pb_first_row.css({ 754 paddingTop: ( header_height + applied_saved_custom_padding ) 755 }); 756 } else { 757 // Pagebuilder ignores #main-content .container's fixed height and uses its row's padding 758 // Anticipate the use of custom section padding. 759 et_pb_first_row_padding_top = header_height + parseInt( $et_pb_first_row.css( 'paddingTop' ) ); 760 761 // Save current styling for the next resize cycle 762 et_save_initial_page_container_style( 763 $et_pb_first_row, 764 'paddingTop' 765 ); 766 767 // Implementing padding-top + header_height 768 $et_pb_first_row.css({ 769 'paddingTop' : et_pb_first_row_padding_top 770 }); 771 } 772 } else if ( is_no_pb_mobile ) { 773 774 // Mobile + not pagebuilder 775 $et_main_content_first_row.css({ 776 'paddingTop' : header_height 777 }); 778 779 } else { 780 781 $('#main-content .container:first-child').css({ 782 'paddingTop' : header_height 783 }); 784 785 } 786 787 // Set #page-container's padding-top to zero after inline styling first row's content has been added 788 if ( ! $('#et_fix_page_container_position').length ){ 789 $( '<style />', { 790 'id' : 'et_fix_page_container_position', 791 'text' : '#page-container{ padding-top: 0 !important;}' 792 }).appendTo('head'); 793 } 794 795 // If the first visible (visibility is significant for for cached split test) section has parallax background, 796 // trigger parallax height resize so the parallax location isn't correctly rendered due to addition of first 797 // section/module margin-top/padding-top which is needed for transparent primary nav 798 if ($('.et_pb_section:visible:first').hasClass('et_pb_section_parallax')) {
799 $(window).trigger('resize.etTrueParallaxBackground'); 800 } 801 802 } else if( et_is_fixed_nav ) { 803 804 $main_container_wrapper.css( 'paddingTop', header_height ); 805 806 } 807 808 $mainHeaderClone.remove(); 809 et_change_primary_nav_position( 0 ); 810 $(document).trigger('et-pb-header-height-calculated'); 811 } 812 window.et_fix_page_container_position = et_fix_page_container_position; 813 814 // Save container width on page load for reference 815 $et_container.data( 'previous-width', $et_container.width() ); 816 817 $( window ).resize( function(){ 818 var window_width = parseInt( $et_window.width() ), 819 et_container_previous_width = parseInt( $et_container.data('previous-width') ), 820 et_container_css_width = $et_container.css( 'width' ), 821 et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '', 822 et_container_actual_width = ( et_container_width_in_pixel ) ? parseInt( $et_container.width() ) : ( ( parseInt( $et_container.width() ) / 100 ) * window_width ), // $et_container.width() doesn't recognize pixel or percentage unit. It's our duty to understand what it returns and convert it properly 823 containerWidthChanged = et_container_previous_width !== et_container_actual_width, 824 $slide_menu_container = $( '.et_slide_in_menu_container' ), 825 isAppFrame = 'undefined' !== typeof window.top, 826 $adminbar = isAppFrame ? window.top.jQuery('#wpadminbar') : $('#wpadminbar'), 827 page_container_margin; 828 829 if ( et_is_fixed_nav && containerWidthChanged ) { 830 if ( typeof update_page_container_position != 'undefined' ){ 831 clearTimeout( update_page_container_position ); 832 } 833 834 var update_page_container_position = setTimeout( function() { 835 et_fix_page_container_position(); 836 if ( typeof et_fix_fullscreen_section === 'function' ) { 837 et_fix_fullscreen_section(); 838 } 839 }, 200 ); 840 841 // Update container width data for future resizing reference 842 $et_container.data('previous-width', et_container_actual_width ); 843 } 844 845 if ( et_hide_nav ) { 846 et_hide_nav_transform(); 847 } 848 849 // Update header and primary adjustment when transitioning across breakpoints or inside visual builder 850 if (($adminbar.length && et_is_fixed_nav && window_width >= 740 && window_width <= 782) || isAppFrame) { 851 et_calculate_header_values(); 852 853 et_change_primary_nav_position( 0 ); 854 } 855 856 et_set_search_form_css(); 857 858 if ( $slide_menu_container.length && ! $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 859 $slide_menu_container.css( { right: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px' } ); 860 861 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) && et_is_fixed_nav ) { 862 page_container_margin = $main_container_wrapper.css( 'margin-left' ); 863 $main_header.css( { left : page_container_margin } ); 864 } 865 } 866 867 if ( $slide_menu_container.length && $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 868 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) ) { 869 var left_position; 870 page_container_margin = parseFloat( $main_container_wrapper.css( 'margin-left' ) ); 871 872 $main_container_wrapper.css( { left: '-' + ( parseInt( $slide_menu_container.innerWidth() ) - page_container_margin ) + 'px' } ); 873 874 if ( et_is_fixed_nav ) { 875 left_position = 0 > parseInt( $slide_menu_container.innerWidth() ) - ( page_container_margin * 2 ) ? Math.abs( $slide_menu_container.innerWidth() - ( page_container_margin * 2 ) ) : '-' + ( $slide_menu_container.innerWidth() - ( page_container_margin * 2 ) ); 876 877 if ( left_position < parseInt( $slide_menu_container.innerWidth() ) ) { 878 $main_header.css( { left: left_position + 'px' } ); 879 } 880 } 881 } else { 882 $( '#page-container, .et_fixed_nav #main-header' ).css( { left: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px' } ); 883 } 884 } 885 886 // adjust the padding in fullscreen menu 887 if ( $slide_menu_container.length && $( 'body' ).hasClass( 'et_header_style_fullscreen' ) ) { 888 var top_bar_height = parseInt( $slide_menu_container.find( '.et_slide_menu_top' ).innerHeight() ); 889 890 $slide_menu_container.css( { 'padding-top': top_bar_height + 20 } ); 891 } 892
893 et_set_right_vertical_menu(); 894 } ); 895 896 $( window ).ready( function(){ 897 if ( $.fn.fitVids ) { 898 $( '#main-content' ).fitVids( { customSelector: "iframe[src^='http://www.hulu.com'], iframe[src^='http://www.dailymotion.com'], iframe[src^='http://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='http://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='http://blip.tv'], iframe[src^='http://www.collegehumor.com']"} ); 899 } 900 } ); 901 902 function et_all_elements_loaded() { 903 if ( et_is_fixed_nav ) { 904 et_calculate_header_values(); 905 } 906 907 // Run container position calculation with 0 timeout to make sure all elements are ready for proper calculation. 908 setTimeout(function() { 909 et_fix_page_container_position(); 910 }, 0); 911 912 // Minified JS is ordered differently to avoid jquery-migrate to cause js error. 913 // This might cause hiccup on some specific configuration (ie. parallax of first module on transparent nav) 914 // Triggerring resize, in most case, re-calculate the UI correctly 915 if ( window.et_is_minified_js && window.et_is_transparent_nav && ! window.et_is_vertical_nav ){ 916 $( window ).trigger( 'resize' ); 917 } 918 919 if ( window.hasOwnProperty( 'et_location_hash' ) && '' !== window.et_location_hash ) { 920 // Handle the page scroll that we prevented earlier in the <head> 921 et_page_load_scroll_to_anchor(); 922 } 923 924 if ( et_header_style_left && !window.et_is_vertical_nav) { 925 $logo_width = parseInt( $( '#logo' ).width() ); 926 if ( et_is_rtl ) { 927 $et_top_navigation.css( 'padding-right', $logo_width + 30 ); 928 } else { 929 $et_top_navigation.css( 'padding-left', $logo_width + 30 ); 930 } 931 } 932 933 if ( $('p.demo_store').length ) { 934 $('#footer-bottom').css('margin-bottom' , $('p.demo_store').innerHeight()); 935 } 936 937 if ( $.fn.waypoint ) { 938 var $waypoint_selector; 939 if ( et_is_vertical_fixed_nav ) { 940 $waypoint_selector = $('#main-content'); 941 942 $waypoint_selector.waypoint( { 943 handler : function( direction ) { 944 et_fix_logo_transition(); 945 946 if ( direction === 'down' ) { 947 $('#main-header').addClass( 'et-fixed-header' ); 948 } else { 949 $('#main-header').removeClass( 'et-fixed-header' ); 950 } 951 } 952 } ); 953 } 954 955 if ( et_is_fixed_nav ) { 956 957 // We don't want product pages with divi-builder to trigger fixed navigation 958 // based on builder row/module position 959 if (window.et_is_transparent_nav && ! (window.et_is_vertical_nav || $('body.woocommerce.single-product').length) && $et_pb_first_row.length) { 960 961 // Fullscreen section at the first row requires specific adjustment 962 if ($et_pb_first_row.is('.et_pb_fullwidth_section')) { 963 $waypoint_selector = $et_pb_first_row.children('.et_pb_module:visible:first'); 964 } else { 965 $waypoint_selector = $et_pb_first_row.find('.et_pb_row:visible:first'); 966 } 967 968 // Fallback for a less likely but possible scenario: a) fullwidth section 969 // has no module OR b) other section has no row. When this happened, 970 // the safest option is look for the first visible module and use it 971 // as waypoint selector 972 if (! $waypoint_selector.length) { 973 $waypoint_selector = $('body.et_pb_pagebuilder_layout .et_pb_module:visible:first'); 974 } 975 } else if (window.et_is_transparent_nav && ! window.et_is_vertical_nav && $et_main_content_first_row.length) { 976 $waypoint_selector = $('#content-area'); 977 } else { 978 $waypoint_selector = $('#main-content'); 979 } 980 981 // Disabled section/row/module can cause waypoint to trigger 'down' event during its setup even if 982 // no scrolling happened, which would result in 'et-fixed-header' class being prematurely added. 983 // Since this only happens when page is loaded, we add an extra check that is no longer needed 984 // as soon as waypoint initialization is finished. 985 var checkIfScrolled = true; 986 setTimeout(function() { checkIfScrolled = false; }, 0); 987 988 $waypoint_selector.waypoint( { 989 offset: function() { 990 if ( etRecalculateOffset ) { 991 setTimeout( function() { 992 et_calculate_header_values(); 993 }, 200 ); 994 995 etRecalculateOffset = false;
996 } 997 if ( et_hide_nav ) { 998 return et_header_offset - et_header_height - 200; 999 } else { 1000 1001 // Transparent nav modification: #page-container's offset is set to 0. Modify et_header_offset's according to header height 1002 var waypoint_selector_offset = $waypoint_selector.offset(); 1003 1004 if ( waypoint_selector_offset.top < et_header_offset ) { 1005 et_header_offset = 0 - ( et_header_offset - waypoint_selector_offset.top ); 1006 } 1007 1008 return et_header_offset; 1009 } 1010 }, 1011 handler : function( direction ) { 1012 et_fix_logo_transition(); 1013 1014 if ( direction === 'down' ) { 1015 if (checkIfScrolled && $et_window.scrollTop() === 0) { 1016 return; 1017 } 1018 $main_header.addClass( 'et-fixed-header' ); 1019 $main_container_wrapper.addClass ( 'et-animated-content' ); 1020 $top_header.addClass( 'et-fixed-header' ); 1021 1022 if ( ! et_hide_nav && ! window.et_is_transparent_nav && ! $( '.mobile_menu_bar_toggle' ).is(':visible') ) { 1023 var secondary_nav_height = $top_header.length ? parseInt( $top_header.height() ) : 0, 1024 $clone_header, 1025 clone_header_height, 1026 fix_padding; 1027 1028 $clone_header = $main_header.clone().addClass( 'et-fixed-header, et_header_clone' ).css( { 'transition': 'none', 'display' : 'none' } ); 1029 1030 clone_header_height = parseInt( $clone_header.prependTo( 'body' ).height() ); 1031 1032 // Vertical nav doesn't need #page-container margin-top adjustment 1033 if ( ! window.et_is_vertical_nav ) { 1034 fix_padding = parseInt( $main_container_wrapper.css( 'padding-top' ) ) - clone_header_height - secondary_nav_height + 1 ; 1035 1036 $main_container_wrapper.css( 'margin-top', -fix_padding ); 1037 } 1038 1039 $( '.et_header_clone' ).remove(); 1040 } 1041 1042 } else { 1043 $main_header.removeClass( 'et-fixed-header' ); 1044 $top_header.removeClass( 'et-fixed-header' ); 1045 $main_container_wrapper.css( 'margin-top', '-1px' ); 1046 } 1047 setTimeout( function() { 1048 et_set_search_form_css(); 1049 }, 400 ); 1050 } 1051 } ); 1052 } 1053 1054 if ( et_hide_nav ) { 1055 et_hide_nav_transform(); 1056 } 1057 } 1058 } 1059 1060 $( 'a[href*="#"]:not([href="#"])' ).click( function() { 1061 var $this_link = $( this ), 1062 has_closest_smooth_scroll_disabled = $this_link.closest( '.et_smooth_scroll_disabled' ).length, 1063 has_closest_woocommerce_tabs = ( $this_link.closest( '.woocommerce-tabs' ).length && $this_link.closest( '.tabs' ).length ), 1064 has_closest_timetable_tab = $this_link.closest( '.tt_tabs_navigation' ).length, 1065 has_closest_eab_cal_link = $this_link.closest( '.eab-shortcode_calendar-navigation-link' ).length, 1066 has_closest_ee_cart_link = $this_link.closest( '.view-cart-lnk' ).length, 1067 has_acomment_reply = $this_link.hasClass( 'acomment-reply' ), 1068 is_woocommerce_review_link = $this_link.hasClass( 'woocommerce-review-link' ), 1069 disable_scroll = has_closest_smooth_scroll_disabled || has_closest_ee_cart_link || has_closest_woocommerce_tabs || has_closest_eab_cal_link || has_acomment_reply || is_woocommerce_review_link || has_closest_timetable_tab; 1070 1071 if ( ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) && ! disable_scroll ) { 1072 var target = $( this.hash ); 1073 target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' ); 1074 if ( target.length ) { 1075 1076 // automatically close fullscreen menu if clicked from there 1077 if ( $this_link.closest( '.et_pb_fullscreen_menu_opened' ).length > 0 ) { 1078 et_pb_toggle_fullscreen_menu(); 1079 } 1080 1081 et_pb_smooth_scroll( target, false, 800 ); 1082 1083 if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) { 1084 setTimeout(function(){ 1085 et_pb_smooth_scroll( target, false, 40, 'linear' ); 1086 }, 780 ); 1087 } 1088 1089 return false; 1090 } 1091 } 1092 }); 1093 1094 window.et_pb_window_side_nav_scroll_init = function() { 1095 if ( true === window.et_calculating_scroll_position || false === window.et_side_nav_links_initialized ) { 1096 return; 1097 } 1098 1099 window.et_calculating_scroll_position = true; 1100 1101 var add_offset = $( 'body' ).hasClass( 'et_fixed_nav' ) ? 20 : -90; 1102 var top_header_height = $( '#top-header' ).length > 0 ? parseInt( $( '#top-header' ).height() ) : 0; 1103 var main_header_height = $( '#main-header' ).length > 0 ? parseInt( $( '#main-header' ).height() ) : 0; 1104 var side_offset; 1105 1106 if ( $( '#wpadminbar' ).length > 0 && parseInt( $( window ).width() ) > 600 ) { 1107 add_offset += parseInt( $( '#wpadminbar' ).outerHeight() ); 1108 } 1109 1110 if ( window.et_is_vertical_nav ) { 1111 side_offset = top_header_height + add_offset + 60; 1112 } else { 1113 side_offset = top_header_height + main_header_height + add_offset; 1114 } 1115 1116 var window_height = parseInt( $( window ).height() ); 1117 var scroll_position = parseInt( $( window ).scrollTop() ); 1118 var document_height = parseInt( $( document ).height() ); 1119 var at_bottom_of_page = ( window_height + scroll_position ) === document_height; 1120 var total_links = $( '.side_nav_item a' ).length - 1; 1121 1122 for ( var link = 0; link <= total_links; link++ ) { 1123 var $target_section = $( '.et_pb_section:visible:not(.et_pb_section div)' ).eq( link ); 1124 var at_top_of_page = 'undefined' === typeof $target_section.offset(); 1125 var current_active = $( '.side_nav_item a.active' ).parent().index(); 1126 var next_active = null; 1127 var target_offset = ( false === at_top_of_page ) ? $target_section.offset().top - side_offset : 0; 1128 1129 if ( at_top_of_page ) { 1130 next_active = 0; 1131 } else if ( at_bottom_of_page ) { 1132 next_active = total_links; 1133 } else if ( scroll_position >= target_offset ) { 1134 next_active = link; 1135 } 1136 1137 if ( null !== next_active && next_active !== current_active ) { 1138 $( '.side_nav_item a' ).removeClass( 'active' ); 1139 $( 'a#side_nav_item_id_' + next_active ).addClass( 'active' ); 1140 } 1141 } 1142 1143 window.et_calculating_scroll_position = false;
1144 }; 1145 1146 window.et_pb_side_nav_page_init = function() { 1147 var $sections = $( '.et_pb_section:visible:not(.et_pb_section div)' ); 1148 var total_sections = $sections.length; 1149 var side_nav_offset = parseInt( ( total_sections * 20 + 40 ) / 2 ); 1150 1151 window.et_side_nav_links_initialized = false; 1152 1153 window.et_calculating_scroll_position = false; 1154 1155 if ( total_sections > 1 && $( '.et_pb_side_nav_page' ).length ) { 1156 1157 $( '#main-content' ).append( '<ul class="et_pb_side_nav"></ul>' ); 1158 1159 $sections.each( function( index, element ) { 1160 var active_class = ( 0 === index ) ? 'active' : ''; 1161 $( '.et_pb_side_nav' ).append( '<li class="side_nav_item"><a href="#" id="side_nav_item_id_' + index + '" class= "' + active_class + '">' + index + '</a></li>' ); 1162 1163 if ( total_sections - 1 === index ) { 1164 window.et_side_nav_links_initialized = true; 1165 } 1166 }); 1167 1168 $( 'ul.et_pb_side_nav' ).css( 'marginTop', '-' + side_nav_offset + 'px' ); 1169 $( '.et_pb_side_nav' ).addClass( 'et-visible' ); 1170 1171 $( '.et_pb_side_nav a' ).click( function() { 1172 // We use the index position of the sections to locate them instead of custom classes so 1173 // that we have the same implementation for the frontend website and the Visual Builder. 1174 var index = parseInt( $( this ).text() ); 1175 var $target = $( '.et_pb_section:visible:not(.et_pb_section div)' ).eq( index ); 1176 var top_section = $(this).text() == "0"; 1177 1178 et_pb_smooth_scroll( $target, top_section, 800 ); 1179 1180 if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && parseInt( $( window ).width() ) > 980 ) { 1181 setTimeout( function() { 1182 et_pb_smooth_scroll( $target, top_section, 200 ); 1183 }, 500 ); 1184 } 1185 1186 return false; 1187 }); 1188 1189 $( window ).on( 'scroll', et_pb_window_side_nav_scroll_init ); 1190 } 1191 }; 1192 1193 et_pb_side_nav_page_init(); 1194 1195 if ( $('.et_pb_scroll_top').length ) { 1196 $(window).scroll(function(){ 1197 if ($(this).scrollTop() > 800) { 1198 $('.et_pb_scroll_top').show().removeClass( 'et-hidden' ).addClass( 'et-visible' ); 1199 } else { 1200 $('.et_pb_scroll_top').removeClass( 'et-visible' ).addClass( 'et-hidden' ); 1201 } 1202 }); 1203 1204 //Click event to scroll to top 1205 $('.et_pb_scroll_top').click(function(){ 1206 $('html, body').animate({scrollTop : 0},800); 1207 }); 1208 } 1209 1210 if ( $( '.comment-reply-link' ).length ) { 1211 $( '.comment-reply-link' ).addClass( 'et_pb_button' ); 1212 } 1213 1214 $( '#et_top_search' ).click( function() { 1215 var $search_container = $( '.et_search_form_container' ); 1216 1217 if ( $search_container.hasClass('et_pb_is_animating') ) { 1218 return; 1219 } 1220 1221 $( '.et_menu_container' ).removeClass( 'et_pb_menu_visible et_pb_no_animation' ).addClass('et_pb_menu_hidden'); 1222 $search_container.removeClass( 'et_pb_search_form_hidden et_pb_no_animation' ).addClass('et_pb_search_visible et_pb_is_animating'); 1223 setTimeout( function() { 1224 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 1225 $search_container.addClass( 'et_pb_no_animation' ).removeClass('et_pb_is_animating'); 1226 }, 1000); 1227 $search_container.find( 'input' ).focus(); 1228 1229 et_set_search_form_css(); 1230 }); 1231 1232 function et_hide_search() { 1233 if ( $( '.et_search_form_container' ).hasClass('et_pb_is_animating') ) { 1234 return; 1235 } 1236 1237 $( '.et_menu_container' ).removeClass( 'et_pb_menu_hidden et_pb_no_animation' ).addClass( 'et_pb_menu_visible' ); 1238 $( '.et_search_form_container' ).removeClass('et_pb_search_visible et_pb_no_animation' ).addClass( 'et_pb_search_form_hidden et_pb_is_animating' ); 1239 setTimeout( function() { 1240 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 1241 $( '.et_search_form_container' ).addClass( 'et_pb_no_animation' ).removeClass('et_pb_is_animating'); 1242 }, 1000); 1243 } 1244 1245 function et_set_search_form_css() { 1246 var $search_container = $( '.et_search_form_container' ); 1247 var $body = $( 'body' ); 1248 if ( $search_container.hasClass( 'et_pb_search_visible' ) ) { 1249 var header_height = $( '#main-header' ).innerHeight(), 1250 menu_width = $( '#top-menu' ).width(), 1251 font_size = $( '#top-menu li a' ).css( 'font-size' ); 1252 $search_container.css( { 'height' : header_height + 'px' } );
1253 $search_container.find( 'input' ).css( 'font-size', font_size ); 1254 if ( ! $body.hasClass( 'et_header_style_left' ) ) { 1255 $search_container.css( 'max-width', menu_width + 60 ); 1256 } else { 1257 $search_container.find( 'form' ).css( 'max-width', menu_width + 60 ); 1258 } 1259 } 1260 } 1261 1262 $( '.et_close_search_field' ).click( function() { 1263 et_hide_search(); 1264 }); 1265 1266 $( document ).mouseup( function(e) { 1267 var $header = $( '#main-header' ); 1268 if ( $( '.et_menu_container' ).hasClass('et_pb_menu_hidden') ) { 1269 if ( ! $header.is( e.target ) && $header.has( e.target ).length === 0 ) { 1270 et_hide_search(); 1271 } 1272 } 1273 }); 1274 1275 // Detect actual logo dimension, used for tricky fixed navigation transition 1276 function et_define_logo_dimension() { 1277 var $logo = $('#logo'), 1278 logo_src = $logo.attr( 'src' ), 1279 is_svg = logo_src.substr( -3, 3 ) === 'svg' ? true : false, 1280 $logo_wrap, 1281 logo_width, 1282 logo_height; 1283 1284 // Append invisible wrapper at the bottom of the page 1285 $('body').append( $('<div />', { 1286 'id' : 'et-define-logo-wrap', 1287 'style' : 'position: fixed; bottom: 0; opacity: 0;' 1288 })); 1289 1290 // Define logo wrap 1291 $logo_wrap = $('#et-define-logo-wrap'); 1292 1293 if( is_svg ) { 1294 $logo_wrap.addClass( 'svg-logo' ); 1295 } 1296 1297 // Clone logo to invisible wrapper 1298 $logo_wrap.html( $logo.clone().css({ 'display' : 'block' }).removeAttr( 'id' ) ); 1299 1300 // Get dimension 1301 logo_width = $logo_wrap.find('img').width(); 1302 logo_height = $logo_wrap.find('img').height(); 1303 1304 // Add data attribute to $logo 1305 $logo.attr({ 1306 'data-actual-width' : logo_width, 1307 'data-actual-height' : logo_height 1308 }); 1309 1310 // Destroy invisible wrapper 1311 $logo_wrap.remove(); 1312 1313 // Init logo transition onload 1314 et_fix_logo_transition( true ); 1315 } 1316 1317 if ( $('#logo').length ) { 1318 // Wait until logo is loaded before performing logo dimension fix 1319 // This comes handy when the page is heavy due to the use of images or other assets 1320 et_preload_image( $('#logo').attr('src'), et_define_logo_dimension ); 1321 } 1322 1323 // Set width for adsense in footer widget 1324 $('.footer-widget').each(function(){ 1325 var $footer_widget = $(this), 1326 footer_widget_width = $footer_widget.width(), 1327 $adsense_ins = $footer_widget.find( '.widget_adsensewidget ins' ); 1328 1329 if ( $adsense_ins.length ) { 1330 $adsense_ins.width( footer_widget_width ); 1331 } 1332 }); 1333 1334 /** 1335 * Visual Builder adjustment 1336 */ 1337 function et_fb_side_nav_page_init() { 1338 $( window ).off( 'scroll', window.et_pb_window_side_nav_scroll_init ); 1339 $( '#main-content .et_pb_side_nav' ).off( 'click', '.et_pb_side_nav a' ); 1340 $( '#main-content .et_pb_side_nav' ).remove(); 1341 et_pb_side_nav_page_init(); 1342 } 1343 if ( $('body').is('.et-fb') ) { 1344 $(window).on( 'et_fb_root_did_mount', function() { 1345 et_fb_side_nav_page_init(); 1346 1347 et_all_elements_loaded(); 1348 } ); 1349 1350 $(window).on( 'et_fb_section_content_change', et_fb_side_nav_page_init ); 1351 } else { 1352 $( window ).load( et_all_elements_loaded ); 1353 } 1354 } ); 1355 1356 // Fixing logo size transition in tricky header style 1357 function et_fix_logo_transition( is_onload ) { 1358 var $body = $( 'body' ), 1359 $logo = $( '#logo' ), 1360 logo_actual_width = parseInt( $logo.attr( 'data-actual-width' ) ), 1361 logo_actual_height = parseInt( $logo.attr( 'data-actual-height' ) ), 1362 logo_height_percentage = parseInt( $logo.attr( 'data-height-percentage' ) ), 1363 $top_nav = $( '#et-top-navigation' ), 1364 top_nav_height = parseInt( $top_nav.attr( 'data-height' ) ), 1365 top_nav_fixed_height = parseInt( $top_nav.attr( 'data-fixed-height' ) ), 1366 $main_header = $('#main-header'), 1367 is_header_split = $body.hasClass( 'et_header_style_split' ), 1368 is_fixed_nav = $main_header.hasClass( 'et-fixed-header' ), 1369 is_hide_primary_logo = $body.hasClass( 'et_hide_primary_logo' ), 1370 is_hide_fixed_logo = $body.hasClass( 'et_hide_fixed_logo' ), 1371 logo_height_base = is_fixed_nav ? top_nav_height : top_nav_fixed_height, 1372 logo_wrapper_width, 1373 logo_wrapper_height; 1374 1375 is_onload = typeof is_onload === 'undefined' ? false : is_onload; 1376 1377 // Fix for inline centered logo in horizontal nav 1378 if ( is_header_split && ! window.et_is_vertical_nav ) { 1379 // On page load, logo_height_base should be top_nav_height 1380 if ( is_onload ) { 1381 logo_height_base = top_nav_height; 1382 } 1383 1384 // Calculate logo wrapper height 1385 logo_wrapper_height = ( logo_height_base * ( logo_height_percentage / 100 ) + 22 ); 1386 1387 // Calculate logo wrapper width 1388 logo_wrapper_width = logo_actual_width * ( logo_wrapper_height / logo_actual_height ); 1389 1390 // Override logo wrapper width to 0 if it is hidden 1391 if ( is_hide_primary_logo && ( is_fixed_nav || is_onload ) ) { 1392 logo_wrapper_width = 0; 1393 } 1394 1395 if ( is_hide_fixed_logo && ! is_fixed_nav && ! is_onload ) { 1396 logo_wrapper_width = 0; 1397 } 1398
1399 // Set fixed width for logo wrapper to force correct dimension 1400 $( '.et_header_style_split .centered-inline-logo-wrap' ).css( { 'width' : logo_wrapper_width } ); 1401 } 1402 } 1403 1404 function et_toggle_slide_menu( force_state ) { 1405 var $slide_menu_container = $( '.et_header_style_slide .et_slide_in_menu_container' ), 1406 $page_container = $( '.et_header_style_slide #page-container, .et_header_style_slide.et_fixed_nav #main-header' ), 1407 $header_container = $( '.et_header_style_slide #main-header' ), 1408 is_menu_opened = $slide_menu_container.hasClass( 'et_pb_slide_menu_opened' ), 1409 set_to = typeof force_state !== 'undefined' ? force_state : 'auto', 1410 is_boxed_layout = $( 'body' ).hasClass( 'et_boxed_layout' ), 1411 page_container_margin = is_boxed_layout ? parseFloat( $( '#page-container' ).css( 'margin-left' ) ) : 0, 1412 slide_container_width = $slide_menu_container.innerWidth(); 1413 1414 if ( 'auto' !== set_to && ( ( is_menu_opened && 'open' === set_to ) || ( ! is_menu_opened && 'close' === set_to ) ) ) { 1415 return; 1416 } 1417 1418 if ( is_menu_opened ) { 1419 $slide_menu_container.css( { right: '-' + slide_container_width + 'px' } ); 1420 $page_container.css( { left: '0' } ); 1421 1422 if ( is_boxed_layout && et_is_fixed_nav ) { 1423 $header_container.css( { left : page_container_margin + 'px' } ); 1424 } 1425 1426 // hide the menu after animation completed 1427 setTimeout( function() { 1428 $slide_menu_container.css( { 'display' : 'none' } ); 1429 }, 700 ); 1430 } else { 1431 $slide_menu_container.css( { 'display' : 'block' } ); 1432 // add some delay to make sure css animation applied correctly 1433 setTimeout( function() { 1434 $slide_menu_container.css( { right: '0' } ); 1435 $page_container.css( { left: '-' + ( slide_container_width - page_container_margin ) + 'px' } ); 1436 1437 if ( is_boxed_layout && et_is_fixed_nav ) { 1438 var left_position = 0 > slide_container_width - ( page_container_margin * 2 ) ? Math.abs( slide_container_width - ( page_container_margin * 2 ) ) : '-' + ( slide_container_width - ( page_container_margin * 2 ) ); 1439 1440 if ( left_position < slide_container_width ) { 1441 $header_container.css( { left: left_position + 'px' } ); 1442 } 1443 } 1444 }, 50 ); 1445 } 1446 1447 $( 'body' ).toggleClass( 'et_pb_slide_menu_active' ); 1448 $slide_menu_container.toggleClass( 'et_pb_slide_menu_opened' ); 1449 } 1450 1451 // Scrolling to the correct place on page if Fixed Nav enabled 1452 function et_adjust_woocommerce_checkout_scroll() { 1453 if ( ! et_is_fixed_nav ) { 1454 return; 1455 } 1456 1457 var window_width = parseInt( $et_window.width() ); 1458 1459 if ( 980 >= window_width ) { 1460 return; 1461 } 1462 1463 var headerHeight = parseInt( $( '#main-header' ).innerHeight() ); 1464 1465 // scroll to the top of checkout form taking into account fixed header height 1466 $( 'html, body' ).animate({ 1467 scrollTop: ( $( 'form.checkout' ).offset().top - 100 - headerHeight ) 1468 }, 1000 ); 1469 } 1470 1471 $( '#main-header' ).on( 'click', '.et_toggle_slide_menu', function() { 1472 et_toggle_slide_menu(); 1473 }); 1474 1475 if ( et_is_touch_device ) { 1476 // open slide menu on swipe left 1477 $et_window.on( 'swipeleft', function( event ) { 1478 var window_width = parseInt( $et_window.width() ), 1479 swipe_start = parseInt( event.swipestart.coords[0] ); // horizontal coordinates of the swipe start 1480 1481 // if swipe started from the right edge of screen then open slide menu 1482 if ( 30 >= window_width - swipe_start ) { 1483 et_toggle_slide_menu( 'open' ); 1484 } 1485 } ); 1486 1487 // close slide menu on swipe right 1488 $et_window.on( 'swiperight', function( event ){ 1489 if ( $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 1490 et_toggle_slide_menu( 'close' ); 1491 } 1492 }); 1493 } 1494 1495 $( '#page-container' ).on( 'click', '.et_toggle_fullscreen_menu', function() { 1496 et_pb_toggle_fullscreen_menu(); 1497 }); 1498 1499 function et_pb_toggle_fullscreen_menu() { 1500 var $menu_container = $( '.et_header_style_fullscreen .et_slide_in_menu_container' ), 1501 top_bar_height = $menu_container.find( '.et_slide_menu_top' ).innerHeight(); 1502 1503 $menu_container.toggleClass( 'et_pb_fullscreen_menu_opened' ); 1504 $( 'body' ).toggleClass( 'et_pb_fullscreen_menu_active' ); 1505 1506 if ( $menu_container.hasClass( 'et_pb_fullscreen_menu_opened' ) ) { 1507 $menu_container.addClass( 'et_pb_fullscreen_menu_animated' ); 1508 1509 // adjust the padding in fullscreen menu 1510 $menu_container.css( { 'padding-top': top_bar_height + 20 } ); 1511 } else { 1512 setTimeout( function() { 1513 $menu_container.removeClass( 'et_pb_fullscreen_menu_animated' ); 1514 }, 1000 ); 1515 } 1516 } 1517 1518 $( window ).unload( function () { 1519 /** 1520 * Fix the issue with Fullscreen menu, that remains open, 1521 * when back button is clicked in Firefox 1522 */ 1523 if ( $('body').hasClass('et_pb_fullscreen_menu_active') ) { 1524 $('.et_toggle_fullscreen_menu').trigger('click'); 1525 } 1526 } ); 1527 1528 $( '.et_pb_fullscreen_nav_container' ).on( 'click', 'li.menu-item-has-children > a', function() { 1529 var $this_parent = $( this ).closest( 'li' ), 1530 $this_arrow = $this_parent.find( '>a .et_mobile_menu_arrow' ), 1531 $closest_submenu = $this_parent.find( '>ul' ), 1532 is_opened_submenu = $this_arrow.hasClass( 'et_pb_submenu_opened' ), 1533 sub_menu_max_height; 1534 1535 $this_arrow.toggleClass( 'et_pb_submenu_opened' ); 1536 1537 if ( is_opened_submenu ) { 1538 $closest_submenu.removeClass( 'et_pb_slide_dropdown_opened' ); 1539 $closest_submenu.slideToggle( 700, 'easeInOutCubic' ); 1540 } else { 1541 $closest_submenu.slideToggle( 700, 'easeInOutCubic' ); 1542 $closest_submenu.addClass( 'et_pb_slide_dropdown_opened' ); 1543 } 1544 1545 return false;
1546 } ); 1547 1548 // define initial padding-top for fullscreen menu container 1549 if ( $( 'body' ).hasClass( 'et_header_style_fullscreen' ) ) { 1550 var $menu_container = $( '.et_header_style_fullscreen .et_slide_in_menu_container' ); 1551 1552 if ( $menu_container.length ) { 1553 var top_bar_height = $menu_container.find( '.et_slide_menu_top' ).innerHeight(); 1554 $menu_container.css( { 'padding-top': top_bar_height + 20 } ); 1555 } 1556 } 1557 1558 // adjust the scrolling position on Woocommerce checkout page in case of error 1559 $( document.body ).on( 'checkout_error', function() { 1560 et_adjust_woocommerce_checkout_scroll(); 1561 } ); 1562 1563 $( document.body ).on( 'updated_checkout', function( data ) { 1564 if ( 'failure' !== data.result ) { 1565 return; 1566 } 1567 1568 et_adjust_woocommerce_checkout_scroll(); 1569 } ); 1570 1571})(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.