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