et_is_ipad = navigator.userAgent.match(/iPad/),
$et_container = $('.container'),
et_container_width = $et_container.width(),
et_is_fixed_nav = $('body').hasClass('et_fixed_nav') || $('body').hasClass('et_vertical_fixed'),
et_is_vertical_fixed_nav = $('body').hasClass('et_vertical_fixed'),
et_is_rtl = $('body').hasClass('rtl'),
et_hide_nav = $('body').hasClass('et_hide_nav'),
et_header_style_left = $('body').hasClass('et_header_style_left'),
$top_header = $('#top-header'),
$main_header = $('#main-header'),
$main_container_wrapper = $('#page-container'),
$et_main_content_first_row = $('#main-content .container:first-child'),
$et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'),
$et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find('h1.entry-title'),
$et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'),
$et_single_post = $('body.single'),
etRecalculateOffset = false,
$et_header_style_split = $('.et_header_style_split'),
$et_top_navigation = $('#et-top-navigation'),
$et_pb_first_row = et_get_first_section(),
et_is_touch_device = 'ontouchstart' in window || navigator.maxTouchPoints,
$et_top_cart = $('#et-secondary-menu a.et-cart-info'); // Modification of underscore's _.debounce()
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
function et_debounce(func, wait, immediate) {
var timeout, args, context, timestamp, result;
var now = Date.now || new Date().getTime();
var later = function later() {
var last = now - timestamp;
if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
result = func.apply(context, args);
if (!timeout) context = args = null;
var callNow = immediate && !timeout;
if (!timeout) timeout = setTimeout(later, wait);
result = func.apply(context, args);
function et_preload_image(src, callback) {
} // We need to check first to see if we are on a woocommerce single product.
if ($(".woocommerce .woocommerce-product-gallery").length > 0) {
// get the gallery container.
var gal = $(".woocommerce-product-gallery")[0]; // let's replace the data attribute since Salvatorre reconfigures
// data-columns on the resize event.
var newstr = gal.outerHTML.replace('data-columns', 'data-cols'); // finally we re-insert.
} // update the cart item on the secondary menu.
if ($et_top_cart.length > 0 && $('.shop_table.cart').length > 0) {
$(document.body).on('updated_wc_div', function () {
$('.shop_table.cart').find('.product-quantity input').each(function () {
new_total = new_total + parseInt($(this).val());
new_text = DIVI.item_count;
new_text = DIVI.items_count;
new_text = new_text.replace('%d', new_total);
$et_top_cart.find('span').text(new_text);
document.addEventListener('DOMContentLoaded', function () {
var $et_top_menu = $('ul.nav, ul.menu'),
$et_search_icon = $('#et_search_icon'),
et_parent_menu_longpress_limit = 300,
et_parent_menu_longpress_start,
et_parent_menu_click = true,
is_customize_preview = $('body').hasClass('et_is_customize_preview');
window.et_pb_init_nav_menu($et_top_menu);
function et_header_menu_split() {
var $logo_container = $('#main-header > .container > .logo_container'),
$logo_container_splitted = $('.centered-inline-logo-wrap > .logo_container'),
et_top_navigation_li_size = $et_top_navigation.children('nav').children('ul').children('li').size(),
et_top_navigation_li_break_index = Math.round(et_top_navigation_li_size / 2) - 1,
window_width = window.innerWidth || $et_window.width();
if (window_width > 980 && $logo_container.length && $('body').hasClass('et_header_style_split')) {
$('<li class="centered-inline-logo-wrap"></li>').insertAfter($et_top_navigation.find('nav > ul >li:nth(' + et_top_navigation_li_break_index + ')'));
$logo_container.appendTo($et_top_navigation.find('.centered-inline-logo-wrap'));
if (window_width <= 980 && $logo_container_splitted.length) {
$logo_container_splitted.prependTo('#main-header > .container');
$('#main-header .centered-inline-logo-wrap').remove();
function et_set_right_vertical_menu() {
if ($body.hasClass('et_boxed_layout') && $body.hasClass('et_vertical_fixed') && $body.hasClass('et_vertical_right')) {
var header_offset = parseFloat($('#page-container').css('margin-right'));
header_offset += parseFloat($('#et-main-area').css('margin-right')) - 225;
header_offset = 0 > header_offset ? 0 : header_offset;
$('#main-header').addClass('et_vertical_menu_set').css({
if ($et_header_style_split.length && !window.et_is_vertical_nav || is_customize_preview) {
$(window).resize(function () {
if (window.et_is_vertical_nav) {
if ($('#main-header').height() < $('#et-top-navigation').height()) {
$('#main-header').height($('#et-top-navigation').height() + $('#logo').height() + 100);
et_set_right_vertical_menu();
window.et_calculate_header_values = function () {
var $top_header = $('#top-header'),
secondary_nav_height = $top_header.length && $top_header.is(':visible') ? parseInt($top_header.innerHeight()) : 0,
admin_bar_height = $('#wpadminbar').length ? parseInt($('#wpadminbar').innerHeight()) : 0,
$slide_menu_container = $('.et_header_style_slide .et_slide_in_menu_container'),
is_rtl = $('body').hasClass('rtl');
et_header_height = parseInt($('#main-header').innerHeight()) + secondary_nav_height;
et_header_modifier = et_header_height <= 90 ? et_header_height - 29 : et_header_height - 56;
et_header_offset = et_header_modifier + admin_bar_height;
et_primary_header_top = secondary_nav_height + admin_bar_height;
if ($slide_menu_container.length && !$('body').hasClass('et_pb_slide_menu_active')) {
$slide_menu_container.css({
left: '-' + parseInt($slide_menu_container.innerWidth()) + 'px',
$slide_menu_container.css({
right: '-' + parseInt($slide_menu_container.innerWidth()) + 'px',
if ($('body').hasClass('et_boxed_layout')) {
var page_container_margin = $main_container_wrapper.css('margin-right');
right: page_container_margin
var page_container_margin = $main_container_wrapper.css('margin-left');
left: page_container_margin
var $comment_form = $('#commentform');
et_pb_form_placeholders_init($comment_form);
$comment_form.submit(function () {
et_pb_remove_placeholder_text($comment_form);
et_duplicate_menu($('#et-top-navigation ul.nav'), $('#et-top-navigation .mobile_nav'), 'mobile_menu', 'et_mobile_menu');
et_duplicate_menu('', $('.et_pb_fullscreen_nav_container'), 'mobile_menu_slide', 'et_mobile_menu', 'no_click_event'); // Handle `Disable top tier dropdown menu links` Theme Option.
if ($('ul.et_disable_top_tier').length) {
var $disbaled_top_tier_links = $("ul.et_disable_top_tier > li > ul").prev('a');
$disbaled_top_tier_links.attr('href', '#');
$disbaled_top_tier_links.on('click', function (e) {
}); // Handle top tier links in cloned mobile menu
var $disbaled_top_tier_links_mobile = $("ul#mobile_menu > li > ul").prev('a');
$disbaled_top_tier_links_mobile.attr('href', '#');
$disbaled_top_tier_links_mobile.on('click', function (e) {
if ($('#et-secondary-nav').length) {
$('#et-top-navigation #mobile_menu').append($('#et-secondary-nav').clone().html());
} // adding arrows for the slide/fullscreen menus
if ($('.et_slide_in_menu_container').length) {
var $item_with_sub = $('.et_slide_in_menu_container').find('.menu-item-has-children > a'); // add arrows for each menu item which has submenu
if ($item_with_sub.length) {
$item_with_sub.append('<span class="et_mobile_menu_arrow"></span>');
function et_change_primary_nav_position(delay) {
var etPrimaryHeaderTop = 0;
var $wpadminbar = builder_scripts_utils_utils__WEBPACK_IMPORTED_MODULE_0__["isBuilder"] ? top_window.jQuery('#wpadminbar') : $('#wpadminbar');
var $topHTML = top_window.jQuery('html');
var $topHeader = $('#top-header');
var isPreviewMode = $topHTML.is('.et-fb-preview--zoom:not(.et-fb-preview--desktop)');
isPreviewMode = isPreviewMode || $topHTML.is('.et-fb-preview--tablet');
isPreviewMode = isPreviewMode || $topHTML.is('.et-fb-preview--phone');
if ($wpadminbar.length && !Number.isNaN($wpadminbar.innerHeight())) {
var adminbarHeight = parseFloat($wpadminbar.innerHeight()); // Adjust admin bar height for builder's preview mode
// since admin bar is rendered on top window in these modes.
etPrimaryHeaderTop += builder_scripts_utils_utils__WEBPACK_IMPORTED_MODULE_0__["isBuilder"] && isPreviewMode ? 0 : adminbarHeight;
if ($topHeader.length && $topHeader.is(':visible')) {
etPrimaryHeaderTop += $topHeader.innerHeight();
var isFixedNav = $body.hasClass('et_fixed_nav');
var isAbsolutePrimaryNav = !isFixedNav && $body.hasClass('et_transparent_nav') && $body.hasClass('et_secondary_nav_enabled');
if (!window.et_is_vertical_nav && (isFixedNav || isAbsolutePrimaryNav)) {
$('#main-header').css('top', etPrimaryHeaderTop);
window.et_change_primary_nav_position = et_change_primary_nav_position;
function et_hide_nav_transform() {
$body_height = $(document).height(),
$viewport_height = $(window).height() + et_header_height + 200; // Do nothing when Vertical Navigation is Enabled
if ($body.hasClass('et_vertical_nav')) {
if ($body.hasClass('et_hide_nav') || $body.hasClass('et_hide_nav_disabled') && $body.hasClass('et_fixed_nav')) {
if ($body_height > $viewport_height) {
if ($body.hasClass('et_hide_nav_disabled')) {
$body.addClass('et_hide_nav');
$body.removeClass('et_hide_nav_disabled');
$('#main-header').css('transform', 'translateY(-' + et_header_height + 'px)');
$('#top-header').css('transform', 'translateY(-' + et_header_height + 'px)');
'transform': 'translateY(0)',
'transform': 'translateY(0)',
$body.removeClass('et_hide_nav');
$body.addClass('et_hide_nav_disabled');
} // Run fix page container again, needed when body height is not tall enough and
// adjustment has been aded
et_fix_page_container_position();
} // Saving current styling for the next resize cycle
function et_save_initial_page_container_style($selector, property) {
styling[property] = $selector.css(property);
'data-fix-page-container': 'on'
'fix_page_container_style': styling
function et_page_load_scroll_to_anchor() {
var location_hash = window.et_location_hash.replace(/(\|)/g, "\\$1");
if ($(location_hash).length === 0) {
var $map_container = $(location_hash + ' .et_pb_map_container');
var $map = $map_container.children('.et_pb_map');
var $target = $(location_hash); // Make the target element visible again
if ('undefined' !== typeof window.et_location_hash_style) {
$target.css('display', window.et_location_hash_style);
var distance = 'undefined' !== typeof $target.offset().top ? $target.offset().top : 0;
var speed = distance > 4000 ? 1600 : 800;
if ($map_container.length) {
google.maps.event.trigger($map[0], 'resize');
} // Workaround for reviews tab in woo tabs.
if ($target.parents().hasClass('commentlist')) {
$('.reviews_tab').click().animate({
scrollTop: $target.offset().top
} // Allow the header sizing functions enough time to finish before scrolling the page
et_pb_smooth_scroll($target, false, speed, 'swing'); // During the page scroll animation, the header's height might change.
// Do the scroll animation again to ensure its accuracy.
et_pb_smooth_scroll($target, false, 150, 'linear');
} // Retrieving padding/margin value based on formatted saved padding/margin strings
function et_get_saved_padding_margin_value(saved_value, order) {
if (typeof saved_value === 'undefined') {
var values = saved_value.split('|');
return typeof values[order] !== 'undefined' ? values[order] : false;
function et_fix_page_container_position() {
var et_window_width = parseInt($et_window.width()),
$top_header = $('#top-header'),
$et_pb_first_row = et_get_first_section(),
secondary_nav_height = $top_header.length && $top_header.is(':visible') ? parseInt($top_header.innerHeight()) : 0,
main_header_fixed_height = 0,
et_pb_first_row_padding_top;
var $mainHeaderClone = $main_header.clone().addClass('et-disabled-animations main-header-clone').css({
}).appendTo($('body')); // Replace previous resize cycle's adjustment
if (!$('body').hasClass('et-bfb')) {
$('*[data-fix-page-container="on"]').each(function () {
var $adjusted_element = $(this),
styling = $adjusted_element.data();
if (styling && styling.fix_page_container_style) {
// Reapply previous styling
$adjusted_element.css(styling.fix_page_container_style);
} // Set data-height-onload for header if the page is loaded on large screen
// If the page is loaded from small screen, rely on data-height-onload printed on the markup,
// prevent window resizing issue from small to large
// ignore data-height-loaded in VB to make sure it calculated correctly.
if (et_window_width > 980 && (!$main_header.attr('data-height-loaded') || $('body').is('.et-fb'))) {
var mainHeaderHeight = 0;
if ($main_header.hasClass('et-fixed-header')) {
$mainHeaderClone.removeClass('et-fixed-header');
mainHeaderHeight = $mainHeaderClone.height();
$mainHeaderClone.addClass('et-fixed-header');
mainHeaderHeight = $main_header.height();
'data-height-onload': parseInt(mainHeaderHeight),
'data-height-loaded': true
} // Use on page load calculation for large screen. Use on the fly calculation for small screen (980px below)
if (et_window_width <= 980) {
header_height = parseInt($main_header.innerHeight()) + secondary_nav_height - ($('body').hasClass('et-fb') ? 0 : 1); // If transparent is detected, #main-content .container's padding-top needs to be added to header_height
// And NOT a pagebuilder page
if (window.et_is_transparent_nav && !$et_pb_first_row.length) {
// Get header height from header attribute
header_height = parseInt($main_header.attr('data-height-onload')) + secondary_nav_height; // Non page builder page needs to be added by #main-content .container's fixed height
if (window.et_is_transparent_nav && !window.et_is_vertical_nav && $et_main_content_first_row.length) {
} // Calculate fixed header height by cloning, emulating, and calculating its height
main_header_fixed_height = $mainHeaderClone.height();
var topNavHeightDiff = parseInt($et_top_navigation.data('height')) - parseInt($et_top_navigation.data('fixed-height'));
main_header_fixed_height = parseInt($main_header.data('height-onload')) - topNavHeightDiff;
} // Saved fixed main header height calculation
'data-fixed-height-onload': main_header_fixed_height
var $wooCommerceNotice = $('.et_fixed_nav.et_transparent_nav.et-db.et_full_width_page #left-area > .woocommerce-notices-wrapper');
if ($wooCommerceNotice.length > 0 && 'yes' !== $wooCommerceNotice.attr('data-position-set')) {
var wooNoticeMargin = main_header_fixed_height;
if (0 === wooNoticeMargin && $main_header.attr('data-height-onload')) {
wooNoticeMargin = $main_header.attr('data-height-onload');
$wooCommerceNotice.css('marginTop', parseFloat(wooNoticeMargin));
$wooCommerceNotice.animate({
$wooCommerceNotice.attr('data-position-set', 'yes');
} // Specific adjustment required for transparent nav + not vertical nav + (not hidden nav
// OR hidden nav but document height is shorter than "viewport" height)
// 1. hidden nav: nav is initially hidden then appears as the window is scrolled)
// 2. in hidden nav, nav is displayed as window is scrolled. If document height is
// shorter than viewport, vertical scroll doesn't exist and nav is directly rendered.
// Thus, transparent nav adjustment need to be applied if body is shorter than window
// 3. Hidden nav only works on desktop breakpoint. Nav is always displayed on tablet
// and smaller breakpoints
// 4. "viewport" height calculation needs to be identical with viewport calculation used
// at `et_hide_nav_transform()` to make sure that when nav is displayed due to short
// document height, the padding gets added
var bodyHeight = $(document).height();
var viewportHeight = $(window).height() + et_header_height + 200;
var isBodyShorterThanViewport = viewportHeight > bodyHeight;
var isDesktop = parseInt($(window).width()) > 980;
var isHideNavDesktop = isDesktop && et_hide_nav;
if (window.et_is_transparent_nav && !window.et_is_vertical_nav && (!isHideNavDesktop || isBodyShorterThanViewport)) {
if (!$('body').hasClass('et-bfb')) {
// Add class for first row for custom section padding purpose
$et_pb_first_row.addClass('et_pb_section_first');
} // List of conditionals
var is_pb = $et_pb_first_row.length,
is_post_pb = is_pb && $et_single_post.length,
is_post_pb_full_layout_has_title = $et_pb_post_fullwidth.length && $et_main_content_first_row_meta_wrapper_title.length,
is_post_pb_full_layout_no_title = $et_pb_post_fullwidth.length && 0 === $et_main_content_first_row_meta_wrapper_title.length,
is_post_with_tb_body = is_post_pb && $('.et-l--body').length,
is_pb_fullwidth_section_first = $et_pb_first_row.is('.et_pb_fullwidth_section'),
is_no_pb_mobile = et_window_width <= 980 && $et_main_content_first_row.length,
isProject = $('body').hasClass('single-project');
if (!is_post_with_tb_body && is_post_pb && !(is_post_pb_full_layout_no_title && is_pb_fullwidth_section_first) && !isProject) {