PageSourceSearch

https://kimnew.ru/wp-content/plugins/divi-builder/framework/scripts/frontend-builder-scripts.js?ver=1.3

js kimnew.ru collected 2026-10-04 23:43:29 UTC 133,304 bytes, 3,554 lines download raw bytes

1(function($){
2	window.et_load_event_fired = false;
3
4	jQuery.fn.reverse = [].reverse;
5
6	jQuery.fn.closest_descendent = function( selector ) {
7		var $found,
8			$current_children = this.children();
9
10		while ( $current_children.length ) {
11			$found = $current_children.filter( selector );
12			if ( $found.length ) {
13				break;
14			}
15			$current_children = $current_children.children();
16		}
17
18		return $found;
19	};
20
21	if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) {
22		// update the window.et_load_event_fired variable to initiate the scripts properly
23		$( window ).load( function() {
24			window.et_load_event_fired = true;
25		});
26
27		// get the subject id for current visitor and display it
28		// this ajax request performed only if split testing is enabled and cache plugin active
29		$.ajax( {
30			type: "POST",
31			url: et_pb_custom.ajaxurl,
32			dataType: "json",
33			data:
34			{
35				action : 'et_pb_ab_get_subject_id',
36				et_frontend_nonce : et_pb_custom.et_frontend_nonce,
37				et_pb_ab_test_id : et_pb_custom.page_id
38			},
39			success: function( subject_data ) {
40				if ( subject_data ) {
41					// append the subject content to appropriate placeholder
42					$( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content );
43					// remove all other placeholders from the DOM
44					$( '.et_pb_subject_placeholder' ).remove();
45
46					// init all scripts once the subject loaded
47					et_pb_init_modules();
48					$( 'body' ).trigger( 'et_pb_ab_subject_ready' );
49				}
50			}
51		});
52	} else {
53		et_pb_init_modules();
54	}
55
56	function et_pb_init_modules() {
57		$.et_pb_simple_slider = function(el, options) {
58			var settings = $.extend( {
59				slide         			: '.et-slide',				 	// slide class
60				arrows					: '.et-pb-slider-arrows',		// arrows container class
61				prev_arrow				: '.et-pb-arrow-prev',			// left arrow class
62				next_arrow				: '.et-pb-arrow-next',			// right arrow class
63				controls 				: '.et-pb-controllers a',		// control selector
64				carousel_controls 		: '.et_pb_carousel_item',		// carousel control selector
65				control_active_class	: 'et-pb-active-control',		// active control class name
66				previous_text			: et_pb_custom.previous,			// previous arrow text
67				next_text				: et_pb_custom.next,				// next arrow text
68				fade_speed				: 500,							// fade effect speed
69				use_arrows				: true,							// use arrows?
70				use_controls			: true,							// use controls?
71				manual_arrows			: '',							// html code for custom arrows
72				append_controls_to		: '',							// controls are appended to the slider element by default, here you can specify the element it should append to
73				controls_below			: false,
74				controls_class			: 'et-pb-controllers',				// controls container class name
75				slideshow				: false,						// automattic animation?
76				slideshow_speed			: 7000,							// automattic animation speed
77				show_progress_bar		: false,							// show progress bar if automattic animation is active
78				tabs_animation			: false,
79				use_carousel			: false
80			}, options );
81
82			var $et_slider 			= $(el),
83				$et_slide			= $et_slider.closest_descendent( settings.slide ),
84				et_slides_number	= $et_slide.length,
85				et_fade_speed		= settings.fade_speed,
86				et_active_slide		= 0,
87				$et_slider_arrows,
88				$et_slider_prev,
89				$et_slider_next,
90				$et_slider_controls,
91				$et_slider_carousel_controls,
92				et_slider_timer,
93				controls_html = '',
94				carousel_html = '',
95				$progress_bar = null,
96				progress_timer_count = 0,
97				$et_pb_container = $et_slider.find( '.et_pb_container' ),
98				et_pb_container_width = $et_pb_container.width(),
99				is_post_slider = $et_slider.hasClass( 'et_pb_post_slider' );
100
101				$et_slider.et_animation_running = false;
102
103				$.data(el, "et_pb_simple_slider", $et_slider);
104
105				$et_slide.eq(0).addClass( 'et-pb-active-slide' );
106
107				if ( ! settings.tabs_animation ) {
108					if ( !$et_slider.hasClass('et_pb_bg_layout_dark') && !$et_slider.hasClass('et_pb_bg_layout_light') ) {
109						$et_slider.addClass( et_get_bg_layout_color( $et_slide.eq(0) ) );
110					}
111				}
112
113				if ( settings.use_arrows && et_slides_number > 1 ) {
114					if ( settings.manual_arrows == '' )
115						$et_slider.append( '<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">
115' + '<span>' +settings.previous_text + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + settings.next_text + '</span>' + '</a></div>' );
116					else
117						$et_slider.append( settings.manual_arrows );
118
119					$et_slider_arrows 	= $et_slider.find( settings.arrows );
120					$et_slider_prev 	= $et_slider.find( settings.prev_arrow );
121					$et_slider_next 	= $et_slider.find( settings.next_arrow );
122
123					$et_slider_next.click( function(){
124						if ( $et_slider.et_animation_running )	return false;
125
126						$et_slider.et_slider_move_to( 'next' );
127
128						return false;
129					} );
130
131					$et_slider_prev.click( function(){
132						if ( $et_slider.et_animation_running )	return false;
133
134						$et_slider.et_slider_move_to( 'previous' );
135
136						return false;
137					} );
138
139					// swipe support requires et-jquery-touch-mobile
140					$et_slider.find( settings.slide ).on( 'swipeleft', function() {
141						$et_slider.et_slider_move_to( 'next' );
142					});
143					$et_slider.find( settings.slide ).on( 'swiperight', function() {
144						$et_slider.et_slider_move_to( 'previous' );
145					});
146				}
147
148				if ( settings.use_controls && et_slides_number > 1 ) {
149					for ( var i = 1; i <= et_slides_number; i++ ) {
150						controls_html += '<a href="#"' + ( i == 1 ? ' class="' + settings.control_active_class + '"' : '' ) + '>
150' + i + '</a>';
151					}
152
153					controls_html =
154						'<div class="' + settings.controls_class + '">' +
155							controls_html +
156						'</div>';
157
158					if ( settings.append_controls_to == '' )
159						$et_slider.append( controls_html );
160					else
161						$( settings.append_controls_to ).append( controls_html );
162
163					if ( settings.controls_below )
164						$et_slider_controls	= $et_slider.parent().find( settings.controls );
165					else
166						$et_slider_controls	= $et_slider.find( settings.controls );
167
168					et_maybe_set_controls_color( $et_slide.eq(0) );
169
170					$et_slider_controls.click( function(){
171						if ( $et_slider.et_animation_running )	return false;
172
173						$et_slider.et_slider_move_to( $(this).index() );
174
175						return false;
176					} );
177				}
178
179				if ( settings.use_carousel && et_slides_number > 1 ) {
180					for ( var i = 1; i <= et_slides_number; i++ ) {
181						slide_id = i - 1;
182						image_src = ( $et_slide.eq(slide_id).data('image') !== undefined ) ? 'url(' + $et_slide.eq(slide_id).data('image') + ')' : 'none';
183						carousel_html += '<div class="et_pb_carousel_item ' + ( i == 1 ? settings.control_active_class : '' ) + '" data-slide-id="'+ slide_id +'">' +
184							'<div class="et_pb_video_overlay" href="#" style="background-image: ' + image_src + ';">' +
185								'<div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div>' +
186							'</div>' +
187						'</div>';
188					}
189
190					carousel_html =
191						'<div class="et_pb_carousel">' +
192						'<div class="et_pb_carousel_items">' +
193							carousel_html +
194						'</div>' +
195						'</div>';
196					$et_slider.after( carousel_html );
197
198					$et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find( settings.carousel_controls );
199					$et_slider_carousel_controls.click( function(){
200						if ( $et_slider.et_animation_running )	return false;
201
202						var $this = $(this);
203						$et_slider.et_slider_move_to( $this.data('slide-id') );
204
205						return false;
206					} );
207				}
208
209				if ( settings.slideshow && et_slides_number > 1 ) {
210					$et_slider.hover( function() {
211						if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) {
212							return;
213						}
214
215						$et_slider.addClass( 'et_slider_hovered' );
216
217						if ( typeof et_slider_timer != 'undefined' ) {
218							clearInterval( et_slider_timer );
219						}
220					}, function() {
221						if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) {
222							return;
223						}
224
225						$et_slider.removeClass( 'et_slider_hovered' );
226
227						et_slider_auto_rotate();
228					} );
229				}
230
231				et_slider_auto_rotate();
232
233				function et_slider_auto_rotate(){
234					if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) {
235						et_slider_timer = setTimeout( function() {
236							$et_slider.et_slider_move_to( 'next' );
237						}, settings.slideshow_speed );
238					}
239				}
240
241				function et_stop_video( active_slide ) {
242					var $et_video, et_video_src;
243
244					// if there is a video in the slide, stop it when switching to another slide
245					if ( active_slide.has( 'iframe' ).length ) {
246						$et_video = active_slide.find( 'iframe' );
247						et_video_src = $et_video.attr( 'src' );
248
249						$et_video.attr( 'src', '' );
250						$et_video.attr( 'src', et_video_src );
251
252					} else if ( active_slide.has( 'video' ).length ) {
253						if ( !active_slide.find('.et_pb_section_video_bg').length ) {
254							$et_video = active_slide.find( 'video' );
255							$et_video[0].pause();
256						}
257					}
258				}
259
260				function et_fix_slider_content_images() {
261					var $this_slider           = $et_slider,
262						$slide_image_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_image' );
263						$slide_video_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_video' );
264						$slide                 = $slide_image_container.closest( '.et_pb_slide' ),
265						$slider                = $slide.closest( '.et_pb_slider' ),
266						slide_height           = $slider.innerHeight(),
267						image_height           = parseInt( slide_height * 0.8 ),
268						$top_header 		   = $('#top-header'),
269						$main_header		   = $('#main-header'),
270						$et_transparent_nav    = $( '.et_transparent_nav' ),
271						$et_vertical_nav 	   = $('.et_vertical_nav');
272
273					$slide_image_container.find( 'img' ).css( 'maxHeight', image_height + 'px' );
274
275					if ( $slide.hasClass( 'et_pb_media_alignment_center' ) ) {
276						$slide_image_container.css( 'marginTop', '-' + parseInt( $slide_image_container.height() / 2 ) + 'px' );
277					}
278
279					$slide_video_container.css( 'marginTop', '-' + parseInt( $slide_video_container.height() / 2 ) + 'px' );
280
281					$slide_image_container.find( 'img' ).addClass( 'active' );
282				}
283
284				function et_get_bg_layout_color( $slide ) {
285					if ( $slide.hasClass( 'et_pb_bg_layout_dark' ) ) {
286						return 'et_pb_bg_layout_dark';
287					}
288
289					return 'et_pb_bg_layout_light';
290				}
291
292				function et_maybe_set_controls_color( $slide ) {
293					var next_slide_dot_color,
294						$arrows,
295						arrows_color;
296
297					if ( typeof $et_slider_controls !== 'undefined' && $et_slider_controls.length ) {
298						next_slide_dot_color = $slide.data( 'dots_color' ) || '';
299
300						if ( next_slide_dot_color !== '' ) {
301							$et_slider_controls.attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color, '0.3' ) + ';' )
302							$et_slider_controls.filter( '.et-pb-active-control' ).attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color ) + '!important;' );
303						} else {
304							$et_slider_controls.removeAttr( 'style' );
305						}
306					}
307
308					if ( typeof $et_slider_arrows !== 'undefined' && $et_slider_arrows.length ) {
309						$arrows      = $et_slider_arrows.find( 'a' );
310						arrows_color = $slide.data( 'arrows_color' ) || '';
311
312						if ( arrows_color !== '' ) {
313							$arrows.css( 'color', arrows_color );
314						} else {
315							$arrows.css( 'color', 'inherit' );
316						}
317					}
318				}
319
320				// fix the appearance of some modules inside the post slider
321				function et_fix_builder_content() {
322					if ( is_post_slider ) {
323						setTimeout( function() {
324							var $et_pb_circle_counter = $( '.et_pb_circle_counter' ),
325								$et_pb_number_counter = $( '.et_pb_number_counter' );
326
327							window.et_fix_testimonial_inner_width();
328
329							if ( $et_pb_circle_counter.length ) {
330								window.et_pb_reinit_circle_counters( $et_pb_circle_counter );
331							}
332
333							if ( $et_pb_number_counter.length ) {
334								window.et_pb_reinit_number_counters( $et_pb_number_counter );
335							}
336							window.et_reinint_waypoint_modules();
337						}, 1000 );
338					}
339				}
340
341				function hex_to_rgba( color, alpha ) {
342					var color_16 = parseInt( color.replace( '#', '' ), 16 ),
343						red      = ( color_16 >> 16 ) & 255,
344						green    = ( color_16 >> 8 ) & 255,
345						blue     = color_16 & 255,
346						alpha    = alpha || 1,
347						rgba;
348
349					rgba = red + ',' + green + ',' + blue + ',' + alpha;
350					rgba = 'rgba(' + rgba + ')';
351
352					return rgba;
353				}
354
355				if ( window.et_load_event_fired ) {
356					et_fix_slider_content_images();
357				} else {
358					$et_window.load( function() {
359						et_fix_slider_content_images();
360					} );
361				}
362
363				$et_window.resize( function() {
364					et_fix_slider_content_images();
365				} );
366
367				$et_slider.et_slider_move_to = function ( direction ) {
368					var $active_slide = $et_slide.eq( et_active_slide ),
369						$next_slide;
370
371					$et_slider.et_animation_running = true;
372
373					$et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass('et_slide_transition_to_' + direction );
374
375					$et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide');
376
377					if ( direction == 'next' || direction == 'previous' ){
378
379						if ( direction == 'next' )
380							et_active_slide = ( et_active_slide + 1 ) < et_slides_number ? et_active_slide + 1 : 0;
381						else
382							et_active_slide = ( et_active_slide - 1 ) >= 0 ? et_active_slide - 1 : et_slides_number - 1;
383
384					} else {
385
386						if ( et_active_slide == direction ) {
387							$et_slider.et_animation_running = false;
388							return;
389						}
390
391						et_active_slide = direction;
392
393					}
394
395					if ( typeof et_slider_timer != 'undefined' )
396						clearInterval( et_slider_timer );
397
398					$next_slide	= $et_slide.eq( et_active_slide );
399
400					if ( typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0]['player'] !== 'undefined' ) {
401						$active_slide.find('video')[0].player.pause();
402					}
403
404					if ( typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0]['player'] !== 'undefined' ) {
405						$next_slide.find('video')[0].player.play();
406					}
407
408					$et_slider.trigger( 'simple_slider_before_move_to', { direction : direction, next_slide : $next_slide });
409
410					$et_slide.each( function(){
411						$(this).css( 'zIndex', 1 );
412					} );
413					$active_slide.css( 'zIndex', 2 ).removeClass( 'et-pb-active-slide' ).addClass('et-pb-moved-slide');
414					$next_slide.css( { 'display' : 'block', opacity : 0 } ).addClass( 'et-pb-active-slide' );
415
416					et_fix_slider_content_images();
417
418					et_fix_builder_content();
419
420					if ( settings.use_controls )
421						$et_slider_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class );
422
423					if ( settings.use_carousel )
424						$et_slider_carousel_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class );
425
426					if ( ! settings.tabs_animation ) {
427						et_maybe_set_controls_color( $next_slide );
428
429						$next_slide.animate( { opacity : 1 }, et_fade_speed );
430						$active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'list-item', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){
431							var active_slide_layout_bg_color = et_get_bg_layout_color( $active_slide ),
432								next_slide_layout_bg_color = et_get_bg_layout_color( $next_slide );
433
434							$(this).css('display', 'none').removeClass( 'et_slide_transition' );
435
436							et_stop_video( $active_slide );
437
438							$et_slider
439								.removeClass( active_slide_layout_bg_color )
440								.addClass( next_slide_layout_bg_color );
441
442							$et_slider.et_animation_running = false;
443
444							$et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } );
445						} );
446					} else {
447						$next_slide.css( { 'display' : 'none', opacity : 0 } );
448
449						$active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'block', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){
450							$(this).css('display', 'none').removeClass( 'et_slide_transition' );
451
452							$next_slide.css( { 'display' : 'block', 'opacity' : 0 } ).animate( { opacity : 1 }, et_fade_speed, function() {
453								$et_slider.et_animation_running = false;
454
455								$et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } );
456							} );
457						} );
458					}
459
460					et_slider_auto_rotate();
461				}
462		}
463
464		$.fn.et_pb_simple_slider = function( options ) {
465			return this.each(function() {
466				new $.et_pb_simple_slider(this, options);
467			});
468		}
469
470		var et_hash_module_seperator = '||',
471			et_hash_module_param_seperator = '|';
472
473		function process_et_hashchange( hash ) {
474			if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) {
475				modules = hash.split( et_hash_module_seperator );
476				for ( var i = 0; i < modules.length; i++ ) {
477					var module_params = modules[i].split( et_hash_module_param_seperator );
478					var element = module_params[0];
479					module_params.shift();
480					if ( $('#' + element ).length ) {
481						$('#' + element ).trigger({
482							type: "et_hashchange",
483							params: module_params
484						});
485					}
486				}
487			} else {
488				module_params = hash.split( et_hash_module_param_seperator );
489				var element = module_params[0];
490				module_params.shift();
491				if ( $('#' + element ).length ) {
492					$('#' + element ).trigger({
493						type: "et_hashchange",
494						params: module_params
495					});
496				}
497			}
498		}
499
500		function et_set_hash( module_state_hash ) {
501			module_id = module_state_hash.split( et_hash_module_param_seperator )[0];
502			if ( !$('#' + module_id ).length ) {
503				return;
504			}
505
506			if ( window.location.hash ) {
507				var hash = window.location.hash.substring(1), //Puts hash in variable, and removes the # character
508					new_hash = [];
509
510				if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) {
511					modules = hash.split( et_hash_module_seperator );
512					var in_hash = false;
513					for ( var i = 0; i < modules.length; i++ ) {
514						var element = modules[i].split( et_hash_module_param_seperator )[0];
515						if ( element === module_id ) {
516							new_hash.push( module_state_hash );
517							in_hash = true;
518						} else {
519							new_hash.push( modules[i] );
520						}
521					}
522					if ( !in_hash ) {
523						new_hash.push( module_state_hash );
524					}
525				} else {
526					module_params = hash.split( et_hash_module_param_seperator );
527					var element = module_params[0];
528					if ( element !== module_id ) {
529						new_hash.push( hash );
530					}
531					new_hash.push( module_state_hash );
532				}
533
534				hash = new_hash.join( et_hash_module_seperator );
535			} else {
536				hash = module_state_hash;
537			}
538
539			var yScroll = document.body.scrollTop;
540			window.location.hash = hash;
541			document.body.scrollTop = yScroll;
542		}
543
544		$.et_pb_simple_carousel = function(el, options) {
545			var settings = $.extend( {
546				slide_duration	: 500,
547			}, options );
548
549			var $et_carousel 			= $(el),
550				$carousel_items 		= $et_carousel.find('.et_pb_carousel_items'),
551				$the_carousel_items 	= $carousel_items.find('.et_pb_carousel_item');
552
553			$et_carousel.et_animation_running = false;
554
555			$et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', function( event ){
556				set_carousel_columns( $et_carousel );
557				set_carousel_height( $et_carousel );
558			});
559
560			$carousel_items.data('items', $the_carousel_items.toArray() );
561			$et_carousel.data('columns_setting_up', false );
562
563			$carousel_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-slider-arrow et-pb-arrow-prev" href="#">' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-slider-arrow et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>');
564
565			set_carousel_columns( $et_carousel );
566			set_carousel_height( $et_carousel );
567
568			$et_carousel_next 	= $et_carousel.find( '.et-pb-arrow-next' );
569			$et_carousel_prev 	= $et_carousel.find( '.et-pb-arrow-prev'  );
570
571			$et_carousel_next.click( function(){
572				if ( $et_carousel.et_animation_running ) return false;
573
574				$et_carousel.et_carousel_move_to( 'next' );
575
576				return false;
577			} );
578
579			$et_carousel_prev.click( function(){
580				if ( $et_carousel.et_animation_running ) return false;
581
582				$et_carousel.et_carousel_move_to( 'previous' );
583
584				return false;
585			} );
586
587			// swipe support requires et-jquery-touch-mobile
588			$et_carousel.on( 'swipeleft', function() {
589				$et_carousel.et_carousel_move_to( 'next' );
590			});
591			$et_carousel.on( 'swiperight', function() {
592				$et_carousel.et_carousel_move_to( 'previous' );
593			});
594
595			function set_carousel_height( $the_carousel ) {
596				var carousel_items_width = $the_carousel_items.width(),
597					carousel_items_height = $the_carousel_items.height();
598
599				$carousel_items.css('height', carousel_items_height + 'px' );
600			}
601
602			function set_carousel_columns( $the_carousel ) {
603				var columns,
604					$carousel_parent = $the_carousel.parents('.et_pb_column'),
605					carousel_items_width = $carousel_items.width(),
606					carousel_item_count = $the_carousel_items.length;
607
608				if ( $carousel_parent.hasClass('et_pb_column_4_4') || $carousel_parent.hasClass('et_pb_column_3_4') || $carousel_parent.hasClass('et_pb_column_2_3') ) {
609					if ( $et_window.width() < 768 ) {
610						columns = 3;
611					} else {
612						columns = 4;
613					}
614				} else if ( $carousel_parent.hasClass('et_pb_column_1_2') || $carousel_parent.hasClass('et_pb_column_3_8') || $carousel_parent.hasClass('et_pb_column_1_3') ) {
615					columns = 3;
616				} else if ( $carousel_parent.hasClass('et_pb_column_1_4') ) {
617					if ( $et_window.width() > 480 && $et_window.width() < 980 ) {
618						columns = 3;
619					} else {
620						columns = 2;
621					}
622				}
623
624				if ( columns === $carousel_items.data('portfolio-columns') ) {
625					return;
626				}
627
628				if ( $the_carousel.data('columns_setting_up') ) {
629					return;
630				}
631
632				$the_carousel.data('columns_setting_up', true );
633
634				// store last setup column
635				$carousel_items.removeClass('columns-' + $carousel_items.data('portfolio-columns') );
636				$carousel_items.addClass('columns-' + columns );
637				$carousel_items.data('portfolio-columns', columns );
638
639				// kill all previous groups to get ready to re-group
640				if ( $carousel_items.find('.et-carousel-group').length ) {
641					$the_carousel_items.appendTo( $carousel_items );
642					$carousel_items.find('.et-carousel-group').remove();
643				}
644
645				// setup the grouping
646				var the_carousel_items = $carousel_items.data('items'),
647					$carousel_group = $('<div class="et-carousel-group active">').appendTo( $carousel_items );
648
649				$the_carousel_items.data('position', '');
650				if ( the_carousel_items.length <= columns ) {
651					$carousel_items.find('.et-pb-slider-arrows').hide();
652				} else {
653					$carousel_items.find('.et-pb-slider-arrows').show();
654				}
655
656				for ( position = 1, x=0 ;x < the_carousel_items.length; x++, position++ ) {
657					if ( x < columns ) {
658						$( the_carousel_items[x] ).show();
659						$( the_carousel_items[x] ).appendTo( $carousel_group );
660						$( the_carousel_items[x] ).data('position', position );
661						$( the_carousel_items[x] ).addClass('position_' + position );
662					} else {
663						position = $( the_carousel_items[x] ).data('position');
664						$( the_carousel_items[x] ).removeClass('position_' + position );
665						$( the_carousel_items[x] ).data('position', '' );
666						$( the_carousel_items[x] ).hide();
667					}
668				}
669
670				$the_carousel.data('columns_setting_up', false );
671
672			} /* end set_carousel_columns() */
673
674			$et_carousel.et_carousel_move_to = function ( direction ) {
675				var $active_carousel_group 	= $carousel_items.find('.et-carousel-group.active'),
676					items 					= $carousel_items.data('items'),
677					columns 				= $carousel_items.data('portfolio-columns');
678
679				$et_carousel.et_animation_running = true;
680
681				var left = 0;
682				$active_carousel_group.children().each(function(){
683					$(this).css({'position':'absolute', 'left': left });
684					left = left + $(this).outerWidth(true);
685				});
686
687				if ( direction == 'next' ) {
688					var $next_carousel_group,
689						current_position = 1,
690						next_position = 1,
691						active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ),
692						active_items_end = active_items_start + columns,
693						next_items_start = active_items_end,
694						next_items_end = next_items_start + columns;
695
696					$next_carousel_group = $('<div class="et-carousel-group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group );
697					$next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show();
698
699					// this is an endless loop, so it can decide internally when to break out, so that next_position
700					// can get filled up, even to the extent of an element having both and current_ and next_ position
701					for( x = 0, total = 0 ; ; x++, total++ ) {
702						if ( total >= active_items_start && total < active_items_end ) {
703							$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
704							$( items[x] ).data('current_position', current_position );
705							current_position++;
706						}
707
708						if ( total >= next_items_start && total < next_items_end ) {
709							$( items[x] ).data('next_position', next_position );
710							$( items[x] ).addClass('changing_position next_position next_position_' + next_position );
711
712							if ( !$( items[x] ).hasClass( 'current_position' ) ) {
713								$( items[x] ).addClass('container_append');
714							} else {
715								$( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
716								$( items[x] ).addClass('delayed_container_append');
717							}
718
719							next_position++;
720						}
721
722						if ( next_position > columns ) {
723							break;
724						}
725
726						if ( x >= ( items.length -1 )) {
727							x = -1;
728						}
729					}
730
731					var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
732						var el_a_position = parseInt( $(a).data('next_position') );
733						var el_b_position = parseInt( $(b).data('next_position') );
734						return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
735					});
736
737					$( sorted ).show().appendTo( $next_carousel_group );
738
739					var left = 0;
740					$next_carousel_group.children().each(function(){
741						$(this).css({'position':'absolute', 'left': left });
742						left = left + $(this).outerWidth(true);
743					});
744
745					$active_carousel_group.animate({
746						left: '-100%'
747					}, {
748						duration: settings.slide_duration,
749						complete: function() {
750							$carousel_items.find('.delayed_container_append').each(function(){
751								left = $( '#' + $(this).attr('id') + '-dup' ).css('left');
752								$(this).css({'position':'absolute', 'left': left });
753								$(this).appendTo( $next_carousel_group );
754							});
755
756							$active_carousel_group.removeClass('active');
757							$active_carousel_group.children().each(function(){
758								position = $(this).data('position');
759								current_position = $(this).data('current_position');
760								$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
761								$(this).data('position', '');
762								$(this).data('current_position', '');
763								$(this).hide();
764								$(this).css({'position': '', 'left': ''});
765								$(this).appendTo( $carousel_items );
766							});
767
768							$active_carousel_group.remove();
769
770						}
771					} );
772
773					next_left = $active_carousel_group.width() + parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) );
774					$next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: next_left });
775					$next_carousel_group.animate({
776						left: '0%'
777					}, {
778						duration: settings.slide_duration,
779						complete: function(){
780							$next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
781
782							$next_carousel_group.find('.changing_position').each(function( index ){
783								position = $(this).data('position');
784								current_position = $(this).data('current_position');
785								next_position = $(this).data('next_position');
786								$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position );
787								$(this).data('current_position', '');
788								$(this).data('next_position', '');
789								$(this).data('position', ( index + 1 ) );
790							});
791
792							$next_carousel_group.children().css({'position': '', 'left': ''});
793							$next_carousel_group.find('.delayed_container_append_dup').remove();
794
795							$et_carousel.et_animation_running = false;
796						}
797					} );
798
799				} else if ( direction == 'previous' ) {
800					var $prev_carousel_group,
801						current_position = columns,
802						prev_position = columns,
803						columns_span = columns - 1,
804						active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ),
805						active_items_end = active_items_start - columns_span,
806						prev_items_start = active_items_end - 1,
807						prev_items_end = prev_items_start - columns_span;
808
809					$prev_carousel_group = $('<div class="et-carousel-group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group );
810					$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
811
812					// this is an endless loop, so it can decide internally when to break out, so that next_position
813					// can get filled up, even to the extent of an element having both and current_ and next_ position
814					for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
815
816						if ( total <= active_items_start && total >= active_items_end ) {
817							$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
818							$( items[x] ).data('current_position', current_position );
819							current_position--;
820						}
821
822						if ( total <= prev_items_start && total >= prev_items_end ) {
823							$( items[x] ).data('prev_position', prev_position );
824							$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
825
826							if ( !$( items[x] ).hasClass( 'current_position' ) ) {
827								$( items[x] ).addClass('container_append');
828							} else {
829								$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
830								$( items[x] ).addClass('delayed_container_append');
831							}
832
833							prev_position--;
834						}
835
836						if ( prev_position <= 0 ) {
837							break;
838						}
839
840						if ( x == 0 ) {
841							x = items.length;
842						}
843					}
844
845					var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
846						var el_a_position = parseInt( $(a).data('prev_position') );
847						var el_b_position = parseInt( $(b).data('prev_position') );
848						return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
849					});
850
851					$( sorted ).show().appendTo( $prev_carousel_group );
852
853					var left = 0;
854					$prev_carousel_group.children().each(function(){
855						$(this).css({'position':'absolute', 'left': left });
856						left = left + $(this).outerWidth(true);
857					});
858
859					$active_carousel_group.animate({
860						left: '100%'
861					}, {
862						duration: settings.slide_duration,
863						complete: function() {
864							$carousel_items.find('.delayed_container_append').reverse().each(function(){
865								left = $( '#' + $(this).attr('id') + '-dup' ).css('left');
866								$(this).css({'position':'absolute', 'left': left });
867								$(this).prependTo( $prev_carousel_group );
868							});
869
870							$active_carousel_group.removeClass('active');
871							$active_carousel_group.children().each(function(){
872								position = $(this).data('position');
873								current_position = $(this).data('current_position');
874								$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
875								$(this).data('position', '');
876								$(this).data('current_position', '');
877								$(this).hide();
878								$(this).css({'position': '', 'left': ''});
879								$(this).appendTo( $carousel_items );
880							});
881
882							$active_carousel_group.remove();
883						}
884					} );
885
886					prev_left = (-1) * $active_carousel_group.width() - parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) );
887					$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: prev_left });
888					$prev_carousel_group.animate({
889						left: '0%'
890					}, {
891						duration: settings.slide_duration,
892						complete: function(){
893							$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
894
895							$prev_carousel_group.find('.delayed_container_append_dup').remove();
896
897							$prev_carousel_group.find('.changing_position').each(function( index ){
898								position = $(this).data('position');
899								current_position = $(this).data('current_position');
900								prev_position = $(this).data('prev_position');
901								$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
902								$(this).data('current_position', '');
903								$(this).data('prev_position', '');
904								position = index + 1;
905								$(this).data('position', position );
906								$(this).addClass('position_' + position );
907							});
908
909							$prev_carousel_group.children().css({'position': '', 'left': ''});
910							$et_carousel.et_animation_running = false;
911						}
912					} );
913				}
914			}
915		}
916
917		$.fn.et_pb_simple_carousel = function( options ) {
918			return this.each(function() {
919				new $.et_pb_simple_carousel(this, options);
920			});
921		}
922
923		var $et_pb_slider  = $( '.et_pb_slider' ),
924			$et_pb_tabs    = $( '.et_pb_tabs' ),
925			$et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' ),
926			$et_pb_video_section = $('.et_pb_section_video_bg'),
927			$et_pb_newsletter_button = $( '.et_pb_newsletter_button' ),
928			$et_pb_filterable_portfolio = $( '.et_pb_filterable_portfolio' ),
929			$et_pb_fullwidth_portfolio = $( '.et_pb_fullwidth_portfolio' ),
930			$et_pb_gallery = $( '.et_pb_gallery' ),
931			$et_pb_countdown_timer = $( '.et_pb_countdown_timer' ),
932			$et_post_gallery = $( '.et_post_gallery' ),
933			$et_lightbox_image = $( '.et_pb_lightbox_image'),
934			$et_pb_map    = $( '.et_pb_map_container' ),
935			$et_pb_circle_counter = $( '.et_pb_circle_counter' ),
936			$et_pb_number_counter = $( '.et_pb_number_counter' ),
937			$et_pb_parallax = $( '.et_parallax_bg' ),
938			$et_pb_shop = $( '.et_pb_shop' ),
939			$et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ),
940			et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ),
941			et_is_ipad = navigator.userAgent.match( /iPad/ ),
942			$et_container = ! et_pb_custom.is_builder_plugin_used ? $( '.container' ) : $( '.et_pb_row' ),
943			et_container_width = $et_container.width(),
944			et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ),
945			et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ),
946			et_is_rtl = $( 'body' ).hasClass( 'rtl' ),
947			et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ),
948			et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ),
949			et_vertical_navigation = $( 'body' ).hasClass( 'et_vertical_nav' ),
950			$top_header = $('#top-header'),
951			$main_header = $('#main-header'),
952			$main_container_wrapper = $( '#page-container' ),
953			$et_transparent_nav = $( '.et_transparent_nav' ),
954			$et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ),
955			$et_main_content_first_row = $( '#main-content .container:first-child' ),
956			$et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'),
957			$et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1' ),
958			$et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'),
959			$et_single_post = $( 'body.single-post' ),
960			$et_window = $(window),
961			etRecalculateOffset = false,
962			et_header_height,
963			et_header_modifier,
964			et_header_offset,
965			et_primary_header_top,
966			$et_vertical_nav = $('.et_vertical_nav'),
967			$et_header_style_split = $('.et_header_style_split'),
968			$et_top_navigation = $('#et-top-navigation'),
969			$logo = $('#logo'),
970			$et_sticky_image = $('.et_pb_image_sticky'),
971			$et_pb_counter_amount = $('.et_pb_counter_amount'),
972			$et_pb_carousel = $( '.et_pb_carousel' ),
973			$et_menu_selector = et_pb_custom.is_divi_theme_used ? $( 'ul.nav' ) : $( '.et_pb_fullwidth_menu ul.nav' ),
974			et_pb_ab_bounce_rate = et_pb_custom.ab_bounce_rate * 1000,
975			et_pb_ab_logged_status = {
976				read_page: false,
977				read_goal: false,
978				view_goal: false,
979				click_goal: false,
980				con_goal: false,
981				con_short: false,
982			};
983
984		$(document).ready( function(){
985			var $et_top_menu = $et_menu_selector,
986				et_parent_menu_longpress_limit = 300,
987				et_parent_menu_longpress_start,
988				et_parent_menu_click = true;
989
990			// log the conversion if visitor is on Thank You page and comes from the Shop module which is the Goal
991			if ( $( '.et_pb_ab_shop_conversion' ).length && typeof et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) !== 'undefined' && '' !== et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) ) {
992				var shop_log_data = et_pb_get_cookie_value( 'et_pb_ab_shop_log' ).split( '_' );
993					page_id = shop_log_data[0],
994					subject_id = shop_log_data[1],
995					test_id = shop_log_data[2];
996
997				et_pb_ab_update_stats( 'con_goal', page_id, subject_id, test_id );
998
999				// remove the cookie after conversion is logged
1000				et_pb_set_cookie( 0, 'et_pb_ab_shop_log=true' );
1001			}
1002
1003			// log the conversion if visitor is on page with tracking shortcode
1004			if ( $( '.et_pb_ab_split_track' ).length ) {
1005				$( '.et_pb_ab_split_track' ).each( function() {
1006					var tracking_test = $( this ).data( 'test_id' ),
1007						cookies_name = 'et_pb_ab_shortcode_track_' + tracking_test;
1008
1009					if ( typeof et_pb_get_cookie_value( cookies_name ) !== 'undefined' && '' !== et_pb_get_cookie_value( cookies_name ) ) {
1010						var track_data = et_pb_get_cookie_value( cookies_name ).split( '_' );
1011							page_id = track_data[0],
1012							subject_id = track_data[1],
1013							test_id = track_data[2];
1014
1015						et_pb_ab_update_stats( 'con_short', page_id, subject_id, test_id );
1016
1017						// remove the cookie after conversion is logged
1018						et_pb_set_cookie( 0, cookies_name + '=true' );
1019					}
1020				});
1021			}
1022
1023			// init split testing if enabled
1024			if ( et_pb_custom.is_ab_testing_active ) {
1025				et_pb_init_ab_test();
1026			}
1027
1028			if ( $( '.et_pb_row' ).length ) {
1029				$( '.et_pb_row' ).each( function() {
1030					var $this_row = $( this ),
1031						row_class = '';
1032
1033					row_class = et_get_column_types( $this_row.find( '>.et_pb_column' ) );
1034
1035					if ( '' !== row_class && ( -1 !== row_class.indexOf( '1-4' ) || '_4col' === row_class ) ) {
1036						$this_row.addClass( 'et_pb_row' + row_class );
1037					}
1038
1039					if ( $this_row.find( '.et_pb_row_inner' ).length ) {
1040						$this_row.find( '.et_pb_row_inner' ).each( function() {
1041							var $this_row_inner = $( this );
1042							row_class = et_get_column_types( $this_row_inner.find( '.et_pb_column' ) );
1043
1044							if ( '' !== row_class && -1 !== row_class.indexOf( '1-4' ) ) {
1045								$this_row_inner.addClass( 'et_pb_row' + row_class );
1046							}
1047						});
1048					}
1049				});
1050			}
1051
1052			function et_get_column_types( $columns ) {
1053				var row_class = '';
1054
1055				if ( $columns.length ) {
1056					$columns.each( function() {
1057						var $this_column = $( this ),
1058							column_type = $this_column.attr( 'class' ).split( 'et_pb_column_' )[1],
1059							column_type_clean = column_type.split( ' ', 1 )[0],
1060							column_type_updated = column_type_clean.replace( '_', '-' ).trim();
1061
1062						row_class += '_' + column_type_updated;
1063					});
1064
1065					row_class = '_1-4_1-4_1-4_1-4' === row_class ? '_4col' : row_class;
1066				}
1067
1068				return row_class;
1069			}
1070
1071			$et_top_menu.find( 'li' ).hover( function() {
1072				if ( ! $(this).closest( 'li.mega-menu' ).length || $(this).hasClass( 'mega-menu' ) ) {
1073					$(this).addClass( 'et-show-dropdown' );
1074					$(this).removeClass( 'et-hover' ).addClass( 'et-hover' );
1075				}
1076			}, function() {
1077				var $this_el = $(this);
1078
1079				$this_el.removeClass( 'et-show-dropdown' ).addClass( 'et-dropdown-removing' );
1080
1081				setTimeout( function() {
1082					if ( ! $this_el.hasClass( 'et-show-dropdown' ) ) {
1083						$this_el.removeClass( 'et-hover' ).removeClass( 'et-dropdown-removing' );
1084					}
1085				}, 200 );
1086			} );
1087
1088			// Dropdown menu adjustment for touch screen
1089			$et_top_menu.find('.menu-item-has-children > a').on( 'touchstart', function(){
1090				et_parent_menu_longpress_start = new Date().getTime();
1091			} ).on( 'touchend', function(){
1092				var et_parent_menu_longpress_end = new Date().getTime()
1093				if ( et_parent_menu_longpress_end  >= et_parent_menu_longpress_start + et_parent_menu_longpress_limit ) {
1094					et_parent_menu_click = true;
1095				} else {
1096					et_parent_menu_click = false;
1097
1098					// Close sub-menu if toggled
1099					var $et_parent_menu = $(this).parent('li');
1100					if ( $et_parent_menu.hasClass( 'et-hover') ) {
1101						$et_parent_menu.trigger( 'mouseleave' );
1102					} else {
1103						$et_parent_menu.trigger( 'mouseenter' );
1104					}
1105				}
1106				et_parent_menu_longpress_start = 0;
1107			} ).click(function() {
1108				if ( et_parent_menu_click ) {
1109					return true;
1110				}
1111
1112				return false;
1113			} );
1114
1115			$et_top_menu.find( 'li.mega-menu' ).each(function(){
1116				var $li_mega_menu           = $(this),
1117					$li_mega_menu_item      = $li_mega_menu.children( 'ul' ).children( 'li' ),
1118					li_mega_menu_item_count = $li_mega_menu_item.length;
1119
1120				if ( li_mega_menu_item_count < 4 ) {
1121					$li_mega_menu.addClass( 'mega-menu-parent mega-menu-parent-' + li_mega_menu_item_count );
1122				}
1123			});
1124
1125			$et_sticky_image.each( function() {
1126				var $this_el            = $(this),
1127					$row                = $this_el.closest('.et_pb_row'),
1128					$section            = $row.closest('.et_pb_section'),
1129					$column             = $this_el.closest( '.et_pb_column' ),
1130					sticky_class        = 'et_pb_section_sticky',
1131					sticky_mobile_class = 'et_pb_section_sticky_mobile';
1132
1133				// If it is not in the last row, continue
1134				if ( ! $row.is( ':last-child' ) ) {
1135					return true;
1136				}
1137
1138				// Make sure sticky image is the last element in the column
1139				if ( ! $this_el.is( ':last-child' ) ) {
1140					return true;
1141				}
1142
1143				// If it is in the last row, find the parent section and attach new class to it
1144				if ( ! $section.hasClass( sticky_class ) ) {
1145					$section.addClass( sticky_class );
1146				}
1147
1148				$column.addClass( 'et_pb_row_sticky' );
1149
1150				if ( ! $section.hasClass( sticky_mobile_class ) && $column.is( ':last-child' ) ) {
1151					$section.addClass( sticky_mobile_class );
1152				}
1153			} );
1154
1155			if ( et_is_mobile_device ) {
1156				$( '.et_pb_section_video_bg' ).each( function() {
1157					var $this_el = $(this);
1158
1159					$this_el.css( 'visibility', 'hidden' ).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' )
1160				} );
1161
1162				$( 'body' ).addClass( 'et_mobile_device' );
1163
1164				if ( ! et_is_ipad ) {
1165					$( 'body' ).addClass( 'et_mobile_device_not_ipad' );
1166				}
1167			}
1168
1169			if ( $et_pb_video_section.length ) {
1170				$et_pb_video_section.find( 'video' ).mediaelementplayer( {
1171					pauseOtherPlayers: false,
1172					success : function( mediaElement, domObject ) {
1173						mediaElement.addEventListener( 'loadeddata', function() {
1174							et_pb_resize_section_video_bg( $(domObject) );
1175							et_pb_center_video( $(domObject) );
1176						}, false );
1177
1178						mediaElement.addEventListener( 'canplay', function() {
1179							$(domObject).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
1180						}, false );
1181					}
1182				} );
1183			}
1184
1185			if ( $et_post_gallery.length ) {
1186				// swipe support in magnific popup only if gallery exists
1187				var magnificPopup = $.magnificPopup.instance;
1188
1189				$( 'body' ).on( 'swiperight', '.mfp-container', function() {
1190					magnificPopup.prev();
1191				} );
1192				$( 'body' ).on( 'swipeleft', '.mfp-container', function() {
1193					magnificPopup.next();
1194				} );
1195
1196				$et_post_gallery.each(function() {
1197					$(this).magnificPopup( {
1198						delegate: 'a',
1199						type: 'image',
1200						removalDelay: 500,
1201						gallery: {
1202							enabled: true,
1203							navigateByImgClick: true
1204						},
1205						mainClass: 'mfp-fade',
1206						zoom: {
1207							enabled: true,
1208							duration: 500,
1209							opener: function(element) {
1210								return element.find('img');
1211							}
1212						}
1213					} );
1214				} );
1215				// prevent attaching of any further actions on click
1216				$et_post_gallery.find( 'a' ).unbind( 'click' );
1217			}
1218
1219			if ( $et_lightbox_image.length ) {
1220				// prevent attaching of any further actions on click
1221				$et_lightbox_image.unbind( 'click' );
1222				$et_lightbox_image.bind( 'click' );
1223
1224				$et_lightbox_image.magnificPopup( {
1225					type: 'image',
1226					removalDelay: 500,
1227					mainClass: 'mfp-fade',
1228					zoom: {
1229						enabled: true,
1230						duration: 500,
1231						opener: function(element) {
1232							return element.find('img');
1233						}
1234					}
1235				} );
1236			}
1237
1238			if ( $et_pb_slider.length ) {
1239				$et_pb_slider.each( function() {
1240					var $this_slider = $(this),
1241						et_slider_settings = {
1242							fade_speed 		: 700,
1243							slide			: ! $this_slider.hasClass( 'et_pb_gallery' ) ? '.et_pb_slide' : '.et_pb_gallery_item'
1244						}
1245
1246					if ( $this_slider.hasClass('et_pb_slider_no_arrows') )
1247						et_slider_settings.use_arrows = false;
1248
1249					if ( $this_slider.hasClass('et_pb_slider_no_pagination') )
1250						et_slider_settings.use_controls = false;
1251
1252					if ( $this_slider.hasClass('et_slider_auto') ) {
1253						var et_slider_autospeed_class_value = /et_slider_speed_(\d+)/g;
1254
1255						et_slider_settings.slideshow = true;
1256
1257						et_slider_autospeed = et_slider_autospeed_class_value.exec( $this_slider.attr('class') );
1258
1259						et_slider_settings.slideshow_speed = et_slider_autospeed[1];
1260					}
1261
1262					if ( $this_slider.parent().hasClass('et_pb_video_slider') ) {
1263						et_slider_settings.controls_below = true;
1264						et_slider_settings.append_controls_to = $this_slider.parent();
1265
1266						setTimeout( function() {
1267							$( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
1268						}, 500 );
1269					}
1270
1271					if ( $this_slider.hasClass('et_pb_slider_carousel') )
1272						et_slider_settings.use_carousel = true;
1273
1274					$this_slider.et_pb_simple_slider( et_slider_settings );
1275
1276				} );
1277			}
1278
1279			$et_pb_carousel  = $( '.et_pb_carousel' );
1280			if ( $et_pb_carousel.length ) {
1281				$et_pb_carousel.each( function() {
1282					var $this_carousel = $(this),
1283						et_carousel_settings = {
1284							fade_speed 		: 1000
1285						};
1286
1287					$this_carousel.et_pb_simple_carousel( et_carousel_settings );
1288				} );
1289			}
1290
1291			if ( $et_pb_fullwidth_portfolio.length ) {
1292
1293				function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) {
1294					var columns,
1295						$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1296						portfolio_items_width = $portfolio_items.width(),
1297						$the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'),
1298						portfolio_item_count = $the_portfolio_items.length;
1299
1300					// calculate column breakpoints
1301					if ( portfolio_items_width >= 1600 ) {
1302						columns = 5;
1303					} else if ( portfolio_items_width >= 1024 ) {
1304						columns = 4;
1305					} else if ( portfolio_items_width >= 768 ) {
1306						columns = 3;
1307					} else if ( portfolio_items_width >= 480 ) {
1308						columns = 2;
1309					} else {
1310						columns = 1;
1311					}
1312
1313					// set height of items
1314					portfolio_item_width = portfolio_items_width / columns;
1315					portfolio_item_height = portfolio_item_width * .75;
1316
1317					if ( carousel_mode ) {
1318						$portfolio_items.css({ 'height' : portfolio_item_height });
1319					}
1320
1321					$the_portfolio_items.css({ 'height' : portfolio_item_height });
1322
1323					if ( columns === $portfolio_items.data('portfolio-columns') ) {
1324						return;
1325					}
1326
1327					if ( $the_portfolio.data('columns_setting_up') ) {
1328						return;
1329					}
1330
1331					$the_portfolio.data('columns_setting_up', true );
1332
1333					var portfolio_item_width_percentage = ( 100 / columns ) + '%';
1334					$the_portfolio_items.css({ 'width' : portfolio_item_width_percentage });
1335
1336					// store last setup column
1337					$portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') );
1338					$portfolio_items.addClass('columns-' + columns );
1339					$portfolio_items.data('portfolio-columns', columns );
1340
1341					if ( !carousel_mode ) {
1342						return $the_portfolio.data('columns_setting_up', false );
1343					}
1344
1345					// kill all previous groups to get ready to re-group
1346					if ( $portfolio_items.find('.et_pb_carousel_group').length ) {
1347						$the_portfolio_items.appendTo( $portfolio_items );
1348						$portfolio_items.find('.et_pb_carousel_group').remove();
1349					}
1350
1351					// setup the grouping
1352					var the_portfolio_items = $portfolio_items.data('items' ),
1353						$carousel_group = $('<div class="et_pb_carousel_group active">').appendTo( $portfolio_items );
1354
1355					$the_portfolio_items.data('position', '');
1356					if ( the_portfolio_items.length <= columns ) {
1357						$portfolio_items.find('.et-pb-slider-arrows').hide();
1358					} else {
1359						$portfolio_items.find('.et-pb-slider-arrows').show();
1360					}
1361
1362					for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) {
1363						if ( x < columns ) {
1364							$( the_portfolio_items[x] ).show();
1365							$( the_portfolio_items[x] ).appendTo( $carousel_group );
1366							$( the_portfolio_items[x] ).data('position', position );
1367							$( the_portfolio_items[x] ).addClass('position_' + position );
1368						} else {
1369							position = $( the_portfolio_items[x] ).data('position');
1370							$( the_portfolio_items[x] ).removeClass('position_' + position );
1371							$( the_portfolio_items[x] ).data('position', '' );
1372							$( the_portfolio_items[x] ).hide();
1373						}
1374					}
1375
1376					$the_portfolio.data('columns_setting_up', false );
1377
1378				}
1379
1380				function et_carousel_auto_rotate( $carousel ) {
1381					if ( 'on' === $carousel.data('auto-rotate') && $carousel.find('.et_pb_portfolio_item').length > $carousel.find('.et_pb_carousel_group .et_pb_portfolio_item').length && ! $carousel.hasClass( 'et_carousel_hovered' ) ) {
1382
1383						et_carousel_timer = setTimeout( function() {
1384							$carousel.find('.et-pb-arrow-next').click();
1385						}, $carousel.data('auto-rotate-speed') );
1386
1387						$carousel.data('et_carousel_timer', et_carousel_timer);
1388					}
1389				}
1390
1391				$et_pb_fullwidth_portfolio.each(function(){
1392					var $the_portfolio = $(this),
1393						$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items');
1394
1395						$portfolio_items.data('items', $portfolio_items.find('.et_pb_portfolio_item').toArray() );
1396						$the_portfolio.data('columns_setting_up', false );
1397
1398					if ( $the_portfolio.hasClass('et_pb_fullwidth_portfolio_carousel') ) {
1399						// add left and right arrows
1400						$portfolio_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>');
1401
1402						set_fullwidth_portfolio_columns( $the_portfolio, true );
1403
1404						et_carousel_auto_rotate( $the_portfolio );
1405
1406						// swipe support
1407						$the_portfolio.on( 'swiperight', function() {
1408							$( this ).find( '.et-pb-arrow-prev' ).click();
1409						});
1410						$the_portfolio.on( 'swipeleft', function() {
1411							$( this ).find( '.et-pb-arrow-next' ).click();
1412						});
1413
1414						$the_portfolio.hover(
1415							function(){
1416								$(this).addClass('et_carousel_hovered');
1417								if ( typeof $(this).data('et_carousel_timer') != 'undefined' ) {
1418									clearInterval( $(this).data('et_carousel_timer') );
1419								}
1420							},
1421							function(){
1422								$(this).removeClass('et_carousel_hovered');
1423								et_carousel_auto_rotate( $(this) );
1424							}
1425						);
1426
1427						$the_portfolio.data('carouseling', false );
1428
1429						$the_portfolio.on('click', '.et-pb-slider-arrows a', function(e){
1430							var $the_portfolio = $(this).parents('.et_pb_fullwidth_portfolio'),
1431								$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1432								$the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'),
1433								$active_carousel_group = $portfolio_items.find('.et_pb_carousel_group.active'),
1434								slide_duration = 700,
1435								items = $portfolio_items.data('items'),
1436								columns = $portfolio_items.data('portfolio-columns'),
1437								item_width = $active_carousel_group.innerWidth() / columns, //$active_carousel_group.children().first().innerWidth(),
1438								original_item_width = ( 100 / columns ) + '%';
1439
1440							e.preventDefault();
1441
1442							if ( $the_portfolio.data('carouseling') ) {
1443								return;
1444							}
1445
1446							$the_portfolio.data('carouseling', true);
1447
1448							$active_carousel_group.children().each(function(){
1449								$(this).css({'width': $(this).innerWidth() + 1, 'position':'absolute', 'left': ( $(this).innerWidth() * ( $(this).data('position') - 1 ) ) });
1450							});
1451
1452							if ( $(this).hasClass('et-pb-arrow-next') ) {
1453								var $next_carousel_group,
1454									current_position = 1,
1455									next_position = 1,
1456									active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ),
1457									active_items_end = active_items_start + columns,
1458									next_items_start = active_items_end,
1459									next_items_end = next_items_start + columns;
1460
1461								$next_carousel_group = $('<div class="et_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group );
1462								$next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show();
1463
1464								// this is an endless loop, so it can decide internally when to break out, so that next_position
1465								// can get filled up, even to the extent of an element having both and current_ and next_ position
1466								for( x = 0, total = 0 ; ; x++, total++ ) {
1467									if ( total >= active_items_start && total < active_items_end ) {
1468										$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
1469										$( items[x] ).data('current_position', current_position );
1470										current_position++;
1471									}
1472
1473									if ( total >= next_items_start && total < next_items_end ) {
1474										$( items[x] ).data('next_position', next_position );
1475										$( items[x] ).addClass('changing_position next_position next_position_' + next_position );
1476
1477										if ( !$( items[x] ).hasClass( 'current_position' ) ) {
1478											$( items[x] ).addClass('container_append');
1479										} else {
1480											$( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
1481											$( items[x] ).addClass('delayed_container_append');
1482										}
1483
1484										next_position++;
1485									}
1486
1487									if ( next_position > columns ) {
1488										break;
1489									}
1490
1491									if ( x >= ( items.length -1 )) {
1492										x = -1;
1493									}
1494								}
1495
1496								sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
1497									var el_a_position = parseInt( $(a).data('next_position') );
1498									var el_b_position = parseInt( $(b).data('next_position') );
1499									return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
1500								});
1501
1502								$( sorted ).show().appendTo( $next_carousel_group );
1503
1504								$next_carousel_group.children().each(function(){
1505									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
1506								});
1507
1508								$active_carousel_group.animate({
1509									left: '-100%'
1510								}, {
1511									duration: slide_duration,
1512									complete: function() {
1513										$portfolio_items.find('.delayed_container_append').each(function(){
1514											$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
1515											$(this).appendTo( $next_carousel_group );
1516										});
1517
1518										$active_carousel_group.removeClass('active');
1519										$active_carousel_group.children().each(function(){
1520											position = $(this).data('position');
1521											current_position = $(this).data('current_position');
1522											$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
1523											$(this).data('position', '');
1524											$(this).data('current_position', '');
1525											$(this).hide();
1526											$(this).css({'position': '', 'width': '', 'left': ''});
1527											$(this).appendTo( $portfolio_items );
1528										});
1529
1530										$active_carousel_group.remove();
1531
1532										et_carousel_auto_rotate( $the_portfolio );
1533
1534									}
1535								} );
1536
1537								$next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'});
1538								$next_carousel_group.animate({
1539									left: '0%'
1540								}, {
1541									duration: slide_duration,
1542									complete: function(){
1543										setTimeout(function(){
1544											$next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
1545
1546											$next_carousel_group.find('.delayed_container_append_dup').remove();
1547
1548											$next_carousel_group.find('.changing_position').each(function( index ){
1549												position = $(this).data('position');
1550												current_position = $(this).data('current_position');
1551												next_position = $(this).data('next_position');
1552												$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position );
1553												$(this).data('current_position', '');
1554												$(this).data('next_position', '');
1555												$(this).data('position', ( index + 1 ) );
1556											});
1557
1558											$next_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
1559
1560											$the_portfolio.data('carouseling', false);
1561										}, 100 );
1562									}
1563								} );
1564
1565							} else {
1566								var $prev_carousel_group,
1567									current_position = columns,
1568									prev_position = columns,
1569									columns_span = columns - 1,
1570									active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ),
1571									active_items_end = active_items_start - columns_span,
1572									prev_items_start = active_items_end - 1,
1573									prev_items_end = prev_items_start - columns_span;
1574
1575								$prev_carousel_group = $('<div class="et_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group );
1576								$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
1577
1578								// this is an endless loop, so it can decide internally when to break out, so that next_position
1579								// can get filled up, even to the extent of an element having both and current_ and next_ position
1580								for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
1581
1582									if ( total <= active_items_start && total >= active_items_end ) {
1583										$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
1584										$( items[x] ).data('current_position', current_position );
1585										current_position--;
1586									}
1587
1588									if ( total <= prev_items_start && total >= prev_items_end ) {
1589										$( items[x] ).data('prev_position', prev_position );
1590										$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
1591
1592										if ( !$( items[x] ).hasClass( 'current_position' ) ) {
1593											$( items[x] ).addClass('container_append');
1594										} else {
1595											$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
1596											$( items[x] ).addClass('delayed_container_append');
1597										}
1598
1599										prev_position--;
1600									}
1601
1602									if ( prev_position <= 0 ) {
1603										break;
1604									}
1605
1606									if ( x == 0 ) {
1607										x = items.length;
1608									}
1609								}
1610
1611								sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
1612									var el_a_position = parseInt( $(a).data('prev_position') );
1613									var el_b_position = parseInt( $(b).data('prev_position') );
1614									return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
1615								});
1616
1617								$( sorted ).show().appendTo( $prev_carousel_group );
1618
1619								$prev_carousel_group.children().each(function(){
1620									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
1621								});
1622
1623								$active_carousel_group.animate({
1624									left: '100%'
1625								}, {
1626									duration: slide_duration,
1627									complete: function() {
1628										$portfolio_items.find('.delayed_container_append').reverse().each(function(){
1629											$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
1630											$(this).prependTo( $prev_carousel_group );
1631										});
1632
1633										$active_carousel_group.removeClass('active');
1634										$active_carousel_group.children().each(function(){
1635											position = $(this).data('position');
1636											current_position = $(this).data('current_position');
1637											$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
1638											$(this).data('position', '');
1639											$(this).data('current_position', '');
1640											$(this).hide();
1641											$(this).css({'position': '', 'width': '', 'left': ''});
1642											$(this).appendTo( $portfolio_items );
1643										});
1644
1645										$active_carousel_group.remove();
1646									}
1647								} );
1648
1649								$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'});
1650								$prev_carousel_group.animate({
1651									left: '0%'
1652								}, {
1653									duration: slide_duration,
1654									complete: function(){
1655										setTimeout(function(){
1656											$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
1657
1658											$prev_carousel_group.find('.delayed_container_append_dup').remove();
1659
1660											$prev_carousel_group.find('.changing_position').each(function( index ){
1661												position = $(this).data('position');
1662												current_position = $(this).data('current_position');
1663												prev_position = $(this).data('prev_position');
1664												$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
1665												$(this).data('current_position', '');
1666												$(this).data('prev_position', '');
1667												position = index + 1;
1668												$(this).data('position', position );
1669												$(this).addClass('position_' + position );
1670											});
1671
1672											$prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
1673											$the_portfolio.data('carouseling', false);
1674										}, 100 );
1675									}
1676								} );
1677							}
1678
1679							return false;
1680						});
1681
1682					} else {
1683						// setup fullwidth portfolio grid
1684						set_fullwidth_portfolio_columns( $the_portfolio, false );
1685					}
1686
1687				});
1688			}
1689
1690			function et_audio_module_set() {
1691				if ( $( '.et_pb_audio_module .mejs-audio' ).length || $( '.et_audio_content .mejs-audio' ).length ) {
1692					$( '.et_audio_container' ).each( function(){
1693						var $this_player = $( this ),
1694							$time_rail = $this_player.find( '.mejs-time-rail' ),
1695							$time_slider = $this_player.find( '.mejs-time-slider' );
1696						// remove previously added width and min-width attributes to calculate the new sizes accurately
1697						$time_rail.removeAttr( 'style' );
1698						$time_slider.removeAttr( 'style' );
1699
1700						var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ),
1701							player_width = $this_player.width(),
1702							controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(),
1703							time_width = $this_player.find( '.mejs-currenttime-container' ).outerWidth(),
1704							volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(),
1705							volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(),
1706							new_time_rail_width;
1707
1708						$count_timer.addClass( 'custom' );
1709						$this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer );
1710						new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 65 );
1711
1712						if ( 0 < new_time_rail_width ) {
1713							$time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
1714							$time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
1715						}
1716					});
1717				}
1718			}
1719
1720			if ( $('.et_pb_section_video').length ) {
1721				window._wpmejsSettings.pauseOtherPlayers = false;
1722			}
1723
1724			if ( $et_pb_filterable_portfolio.length ) {
1725
1726				function et_pb_filterable_portfolio_init() {
1727					$et_pb_filterable_portfolio.each(function(){
1728						var $the_portfolio = $(this),
1729							$the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1730							$left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true;
1731
1732						$the_portfolio.show();
1733
1734						set_filterable_grid_items( $the_portfolio );
1735
1736						$the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){
1737							e.preventDefault();
1738							var category_slug = $(this).data('category-slug');
1739							$the_portfolio_items = $(this).parents('.et_pb_filterable_portfolio').find('.et_pb_portfolio_items');
1740
1741							if ( 'all' == category_slug ) {
1742								$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
1743								$the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active');
1744								$the_portfolio.find('.et_pb_portfolio_item').removeClass('active inactive');
1745								$the_portfolio.find('.et_pb_portfolio_item').show();
1746								$the_portfolio.find('.et_pb_portfolio_item').addClass('active');
1747							} else {
1748								$the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active');
1749								$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
1750								$the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active');
1751								$(this).addClass('active');
1752
1753								$the_portfolio_items.find('.et_pb_portfolio_item').hide();
1754								$the_portfolio_items.find('.et_pb_portfolio_item').addClass( 'inactive' );
1755								$the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active');
1756								$the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).show();
1757								$the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' );
1758							}
1759
1760							set_filterable_grid_items( $the_portfolio );
1761							setTimeout(function(){
1762								set_filterable_portfolio_hash( $the_portfolio );
1763							}, 500 );
1764						});
1765
1766						$(this).on('et_hashchange', function( event ){
1767							var params = event.params;
1768							$the_portfolio = $( '#' + event.target.id );
1769
1770							if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) {
1771								$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click();
1772							}
1773
1774							if ( params[1] ) {
1775								setTimeout(function(){
1776									if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) {
1777										$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click();
1778									}
1779								}, 300 );
1780							}
1781						});
1782					});
1783				}
1784
1785				// init portfolio if .load event was fired already, wait for the window load otherwise.
1786				if ( window.et_load_event_fired ) {
1787					et_pb_filterable_portfolio_init();
1788				} else {
1789					$(window).load(function(){
1790						et_pb_filterable_portfolio_init();
1791					}); // End $(window).load()
1792				}
1793
1794				function set_filterable_grid_items( $the_portfolio ) {
1795					var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug'),
1796						container_width = $the_portfolio.find( '.et_pb_portfolio_items' ).innerWidth(),
1797						item_width = $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth( true ),
1798						last_item_margin = item_width - $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth(),
1799						columns_count = Math.round( ( container_width + last_item_margin ) / item_width ),
1800						counter = 1,
1801						first_in_row = 1;
1802
1803						$the_portfolio.find( '.et_pb_portfolio_item' ).removeClass( 'last_in_row first_in_row' );
1804						$the_portfolio.find( '.et_pb_portfolio_item' ).each( function() {
1805							var $this_el = $( this );
1806
1807							if ( ! $this_el.hasClass( 'inactive' ) ) {
1808								if ( first_in_row === counter ) {
1809									$this_el.addClass( 'first_in_row' );
1810								}
1811
1812								if ( 0 === counter % columns_count ) {
1813									$this_el.addClass( 'last_in_row' );
1814									first_in_row = counter + 1;
1815								}
1816								counter++;
1817							}
1818						});
1819
1820					if ( 'all' === active_category ) {
1821						$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item');
1822					} else {
1823						$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category);
1824					}
1825
1826					var visible_grid_items = $the_portfolio_visible_items.length,
1827						posts_number = $the_portfolio.data('posts-number'),
1828						pages = Math.ceil( visible_grid_items / posts_number );
1829
1830					set_filterable_grid_pages( $the_portfolio, pages );
1831
1832					var visible_grid_items = 0;
1833					var _page = 1;
1834					$the_portfolio.find('.et_pb_portfolio_item').data('page', '');
1835					$the_portfolio_visible_items.each(function(i){
1836						visible_grid_items++;
1837						if ( 0 === parseInt( visible_grid_items % posts_number ) ) {
1838							$(this).data('page', _page);
1839							_page++;
1840						} else {
1841							$(this).data('page', _page);
1842						}
1843					});
1844
1845					$the_portfolio_visible_items.filter(function() {
1846						return $(this).data('page') == 1;
1847					}).show();
1848
1849					$the_portfolio_visible_items.filter(function() {
1850						return $(this).data('page') != 1;
1851					}).hide();
1852				}
1853
1854				function set_filterable_grid_pages( $the_portfolio, pages ) {
1855					$pagination = $the_portfolio.find('.et_pb_portofolio_pagination');
1856
1857					if ( !$pagination.length ) {
1858						return;
1859					}
1860
1861					$pagination.html('<ul></ul>');
1862					if ( pages <= 1 ) {
1863						return;
1864					}
1865
1866					$pagination_list = $pagination.children('ul');
1867					$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>');
1868					for( var page = 1; page <= pages; page++ ) {
1869						var first_page_class = page === 1 ? ' active' : '',
1870							last_page_class = page === pages ? ' last-page' : '',
1871							hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
1872						$pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>');
1873					}
1874					$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>');
1875				}
1876
1877				$et_pb_filterable_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){
1878					e.preventDefault();
1879
1880					var to_page = $(this).data('page'),
1881						$the_portfolio = $(this).parents('.et_pb_filterable_portfolio'),
1882						$the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items');
1883
1884					et_pb_smooth_scroll( $the_portfolio, false, 800 );
1885
1886					if ( $(this).hasClass('page-prev') ) {
1887						to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
1888					} else if ( $(this).hasClass('page-next') ) {
1889						to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
1890					}
1891
1892					$(this).parents('ul').find('a').removeClass('active');
1893					$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
1894
1895					var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
1896						total_pages = $(this).parents('ul').find('li.page').length;
1897
1898					$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
1899					$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
1900
1901					$(this).parents('ul').find('li.page').each(function(i){
1902						if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
1903							if ( i < ( current_index - 3 ) ) {
1904								$(this).hide();
1905							} else if ( i > ( current_index + 1 ) ) {
1906								$(this).hide();
1907							} else {
1908								$(this).show();
1909							}
1910
1911							if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
1912								$(this).show();
1913							} else if ( current_index <= 3 && i <= 4 ) {
1914								$(this).show();
1915							}
1916
1917						}
1918					});
1919
1920					if ( to_page > 1 ) {
1921						$(this).parents('ul').find('li.prev').show();
1922					} else {
1923						$(this).parents('ul').find('li.prev').hide();
1924					}
1925
1926					if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
1927						$(this).parents('ul').find('li.next').hide();
1928					} else {
1929						$(this).parents('ul').find('li.next').show();
1930					}
1931
1932					$the_portfolio.find('.et_pb_portfolio_item').hide();
1933					$the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) {
1934						return $(this).data('page') === to_page;
1935					}).show();
1936
1937					setTimeout(function(){
1938						set_filterable_portfolio_hash( $the_portfolio );
1939					}, 500 );
1940				});
1941
1942				function set_filterable_portfolio_hash( $the_portfolio ) {
1943
1944					if ( !$the_portfolio.attr('id') ) {
1945						return;
1946					}
1947
1948					var this_portfolio_state = [];
1949					this_portfolio_state.push( $the_portfolio.attr('id') );
1950					this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') );
1951
1952					if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) {
1953						this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') );
1954					} else {
1955						this_portfolio_state.push( 1 );
1956					}
1957
1958					this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator );
1959
1960					et_set_hash( this_portfolio_state );
1961				}
1962			} /*  end if ( $et_pb_filterable_portfolio.length ) */
1963
1964			if ( $et_pb_gallery.length ) {
1965
1966				function set_gallery_grid_items( $the_gallery ) {
1967					var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
1968						$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
1969
1970					var total_grid_items = $the_gallery_items.length,
1971						posts_number = $the_gallery_items_container.data('per_page'),
1972						pages = Math.ceil( total_grid_items / posts_number );
1973
1974					set_gallery_grid_pages( $the_gallery, pages );
1975
1976					var total_grid_items = 0;
1977					var _page = 1;
1978					$the_gallery_items.data('page', '');
1979					$the_gallery_items.each(function(i){
1980						total_grid_items++;
1981						if ( 0 === parseInt( total_grid_items % posts_number ) ) {
1982							$(this).data('page', _page);
1983							_page++;
1984						} else {
1985							$(this).data('page', _page);
1986						}
1987
1988					});
1989
1990					var visible_items = $the_gallery_items.filter(function() {
1991						return $(this).data('page') == 1;
1992					}).show();
1993
1994					$the_gallery_items.filter(function() {
1995						return $(this).data('page') != 1;
1996					}).hide();
1997				}
1998
1999				function set_gallery_grid_pages( $the_gallery, pages ) {
2000					$pagination = $the_gallery.find('.et_pb_gallery_pagination');
2001
2002					if ( !$pagination.length ) {
2003						return;
2004					}
2005
2006					$pagination.html('<ul></ul>');
2007					if ( pages <= 1 ) {
2008						$pagination.hide();
2009						return;
2010					}
2011
2012					$pagination_list = $pagination.children('ul');
2013					$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>');
2014					for( var page = 1; page <= pages; page++ ) {
2015						var first_page_class = page === 1 ? ' active' : '',
2016							last_page_class = page === pages ? ' last-page' : '',
2017							hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
2018						$pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>');
2019					}
2020					$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>');
2021				}
2022
2023				function set_gallery_hash( $the_gallery ) {
2024
2025					if ( !$the_gallery.attr('id') ) {
2026						return;
2027					}
2028
2029					var this_gallery_state = [];
2030					this_gallery_state.push( $the_gallery.attr('id') );
2031
2032					if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) {
2033						this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') );
2034					} else {
2035						this_gallery_state.push( 1 );
2036					}
2037
2038					this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator );
2039
2040					et_set_hash( this_gallery_state );
2041				}
2042
2043				$et_pb_gallery.each(function(){
2044					var $the_gallery = $(this);
2045
2046					if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) {
2047
2048						$the_gallery.show();
2049						set_gallery_grid_items( $the_gallery );
2050
2051						$the_gallery.on('et_hashchange', function( event ){
2052							var params = event.params;
2053							$the_gallery = $( '#' + event.target.id );
2054
2055							if ( page_to = params[0] ) {
2056								if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) {
2057									$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click();
2058								}
2059							}
2060						});
2061					}
2062
2063				});
2064
2065				$et_pb_gallery.data('paginating', false );
2066				$et_pb_gallery.on('click', '.et_pb_gallery_pagination a', function(e){
2067					e.preventDefault();
2068
2069					var to_page = $(this).data('page'),
2070						$the_gallery = $(this).parents('.et_pb_gallery'),
2071						$the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
2072						$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
2073
2074					if ( $the_gallery.data('paginating') ) {
2075						return;
2076					}
2077
2078					$the_gallery.data('paginating', true );
2079
2080					if ( $(this).hasClass('page-prev') ) {
2081						to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
2082					} else if ( $(this).hasClass('page-next') ) {
2083						to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
2084					}
2085
2086					$(this).parents('ul').find('a').removeClass('active');
2087					$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
2088
2089					var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
2090						total_pages = $(this).parents('ul').find('li.page').length;
2091
2092					$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
2093					$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
2094
2095					$(this).parents('ul').find('li.page').each(function(i){
2096						if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
2097							if ( i < ( current_index - 3 ) ) {
2098								$(this).hide();
2099							} else if ( i > ( current_index + 1 ) ) {
2100								$(this).hide();
2101							} else {
2102								$(this).show();
2103							}
2104
2105							if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
2106								$(this).show();
2107							} else if ( current_index <= 3 && i <= 4 ) {
2108								$(this).show();
2109							}
2110
2111						}
2112					});
2113
2114					if ( to_page > 1 ) {
2115						$(this).parents('ul').find('li.prev').show();
2116					} else {
2117						$(this).parents('ul').find('li.prev').hide();
2118					}
2119
2120					if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
2121						$(this).parents('ul').find('li.next').hide();
2122					} else {
2123						$(this).parents('ul').find('li.next').show();
2124					}
2125
2126					$the_gallery_items.hide();
2127					var visible_items = $the_gallery_items.filter(function( index ) {
2128						return $(this).data('page') === to_page;
2129					}).show();
2130
2131					$the_gallery.data('paginating', false );
2132
2133					setTimeout(function(){
2134						set_gallery_hash( $the_gallery );
2135					}, 100 );
2136
2137					$( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 );
2138				});
2139
2140			} /*  end if ( $et_pb_gallery.length ) */
2141
2142			if ( $et_pb_counter_amount.length ) {
2143				$et_pb_counter_amount.each(function(){
2144					var $bar_item           = $(this),
2145						bar_item_width      = $bar_item.attr( 'data-width' ),
2146						bar_item_padding    = Math.ceil( parseFloat( $bar_item.css('paddingLeft') ) ) + Math.ceil( parseFloat( $bar_item.css('paddingRight') ) ),
2147						$bar_item_text      = $bar_item.children( '.et_pb_counter_amount_number' ),
2148						bar_item_text_width = $bar_item_text.width() + bar_item_padding;
2149
2150					$bar_item.css({
2151						'width' : bar_item_width,
2152						'min-width' : bar_item_text_width
2153					});
2154				});
2155			} /* $et_pb_counter_amount.length */
2156
2157			function et_countdown_timer( timer ) {
2158				var end_date = parseInt( timer.data( 'end-timestamp') ),
2159					current_date = new Date().getTime() / 1000,
2160					seconds_left = ( end_date - current_date );
2161
2162				days = parseInt(seconds_left / 86400);
2163				days = days > 0 ? days : 0;
2164				seconds_left = seconds_left % 86400;
2165
2166				hours = parseInt(seconds_left / 3600);
2167				hours = hours > 0 ? hours : 0;
2168
2169				seconds_left = seconds_left % 3600;
2170
2171				minutes = parseInt(seconds_left / 60);
2172				minutes = minutes > 0 ? minutes : 0;
2173
2174				seconds = parseInt(seconds_left % 60);
2175				seconds = seconds > 0 ? seconds : 0;
2176
2177				if ( days == 0 ) {
2178					if ( !timer.find('.days > .value').parent('.section').hasClass('zero') ) {
2179						timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero');
2180					}
2181				} else {
2182					days_slice = days.toString().length >= 3 ? days.toString().length : 3;
2183					timer.find('.days > .value').html( ('000' + days).slice(-days_slice) );
2184				}
2185
2186				if ( days == 0 && hours == 0 ) {
2187					if ( !timer.find('.hours > .value').parent('.section').hasClass('zero') ) {
2188						timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
2189					}
2190				} else {
2191					timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) );
2192				}
2193
2194				if ( days == 0 && hours == 0 && minutes == 0 ) {
2195					if ( !timer.find('.minutes > .value').parent('.section').hasClass('zero') ) {
2196						timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
2197					}
2198				} else {
2199					timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) );
2200				}
2201
2202				if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) {
2203					if ( !timer.find('.seconds > .value').parent('.section').hasClass('zero') ) {
2204						timer.find('.seconds > .value').html('00').parent('.section').addClass('zero');
2205					}
2206				} else {
2207					timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) );
2208				}
2209			}
2210
2211			function et_countdown_timer_labels( timer ) {
2212				if ( timer.closest( '.et_pb_column_3_8' ).length || timer.closest( '.et_pb_column_1_4' ).length || timer.children('.et_pb_countdown_timer_container').width() <= 400 ) {
2213					timer.find('.days .label').html( timer.find('.days').data('short') );
2214					timer.find('.hours .label').html( timer.find('.hours').data('short') );
2215					timer.find('.minutes .label').html( timer.find('.minutes').data('short') );
2216					timer.find('.seconds .label').html( timer.find('.seconds').data('short') );
2217				} else {
2218					timer.find('.days .label').html( timer.find('.days').data('full') );
2219					timer.find('.hours .label').html( timer.find('.hours').data('full') );
2220					timer.find('.minutes .label').html( timer.find('.minutes').data('full') );
2221					timer.find('.seconds .label').html( timer.find('.seconds').data('full') );
2222				}
2223			}
2224
2225			if ( $et_pb_countdown_timer.length ) {
2226				$et_pb_countdown_timer.each(function(){
2227					var timer = $(this);
2228					et_countdown_timer_labels( timer );
2229					et_countdown_timer( timer );
2230					setInterval(function(){
2231						et_countdown_timer( timer );
2232					}, 1000);
2233				});
2234			}
2235
2236			if ( $et_pb_tabs.length ) {
2237				$et_pb_tabs.et_pb_simple_slider( {
2238					use_controls   : false,
2239					use_arrows     : false,
2240					slide          : '.et_pb_all_tabs > div',
2241					tabs_animation : true
2242				} ).on('et_hashchange', function( event ){
2243					var params = event.params;
2244					var $the_tabs = $( '#' + event.target.id );
2245					var active_tab = params[0];
2246					if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) {
2247						$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click();
2248					}
2249				});
2250
2251				$et_pb_tabs_li.click( function() {
2252					var $this_el        = $(this),
2253						$tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider');
2254
2255					if ( $tabs_container.et_animation_running ) return false;
2256
2257					$this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' );
2258
2259					$tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() );
2260
2261					if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) {
2262						var tab_state = [];
2263						tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') );
2264						tab_state.push( $this_el.index() );
2265						tab_state = tab_state.join( et_hash_module_param_seperator );
2266						et_set_hash( tab_state );
2267					}
2268
2269					return false;
2270				} );
2271			}
2272
2273			if ( $et_pb_map.length ) {
2274				function et_pb_init_maps() {
2275					$et_pb_map.each(function(){
2276						var $this_map_container = $(this),
2277							$this_map = $this_map_container.children('.et_pb_map'),
2278							this_map_grayscale = $this_map_container.data( 'grayscale' ) || 0,
2279							infowindow_active;
2280
2281						if ( this_map_grayscale !== 0 ) {
2282							this_map_grayscale = '-' + this_map_grayscale.toString();
2283						}
2284
2285						$this_map_container.data('map', new google.maps.Map( $this_map[0], {
2286							zoom: parseInt( $this_map.data('zoom') ),
2287							center: new google.maps.LatLng( parseFloat( $this_map.data('center-lat') ) , parseFloat( $this_map.data('center-lng') )),
2288							mapTypeId: google.maps.MapTypeId.ROADMAP,
2289							scrollwheel: $this_map.data('mouse-wheel') == 'on' ? true : false,
2290							panControlOptions: {
2291								position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
2292							},
2293							zoomControlOptions: {
2294								position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
2295							},
2296							styles: [ {
2297								stylers: [
2298									{ saturation: parseInt( this_map_grayscale ) }
2299								]
2300							} ]
2301						}));
2302
2303						$this_map_container.find('.et_pb_map_pin').each(function(){
2304							var $this_marker = $(this);
2305
2306							var marker = new google.maps.Marker({
2307								position: new google.maps.LatLng( parseFloat( $this_marker.data('lat') ) , parseFloat( $this_marker.data('lng') ) ),
2308								map: $this_map_container.data('map'),
2309								title: $this_marker.data('title'),
2310								icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) },
2311								shape: { coord: [1, 1, 46, 43], type: 'rect' },
2312								anchorPoint: new google.maps.Point(0, -45)
2313							});
2314
2315							if ( $this_marker.find('.infowindow').length ) {
2316								var infowindow = new google.maps.InfoWindow({
2317									content: $this_marker.html()
2318								});
2319
2320								google.maps.event.addListener( $this_map_container.data('map'), 'click', function() {
2321									infowindow.close();
2322								});
2323
2324								google.maps.event.addListener(marker, 'click', function() {
2325									if( infowindow_active ) {
2326										infowindow_active.close();
2327									}
2328									infowindow_active = infowindow;
2329
2330									infowindow.open( $this_map_container.data('map'), marker );
2331								});
2332							}
2333						});
2334					});
2335				}
2336
2337				if ( window.et_load_event_fired ) {
2338					et_pb_init_maps();
2339				} else {
2340					google.maps.event.addDomListener(window, 'load', function() {
2341						et_pb_init_maps();
2342					} );
2343				}
2344			}
2345
2346			if ( $et_pb_shop.length ) {
2347				$et_pb_shop.each( function() {
2348					var $this_el = $(this),
2349						icon     = $this_el.data('icon') || '';
2350
2351					if ( icon === '' ) {
2352						return true;
2353					}
2354
2355					$this_el.find( '.et_overlay' )
2356						.attr( 'data-icon', icon )
2357						.addClass( 'et_pb_inline_icon' );
2358				} );
2359			}
2360
2361			if ( $et_pb_circle_counter.length ) {
2362
2363				window.et_pb_circle_counter_init = function($the_counter, animate) {
2364					if ( 0 === $the_counter.width() ) {
2365						return;
2366					}
2367
2368					$the_counter.easyPieChart({
2369						animate: {
2370							duration: 1800,
2371							enabled: true
2372						},
2373						size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors
2374						barColor: $the_counter.data( 'bar-bg-color' ),
2375						trackColor: $the_counter.data( 'color' ) || '#000000',
2376						trackAlpha: $the_counter.data( 'alpha' ) || '0.1',
2377						scaleColor: false,
2378						lineWidth: 5,
2379						onStart: function() {
2380							$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
2381						},
2382						onStep: function(from, to, percent) {
2383							$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
2384						},
2385						onStop: function(from, to) {
2386							$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
2387						}
2388					});
2389				}
2390
2391				window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) {
2392					$et_pb_circle_counter.each(function(){
2393						var $the_counter = $(this);
2394						window.et_pb_circle_counter_init($the_counter, false);
2395
2396						$the_counter.on('containerWidthChanged', function( event ){
2397							$the_counter = $( event.target );
2398							$the_counter.find('canvas').remove();
2399							$the_counter.removeData('easyPieChart' );
2400							window.et_pb_circle_counter_init($the_counter, true);
2401						});
2402
2403					});
2404				}
2405				window.et_pb_reinit_circle_counters( $et_pb_circle_counter );
2406			}
2407
2408			if ( $et_pb_number_counter.length ) {
2409				window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) {
2410					if ( $.fn.fitText ) {
2411						$et_pb_number_counter.find( '.percent p' ).fitText( 0.3 );
2412					}
2413
2414					$et_pb_number_counter.each(function(){
2415						var $this_counter = $(this);
2416						$this_counter.easyPieChart({
2417							animate: {
2418								duration: 1800,
2419								enabled: true
2420							},
2421							size: 0,
2422							trackColor: false,
2423							scaleColor: false,
2424							lineWidth: 0,
2425							onStart: function() {
2426								$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
2427							},
2428							onStep: function(from, to, percent) {
2429								if ( percent != to )
2430									$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
2431							},
2432							onStop: function(from, to) {
2433								$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
2434							}
2435						});
2436					});
2437				}
2438				window.et_pb_reinit_number_counters( $et_pb_number_counter );
2439			}
2440
2441			function et_apply_parallax() {
2442				var $this = $(this),
2443					element_top = $this.offset().top,
2444					window_top = $et_window.scrollTop(),
2445					y_pos = ( ( ( window_top + $et_window.height() ) - element_top ) * 0.3 ),
2446					main_position;
2447
2448				main_position = 'translate(0, ' + y_pos + 'px)';
2449
2450				$this.find('.et_parallax_bg').css( {
2451					'-webkit-transform' : main_position,
2452					'-moz-transform'    : main_position,
2453					'-ms-transform'     : main_position,
2454					'transform'         : main_position
2455				} );
2456			}
2457
2458			function et_parallax_set_height() {
2459				var $this = $(this),
2460					bg_height;
2461
2462				bg_height = ( $et_window.height() * 0.3 + $this.innerHeight() );
2463
2464				$this.find('.et_parallax_bg').css( { 'height' : bg_height } );
2465			}
2466
2467			$('.et_pb_toggle_title').click( function(){
2468				var $this_heading         = $(this),
2469					$module               = $this_heading.closest('.et_pb_toggle'),
2470					$section              = $module.parents( '.et_pb_section' ),
2471					$content              = $module.find('.et_pb_toggle_content'),
2472					$accordion            = $module.closest( '.et_pb_accordion' ),
2473					is_accordion          = $accordion.length,
2474					is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ),
2475					window_offset_top     = $(window).scrollTop(),
2476					fixed_header_height   = 0,
2477					$accordion_active_toggle,
2478					module_offset;
2479
2480				if ( is_accordion ) {
2481					if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) {
2482						return false;
2483					}
2484
2485					$accordion.addClass( 'et_pb_accordion_toggling' );
2486					$accordion_active_toggle = $module.siblings('.et_pb_toggle_open');
2487				}
2488
2489				if ( $content.is( ':animated' ) ) {
2490					return;
2491				}
2492
2493				$content.slideToggle( 700, function() {
2494					if ( $module.hasClass('et_pb_toggle_close') ) {
2495						$module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open');
2496					} else {
2497						$module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close');
2498					}
2499
2500					if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) {
2501						$.proxy( et_parallax_set_height, $section )();
2502					}
2503				} );
2504
2505				if ( is_accordion ) {
2506					$accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() {
2507						$accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close');
2508						$accordion.removeClass( 'et_pb_accordion_toggling' );
2509
2510						module_offset = $module.offset();
2511
2512						// Calculate height of fixed nav
2513						if ( $('#wpadminbar').length ) {
2514							fixed_header_height += $('#wpadminbar').height();
2515						}
2516
2517						if ( $('#top-header').length ) {
2518							fixed_header_height += $('#top-header').height();
2519						}
2520
2521						if ( $('#main-header').length ) {
2522							fixed_header_height += $('#main-header').height();
2523						}
2524
2525						// Compare accordion offset against window's offset and adjust accordingly
2526						if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) {
2527							$('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) });
2528						}
2529					} );
2530				}
2531			} );
2532
2533			var $et_contact_container = $( '.et_pb_contact_form_container' );
2534
2535			if ( $et_contact_container.length ) {
2536				$et_contact_container.each( function() {
2537					var $this_contact_container = $( this ),
2538						$et_contact_form = $this_contact_container.find( 'form' ),
2539						$et_contact_submit = $this_contact_container.find( 'input.et_pb_contact_submit' ),
2540						$et_inputs = $et_contact_form.find( 'input[type=text],textarea' ),
2541						et_email_reg = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/,
2542						redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : '';
2543
2544					$et_inputs.live( 'focus', function() {
2545						if ( $( this ).val() === $( this ).siblings('label').text() ) {
2546							$( this ).val('');
2547						}
2548					}).live( 'blur', function() {
2549						if ( '' === $( this ).val() ) {
2550							$( this ).val( $( this ).siblings( 'label' ).text() );
2551						}
2552					});
2553
2554					$et_contact_form.on( 'submit', function( event ) {
2555						var $this_contact_form = $( this ),
2556							$this_inputs = $this_contact_form.find( 'input[type=text],textarea' ),
2557							this_et_contact_error = false,
2558							$et_contact_message = $this_contact_form.closest( '.et_pb_contact_form_container' ).find( '.et-pb-contact-message' ),
2559							et_message = '',
2560							et_fields_message = '',
2561							$this_contact_container = $this_contact_form.closest( '.et_pb_contact_form_container' ),
2562							$captcha_field = $this_contact_form.find( '.et_pb_contact_captcha' ),
2563							form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0,
2564							inputs_list = [];
2565						et_message = '<ul>';
2566
2567						$this_inputs.removeClass( 'et_contact_error' );
2568
2569						$this_inputs.each( function(){
2570							var $this_el = $( this ),
2571								this_val = $this_el.val(),
2572								this_label = $this_el.siblings( 'label' ).text(),
2573								field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text',
2574								required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required',
2575								original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : '',
2576								default_value;
2577
2578							// add current field data into array of inputs
2579							if ( typeof $this_el.attr( 'id' ) !== 'undefined' ) {
2580								inputs_list.push( { 'field_id' : $this_el.attr( 'id' ), 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } );
2581							}
2582
2583							// add error message for the field if it is required and empty
2584							if ( 'required' === required_mark && ( '' === this_val || this_label === this_val ) ) {
2585								$this_el.addClass( 'et_contact_error' );
2586								this_et_contact_error = true;
2587
2588								default_value = this_label;
2589
2590								if ( '' === default_value ) {
2591									default_value = et_pb_custom.captcha;
2592								}
2593
2594								et_fields_message += '<li>' + default_value + '</li>';
2595							}
2596
2597							// add error message if email field is not empty and fails the email validation
2598							if ( 'email' === field_type && '' !== this_val && this_label !== this_val && ! et_email_reg.test( this_val ) ) {
2599								$this_el.addClass( 'et_contact_error' );
2600								this_et_contact_error = true;
2601
2602								if ( ! et_email_reg.test( this_val ) ) {
2603									et_message += '<li>' + et_pb_custom.invalid + '</li>';
2604								}
2605							}
2606						});
2607
2608						// check the captcha value if required for current form
2609						if ( $captcha_field.length && '' !== $captcha_field.val() ) {
2610							var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ),
2611								second_digit = parseInt( $captcha_field.data( 'second_digit' ) );
2612
2613							if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) {
2614
2615								et_message += '<li>' + et_pb_custom.wrong_captcha + '</li>';
2616								this_et_contact_error = true;
2617
2618								// generate new digits for captcha
2619								first_digit = Math.floor( ( Math.random() * 15 ) + 1 );
2620								second_digit = Math.floor( ( Math.random() * 15 ) + 1 );
2621
2622								// set new digits for captcha
2623								$captcha_field.data( 'first_digit', first_digit );
2624								$captcha_field.data( 'second_digit', second_digit );
2625
2626								// regenerate captcha on page
2627								$this_contact_form.find( '.et_pb_contact_captcha_question' ).empty().append( first_digit  + ' + ' + second_digit );
2628							}
2629
2630						}
2631
2632						if ( ! this_et_contact_error ) {
2633							var $href = $( this ).attr( 'action' ),
2634								form_data = $( this ).serializeArray();
2635
2636							form_data.push( { 'name': 'et_pb_contact_email_fields_' + form_unique_id, 'value' : JSON.stringify( inputs_list ) } );
2637
2638							$this_contact_container.fadeTo( 'fast', 0.2 ).load( $href + ' #' + $this_contact_form.closest( '.et_pb_contact_form_container' ).attr( 'id' ), form_data, function( responseText ) {
2639								if ( ! $( responseText ).find( '.et_pb_contact_error_text').length ) {
2640
2641									et_pb_maybe_log_event( $this_contact_container, 'con_goal' );
2642
2643									// redirect if redirect URL is not empty and no errors in contact form
2644									if ( '' !== redirect_url ) {
2645										window.location.href = redirect_url;
2646									}
2647								}
2648
2649								$this_contact_container.fadeTo( 'fast', 1 );
2650							} );
2651						}
2652
2653						et_message += '</ul>';
2654
2655						if ( '' !== et_fields_message ) {
2656							if ( et_message != '<ul></ul>' ) {
2657								et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message;
2658							}
2659
2660							et_fields_message = '<ul>' + et_fields_message + '</ul>';
2661
2662							et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message;
2663
2664							et_message = et_fields_message + et_message;
2665						}
2666
2667						if ( et_message != '<ul></ul>' ) {
2668							$et_contact_message.html( et_message );
2669
2670							// If parent of this contact form uses parallax
2671							if ( $this_contact_container.parents('.et_pb_section_parallax').length ) {
2672								$this_contact_container.parents('.et_pb_section_parallax').each(function() {
2673									var $parallax_element = $(this),
2674										$parallax         = $parallax_element.children('.et_parallax_bg'),
2675										is_true_parallax  = ( ! $parallax.hasClass( 'et_pb_parallax_css' ) );
2676
2677									if ( is_true_parallax ) {
2678										$et_window.trigger( 'resize' );
2679									}
2680								});
2681							}
2682						}
2683
2684						event.preventDefault();
2685					});
2686				});
2687			}
2688
2689			$( '.et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() {
2690				var $this        = $(this),
2691					$video_image = $this.closest( '.et_pb_video_overlay' );
2692
2693				$video_image.fadeTo( 500, 0, function() {
2694					var $image = $(this);
2695
2696					$image.css( 'display', 'none' );
2697				} );
2698
2699				return false;
2700			} );
2701
2702			function et_pb_resize_section_video_bg( $video ) {
2703				$element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' );
2704
2705				$element.each( function() {
2706					var $this_el = $(this),
2707						ratio = ( typeof $this_el.attr( 'data-ratio' ) !== 'undefined' )
2708							? $this_el.attr( 'data-ratio' )
2709							: $this_el.find('video').attr( 'width' ) / $this_el.find('video').attr( 'height' ),
2710						$video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ),
2711						$container = $this_el.closest( '.et_pb_section_video' ).length
2712							? $this_el.closest( '.et_pb_section_video' )
2713							: $this_el.closest( '.et_pb_slides' ),
2714						body_width = $container.width(),
2715						container_height = $container.innerHeight(),
2716						width, height;
2717
2718					if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' )
2719						$this_el.attr( 'data-ratio', ratio );
2720
2721					if ( body_width / container_height < ratio ) {
2722						width = container_height * ratio;
2723						height = container_height;
2724					} else {
2725						width = body_width;
2726						height = body_width / ratio;
2727					}
2728
2729					$video_elements.width( width ).height( height );
2730				} );
2731			}
2732
2733			function et_pb_center_video( $video ) {
2734				$element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' );
2735
2736				$element.each( function() {
2737					var $video_width = $(this).width() / 2;
2738					var $video_width_negative = 0 - $video_width;
2739					$(this).css("margin-left",$video_width_negative );
2740
2741					if ( typeof $video !== 'undefined' ) {
2742						if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length )
2743							return false;
2744					}
2745				} );
2746			}
2747
2748			function et_fix_slider_height() {
2749				if ( ! $et_pb_slider.length ) return;
2750
2751				$et_pb_slider.each( function() {
2752					var $slide_section = $(this).parent( '.et_pb_section' ),
2753						$slide = $(this).find( '.et_pb_slide' ),
2754						$slide_container = $slide.find( '.et_pb_container' ),
2755						max_height = 0;
2756
2757					// If this is appears at the first section benath transparent nav, skip it
2758					// leave it to et_fix_page_container_position()
2759					if ( $slide_section.is( '.et_pb_section_first' ) ){
2760						return true;
2761					}
2762
2763					$slide_container.css( 'min-height', 0 );
2764
2765					$slide.each( function() {
2766						var $this_el = $(this),
2767							height = $this_el.innerHeight();
2768
2769						if ( max_height < height )
2770							max_height = height;
2771					} );
2772
2773					$slide_container.css( 'min-height', max_height );
2774				} );
2775			}
2776
2777			/**
2778			 * Add conditional class to prevent unwanted dropdown nav
2779			 */
2780			function et_fix_nav_direction() {
2781				window_width = $(window).width();
2782				$('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' );
2783				$('.nav li li ul').each(function(){
2784					var $dropdown       = $(this),
2785						dropdown_width  = $dropdown.width(),
2786						dropdown_offset = $dropdown.offset(),
2787						$parents        = $dropdown.parents('.nav > li');
2788
2789					if ( dropdown_offset.left > ( window_width - dropdown_width ) ) {
2790						$parents.addClass( 'et-reverse-direction-nav' );
2791					}
2792				});
2793			}
2794			et_fix_nav_direction();
2795
2796			et_pb_form_placeholders_init( $( '.et_pb_newsletter_form' ) );
2797
2798			$('.et_pb_fullwidth_menu ul.nav').each(function(i) {
2799				i++;
2800				et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' );
2801			});
2802
2803			$('.et_pb_fullwidth_menu').each(function() {
2804				var this_menu = $( this ),
2805					bg_color = this_menu.data( 'bg_color' );
2806				if ( bg_color ) {
2807					this_menu.find( 'ul' ).css( { 'background-color' : bg_color } );
2808				}
2809			});
2810
2811			$et_pb_newsletter_button.click( function( event ) {
2812				if ( $(this).closest( '.et_pb_login_form' ).length || $(this).closest( '.et_pb_feedburner_form' ).length ) {
2813					et_pb_maybe_log_event( $(this).closest( '.et_pb_newsletter' ), 'con_goal' );
2814					return;
2815				}
2816
2817				event.preventDefault();
2818
2819				var $newsletter_container = $(this).closest( '.et_pb_newsletter' ),
2820					$firstname = $newsletter_container.find( 'input[name="et_pb_signup_firstname"]' ),
2821					$lastname = $newsletter_container.find( 'input[name="et_pb_signup_lastname"]' ),
2822					$email = $newsletter_container.find( 'input[name="et_pb_signup_email"]' ),
2823					list_id = $newsletter_container.find( 'input[name="et_pb_signup_list_id"]' ).val(),
2824					$result = $newsletter_container.find( '.et_pb_newsletter_result' ).hide(),
2825					service = $(this).closest( '.et_pb_newsletter_form' ).data( 'service' ) || 'mailchimp';
2826
2827				$firstname.removeClass( 'et_pb_signup_error' );
2828				$lastname.removeClass( 'et_pb_signup_error' );
2829				$email.removeClass( 'et_pb_signup_error' );
2830
2831				et_pb_remove_placeholder_text( $(this).closest( '.et_pb_newsletter_form' ) );
2832
2833				if ( $firstname.val() == '' || $email.val() == '' || list_id === '' ) {
2834					if ( $firstname.val() == '' ) $firstname.addClass( 'et_pb_signup_error' );
2835
2836					if ( $email.val() == '' ) $email.addClass( 'et_pb_signup_error' );
2837
2838					if ( $firstname.val() == '' )
2839						$firstname.val( $firstname.siblings( '.et_pb_contact_form_label' ).text() );
2840
2841					if ( $lastname.val() == '' )
2842						$lastname.val( $lastname.siblings( '.et_pb_contact_form_label' ).text() );
2843
2844					if ( $email.val() == '' )
2845						$email.val( $email.siblings( '.et_pb_contact_form_label' ).text() );
2846
2847					return;
2848				}
2849
2850				$.ajax( {
2851					type: "POST",
2852					url: et_pb_custom.ajaxurl,
2853					dataType: "json",
2854					data:
2855					{
2856						action : 'et_pb_submit_subscribe_form',
2857						et_frontend_nonce : et_pb_custom.et_frontend_nonce,
2858						et_list_id : list_id,
2859						et_firstname : $firstname.val(),
2860						et_lastname : $lastname.val(),
2861						et_email : $email.val(),
2862						et_service : service
2863					},
2864					beforeSend: function() {
2865						$newsletter_container
2866							.find( '.et_pb_newsletter_button' )
2867							.addClass( 'et_pb_button_text_loading' )
2868							.find('.et_subscribe_loader')
2869							.show();
2870					},
2871					complete: function(){
2872						$newsletter_container
2873							.find( '.et_pb_newsletter_button' )
2874							.removeClass( 'et_pb_button_text_loading' )
2875							.find('.et_subscribe_loader')
2876							.hide();
2877					},
2878					success: function( data ){
2879						if ( data ) {
2880							if ( data.error ) {
2881								$result.html( data.error ).show();
2882							}
2883							if ( data.success ) {
2884								$newsletter_container.find( '.et_pb_newsletter_form > p' ).hide();
2885								$result.html( data.success ).show();
2886
2887								et_pb_maybe_log_event( $newsletter_container, 'con_goal' );
2888							}
2889						} else {
2890							$result.html( et_pb_custom.subscription_failed ).show();
2891						}
2892					}
2893				} );
2894			} );
2895
2896			window.et_fix_testimonial_inner_width = function() {
2897				var window_width = $( window ).width();
2898
2899				if( window_width > 767 ){
2900					$( '.et_pb_testimonial' ).each( function() {
2901						if ( ! $(this).is(':visible') ) {
2902							return;
2903						}
2904
2905						var $testimonial      = $(this),
2906							testimonial_width = $testimonial.width(),
2907							$portrait         = $testimonial.find( '.et_pb_testimonial_portrait' ),
2908							portrait_width    = $portrait.width(),
2909							$testimonial_inner= $testimonial.find( '.et_pb_testimonial_description_inner' ),
2910							$outer_column     = $testimonial.closest( '.et_pb_column' ),
2911							testimonial_inner_width = testimonial_width,
2912							subtract = ! ( $outer_column.hasClass( 'et_pb_column_1_3' ) || $outer_column.hasClass( 'et_pb_column_1_4' ) || $outer_column.hasClass( 'et_pb_column_3_8' ) ) ? portrait_width + 31 : 0;
2913
2914							$testimonial_inner.width( testimonial_inner_width - subtract );
2915					} );
2916				} else {
2917					$( '.et_pb_testimonial_description_inner' ).removeAttr( 'style' );
2918				}
2919			}
2920			window.et_fix_testimonial_inner_width();
2921
2922			window.et_reinint_waypoint_modules = function() {
2923				if ( $.fn.waypoint ) {
2924					var $et_pb_circle_counter = $( '.et_pb_circle_counter' ),
2925						$et_pb_number_counter = $( '.et_pb_number_counter' ),
2926						$et_pb_video_background = $( '.et_pb_section_video_bg video' );
2927
2928					$( '.et_pb_counter_container, .et-waypoint' ).waypoint( {
2929						offset: '75%',
2930						handler: function() {
2931							$(this.element).addClass( 'et-animated' );
2932						}
2933					} );
2934
2935					// fallback to 'bottom-in-view' offset, to make sure element become visible when it's on the bottom of page and other offsets are not triggered
2936					$( '.et_pb_counter_container, .et-waypoint' ).waypoint( {
2937						offset: 'bottom-in-view',
2938						handler: function() {
2939							$(this.element).addClass( 'et-animated' );
2940						}
2941					} );
2942
2943					if ( $et_pb_circle_counter.length ) {
2944						$et_pb_circle_counter.each(function(){
2945							var $this_counter = $(this);
2946							if ( ! $this_counter.is( ':visible' ) ) {
2947								return;
2948							}
2949							$this_counter.waypoint({
2950								offset: '65%',
2951								handler: function() {
2952									if ( $this_counter.data( 'PieChartHasLoaded' ) ) {
2953										return;
2954									}
2955
2956									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
2957
2958									$this_counter.data( 'PieChartHasLoaded', true );
2959								}
2960							});
2961
2962							// fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered
2963							$this_counter.waypoint({
2964								offset: 'bottom-in-view',
2965								handler: function() {
2966									if ( $this_counter.data( 'PieChartHasLoaded' ) ) {
2967										return;
2968									}
2969
2970									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
2971
2972									$this_counter.data( 'PieChartHasLoaded', true );
2973								}
2974							});
2975						});
2976					}
2977
2978					if ( $et_pb_number_counter.length ) {
2979						$et_pb_number_counter.each(function(){
2980							var $this_counter = $(this);
2981							$this_counter.waypoint({
2982								offset: '75%',
2983								handler: function() {
2984									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
2985								}
2986							});
2987
2988							// fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered
2989							$this_counter.waypoint({
2990								offset: 'bottom-in-view',
2991								handler: function() {
2992									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
2993								}
2994							});
2995						});
2996					}
2997
2998					if ( $( '.et_pb_ab_goal' ).length ) {
2999						var $et_pb_ab_goal = $( '.et_pb_ab_goal' );
3000
3001						$et_pb_ab_goal.waypoint({
3002							offset: '80%',
3003							handler: function() {
3004								if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.visible( true ) ) {
3005									return;
3006								}
3007
3008								// log the goal_read if goal is still visible after 3 seconds.
3009								setTimeout( function() {
3010									if ( $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) {
3011										et_pb_ab_update_stats( 'read_goal' );
3012									}
3013								}, 3000 );
3014
3015								et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' );
3016							}
3017						});
3018					}
3019
3020					if ( $et_pb_video_background.length ) {
3021						$et_pb_video_background.each( function(){
3022							var $this_video_background = $(this),
3023								$video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' ),
3024								this_video_player = this.player;
3025
3026							// Entering video's top viewport
3027							$video_background_wrapper.waypoint({
3028								offset: '100%',
3029								handler : function( direction ) {
3030									if ( $this_video_background.is(':visible') && direction === 'down' ) {
3031										this_video_player.play();
3032									} else if ( $this_video_background.is(':visible') && direction === 'up' ) {
3033										this_video_player.pause();
3034									}
3035								}
3036							});
3037
3038							// Entering video's bottom viewport
3039							$video_background_wrapper.waypoint({
3040								offset: '-50%',
3041								handler : function( direction ) {
3042									if ( $this_video_background.is(':visible') && direction === 'up' ) {
3043										this_video_player.play();
3044									} else if ( $this_video_background.is(':visible') && direction === 'down' ) {
3045										this_video_player.pause();
3046									}
3047								}
3048							});
3049						});
3050					}
3051				}
3052			}
3053
3054			function et_pb_init_ab_test() {
3055				var $et_pb_ab_goal = $( '.et_pb_ab_goal' ),
3056					et_ab_subject_id = et_pb_get_subject_id();
3057
3058				$.each( et_pb_ab_logged_status, function( key, value ) {
3059					var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id;
3060
3061					et_pb_ab_logged_status[key] = et_pb_check_cookie_value( 'et_pb_ab_' + key + '_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + cookie_subject, 'true' );
3062
3063				});
3064
3065				// log the page read event if user stays on page long enough and if not logged for current subject
3066				if ( ! et_pb_ab_logged_status['read_page'] ) {
3067					setTimeout( function() {
3068						et_pb_ab_update_stats( 'read_page' );
3069					}, et_pb_ab_bounce_rate );
3070				}
3071
3072				// add the cookies for shortcode tracking, if enabled
3073				if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) {
3074					et_pb_set_cookie( 365, 'et_pb_ab_shortcode_track_' + et_pb_custom.page_id + '=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id );
3075				}
3076
3077				if ( $et_pb_ab_goal.length ) {
3078					// if goal is a module and has a button then track the conversions, otherwise track clicks
3079					if ( $et_pb_ab_goal.hasClass( 'et_pb_module' ) && ( $et_pb_ab_goal.hasClass( 'et_pb_button' ) || $et_pb_ab_goal.find( '.et_pb_button' ).length ) ) {
3080						// Log con_goal if current goal doesn't require any specific conversion calculation
3081						if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) {
3082							var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' );
3083
3084							if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) {
3085								var page_url = window.location.href,
3086									comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false,
3087									log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' );
3088
3089								if ( comment_submitted && log_conversion ) {
3090									et_pb_ab_update_stats( 'con_goal' );
3091									et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
3092								}
3093							}
3094
3095							$goal_button.click( function(){
3096								if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) {
3097									et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
3098									return;
3099								}
3100
3101								et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
3102							});
3103						}
3104					} else {
3105						$et_pb_ab_goal.click( function() {
3106							if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) {
3107								et_pb_set_cookie( 365, 'et_pb_ab_shop_log=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id );
3108							}
3109
3110							et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
3111						});
3112					}
3113				}
3114			}
3115
3116			function et_pb_maybe_log_event( $goal_container, event ) {
3117				var log_event = typeof event === 'undefined' ? 'con_goal' : event;
3118
3119				if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) {
3120					return;
3121				}
3122
3123				// log the event if it's not logged for current user
3124				et_pb_ab_update_stats( log_event );
3125			}
3126
3127			function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id ) {
3128				var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id,
3129					page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id,
3130					test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id,
3131					stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
3132					cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id;
3133
3134				et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' );
3135
3136				et_pb_ab_logged_status[record_type] = true;
3137
3138				$.ajax({
3139					type: 'POST',
3140					url: et_pb_custom.ajaxurl,
3141					data: {
3142						action : 'et_pb_update_stats_table',
3143						stats_data_array : stats_data,
3144						et_ab_log_nonce : et_pb_custom.et_ab_log_nonce
3145					}
3146				});
3147			}
3148
3149			function et_pb_get_subject_id() {
3150				var subject_id_raw = $( '.et_pb_ab_subject' ).attr( 'class' ).split( 'et_pb_ab_subject_id-' )[1],
3151					subject_id_clean = subject_id_raw.split( ' ' )[0],
3152					subject_id_separated = subject_id_clean.split( '_' ),
3153					subject_id = subject_id_separated[1];
3154
3155				return subject_id;
3156			}
3157
3158			function et_pb_set_cookie_expire( days ) {
3159				var ms = days*24*60*60*1000;
3160
3161				var date = new Date();
3162				date.setTime( date.getTime() + ms );
3163
3164				return "; expires=" + date.toUTCString();
3165			}
3166
3167			function et_pb_check_cookie_value( cookie_name, value ) {
3168				return et_pb_get_cookie_value( cookie_name ) == value;
3169			}
3170
3171			function et_pb_get_cookie_value( cookie_name ) {
3172				return et_pb_parse_cookies()[cookie_name];
3173			}
3174
3175			function et_pb_parse_cookies() {
3176				var cookies = document.cookie.split( '; ' );
3177
3178				var ret = {};
3179				for ( var i = cookies.length - 1; i >= 0; i-- ) {
3180				  var el = cookies[i].split( '=' );
3181				  ret[el[0]] = el[1];
3182				}
3183				return ret;
3184			}
3185
3186			function et_pb_set_cookie( expire, cookie_content ) {
3187				cookie_expire = et_pb_set_cookie_expire( expire );
3188				document.cookie = cookie_content + cookie_expire + "; path=/";
3189			}
3190
3191			window.et_calc_fullscreen_section = function() {
3192				var $et_window = $(window),
3193					$body = $( 'body' ),
3194					$wpadminbar = $( '#wpadminbar' ),
3195					et_is_vertical_nav = $body.hasClass( 'et_vertical_nav' ),
3196					$this_section = $(this),
3197					this_section_index = $this_section.index('.et_pb_fullwidth_header'),
3198					$header = $this_section.children('.et_pb_fullwidth_header_container'),
3199					$header_content = $header.children('.header-content-container'),
3200					$header_image = $header.children('.header-image-container'),
3201					sectionHeight = $et_window.height(),
3202					$wpadminbar = $('#wpadminbar'),
3203					$top_header = $('#top-header'),
3204					$main_header = $('#main-header'),
3205					et_header_height,
3206					secondary_nav_height;
3207
3208					secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? $top_header.innerHeight() : 0;
3209					et_header_height = $main_header.length ? $main_header.innerHeight() + secondary_nav_height : 0;
3210
3211				var calc_header_offset = ( $wpadminbar.length ) ? et_header_height + $wpadminbar.innerHeight() - 1 : et_header_height - 1;
3212
3213				// Section height adjustment differs in vertical and horizontal nav
3214				if ( $body.hasClass('et_vertical_nav') ) {
3215					if ( $et_window.width() >= 980 && $top_header.length ) {
3216						sectionHeight -= $top_header.height();
3217					}
3218
3219					if ( $wpadminbar.length ) {
3220						sectionHeight -= $wpadminbar.height();
3221					}
3222				} else {
3223					if ( $body.hasClass('et_hide_nav' ) ) {
3224						// If user is logged in and hide navigation is in use, adjust the section height
3225						if ( $wpadminbar.length ) {
3226							sectionHeight -= $wpadminbar.height();
3227						}
3228
3229						// In mobile, header always appears. Adjust the section height
3230						if ( $et_window.width() < 981 && ! $body.hasClass('et_transparent_nav') ) {
3231							sectionHeight -= $('#main-header').height();
3232						}
3233					} else {
3234						if ( $this_section.offset().top <= calc_header_offset + 3 ) {
3235							if ( et_is_vertical_nav ) {
3236								var $top_header = $('#top-header'),
3237									top_header_height = ( $top_header.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $top_header.height() : 0,
3238									wpadminbar_height = ( $wpadminbar.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $wpadminbar.height() : 0,
3239									calc_header_offset_vertical = wpadminbar_height + top_header_height;
3240
3241								sectionHeight -= calc_header_offset_vertical;
3242							} else {
3243								sectionHeight -= calc_header_offset;
3244							}
3245						}
3246					}
3247				}
3248
3249				// If the transparent primary nav + hide nav until scroll is being used,
3250				// cancel automatic padding-top added by transparent nav mechanism
3251				if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) &&  0 === this_section_index ) {
3252					$this_section.css( 'padding-top', '' );
3253				}
3254
3255				$this_section.css('min-height', sectionHeight + 'px' );
3256				$header.css('min-height', sectionHeight + 'px' );
3257
3258				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) {
3259					$header.addClass('bottom-bottom');
3260				}
3261
3262				if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) {
3263					$header.addClass('center-center');
3264				}
3265
3266				if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) {
3267					$header.addClass('center-bottom');
3268
3269					var contentHeight = sectionHeight - $header_image.outerHeight( true );
3270
3271					if ( contentHeight > 0 ) {
3272						$header_content.css('min-height', contentHeight + 'px' );
3273					}
3274				}
3275
3276				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
3277					$header.addClass('bottom-center');
3278				}
3279
3280				if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) {
3281					$header.css('justify-content', 'flex-end');
3282				}
3283
3284				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) {
3285					$header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' );
3286				}
3287
3288				if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
3289					$header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' );
3290					$header_image.css('align-self', 'flex-end');
3291				}
3292			}
3293
3294			$( window ).resize( function(){
3295				var window_width                = $et_window.width(),
3296					et_container_css_width      = $et_container.css( 'width' ),
3297					et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '',
3298					et_container_actual_width   = ( et_container_width_in_pixel ) ? $et_container.width() : ( ( $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
3299					containerWidthChanged       = et_container_width !== et_container_actual_width;
3300
3301				et_pb_resize_section_video_bg();
3302				et_pb_center_video();
3303				et_fix_slider_height();
3304				et_fix_nav_direction();
3305
3306				$et_pb_fullwidth_portfolio.each(function(){
3307					set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false;
3308					set_fullwidth_portfolio_columns( $(this), set_container_height );
3309				});
3310
3311				if ( containerWidthChanged ) {
3312					$('.container-width-change-notify').trigger('containerWidthChanged');
3313
3314					setTimeout( function() {
3315						$et_pb_filterable_portfolio.each(function(){
3316							set_filterable_grid_items( $(this) );
3317						});
3318						$et_pb_gallery.each(function(){
3319							if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) {
3320								set_gallery_grid_items( $(this) );
3321							}
3322						});
3323					}, 100 );
3324
3325					et_container_width = et_container_actual_width;
3326
3327					etRecalculateOffset = true;
3328
3329					if ( $et_pb_circle_counter.length ) {
3330						$et_pb_circle_counter.each(function(){
3331							var $this_counter = $(this);
3332							if ( ! $this_counter.is( ':visible' ) ) {
3333								return;
3334							}
3335
3336							$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3337						});
3338					}
3339					if ( $et_pb_countdown_timer.length ) {
3340						$et_pb_countdown_timer.each(function(){
3341							var timer = $(this);
3342							et_countdown_timer_labels( timer );
3343						} );
3344					}
3345				}
3346
3347				window.et_fix_testimonial_inner_width();
3348
3349				et_audio_module_set();
3350			} );
3351
3352			$( window ).ready( function(){
3353				if ( $.fn.fitVids ) {
3354					$( '.et_pb_slide_video' ).fitVids();
3355					$( '.et_pb_module' ).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']"} );
3356				}
3357
3358				et_fix_video_wmode('.fluid-width-video-wrapper');
3359
3360				et_fix_slider_height();
3361
3362				// calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases
3363				$( 'section.et_pb_fullscreen' ).each( function(){
3364					var $this_section = $( this );
3365
3366					$.proxy( et_calc_fullscreen_section, $this_section )();
3367
3368					$et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) );
3369				});
3370			} );
3371
3372			function et_pb_window_load_scripts() {
3373				et_fix_fullscreen_section();
3374
3375				// recalculate fullscreen section sizes on load
3376				$( 'section.et_pb_fullscreen' ).each( function(){
3377					var $this_section = $( this );
3378
3379					$.proxy( et_calc_fullscreen_section, $this_section )();
3380				});
3381
3382				$( '.et_pb_fullwidth_header_scroll a' ).click( function( event ) {
3383					event.preventDefault();
3384
3385					var $this_section      = $(this).parents( 'section' ),
3386						is_next_fullscreen = $this_section.next().hasClass( 'et_pb_fullscreen' ),
3387						$wpadminbar        = $('#wpadminbar'),
3388						wpadminbar_height  = ( $wpadminbar.length && ! is_next_fullscreen ) ? $wpadminbar.height() : 0,
3389						main_header_height = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $main_header.height(),
3390						top_header_height  = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $top_header.height(),
3391						section_bottom     = $this_section.offset().top + $this_section.outerHeight( true ) - ( wpadminbar_height + top_header_height + main_header_height );
3392
3393					if ( $this_section.length ) {
3394						$( 'html, body' ).animate( { scrollTop : section_bottom }, 800 );
3395
3396						if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
3397							setTimeout(function(){
3398								var section_offset_top = $this_section.offset().top,
3399									section_height     = $this_section.outerHeight( true ),
3400									main_header_height = is_next_fullscreen ? 0 : $main_header.height(),
3401									section_bottom     = section_offset_top + section_height - ( main_header_height + top_header_height + wpadminbar_height);
3402
3403								$( 'html, body' ).animate( { scrollTop : section_bottom }, 280, 'linear' );
3404							}, 780 );
3405						}
3406					}
3407				});
3408
3409				setTimeout( function() {
3410					$( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
3411				}, 500 );
3412
3413				if ( $.fn.hashchange ) {
3414					$(window).hashchange( function(){
3415						var hash = window.location.hash.substring(1);
3416						process_et_hashchange( hash );
3417					});
3418					$(window).hashchange();
3419				}
3420
3421				if ( $et_pb_parallax.length && !et_is_mobile_device ) {
3422					$et_pb_parallax.each(function(){
3423						if ( $(this).hasClass('et_pb_parallax_css') ) {
3424							return;
3425						}
3426
3427						var $this_parent = $(this).parent();
3428
3429						$.proxy( et_parallax_set_height, $this_parent )();
3430
3431						$.proxy( et_apply_parallax, $this_parent )();
3432
3433						$et_window.on( 'scroll', $.proxy( et_apply_parallax, $this_parent ) );
3434
3435						$et_window.on( 'resize', $.proxy( et_parallax_set_height, $this_parent ) );
3436						$et_window.on( 'resize', $.proxy( et_apply_parallax, $this_parent ) );
3437
3438						$this_parent.find('.et-learn-more .heading-more').click( function() {
3439							setTimeout(function(){
3440								$.proxy( et_parallax_set_height, $this_parent )();
3441							}, 300 );
3442						});
3443					});
3444				}
3445
3446				et_audio_module_set();
3447
3448				window.et_reinint_waypoint_modules();
3449
3450				if ( $( '.et_audio_content' ).length ) {
3451					$( window ).trigger( 'resize' );
3452				}
3453			}
3454
3455			if ( window.et_load_event_fired ) {
3456				et_pb_window_load_scripts();
3457			} else {
3458				$( window ).load( function() {
3459					et_pb_window_load_scripts();
3460				} );
3461			}
3462
3463			if ( $( '.et_section_specialty' ).length ) {
3464				$( '.et_section_specialty' ).each( function() {
3465					var this_row = $( this ).find( '.et_pb_row' );
3466
3467					this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' );
3468				});
3469			}
3470
3471			/**
3472			* In particular browser, map + parallax doesn't play well due the use of CSS 3D transform
3473			*/
3474			if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) {
3475				$('body').addClass( 'parallax-map-support' );
3476			}
3477
3478			/**
3479			 * Add conditional class for search widget in sidebar module
3480			 */
3481			$('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() {
3482				var $search_wrap              = $(this),
3483					$search_input_submit      = $search_wrap.find('input[type="submit"]'),
3484					search_input_submit_text = $search_input_submit.attr( 'value' ),
3485					$search_button            = $search_wrap.find('button'),
3486					search_button_text       = $search_button.text(),
3487					has_submit_button         = $search_input_submit.length || $search_button.length ? true : false,
3488					min_column_width          = 150;
3489
3490				if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) {
3491					return;
3492				}
3493
3494				// Mark no button state
3495				if ( ! has_submit_button ) {
3496					$search_wrap.addClass( 'et-no-submit-button' );
3497				}
3498
3499				// Mark narrow state
3500				if ( $search_wrap.width() < 150 ) {
3501					$search_wrap.addClass( 'et-narrow-wrapper' );
3502				}
3503
3504				// Fixes issue where theme's search button has no text: treat it as non-existent
3505				if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) {
3506					$search_input_submit.remove();
3507					$search_wrap.addClass( 'et-no-submit-button' );
3508				}
3509
3510				if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) {
3511					$search_button.remove();
3512					$search_wrap.addClass( 'et-no-submit-button' );
3513				}
3514
3515			} );
3516
3517			if ( $( '.et_pb_search' ).length ) {
3518				$( '.et_pb_search' ).each( function() {
3519					var $this_module = $( this ),
3520						$input_field = $this_module.find( '.et_pb_s' ),
3521						$button = $this_module.find( '.et_pb_searchsubmit' ),
3522						input_padding = $this_module.hasClass( 'et_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight',
3523						disabled_button = $this_module.hasClass( 'et_pb_hide_search_button' );
3524
3525					if ( $button.innerHeight() > $input_field.innerHeight() ) {
3526						$input_field.height( $button.innerHeight() );
3527					}
3528
3529					if ( ! disabled_button ) {
3530						$input_field.css( input_padding, $button.innerWidth() + 10 );
3531					}
3532				});
3533			}
3534
3535			// apply required classes for the Reply buttons in Comments Module
3536			if ( $( '.et_pb_comments_module' ).length ) {
3537				$( '.et_pb_comments_module' ).each( function() {
3538					var $comments_module = $( this ),
3539						$comments_module_button = $comments_module.find( '.comment-reply-link' );
3540
3541					if ( $comments_module_button.length ) {
3542						$comments_module_button.addClass( 'et_pb_button' );
3543
3544						if ( typeof $comments_module.data( 'icon' ) !== 'undefined' ) {
3545							$comments_module_button.attr( 'data-icon', $comments_module.data( 'icon' ) );
3546							$comments_module_button.addClass( 'et_pb_custom_button_icon' );
3547						}
3548					}
3549				});
3550			}
3551
3552		});
3553	}
3554})(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.