PageSourceSearch

https://www.bastide-songes.com/wp-content/themes/Divi/js/custom.js?ver=3.0.14

js bastide-songes.com collected 2026-10-09 23:02:50 UTC 47,981 bytes, 1,227 lines download raw bytes

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