1(function($){ 2 window.et_calculating_scroll_position = false; 3 window.et_side_nav_links_initialized = false; 4 5 var $et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ), 6 et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ), 7 et_is_ipad = navigator.userAgent.match( /iPad/ ), 8 $et_container = $( '.container' ), 9 et_container_width = $et_container.width(), 10 et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ), 11 et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ), 12 et_is_rtl = $( 'body' ).hasClass( 'rtl' ), 13 et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ), 14 et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ), 15 $top_header = $('#top-header'), 16 $main_header = $('#main-header'), 17 $main_container_wrapper = $( '#page-container' ), 18 $et_main_content_first_row = $( '#main-content .container:first-child' ), 19 $et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'), 20 $et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1.entry-title' ), 21 $et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'), 22 $et_single_post = $( 'body.single-post' ), 23 $et_window = $(window), 24 etRecalculateOffset = false, 25 et_header_height, 26 et_header_modifier, 27 et_header_offset, 28 et_primary_header_top, 29 $et_header_style_split = $('.et_header_style_split'), 30 $et_top_navigation = $('#et-top-navigation'), 31 $logo = $('#logo'), 32 $et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ), 33 et_is_touch_device = 'ontouchstart' in window || navigator.maxTouchPoints; 34 35 $(document).ready( function(){ 36 var $et_top_menu = $( 'ul.nav' ), 37 $et_search_icon = $( '#et_search_icon' ), 38 et_parent_menu_longpress_limit = 300, 39 et_parent_menu_longpress_start, 40 et_parent_menu_click = true; 41 42 $et_top_menu.find( 'li' ).hover( function() { 43 if ( ! $(this).closest( 'li.mega-menu' ).length || $(this).hasClass( 'mega-menu' ) ) { 44 $(this).addClass( 'et-show-dropdown' ); 45 $(this).removeClass( 'et-hover' ).addClass( 'et-hover' ); 46 } 47 }, function() { 48 var $this_el = $(this); 49 50 $this_el.removeClass( 'et-show-dropdown' ); 51 52 setTimeout( function() { 53 if ( ! $this_el.hasClass( 'et-show-dropdown' ) ) { 54 $this_el.removeClass( 'et-hover' ); 55 } 56 }, 200 ); 57 } ); 58 59 // Dropdown menu adjustment for touch screen 60 $et_top_menu.find('.menu-item-has-children > a').on( 'touchstart', function(){ 61 et_parent_menu_longpress_start = new Date().getTime(); 62 } ).on( 'touchend', function(){ 63 var et_parent_menu_longpress_end = new Date().getTime(); 64 if ( et_parent_menu_longpress_end >= et_parent_menu_longpress_start + et_parent_menu_longpress_limit ) { 65 et_parent_menu_click = true; 66 } else { 67 et_parent_menu_click = false; 68 69 // Close sub-menu if toggled 70 var $et_parent_menu = $(this).parent('li'); 71 if ( $et_parent_menu.hasClass( 'et-hover') ) { 72 $et_parent_menu.trigger( 'mouseleave' ); 73 } else { 74 $et_parent_menu.trigger( 'mouseenter' ); 75 } 76 } 77 et_parent_menu_longpress_start = 0; 78 } ).click(function() { 79 if ( et_parent_menu_click ) { 80 return true; 81 } 82 83 return false; 84 } ); 85 86 $et_top_menu.find( 'li.mega-menu' ).each(function(){ 87 var $li_mega_menu = $(this), 88 $li_mega_menu_item = $li_mega_menu.children( 'ul' ).children( 'li' ), 89 li_mega_menu_item_count = $li_mega_menu_item.length; 90 91 if ( li_mega_menu_item_count < 4 ) { 92 $li_mega_menu.addClass( 'mega-menu-parent mega-menu-parent-' + li_mega_menu_item_count ); 93 } 94 }); 95 96 function et_header_menu_split(){ 97 var $logo_container = $( '#main-header > .container > .logo_container' ), 98 $logo_container_splitted = $('.centered-inline-logo-wrap > .logo_container'), 99 et_top_navigation_li_size = $et_top_navigation.children('nav').children('ul').children('li').size(), 100 et_top_navigation_li_break_index = Math.round( et_top_navigation_li_size / 2 ) - 1; 101 102 if ( $et_window.width() > 980 && $logo_container.length ) { 103 $('<li class="centered-inline-logo-wrap"></li>').insertAfter($et_top_navigation.find('nav > ul >li:nth('+et_top_navigation_li_break_index+')') ); 104 $logo_container.appendTo( $et_top_navigation.find('.centered-inline-logo-wrap') ); 105 } 106 107 if ( $et_window.width() <= 980 && $logo_container_splitted.length ) { 108 $logo_container_splitted.prependTo('#main-header > .container'); 109 $('#main-header .centered-inline-logo-wrap').remove(); 110 } 111 } 112 113 if ( $et_header_style_split.length && ! window.et_is_vertical_nav ) { 114 et_header_menu_split(); 115 116 $(window).resize(function(){ 117 et_header_menu_split(); 118 }); 119 } 120 121 if ( $('ul.et_disable_top_tier').length ) { 122 $("ul.et_disable_top_tier > li > ul").prev('a').attr('href','#'); 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 } 130 131 window.et_calculate_header_values = function() { 132 var $top_header = $( '#top-header' ), 133 secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? parseInt( $top_header.innerHe
133ight() ) : 0, 134 admin_bar_height = $( '#wpadminbar' ).length ? parseInt( $( '#wpadminbar' ).innerHeight() ) : 0, 135 $slide_menu_container = $( '.et_header_style_slide .et_slide_in_menu_container' ); 136 137 et_header_height = parseInt( $( '#main-header' ).innerHeight() ) + secondary_nav_height; 138 et_header_modifier = et_header_height <= 90 ? et_header_height - 29 : et_header_height - 56; 139 et_header_offset = et_header_modifier + admin_bar_height; 140 141 et_primary_header_top = secondary_nav_height + admin_bar_height; 142 143 if ( $slide_menu_container.length && ! $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 144 $slide_menu_container.css( { right: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px', 'display' : 'none' } ); 145 146 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) ) { 147 var page_container_margin = $main_container_wrapper.css( 'margin-left' ); 148 $main_header.css( { left : page_container_margin } ); 149 } 150 } 151 }; 152 153 var $comment_form = $('#commentform'); 154 155 et_pb_form_placeholders_init( $comment_form ); 156 157 $comment_form.submit(function(){ 158 et_pb_remove_placeholder_text( $comment_form ); 159 }); 160 161 et_duplicate_menu( $('#et-top-navigation ul.nav'), $('#et-top-navigation .mobile_nav'), 'mobile_menu', 'et_mobile_menu' ); 162 et_duplicate_menu( '', $('.et_pb_fullscreen_nav_container'), 'mobile_menu_slide', 'et_mobile_menu', 'no_click_event' ); 163 164 if ( $( '#et-secondary-nav' ).length ) { 165 $('#et-top-navigation #mobile_menu').append( $( '#et-secondary-nav' ).clone().html() ); 166 } 167 168 // adding arrows for the slide/fullscreen menus 169 if ( $( '.et_slide_in_menu_container' ).length ) { 170 var $item_with_sub = $( '.et_slide_in_menu_container' ).find( '.menu-item-has-children > a' ); 171 // add arrows for each menu item which has submenu 172 if ( $item_with_sub.length ) { 173 $item_with_sub.append( '<span class="et_mobile_menu_arrow"></span>' ); 174 } 175 } 176 177 function et_change_primary_nav_position( delay ) { 178 setTimeout( function() { 179 var $body = $('body'), 180 $wpadminbar = $( '#wpadminbar' ), 181 $top_header = $( '#top-header' ), 182 et_primary_header_top = 0; 183 184 if ( $wpadminbar.length ) { 185 et_primary_header_top += $wpadminbar.innerHeight(); 186 } 187 188 if ( $top_header.length && $top_header.is(':visible') ) { 189 et_primary_header_top += $top_header.innerHeight(); 190 } 191 192 if ( ! window.et_is_vertical_nav && ( $body.hasClass( 'et_fixed_nav' ) ) ) { 193 $('#main-header').css( 'top', et_primary_header_top ); 194 } 195 }, delay ); 196 } 197 198 function et_hide_nav_transofrm( ) { 199 var $body = $( 'body' ), 200 $body_height = $( document ).height(), 201 $viewport_height = $( window ).height() + et_header_height + 200; 202 203 if ( $body.hasClass( 'et_hide_nav' ) || $body.hasClass( 'et_hide_nav_disabled' ) && ( $body.hasClass( 'et_fixed_nav' ) ) ) { 204 if ( $body_height > $viewport_height ) { 205 if ( $body.hasClass( 'et_hide_nav_disabled' ) ) { 206 $body.addClass( 'et_hide_nav' ); 207 $body.removeClass( 'et_hide_nav_disabled' ); 208 } 209 $('#main-header').css( 'transform', 'translateY(-' + et_header_height +'px)' ); 210 $('#top-header').css( 'transform', 'translateY(-' + et_header_height +'px)' ); 211 } else { 212 $('#main-header').css( { 'transform': 'translateY(0)', 'opacity': '1' } ); 213 $('#top-header').css( { 'transform': 'translateY(0)', 'opacity': '1' } ); 214 $body.removeClass( 'et_hide_nav' ); 215 $body.addClass( 'et_hide_nav_disabled' ); 216 } 217 } 218 } 219 220 function et_page_load_scroll_to_anchor() { 221 var $map_container = $( window.et_location_hash + ' .et_pb_map_container' ), 222 $map = $map_container.children( '.et_pb_map' ), 223 $target = $( window.et_location_hash ); 224 225 // Make the target element visible again 226 $target.css( 'display', window.et_location_hash_style ); 227 228 var distance = ( 'undefined' !== typeof( $target.offset().top ) ) ? $target.offset().top : 0, 229 speed = ( distance > 4000 ) ? 1600 : 800; 230 231 if ( $map_container.length ) { 232 google.maps.event.trigger( $map[0], 'resize' ); 233 } 234 235 // Allow the header sizing functions enough time to finish before scrolling the page 236 setTimeout( function() { 237 et_pb_smooth_scroll( $target, false, speed, 'swing'); 238 239 // During the page scroll animation, the header's height might change. 240 // Do the scroll animation again to ensure its accuracy. 241 setTimeout( function() { 242 et_pb_smooth_scroll( $target, false, 150, 'linear' ); 243 }, speed + 25 ); 244 245 }, 700 ); 246 } 247 248 // Retrieving padding/margin value based on formatted saved padding/margin strings 249 function et_get_saved_padding_margin_value( saved_value, order ) { 250 if ( typeof saved_value === 'undefined' ) { 251 return false;
252 } 253 254 var values = saved_value.split('|'); 255 256 return typeof values[order] !== 'undefined' ? values[order] : false; 257 } 258 259 function et_fix_page_container_position(){ 260 var et_window_width = parseInt( $et_window.width() ), 261 $top_header = $( '#top-header' ), 262 secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? parseInt( $top_header.innerHeight() ) : 0, 263 main_header_fixed_height = 0, 264 header_height; 265 266 // Set data-height-onload for header if the page is loaded on large screen 267 // If the page is loaded from small screen, rely on data-height-onload printed on the markup, 268 // prevent window resizing issue from small to large 269 if ( et_window_width > 980 && ! $main_header.attr( 'data-height-loaded' ) ){ 270 $main_header.attr({ 'data-height-onload' : parseInt( $main_header.height() ), 'data-height-loaded' : true }); 271 } 272 273 // Use on page load calculation for large screen. Use on the fly calculation for small screen (980px below) 274 if ( et_window_width <= 980 ) { 275 header_height = parseInt( $main_header.innerHeight() ) + secondary_nav_height - 1; 276 277 // If transparent is detected, #main-content .container's padding-top needs to be added to header_height 278 // And NOT a pagebuilder page 279 if ( window.et_is_transparent_nav && ! $et_pb_first_row.length ) { 280 header_height += 58; 281 } 282 } else { 283 284 // Get header height from header attribute 285 header_height = parseInt( $main_header.attr( 'data-height-onload' ) ) + secondary_nav_height; 286 287 // Non page builder page needs to be added by #main-content .container's fixed height 288 if ( window.et_is_transparent_nav && ! window.et_is_vertical_nav && $et_main_content_first_row.length ) { 289 header_height += 58; 290 } 291 292 // Calculate fixed header height by cloning, emulating, and calculating its height 293 $main_header.clone().addClass( 294 'main-header-clone et-fixed-header' 295 ).css({ 296 opacity: 0, 297 position: 'fixed', 298 top: 'auto', 299 right: 0, 300 bottom: 0, 301 left: 0 302 }).appendTo( $('body') ); 303 304 main_header_fixed_height = $('.main-header-clone').height(); 305 306 $('.main-header-clone').remove(); 307 } 308 309 // Saved fixed main header height calculation 310 $main_header.attr({ 311 'data-fixed-height-onload': main_header_fixed_height 312 }); 313 314 // Specific adjustment required for transparent nav + not vertical nav 315 if ( window.et_is_transparent_nav && ! window.et_is_vertical_nav ){ 316 317 // Add class for first row for custom section padding purpose 318 $et_pb_first_row.addClass( 'et_pb_section_first' ); 319 320 // List of conditionals 321 var is_pb = $et_pb_first_row.length, 322 is_post_pb = is_pb && $et_single_post.length, 323 is_post_pb_full_layout_has_title = $et_pb_post_fullwidth.length && $et_main_content_first_row_meta_wrapper_title.length, 324 is_post_pb_full_layout_no_title = $et_pb_post_fullwidth.length && 0 === $et_main_content_first_row_meta_wrapper_title.length, 325 is_pb_fullwidth_section_first = $et_pb_first_row.is( '.et_pb_fullwidth_section' ), 326 is_no_pb_mobile = et_window_width <= 980 && $et_main_content_first_row.length; 327 328 if ( is_post_pb && ! ( is_post_pb_full_layout_no_title && is_pb_fullwidth_section_first ) ) { 329 330 /* Desktop / Mobile + Single Post */ 331 332 /* 333 * EXCEPT for fullwidth layout + fullwidth section ( at the first row ). 334 * It is basically the same as page + fullwidth section with few quirk. 335 * Instead of duplicating the conditional for each module, it'll be simpler to negate 336 * fullwidth layout + fullwidth section in is_post_pb and rely it to is_pb_fullwidth_section_first 337 */ 338 339 // Remove main content's inline padding to styling to prevent looping padding-top calculation 340 $et_main_content_first_row.css({ 'paddingTop' : '' }); 341 342 if ( et_window_width < 980 ) { 343 header_height += 40; 344 } 345 346 if ( is_pb_fullwidth_section_first ) { 347 // If the first section is fullwidth, restore the padding-top modified area at first section 348 $et_pb_first_row.css({ 349 'paddingTop' : '0' 350 }); 351 } 352 353 if ( is_post_pb_full_layout_has_title ) { 354 355 // Add header height to post meta wrapper as padding top 356 $et_main_content_first_row_meta_wrapper.css({ 357 'paddingTop' : header_height 358 }); 359 360 } else if ( is_post_pb_full_layout_no_title ) { 361 362 $et_pb_first_row.css({ 363 'paddingTop' : header_height 364 }); 365 366 } else { 367 368 // Add header height to first row content as padding top 369 $et_main_content_first_row.css({ 370 'paddingTop' : header_height 371 }); 372 373 } 374 375 } else if ( is_pb_fullwidth_section_first ){ 376 377 /* Desktop / Mobile + Pagebuilder + Fullwidth Section */ 378 379 var $et_pb_first_row_first_module = $et_pb_first_row.children( '.et_pb_module:first' ); 380 381 // Quirks: If this is post with fullwidth layout + no title + fullwidth section at first row, 382 // Remove the added height at line 2656 383 if ( is_post_pb_full_layout_no_title && is_pb_fullwidth_section_first && et_window_width > 980 ) { 384 header_height = header_height - 58; 385 } 386 387 if ( $et_pb_first_row_first_module.is( '.et_pb_slider' ) ) { 388 389 /* Desktop / Mobile + Pagebuilder + Fullwidth slider */ 390 391 var $et_pb_first_row_first_module_slide_image = $et_pb_first_row_first_module.find( '.et_pb_slide_image' ), 392 $et_pb_first_row_first_module_slide = $et_pb_first_row_first_module.find( '.et_pb_slide' ), 393 $et_pb_first_row_first_module_slide_container = $et_pb_first_row_first_module.find( '.et_pb_slide .et_pb_container' ), 394 et_pb_slide_image_margin_top = 0 - ( parseInt( $et_pb_first_row_first_module_slide_image.height() ) / 2 ), 395 et_pb_slide_container_height = 0, 396 $et_pb_first_row_first_module_slider_arrow = $et_pb_first_row_first_module.find( '.et-pb-slider-arrows a'), 397 et_pb_first_row_slider_arrow_height = $et_pb_first_row_first_module_slider_arrow.height(); 398 399 // Adding padding top to each slide so the transparency become useful 400 $et_pb_first_row_first_module_slide.css({ 401 'paddingTop' : header_height 402 }); 403 404 // delete container's min-height 405 $et_pb_first_row_first_module_slide_container.css({ 406 'min-height' : '' 407 }); 408 409 // Adjusting slider's image, considering additional top padding of slideshow 410 $et_pb_first_row_first_module_slide_image.css({ 411 'marginTop' : et_pb_slide_image_margin_top 412 }); 413 414 // Adjusting slider's arrow, considering additional top padding of slideshow 415 $et_pb_first_row_first_module_slider_arrow.css({ 416 'marginTop' : ( ( header_height / 2 ) - ( et_pb_first_row_slider_arrow_height / 2 ) ) 417 }); 418 419 // Looping the slide and get the highest height of slide 420 var et_pb_first_row_slide_container_height_new = 0; 421 422 $et_pb_first_row_first_module.find( '.et_pb_slide' ).each( function(){ 423 var $et_pb_first_row_first_module_slide_item = $(this), 424 $et_pb_first_row_first_module_slide_container = $et_pb_first_row_first_module_slide_item.find( '.et_pb_container' ); 425 426 // Make sure that the slide is visible to calculate correct height 427 $et_pb_first_row_first_module_slide_item.show(); 428 429 // Remove existing inline css to make sure that it calculates the height 430 $et_pb_first_row_first_module_slide_container.css({ 'min-height' : '' }); 431 432 var et_pb_first_row_slide_container_height = $et_pb_first_row_first_module_slide_container.innerHe
432ight(); 433 434 if ( et_pb_first_row_slide_container_height_new < et_pb_first_row_slide_container_height ){ 435 et_pb_first_row_slide_container_height_new = et_pb_first_row_slide_container_height; 436 } 437 438 // Hide the slide back if it isn't active slide 439 if ( $et_pb_first_row_first_module_slide_item.is( ':not(".et-pb-active-slide")' ) ){ 440 $et_pb_first_row_first_module_slide_item.hide(); 441 } 442 }); 443 444 // Setting appropriate min-height, considering additional top padding of slideshow 445 $et_pb_first_row_first_module_slide_container.css({ 446 'min-height' : et_pb_first_row_slide_container_height_new 447 }); 448 449 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_header' ) ) { 450 451 /* Desktop / Mobile + Pagebuilder + Fullwidth header */ 452 453 // Remove existing inline stylesheet to prevent looping padding 454 $et_pb_first_row_first_module.removeAttr( 'style' ); 455 456 // Get paddingTop from stylesheet 457 var et_pb_first_row_first_module_fullwidth_header_padding_top = parseInt( $et_pb_first_row_first_module.css( 'paddingTop' ) ); 458 459 // Implement stylesheet's padding-top + header_height 460 $et_pb_first_row_first_module.css({ 461 'paddingTop' : ( header_height + et_pb_first_row_first_module_fullwidth_header_padding_top ) 462 } ); 463 464 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_portfolio' ) ) { 465 466 /* Desktop / Mobile + Pagebuilder + Fullwidth Portfolio */ 467 468 $et_pb_first_row_first_module.css({ 'paddingTop' : header_height }); 469 470 } else if ( $et_pb_first_row_first_module.is( '.et_pb_map_container' ) ) { 471 472 /* Desktop / Mobile + Pagebuilder + Fullwidth Map */ 473 474 var $et_pb_first_row_map = $et_pb_first_row_first_module.find( '.et_pb_map' ); 475 476 // Remove existing inline height to prevent looping height calculation 477 $et_pb_first_row_map.css({ 'height' : '' }); 478 479 // Implement map height + header height 480 $et_pb_first_row_first_module.find('.et_pb_map').css({ 481 'height' : header_height + parseInt( $et_pb_first_row_map.css( 'height' ) ) 482 }); 483 484 // Adding specific class to mark the map as first row section element 485 $et_pb_first_row_first_module.addClass( 'et_beneath_transparent_nav' ); 486 487 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_menu' ) ) { 488 489 /* Desktop / Mobile + Pagebuilder + Fullwidth Menu */ 490 $et_pb_first_row_first_module.css({ 'marginTop' : header_height }); 491 492 } else if ( $et_pb_first_row_first_module.is( '.et_pb_fullwidth_code' ) ) { 493 494 /* Desktop / Mobile + Pagebuilder + Fullwidth code */ 495 496 var $et_pb_first_row_first_module_code = $et_pb_first_row_first_module; 497 498 $et_pb_first_row_first_module_code.css({ 'paddingTop' : '' }); 499 500 var et_pb_first_row_first_module_code_padding_top = parseInt( $et_pb_first_row_first_module_code.css( 'paddingTop' ) ); 501 502 $et_pb_first_row_first_module_code.css({ 503 'paddingTop' : header_height + et_pb_first_row_first_module_code_padding_top 504 }); 505 506 } else if ( $et_pb_first_row_first_module.is( '.et_pb_post_title' ) ) { 507 508 /* Desktop / Mobile + Pagebuilder + Fullwidth Post Title */ 509 510 $et_pb_first_row_first_module.css({ 511 'paddingTop' : header_height + 50 512 }); 513 } 514 515 } else if ( is_pb ) { 516 517 /* Desktop / Mobile + Pagebuilder + Regular section */ 518 519 // Remove first row's inline padding top styling to prevent looping padding-top calculation 520 $et_pb_first_row.css({ 'paddingTop' : '' }); 521 522 // Get saved custom padding from data-* attributes. Builder automatically adds 523 // saved custom paddings to data-* attributes on first section 524 var saved_custom_padding = $et_pb_first_row.attr('data-padding'), 525 saved_custom_padding_top = et_get_saved_padding_margin_value( saved_custom_padding, 0 ), 526 saved_custom_padding_tablet = $et_pb_first_row.attr('data-padding-tablet'), 527 saved_custom_padding_tablet_top = et_get_saved_padding_margin_value( saved_custom_padding_tablet, 0 ), 528 saved_custom_padding_phone = $et_pb_first_row.attr('data-padding-phone'), 529 saved_custom_padding_phone_top = et_get_saved_padding_margin_value( saved_custom_padding_phone, 0 ), 530 applied_saved_custom_padding; 531 532 if ( saved_custom_padding_top || saved_custom_padding_tablet_top || saved_custom_padding_phone_top ) { 533 // Applies padding top to first section to automatically convert saved unit into px 534 if ( et_window_width > 980 && saved_custom_padding_top ) { 535 $et_pb_first_row.css({ 536 paddingTop: saved_custom_padding_top 537 }); 538 } else if ( et_window_width > 767 && saved_custom_padding_tablet_top ) { 539 $et_pb_first_row.css({ 540 paddingTop: saved_custom_padding_tablet_top 541 }); 542 } else if ( saved_custom_padding_phone_top ) { 543 $et_pb_first_row.css({ 544 paddingTop: saved_custom_padding_phone_top 545 }); 546 } 547 548 // Get converted custom padding top value 549 applied_saved_custom_padding = parseInt( $et_pb_first_row.css( 'paddingTop' ) ); 550 551 // Implemented saved & converted padding top + header height 552 $et_pb_first_row.css({ 553 paddingTop: ( header_height + applied_saved_custom_padding ) 554 }); 555 } else { 556 // Pagebuilder ignores #main-content .container's fixed height and uses its row's padding
557 // Anticipate the use of custom section padding. 558 et_pb_first_row_padding_top = header_height + parseInt( $et_pb_first_row.css( 'paddingBottom' ) ); 559 560 // Implementing padding-top + header_height 561 $et_pb_first_row.css({ 562 'paddingTop' : et_pb_first_row_padding_top 563 }); 564 } 565 } else if ( is_no_pb_mobile ) { 566 567 // Mobile + not pagebuilder 568 $et_main_content_first_row.css({ 569 'paddingTop' : header_height 570 }); 571 572 } else { 573 574 $('#main-content .container:first-child').css({ 575 'paddingTop' : header_height 576 }); 577 578 } 579 580 // Set #page-container's padding-top to zero after inline styling first row's content has been added 581 if ( ! $('#et_fix_page_container_position').length ){ 582 $( '<style />', { 583 'id' : 'et_fix_page_container_position', 584 'text' : '#page-container{ padding-top: 0 !important;}' 585 }).appendTo('head'); 586 } 587 588 } else if( et_is_fixed_nav ) { 589 590 $main_container_wrapper.css( 'paddingTop', header_height ); 591 592 } 593 594 et_change_primary_nav_position( 0 ); 595 } 596 597 // Save container width on page load for reference 598 $et_container.data( 'previous-width', $et_container.width() ); 599 600 $( window ).resize( function(){ 601 var window_width = parseInt( $et_window.width() ), 602 et_container_previous_width = parseInt( $et_container.data('previous-width') ), 603 et_container_css_width = $et_container.css( 'width' ), 604 et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '', 605 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 606 containerWidthChanged = et_container_previous_width !== et_container_actual_width, 607 $slide_menu_container = $( '.et_slide_in_menu_container' ), 608 page_container_margin; 609 610 if ( et_is_fixed_nav && containerWidthChanged ) { 611 if ( typeof update_page_container_position != 'undefined' ){ 612 clearTimeout( update_page_container_position ); 613 } 614 615 var update_page_container_position = setTimeout( function() { 616 et_fix_page_container_position(); 617 if ( typeof et_fix_fullscreen_section === 'function' ) { 618 et_fix_fullscreen_section(); 619 } 620 }, 200 ); 621 622 // Update container width data for future resizing reference 623 $et_container.data('previous-width', et_container_actual_width ); 624 } 625 626 if ( et_hide_nav ) { 627 et_hide_nav_transofrm(); 628 } 629 630 if ( $( '#wpadminbar' ).length && et_is_fixed_nav && window_width >= 740 && window_width <= 782 ) { 631 et_calculate_header_values(); 632 633 et_change_primary_nav_position( 0 ); 634 } 635 636 et_set_search_form_css(); 637 638 if ( $slide_menu_container.length && ! $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 639 $slide_menu_container.css( { right: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px' } ); 640 641 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) && et_is_fixed_nav ) { 642 page_container_margin = $main_container_wrapper.css( 'margin-left' ); 643 $main_header.css( { left : page_container_margin } ); 644 } 645 } 646 647 if ( $slide_menu_container.length && $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 648 if ( $( 'body' ).hasClass( 'et_boxed_layout' ) ) { 649 var left_position; 650 page_container_margin = parseFloat( $main_container_wrapper.css( 'margin-left' ) ); 651 652 $main_container_wrapper.css( { left: '-' + ( parseInt( $slide_menu_container.innerWidth() ) - page_container_margin ) + 'px' } ); 653 654 if ( et_is_fixed_nav ) { 655 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 ) ); 656 657 if ( left_position < parseInt( $slide_menu_container.innerWidth() ) ) { 658 $main_header.css( { left: left_position + 'px' } ); 659 } 660 } 661 } else { 662 $( '#page-container, .et_fixed_nav #main-header' ).css( { left: '-' + parseInt( $slide_menu_container.innerWidth() ) + 'px' } ); 663 } 664 } 665 666 // adjust the padding in fullscreen menu 667 if ( $slide_menu_container.length && $( 'body' ).hasClass( 'et_header_style_fullscreen' ) ) { 668 var top_bar_height = parseInt( $slide_menu_container.find( '.et_slide_menu_top' ).innerHeight() ); 669 670 $slide_menu_container.css( { 'padding-top': top_bar_height + 20 } ); 671 } 672 } ); 673 674 $( window ).ready( function(){ 675 if ( $.fn.fitVids ) { 676 $( '#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']"} ); 677 } 678 } ); 679 680 function et_all_elements_loaded() { 681 if ( et_is_fixed_nav ) { 682 et_calculate_header_values(); 683 } 684 685 et_fix_page_container_position(); 686 687 if ( window.hasOwnProperty( 'et_location_hash' ) && '' !== window.et_location_hash ) { 688 // Handle the page scroll that we prevented earlier in the <head>
689 et_page_load_scroll_to_anchor(); 690 } 691 692 if ( et_header_style_left && !window.et_is_vertical_nav) { 693 $logo_width = parseInt( $( '#logo' ).width() ); 694 if ( et_is_rtl ) { 695 $et_top_navigation.css( 'padding-right', $logo_width + 30 ); 696 } else { 697 $et_top_navigation.css( 'padding-left', $logo_width + 30 ); 698 } 699 } 700 701 if ( $('p.demo_store').length ) { 702 $('#footer-bottom').css('margin-bottom' , $('p.demo_store').innerHeight()); 703 } 704 705 if ( $.fn.waypoint ) { 706 var $waypoint_selector; 707 if ( et_is_vertical_fixed_nav ) { 708 $waypoint_selector = $('#main-content'); 709 710 $waypoint_selector.waypoint( { 711 handler : function( direction ) { 712 et_fix_logo_transition(); 713 714 if ( direction === 'down' ) { 715 $('#main-header').addClass( 'et-fixed-header' ); 716 } else { 717 $('#main-header').removeClass( 'et-fixed-header' ); 718 } 719 } 720 } ); 721 } 722 723 if ( et_is_fixed_nav ) { 724 725 if ( window.et_is_transparent_nav && ! window.et_is_vertical_nav && $et_pb_first_row.length ){ 726 727 // Fullscreen section at the first row requires specific adjustment 728 if ( $et_pb_first_row.is( '.et_pb_fullwidth_section' ) ){ 729 $waypoint_selector = $et_pb_first_row.children('.et_pb_module'); 730 } else { 731 $waypoint_selector = $et_pb_first_row.find('.et_pb_row'); 732 } 733 } else if ( window.et_is_transparent_nav && ! window.et_is_vertical_nav && $et_main_content_first_row.length ) { 734 $waypoint_selector = $('#content-area'); 735 } else { 736 $waypoint_selector = $('#main-content'); 737 } 738 739 $waypoint_selector.waypoint( { 740 offset: function() { 741 if ( etRecalculateOffset ) { 742 setTimeout( function() { 743 et_calculate_header_values(); 744 }, 200 ); 745 746 etRecalculateOffset = false; 747 } 748 if ( et_hide_nav ) { 749 return et_header_offset - et_header_height - 200; 750 } else { 751 752 // Transparent nav modification: #page-container's offset is set to 0. Modify et_header_offset's according to header height 753 var waypoint_selector_offset = $waypoint_selector.offset(); 754 755 if ( waypoint_selector_offset.top < et_header_offset ) { 756 et_header_offset = 0 - ( et_header_offset - waypoint_selector_offset.top ); 757 } 758 759 return et_header_offset; 760 } 761 }, 762 handler : function( direction ) { 763 et_fix_logo_transition(); 764 765 if ( direction === 'down' ) { 766 $main_header.addClass( 'et-fixed-header' ); 767 $main_container_wrapper.addClass ( 'et-animated-content' ); 768 $top_header.addClass( 'et-fixed-header' ); 769 770 if ( ! et_hide_nav && ! window.et_is_transparent_nav && ! $( '.mobile_menu_bar_toggle' ).is(':visible') ) { 771 var secondary_nav_height = $top_header.length ? parseInt( $top_header.height() ) : 0, 772 $clone_header, 773 clone_header_height, 774 fix_padding; 775 776 $clone_header = $main_header.clone().addClass( 'et-fixed-header, et_header_clone' ).css( { 'transition': 'none', 'display' : 'none' } ); 777 778 clone_header_height = parseInt( $clone_header.prependTo( 'body' ).height() ); 779 780 // Vertical nav doesn't need #page-container margin-top adjustment 781 if ( ! window.et_is_vertical_nav ) { 782 fix_padding = parseInt( $main_container_wrapper.css( 'padding-top' ) ) - clone_header_height - secondary_nav_height + 1 ; 783 784 $main_container_wrapper.css( 'margin-top', -fix_padding ); 785 } 786 787 $( '.et_header_clone' ).remove(); 788 } 789 790 } else { 791 $main_header.removeClass( 'et-fixed-header' ); 792 $top_header.removeClass( 'et-fixed-header' ); 793 $main_container_wrapper.css( 'margin-top', '-1px' ); 794 } 795 setTimeout( function() { 796 et_set_search_form_css(); 797 }, 400 ); 798 } 799 } ); 800 } 801 802 if ( et_hide_nav ) { 803 et_hide_nav_transofrm(); 804 } 805 } 806 } 807 808 $( 'a[href*="#"]:not([href="#"])' ).click( function() { 809 var $this_link = $( this ), 810 has_closest_smooth_scroll_disabled = $this_link.closest( '.et_smooth_scroll_disabled' ).length, 811 has_closest_woocommerce_tabs = ( $this_link.closest( '.woocommerce-tabs' ).length && $this_link.closest( '.tabs' ).length ), 812 has_closest_eab_cal_link = $this_link.closest( '.eab-shortcode_calendar-navigation-link' ).length, 813 has_acomment_reply = $this_link.hasClass( 'acomment-reply' ), 814 disable_scroll = has_closest_smooth_scroll_disabled || has_closest_woocommerce_tabs || has_closest_eab_cal_link || has_acomment_reply; 815 816 if ( ( location.pathname.replace( /^\//,'' ) == this.pathname.replace( /^\//,'' ) && location.hostname == this.hostname ) && ! disable_scroll ) { 817 var target = $( this.hash ); 818 target = target.length ? target : $( '[name=' + this.hash.slice(1) +']' ); 819 if ( target.length ) { 820 821 et_pb_smooth_scroll( target, false, 800 ); 822 823 if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) { 824 setTimeout(function(){ 825 et_pb_smooth_scroll( target, false, 40, 'linear' ); 826 }, 780 ); 827 } 828 829 return false;
830 } 831 } 832 }); 833 834 window.et_pb_window_side_nav_scroll_init = function() { 835 if ( true === window.et_calculating_scroll_position || false === window.et_side_nav_links_initialized ) { 836 return; 837 } 838 839 window.et_calculating_scroll_position = true; 840 841 var add_offset = $( 'body' ).hasClass( 'et_fixed_nav' ) ? 20 : -90; 842 var top_header_height = $( '#top-header' ).length > 0 ? parseInt( $( '#top-header' ).height() ) : 0; 843 var main_header_height = $( '#main-header' ).length > 0 ? parseInt( $( '#main-header' ).height() ) : 0; 844 var side_offset; 845 846 if ( $( '#wpadminbar' ).length > 0 && parseInt( $( window ).width() ) > 600 ) { 847 add_offset += parseInt( $( '#wpadminbar' ).outerHeight() ); 848 } 849 850 if ( window.et_is_vertical_nav ) { 851 side_offset = top_header_height + add_offset + 60; 852 } else { 853 side_offset = top_header_height + main_header_height + add_offset; 854 } 855 856 var window_height = parseInt( $( window ).height() ); 857 var scroll_position = parseInt( $( window ).scrollTop() ); 858 var document_height = parseInt( $( document ).height() ); 859 var at_bottom_of_page = ( window_height + scroll_position ) === document_height; 860 var total_links = $( '.side_nav_item a' ).length - 1; 861 862 for ( var link = 0; link <= total_links; link++ ) { 863 var $target_section = $( '.et_pb_section:visible:not(.et_pb_section div)' ).eq( link ); 864 var at_top_of_page = 'undefined' === typeof $target_section.offset(); 865 var current_active = $( '.side_nav_item a.active' ).parent().index(); 866 var next_active = null; 867 var target_offset = ( false === at_top_of_page ) ? $target_section.offset().top - side_offset : 0; 868 869 if ( at_top_of_page ) { 870 next_active = 0; 871 } else if ( at_bottom_of_page ) { 872 next_active = total_links; 873 } else if ( scroll_position >= target_offset ) { 874 next_active = link; 875 } 876 877 if ( null !== next_active && next_active !== current_active ) { 878 $( '.side_nav_item a' ).removeClass( 'active' ); 879 $( 'a#side_nav_item_id_' + next_active ).addClass( 'active' ); 880 } 881 } 882 883 window.et_calculating_scroll_position = false; 884 }; 885 886 window.et_pb_side_nav_page_init = function() { 887 var $sections = $( '.et_pb_section:visible:not(.et_pb_section div)' ); 888 var total_sections = $sections.length; 889 var side_nav_offset = parseInt( ( total_sections * 20 + 40 ) / 2 ); 890 891 window.et_side_nav_links_initialized = false; 892 893 window.et_calculating_scroll_position = false; 894 895 if ( total_sections > 1 && $( '.et_pb_side_nav_page' ).length ) { 896 897 $( '#main-content' ).append( '<ul class="et_pb_side_nav"></ul>' ); 898 899 $sections.each( function( index, element ) { 900 var active_class = ( 0 === index ) ? 'active' : ''; 901 $( '.et_pb_side_nav' ).append( '<li class="side_nav_item"><a href="#" id="side_nav_item_id_' + index + '" class= "' + active_class + '">' + index + '</a></li>' ); 902 903 if ( total_sections - 1 === index ) { 904 window.et_side_nav_links_initialized = true; 905 } 906 }); 907 908 $( 'ul.et_pb_side_nav' ).css( 'marginTop', '-' + side_nav_offset + 'px' ); 909 $( '.et_pb_side_nav' ).addClass( 'et-visible' ); 910 911 $( '.et_pb_side_nav a' ).click( function() { 912 // We use the index position of the sections to locate them instead of custom classes so 913 // that we have the same implementation for the frontend website and the Visual Builder. 914 var index = parseInt( $( this ).text() ); 915 var $target = $( '.et_pb_section:visible:not(.et_pb_section div)' ).eq( index ); 916 var top_section = $(this).text() == "0"; 917 918 et_pb_smooth_scroll( $target, top_section, 800 ); 919 920 if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && parseInt( $( window ).width() ) > 980 ) { 921 setTimeout( function() { 922 et_pb_smooth_scroll( $target, top_section, 200 ); 923 }, 500 ); 924 } 925 926 return false; 927 }); 928 929 $( window ).on( 'scroll', et_pb_window_side_nav_scroll_init ); 930 } 931 }; 932 933 et_pb_side_nav_page_init(); 934 935 if ( $('.et_pb_scroll_top').length ) { 936 $(window).scroll(function(){ 937 if ($(this).scrollTop() > 800) { 938 $('.et_pb_scroll_top').show().removeClass( 'et-hidden' ).addClass( 'et-visible' ); 939 } else { 940 $('.et_pb_scroll_top').removeClass( 'et-visible' ).addClass( 'et-hidden' ); 941 } 942 }); 943 944 //Click event to scroll to top 945 $('.et_pb_scroll_top').click(function(){ 946 $('html, body').animate({scrollTop : 0},800); 947 }); 948 } 949 950 if ( $( '.comment-reply-link' ).length ) { 951 $( '.comment-reply-link' ).addClass( 'et_pb_button' ); 952 } 953 954 $( '#et_top_search' ).click( function() { 955 var $search_container = $( '.et_search_form_container' ); 956 957 if ( $search_container.hasClass('et_pb_is_animating') ) { 958 return; 959 } 960 961 $( '.et_menu_container' ).removeClass( 'et_pb_menu_visible et_pb_no_animation' ).addClass('et_pb_menu_hidden'); 962 $search_container.removeClass( 'et_pb_search_form_hidden et_pb_no_animation' ).addClass('et_pb_search_visible et_pb_is_animating'); 963 setTimeout( function() { 964 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 965 $search_container.addClass( 'et_pb_no_animation' ).removeClass('et_pb_is_animating'); 966 }, 1000);
967 $search_container.find( 'input' ).focus(); 968 969 et_set_search_form_css(); 970 }); 971 972 function et_hide_search() { 973 if ( $( '.et_search_form_container' ).hasClass('et_pb_is_animating') ) { 974 return; 975 } 976 977 $( '.et_menu_container' ).removeClass( 'et_pb_menu_hidden et_pb_no_animation' ).addClass( 'et_pb_menu_visible' ); 978 $( '.et_search_form_container' ).removeClass('et_pb_search_visible et_pb_no_animation' ).addClass( 'et_pb_search_form_hidden et_pb_is_animating' ); 979 setTimeout( function() { 980 $( '.et_menu_container' ).addClass( 'et_pb_no_animation' ); 981 $( '.et_search_form_container' ).addClass( 'et_pb_no_animation' ).removeClass('et_pb_is_animating'); 982 }, 1000); 983 } 984 985 function et_set_search_form_css() { 986 var $search_container = $( '.et_search_form_container' ); 987 var $body = $( 'body' ); 988 if ( $search_container.hasClass( 'et_pb_search_visible' ) ) { 989 var header_height = $( '#main-header' ).innerHeight(), 990 menu_width = $( '#top-menu' ).width(), 991 font_size = $( '#top-menu li a' ).css( 'font-size' ); 992 $search_container.css( { 'height' : header_height + 'px' } ); 993 $search_container.find( 'input' ).css( 'font-size', font_size ); 994 if ( ! $body.hasClass( 'et_header_style_left' ) ) { 995 $search_container.css( 'max-width', menu_width + 60 ); 996 } else { 997 $search_container.find( 'form' ).css( 'max-width', menu_width + 60 ); 998 } 999 } 1000 } 1001 1002 $( '.et_close_search_field' ).click( function() { 1003 et_hide_search(); 1004 }); 1005 1006 $( document ).mouseup( function(e) { 1007 var $header = $( '#main-header' ); 1008 if ( $( '.et_menu_container' ).hasClass('et_pb_menu_hidden') ) { 1009 if ( ! $header.is( e.target ) && $header.has( e.target ).length === 0 ) { 1010 et_hide_search(); 1011 } 1012 } 1013 }); 1014 1015 // Detect actual logo dimension, used for tricky fixed navigation transition 1016 function et_define_logo_dimension() { 1017 var $logo = $('#logo'), 1018 logo_src = $logo.attr( 'src' ), 1019 is_svg = logo_src.substr( -3, 3 ) === 'svg' ? true : false, 1020 $logo_wrap, 1021 logo_width, 1022 logo_height; 1023 1024 // Append invisible wrapper at the bottom of the page 1025 $('body').append( $('<div />', { 1026 'id' : 'et-define-logo-wrap', 1027 'style' : 'position: fixed; bottom: 0; opacity: 0;' 1028 })); 1029 1030 // Define logo wrap 1031 $logo_wrap = $('#et-define-logo-wrap'); 1032 1033 if( is_svg ) { 1034 $logo_wrap.addClass( 'svg-logo' ); 1035 } 1036 1037 // Clone logo to invisible wrapper 1038 $logo_wrap.html( $logo.clone().css({ 'display' : 'block' }).removeAttr( 'id' ) ); 1039 1040 // Get dimension 1041 logo_width = $logo_wrap.find('img').width(); 1042 logo_height = $logo_wrap.find('img').height(); 1043 1044 // Add data attribute to $logo 1045 $logo.attr({ 1046 'data-actual-width' : logo_width, 1047 'data-actual-height' : logo_height 1048 }); 1049 1050 // Destroy invisible wrapper 1051 $logo_wrap.remove(); 1052 1053 // Init logo transition onload 1054 et_fix_logo_transition( true ); 1055 } 1056 1057 if ( $('#logo').length ) { 1058 // Wait until logo is loaded before performing logo dimension fix 1059 // This comes handy when the page is heavy due to the use of images or other assets 1060 $('#logo').attr( 'src', $('#logo').attr('src') ).load( function(){ 1061 et_define_logo_dimension(); 1062 } ); 1063 } 1064 1065 // Set width for adsense in footer widget 1066 $('.footer-widget').each(function(){ 1067 var $footer_widget = $(this), 1068 footer_widget_width = $footer_widget.width(), 1069 $adsense_ins = $footer_widget.find( '.widget_adsensewidget ins' ); 1070 1071 if ( $adsense_ins.length ) { 1072 $adsense_ins.width( footer_widget_width ); 1073 } 1074 }); 1075 1076 /** 1077 * Visual Builder adjustment 1078 */ 1079 function et_fb_side_nav_page_init() { 1080 $( window ).off( 'scroll', window.et_pb_window_side_nav_scroll_init ); 1081 $( '#main-content .et_pb_side_nav' ).off( 'click', '.et_pb_side_nav a' ); 1082 $( '#main-content .et_pb_side_nav' ).remove(); 1083 et_pb_side_nav_page_init(); 1084 } 1085 if ( $('body').is('.et-fb') ) { 1086 $(window).on( 'et_fb_root_did_mount', function() { 1087 et_fb_side_nav_page_init(); 1088 1089 et_all_elements_loaded(); 1090 } ); 1091 1092 $(window).on( 'et_fb_section_content_change', et_fb_side_nav_page_init ); 1093 } else { 1094 $( window ).load( et_all_elements_loaded ); 1095 } 1096 } ); 1097 1098 // Fixing logo size transition in tricky header style 1099 function et_fix_logo_transition( is_onload ) { 1100 var $body = $( 'body' ), 1101 $logo = $( '#logo' ), 1102 logo_actual_width = parseInt( $logo.attr( 'data-actual-width' ) ), 1103 logo_actual_height = parseInt( $logo.attr( 'data-actual-height' ) ), 1104 logo_height_percentage = parseInt( $logo.attr( 'data-height-percentage' ) ), 1105 $top_nav = $( '#et-top-navigation' ), 1106 top_nav_height = parseInt( $top_nav.attr( 'data-height' ) ), 1107 top_nav_fixed_height = parseInt( $top_nav.attr( 'data-fixed-height' ) ), 1108 $main_header = $('#main-header'), 1109 is_header_split = $body.hasClass( 'et_header_style_split' ), 1110 is_fixed_nav = $main_header.hasClass( 'et-fixed-header' ), 1111 is_hide_primary_logo = $body.hasClass( 'et_hide_primary_logo' ), 1112 is_hide_fixed_logo = $body.hasClass( 'et_hide_fixed_logo' ), 1113 logo_height_base = is_fixed_nav ? top_nav_height : top_nav_fixed_height, 1114 logo_wrapper_width, 1115 logo_wrapper_height; 1116 1117 is_onload = typeof is_onload === 'undefined' ? false : is_onload; 1118 1119 // Fix for inline centered logo in horizontal nav 1120 if ( is_header_split && ! window.et_is_vertical_nav ) { 1121 // On page load, logo_height_base should be top_nav_height 1122 if ( is_onload ) { 1123 logo_height_base = top_nav_height; 1124 } 1125 1126 // Calculate logo wrapper height 1127 logo_wrapper_height = ( logo_height_base * ( logo_height_percentage / 100 ) + 22 ); 1128 1129 // Calculate logo wrapper width 1130 logo_wrapper_width = logo_actual_width * ( logo_wrapper_height / logo_actual_height ); 1131 1132 // Override logo wrapper width to 0 if it is hidden 1133 if ( is_hide_primary_logo && ( is_fixed_nav || is_onload ) ) { 1134 logo_wrapper_width = 0; 1135 } 1136 1137 if ( is_hide_fixed_logo && ! is_fixed_nav && ! is_onload ) { 1138 logo_wrapper_width = 0; 1139 } 1140
1141 // Set fixed width for logo wrapper to force correct dimension 1142 $( '.et_header_style_split .centered-inline-logo-wrap' ).css( { 'width' : logo_wrapper_width } ); 1143 } 1144 } 1145 1146 function et_toggle_slide_menu( force_state ) { 1147 var $slide_menu_container = $( '.et_header_style_slide .et_slide_in_menu_container' ), 1148 $page_container = $( '.et_header_style_slide #page-container, .et_header_style_slide.et_fixed_nav #main-header' ), 1149 $header_container = $( '.et_header_style_slide #main-header' ), 1150 is_menu_opened = $slide_menu_container.hasClass( 'et_pb_slide_menu_opened' ), 1151 set_to = typeof force_state !== 'undefined' ? force_state : 'auto', 1152 is_boxed_layout = $( 'body' ).hasClass( 'et_boxed_layout' ), 1153 page_container_margin = is_boxed_layout ? parseFloat( $( '#page-container' ).css( 'margin-left' ) ) : 0, 1154 slide_container_width = $slide_menu_container.innerWidth(); 1155 1156 if ( 'auto' !== set_to && ( ( is_menu_opened && 'open' === set_to ) || ( ! is_menu_opened && 'close' === set_to ) ) ) { 1157 return; 1158 } 1159 1160 if ( is_menu_opened ) { 1161 $slide_menu_container.css( { right: '-' + slide_container_width + 'px' } ); 1162 $page_container.css( { left: '0' } ); 1163 1164 if ( is_boxed_layout && et_is_fixed_nav ) { 1165 $header_container.css( { left : page_container_margin + 'px' } ); 1166 } 1167 1168 // hide the menu after animation completed 1169 setTimeout( function() { 1170 $slide_menu_container.css( { 'display' : 'none' } ); 1171 }, 700 ); 1172 } else { 1173 $slide_menu_container.css( { 'display' : 'block' } ); 1174 // add some delay to make sure css animation applied correctly 1175 setTimeout( function() { 1176 $slide_menu_container.css( { right: '0' } ); 1177 $page_container.css( { left: '-' + ( slide_container_width - page_container_margin ) + 'px' } ); 1178 1179 if ( is_boxed_layout && et_is_fixed_nav ) { 1180 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 ) ); 1181 1182 if ( left_position < slide_container_width ) { 1183 $header_container.css( { left: left_position + 'px' } ); 1184 } 1185 } 1186 }, 50 ); 1187 } 1188 1189 $( 'body' ).toggleClass( 'et_pb_slide_menu_active' ); 1190 $slide_menu_container.toggleClass( 'et_pb_slide_menu_opened' ); 1191 } 1192 1193 // Scrolling to the correct place on page if Fixed Nav enabled 1194 function et_adjust_woocommerce_checkout_scroll() { 1195 if ( ! et_is_fixed_nav ) { 1196 return; 1197 } 1198 1199 var window_width = parseInt( $et_window.width() ); 1200 1201 if ( 980 >= window_width ) { 1202 return; 1203 } 1204 1205 var headerHeight = parseInt( $( '#main-header' ).innerHeight() ); 1206 1207 // scroll to the top of checkout form taking into account fixed header height 1208 $( 'html, body' ).animate({ 1209 scrollTop: ( $( 'form.checkout' ).offset().top - 100 - headerHeight ) 1210 }, 1000 ); 1211 } 1212 1213 $( '#main-header' ).on( 'click', '.et_toggle_slide_menu', function() { 1214 et_toggle_slide_menu(); 1215 }); 1216 1217 if ( et_is_touch_device ) { 1218 // open slide menu on swipe left 1219 $et_window.on( 'swipeleft', function( event ) { 1220 var window_width = parseInt( $et_window.width() ), 1221 swipe_start = parseInt( event.swipestart.coords[0] ); // horizontal coordinates of the swipe start 1222 1223 // if swipe started from the right edge of screen then open slide menu 1224 if ( 30 >= window_width - swipe_start ) { 1225 et_toggle_slide_menu( 'open' ); 1226 } 1227 } ); 1228 1229 // close slide menu on swipe right 1230 $et_window.on( 'swiperight', function( event ){ 1231 if ( $( 'body' ).hasClass( 'et_pb_slide_menu_active' ) ) { 1232 et_toggle_slide_menu( 'close' ); 1233 } 1234 }); 1235 } 1236 1237 $( '#page-container' ).on( 'click', '.et_toggle_fullscreen_menu', function() { 1238 var $menu_container = $( '.et_header_style_fullscreen .et_slide_in_menu_container' ), 1239 top_bar_height = $menu_container.find( '.et_slide_menu_top' ).innerHeight(); 1240 1241 $menu_container.toggleClass( 'et_pb_fullscreen_menu_opened' ); 1242 $( 'body' ).toggleClass( 'et_pb_fullscreen_menu_active' ); 1243 1244 if ( $menu_container.hasClass( 'et_pb_fullscreen_menu_opened' ) ) { 1245 $menu_container.addClass( 'et_pb_fullscreen_menu_animated' ); 1246 1247 // adjust the padding in fullscreen menu 1248 $menu_container.css( { 'padding-top': top_bar_height + 20 } ); 1249 } else { 1250 setTimeout( function() { 1251 $menu_container.removeClass( 'et_pb_fullscreen_menu_animated' ); 1252 }, 1000 ); 1253 } 1254 }); 1255 1256 $( window ).unload( function () { 1257 /** 1258 * Fix the issue with Fullscreen menu, that remains open, 1259 * when back button is clicked in Firefox 1260 */ 1261 if ( $('body').hasClass('et_pb_fullscreen_menu_active') ) { 1262 $('.et_toggle_fullscreen_menu').trigger('click'); 1263 } 1264 } ); 1265 1266 $( '.et_pb_fullscreen_nav_container' ).on( 'click', 'li.menu-item-has-children > a', function() { 1267 var $this_parent = $( this ).closest( 'li' ), 1268 $this_arrow = $this_parent.find( '>a .et_mobile_menu_arrow' ), 1269 $closest_submenu = $this_parent.find( '>ul' ), 1270 is_opened_submenu = $this_arrow.hasClass( 'et_pb_submenu_opened' ), 1271 sub_menu_max_height; 1272 1273 $this_arrow.toggleClass( 'et_pb_submenu_opened' ); 1274 1275 if ( is_opened_submenu ) { 1276 $closest_submenu.removeClass( 'et_pb_slide_dropdown_opened' ); 1277 $closest_submenu.slideToggle( 700, 'easeInOutCubic' ); 1278 } else { 1279 $closest_submenu.slideToggle( 700, 'easeInOutCubic' ); 1280 $closest_submenu.addClass( 'et_pb_slide_dropdown_opened' ); 1281 } 1282 1283 return false;
1284 } ); 1285 1286 // define initial padding-top for fullscreen menu container 1287 if ( $( 'body' ).hasClass( 'et_header_style_fullscreen' ) ) { 1288 var $menu_container = $( '.et_header_style_fullscreen .et_slide_in_menu_container' ); 1289 1290 if ( $menu_container.length ) { 1291 var top_bar_height = $menu_container.find( '.et_slide_menu_top' ).innerHeight(); 1292 $menu_container.css( { 'padding-top': top_bar_height + 20 } ); 1293 } 1294 } 1295 1296 // adjust the scrolling position on Woocommerce checkout page in case of error 1297 $( document.body ).on( 'checkout_error', function() { 1298 et_adjust_woocommerce_checkout_scroll(); 1299 } ); 1300 1301 $( document.body ).on( 'updated_checkout', function( data ) { 1302 if ( 'failure' !== data.result ) { 1303 return; 1304 } 1305 1306 et_adjust_woocommerce_checkout_scroll(); 1307 } ); 1308 1309})(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.