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