PageSourceSearch

https://rozinaali.com/wp-content/plugins/trx_addons/js/trx_addons.front.js?reload=455912406

js rozinaali.com collected 2026-10-04 21:00:51 UTC 114,219 bytes, 3,032 lines download raw bytes

1/**
2 * Init scripts
3 *
4 * @package ThemeREX Addons
5 * @since v1.0
6 */
7
8/* global jQuery, TRX_ADDONS_STORAGE */
9
10(function() {
11
12	"use strict";
13
14	// Start on DOM ready
15	jQuery( document ).ready( function() {
16
17		var ready_busy = true;
18
19		var vc_init_counter = 0;
20
21		var parallax_controller = null;
22
23		var requestAnimationFrame = trx_addons_request_animation_frame();
24
25		var $window             = jQuery( window ),
26			$document           = jQuery( document ),
27			$html               = jQuery( 'html' ),
28			$body               = jQuery( 'body' );
29
30		var $page_preloader     = jQuery('#page_preloader'),
31			$scroll_to_top      = jQuery('.trx_addons_scroll_to_top'),
32			$scroll_progress    = $scroll_to_top.find('.trx_addons_scroll_progress');
33
34		var _video_sticky_fade  = true;
35
36		var $show_on_scroll,
37			$banner_placeholder,
38			$animated_elements,
39			$animated_hover,
40			$video_sticky,
41			$fixed_columns,
42			$stack_sections,
43			$parallax_wrap,
44			$video_tags,
45			$iframe_tags,
46			$video_autoplay,
47			$video_autoplay_yt,
48			$video_hovers_yt = false;
49
50
51		// Set body classes according User Agent
52		var classes = trx_addons_browser_classes();
53		for ( var ua in classes ) {
54			if ( $body.hasClass( 'ua_' + ua ) ) {
55				if ( ! classes[ua] ) {
56					$body.removeClass( 'ua_' + ua );
57				}
58			} else if ( classes[ua] ) {
59				$body.addClass( 'ua_' + ua );
60			}
61		}
62
63		// Update links and values after the new post added
64		$document.on( 'action.got_ajax_response', update_jquery_links );
65		$document.on( 'action.init_hidden_elements', update_jquery_links );
66		var first_run = true;
67		function update_jquery_links(e) {
68			if ( first_run && e && e.namespace == 'init_hidden_elements' ) {
69				first_run = false;
70				return; 
71			}
72			$show_on_scroll     = jQuery('.trx_addons_show_on_scroll');
73			$banner_placeholder = jQuery('.trx_addons_banner_placeholder');
74			$animated_elements  = jQuery('[data-post-animation^="animated"]:not(.animated)');
75			$animated_hover     = jQuery('[data-hover-animation^="animated"]:not(.animated)');
76			$video_sticky       = jQuery('.trx_addons_video_sticky');
77			$fixed_columns      = jQuery('.sc_column_fixed');
78//			if ( $body.hasClass( 'fixed_blocks_sticky' ) && $fixed_columns.length > 0 ) {
79//				$fixed_columns.each(function() {
80//					jQuery(this).parents('.e-con,.elementor-section,.vc_row').eq(0).toggleClass( 'trx_addons_has_fixed_columns', true );
81//				} );
82//			}
83			$stack_sections     = jQuery('.sc_stack_section_on:not(.elementor-element-edit-mode)');
84			if ( $stack_sections.length > 0 ) {
85				$body.addClass( 'sc_stack_section_present ' + ( window.trx_addons_browser_is_ios() ? 'ua_ios' : 'ua_not_ios' ) );
86			}
87			$parallax_wrap      = jQuery('.sc_parallax_wrap' );
88			$video_tags         = jQuery('video');
89			$iframe_tags        = jQuery('iframe');	// ',.video_frame iframe'
90			// Load Youtube API to enable autoplay videos from Youtube in the iframe on click on the button 'Play' on iOS devices
91			if ( trx_addons_browser_is_ios() ) {
92				$video_hovers_yt = jQuery('.video_hover[data-video*="youtu"],.post_video_hover[data-video*="youtu"],.trx_addons_video_list_controller_item[data-video*="youtu"]');
93				if ( $video_hovers_yt.length > 0 ) {
94					embedYoutubeAPI();
95				}
96			}
97			trx_addons_find_video_autoplay();
98		}
99		update_jquery_links();
100
101		// Update autoplay videos
102		function trx_addons_find_video_autoplay() {
103			$video_autoplay    = jQuery('.with_video_autoplay');
104			$video_autoplay_yt = $video_autoplay.find('iframe[src*="youtu"]');
105		}
106
107
108		// Page preloader
109		//-----------------------------------------
110
111		// Show preloader
112		window.trx_addons_show_preloader = function() {
113			if ( $page_preloader.length > 0 && ( ! jQuery.browser || ! jQuery.browser.safari ) && ! $body.hasClass( 'ua_safari' ) ) {
114				// Trigger action to allow the theme redefine a preloader
115				$page_preloader.data('done', false);
116				$document.trigger( 'action.page_preloader', [$page_preloader] );
117				// If preloader not redefined - display it
118				if ( ! $page_preloader.data('done') ) {
119					$page_preloader
120						.css( {
121							display: 'block',
122							opacity: 0
123						} )
124						.animate( {
125							opacity: $page_preloader.data('opacity')
126						}, 300);
127					setTimeout( trx_addons_hide_preloader, 5000 );
128				}
129			}
130		};
131
132		// Hide preloader
133		window.trx_addons_hide_preloader = function() {
134			if ( $page_preloader.length > 0 ) {
135				$page_preloader.data('done', false);
136				$document.trigger( 'action.page_preloader_hide', [$page_preloader] );
137				// If preloader not redefined - hide it
138				if ( ! $page_preloader.data('done') && $page_preloader.css('opacity') > 0 ) {
139					$page_preloader.animate(
140						{
141							opacity: 0
142						},
143						800,
144						function() {
145							jQuery(this).css( { display: 'none' } );
146						}
147					);
148				}
149			}
150		};
151
152		if ( $page_preloader.length > 0 ) {
153			$page_preloader.data('opacity', $page_preloader.css('opacity'));
154
155			// Show preloader
156			$window.on( 'beforeunload', function(e) {
157				if ( typeof e.srcElement == 'undefined'
158					|| typeof e.srcElement.activeElement == 'undefined'
159					|| typeof e.srcElement.activeElement.href == 'undefined'
160					|| e.srcElement.activeElement.href.indexOf('//') === 0
161					|| e.srcElement.activeElement.href.indexOf('http:') === 0
162					|| e.srcElement.activeElement.href.indexOf('https:') === 0
163				) {
164					trx_addons_show_preloader();
165				}
166			} );
167			$document.on( 'action.before_new_page_content', function( e, $link, show ) {
168				if ( show || show === undefined ) {
169					trx_addons_show_preloader();
170				}
171			} );
172			$document.on( 'action.after_new_page_content', function( e, $link ) {
173				trx_addons_hide_preloader();
174			} );
175
176
177			// Disable preloader on the links with 'tel:' or 'mailto:' or similar (not 'http:' or 'https:')
178			$document.on( 'click', 'a', function() {
179				var href = jQuery(this).attr('href');
180				if ( href !== undefined && href.indexOf('//') !== 0 && href.indexOf('http:') !== 0 && href.indexOf('https:') !== 0 ) {
181					setTimeout( function() {
182						if ( $page_preloader.css( 'display' ) == 'block' ) {
183							$page_preloader.css( {
184								display: 'none',
185								opacity: 0
186							} );
187						}
188					}, 1 );
189				}
190			} );
191		}
192
193		// Page first load actions
194		//==============================================
195		$document.on('action.init_trx_addons', function() {
196			// Close panel on ESC is pressed
197			$document.on('keyup', function(e) {
198				if (e.keyCode === 27) {
199					jQuery( '.sc_layouts_panel_opened' ).each( function() {
200						trx_addons_close_panel( jQuery(this) );
201					} );
202				}
203			});
204		} );
205
206		// Init intersection observer
207		trx_addons_intersection_observer_init();
208
209		// Init all other actions
210		trx_addons_init_actions();
211
212
213		// Init actions
214		//--------------------------------------
215		function trx_addons_init_actions() {
216			if (typeof TRX_ADDONS_STORAGE == 'undefined') {
217				window.TRX_ADDONS_STORAGE = {
218											'vc_edit_mode': false,
219											'popup_engine': 'magnific'
220										};
221			}
222			if (TRX_ADDONS_STORAGE['vc_edit_mode'] && jQuery('.vc_empty-placeholder').length === 0 && vc_init_counter++ < 30) {
223				setTimeout(trx_addons_init_actions, 200);
224				return;
225			}
226
227			$document.trigger('action.before_init_trx_addons');
228
229			// Hide preloader
230			trx_addons_hide_preloader();
231			
232			// Show system message
233			var msg = jQuery('.trx_addons_message_box_system'),
234				msg_delay = 5000;
235			if (msg.length > 0) {
236				setTimeout(function() {
237					msg.fadeIn().delay(msg_delay).fadeOut();
238				}, 1000);
239				var login = jQuery('.trx_addons_login_link');
240				if (msg.hasClass('trx_addons_message_box_error') && login.length > 0) {
241					setTimeout(function() {
242						login.trigger('click');
243					}, 2000+msg_delay);
244				}
245			}
246
247			// Shift page down to display hash-link if menu is fixed
248			// (except WooCommerce product page, because WooCommerce has own handler of the hash url)
249			if (typeof TRX_ADDONS_STORAGE['animate_to_hash']=='undefined' && !$body.hasClass('single-product')) {
250				TRX_ADDONS_STORAGE['animate_to_hash'] = true;
251				setTimeout(function() {
252					var $mc4form = false;
253
254					// Hack for MailChimp - use our scroll to form, because his method damage layouts in the Chrome
255					if (window.mc4wp_forms_config && window.mc4wp_forms_config.submitted_form && window.mc4wp_forms_config.submitted_form.element_id) {
256						trx_addons_document_animate_to(window.mc4wp_forms_config.submitted_form.element_id);
257
258					} else if ( TRX_ADDONS_STORAGE['animate_to_mc4wp_form_submitted'] && ( $mc4form = jQuery( '.mc4wp-form-submitted' ) ).length ) {
259						trx_addons_document_animate_to( $mc4form );
260					
261					// Shift page down on fixed rows height
262					} else if ( location.hash !== '' && location.hash != '#' && location.hash.indexOf('/') == -1 ) {
263						var obj = jQuery(location.hash);
264						if (obj.length > 0) {
265							var off = obj.offset().top;
266							if ( ! isNaN( off )
267								&& ( ( trx_addons_fixed_rows_height() > 0 && off - trx_addons_window_scroll_top() < trx_addons_fixed_rows_height() + 60 )
268									|| trx_addons_window_scroll_top() === 0
269									)
270							) {
271								trx_addons_document_animate_to(off - trx_addons_fixed_rows_height() - 60);
272							}
273						}
274					}
275				}, 600);
276			}
277			
278			// Check for Retina display
279			trx_addons_set_cookie('trx_addons_is_retina', trx_addons_is_retina() ? 1 : 0);
280
281			// On switch to mobile layout: hide hover animations
282			$document.on( 'action.switch_to_mobile_layout', function() {
283				jQuery('[data-hover-animation^="animated"]').each(function() {
284					var $self = jQuery(this);
285					var animation = $self.data('hover-animation');
286					var animation_out = $self.data('animation-out');
287					if (animation_out === undefined) animation_out = "none";
288					$self.removeClass(animation + ' ' + animation_out);
289				});
290			});
291
292			// Init core elements
293			trx_addons_ready_actions();
294
295			// Call plugins specific action (if exists)
296			//----------------------------------------------
297			$document.trigger('action.before_ready_trx_addons');
298			$document.trigger('action.ready_trx_addons');
299			$document.trigger('action.after_ready_trx_addons');
300
301			// Add ready actions to the hidden elements actions
302			$document.on( 'action.init_hidden_elements', function( e, cont ) {
303				trx_addons_ready_actions(e, cont);
304
305				// Generate 'resize' event after hidden elements are inited
306				//$window.trigger('resize');
307
308				// Generate 'scroll' event after hidden elements are inited
309				$window.trigger('scroll');
310			} );
311
312			// Add our handlers after the VC init
313			var vc_js = false;
314			$document.on('vc_js', function() {
315				if ( ! vc_js )	{
316					vc_js = true;
317					trx_addons_add_handlers();
318				}
319			});
320
321			// Add our handlers if VC is no activated
322			setTimeout(function() {
323				if ( ! vc_js )	{
324					trx_addons_add_handlers();
325				}
326			}, 1);
327			
328			// Add our handlers
329			function trx_addons_add_handlers() {		
330
331				// Resize handlers
332				//-----------------------
333				// First run
334				trx_addons_resize_actions();
335				// Add handler
336				$window.on( 'resize', function() {
337					trx_addons_resize_actions();
338				} );
339
340				// Scroll handlers
341				//-----------------------
342				function trx_addons_scroll_start( force ) {
343					if ( requestAnimationFrame && ! force ) {
344						if ( ! TRX_ADDONS_STORAGE['scroll_busy'] ) {
345							TRX_ADDONS_STORAGE['scroll_busy'] = true;
346							requestAnimationFrame( trx_addons_scroll_actions );
347						}
348					} else {
349						TRX_ADDONS_STORAGE['scroll_busy'] = true;
350						trx_addons_scroll_actions();
351					}
352				}
353				// First run
354				trx_addons_scroll_start();
355				// Add handler
356				$window.on( 'scroll', function() {
357					trx_addons_scroll_start();
358				} );
359
360				// Smooth scroll via GSAP TweenMax (if loaded)
361				if ( TRX_ADDONS_STORAGE['smooth_scroll'] > 0 && typeof TweenMax != 'undefined' ) {
362					var $scroll_target = $window;
363					var scroll_time = trx_addons_apply_filters( 'trx_addons_filter_smooth_scroll_time', 0.8 );           // 0.6
364					var scroll_distance = trx_addons_apply_filters( 'trx_addons_filter_smooth_scroll_distance', 400 );   // 400
365					var ie_mobile = -1 !== navigator.userAgent.indexOf("IEMobile"),
366						is_mobile = trx_addons_browser_is_mobile() || $body.hasClass('ua_mobile');
367					var scroll_busy = false;
368					var scroll_coef = trx_addons_apply_filters( 'trx_addons_filter_smooth_scroll_coef', {
369						start: 0.2,
370						multi: 1.5,
371						max: 1.5,
372						value: 0.2
373					} );
374					var scroll_delta = 0;
375					var scroll_tween = null;
376					var clear_scroll_busy = trx_addons_throttle( function() {
377						scroll_busy = false;
378						if ( scroll_tween ) {
379							scroll_tween.kill();
380							scroll_tween = false;
381						}
382					}, scroll_time * 1000 + 10, true );
383
384
385					window.smooth_scroll_listener = function( event ) {
386						if ( trx_addons_window_width() < 768 ) {
387							return;
388						}
389						if ( ! scroll_busy ) {
390							var depth = 8;
391							var $target = jQuery( event.target );
392							$scroll_target = $window;
393 							while( depth-- >= 0 ) {
394								if ( [ 'scroll', 'auto' ].indexOf( $target.css('overflow-y') ) >= 0 ) {
395									$scroll_target = $target;
396									break;
397								}
398								$target = $target.parents( 'div,section,nav,ul' ).eq(0);
399							}
400						}
401						if ( $scroll_target != $window ) {
402							scroll_busy = true;
403							setTimeout( function() { scroll_busy = false; }, scroll_time + 10 );
404							return;
405						}
406						event.preventDefault();
407						var delta = event.wheelDelta / 120 || -event.detail / 3;
408						if ( trx_addons_browser_is_ios() ) delta = Math.max( -1, Math.min( 1, delta ) );
409						scroll_coef.value = scroll_busy && scroll_delta * delta > 0 ? Math.min( scroll_coef.max, scroll_coef.value * scroll_coef.multi ) : scroll_coef.start;
410						scroll_delta = delta;
411						var scroll_top = $scroll_target.scrollTop();
412						var scroll_to = scroll_top - parseInt( delta * scroll_coef.value * scroll_distance, 10 );
413						scroll_busy = true;
414						if ( scroll_tween ) {
415							scroll_tween.kill();
416						}
417						scroll_tween = TweenMax.to( $scroll_target, scroll_time, {
418							onStart: function() {
419								scroll_busy = true;
420								clear_scroll_busy();
421								trx_addons_do_action( 'trx_addons_action_smooth_scroll_start', this, $scroll_target, scroll_to, scroll_time );
422							},
423							onInterrupt: function() {
424								scroll_busy = false;
425								scroll_tween = null;
426								trx_addons_do_action( 'trx_addons_action_smooth_scroll_interrupt', this, $scroll_target, scroll_to, scroll_time );
427							},
428							onComplete: function() {
429								scroll_busy = false;
430								scroll_tween = null;
431								trx_addons_do_action( 'trx_addons_action_smooth_scroll_complete', this, $scroll_target, scroll_to, scroll_time );
432							},
433							onUpdate: function() {
434								trx_addons_do_action( 'trx_addons_action_smooth_scroll_update', this, $scroll_target, scroll_to, scroll_time );
435							},
436							scrollTo: {
437								y: scroll_to,
438								autoKill: true
439							},
440							ease: trx_addons_apply_filters( 'trx_addons_filter_smooth_scroll_ease', Power1.easeOut ),   // Power1 (easest) - Power4 (sharpest)
441//							autoKill: true,
442							overwrite: true, // 5
443							tween_value: 100
444						} );
445					};
446
447					window.smooth_scroll_disable = function() {
448						if (typeof smooth_scroll_listener !== 'undefined') {
449							window.removeEventListener( 'mousewheel', smooth_scroll_listener, {
450								passive: false
451							} );
452							window.removeEventListener( 'DOMMouseScroll', smooth_scroll_listener, {
453								passive: false
454							} );
455						}
456					};
457
458					window.smooth_scroll_enable = function() {
459						if (typeof smooth_scroll_listener !== 'undefined') {
460							window.addEventListener( 'mousewheel', smooth_scroll_listener, {
461								passive: false
462							} );
463							window.addEventListener( 'DOMMouseScroll', smooth_scroll_listener, {
464								passive: false
465							} );
466						}
467					};
468
469					// Add listener if is not a touch device
470					if ( ! ie_mobile && ! $html.hasClass( 'touch' ) ) {
471						smooth_scroll_enable();
472					}
473				}
474
475				// Inject our code to the VC function wpb_prepare_tab_content()
476				// to init our elements on the new VC tabs, tour and accordion activation
477				typeof window.wpb_prepare_tab_content == "function"
478					&& typeof window.wpb_prepare_tab_content_old == "undefined"
479					&& (window.wpb_prepare_tab_content_old = window.wpb_prepare_tab_content)
480					&& (window.wpb_prepare_tab_content = function(e, ui) {
481						// Call ThemeREX Addons actions
482						if (typeof ui.newPanel !== 'undefined' && ui.newPanel.length > 0) {
483							$document.trigger( 'action.init_hidden_elements', [ui.newPanel] );
484						} else if (typeof ui.panel !== 'undefined' && ui.panel.length > 0) {
485							$document.trigger( 'action.init_hidden_elements', [ui.panel] );
486						}
487						// Call old VC handler
488						window.wpb_prepare_tab_content_old(e, ui);
489					} );
490				// Inject our code in the VC function vc_accordionActivate()
491				// to init our elements on the old VC accordion activation
492				typeof window.vc_accordionActivate == "function"
493					&& typeof window.vc_accordionActivate_old == "undefined"
494					&& (window.vc_accordionActivate_old = window.vc_accordionActivate)
495					&& (window.vc_accordionActivate = function(e, ui) {
496						// Call ThemeREX Addons actions
497						if (typeof ui.newPanel !== 'undefined' && ui.newPanel.length > 0) {
498							$document.trigger( 'action.init_hidden_elements', [ui.newPanel] );
499						} else if (typeof ui.panel !== 'undefined' && ui.panel.length > 0) {
500							$document.trigger( 'action.init_hidden_elements', [ui.panel] );
501						}
502						// Call old VC handler
503						window.vc_accordionActivate_old(e, ui);
504					} );
505			}
506			$document.trigger('action.init_trx_addons');
507			$document.trigger('action.after_init_trx_addons');
508		}	// trx_addons_init_actions
509
510		// Init components on DOM ready
511		//==============================================
512		function trx_addons_ready_actions(e, container) {
513
514			if (container === undefined) container = $body;
515			// Maybe comment ? (because this function is called on 'action.init_hidden_elements')
516			//update_jquery_links();
517
518			// Animate to the page-inner links
519			//----------------------------------------------
520			if (TRX_ADDONS_STORAGE['animate_inner_links'] > 0 && !container.hasClass('animate_to_inited')) {
521				container
522					.addClass('animate_to_inited')
523					.on('click', 'a', function(e) {
524						var link_obj = jQuery(this);
525						var link_parent = link_obj.parent();
526						// Skip tabs and accordions
527						if (link_parent.parent().hasClass('trx_addons_tabs_titles')	// trx_addons_tabs
528							|| link_obj.hasClass('trx_addons_panel_link')			// sc_layouts_panel
529							|| link_obj.hasClass('trx_addons_popup_link')			// sc_layouts_popup
530							|| link_parent.hasClass('vc_tta-tab') 					// new VC tabs, old VC tabs, new VC tour
531							|| link_obj.hasClass('vc_pagination-trigger')			// pagination in VC tabs
532							|| link_obj.hasClass('ui-tabs-anchor') 					// old VC tour
533							|| link_parent.hasClass('vc_tta-panel-title')			// new VC accordion
534							|| link_parent.hasClass('wpb_accordion_header') 		// old VC accordion
535							|| link_parent.parents('.wc-tabs').length > 0 			// WooCommerce tabs on the single product page
536							|| link_parent.hasClass('elementor-tab-title')			// Elementor's tabs
537							|| link_parent.parents('ul[class*="tabs"]').length > 0 	// All other tabs
538						) {
539							return true;
540						}
541						var href = link_obj.attr('href');
542						if ( ! href || href == '#' ) return true;
543						if ( trx_addons_is_local_link(href) ) {
544							var pos = href.indexOf('#'),
545								offset = 0;
546							if ( pos >= 0 ) {
547								href = href.substr( pos );
548								if ( jQuery(href).length > 0 ) {
549									// Removing class before menu closing animations started
550									// is need to animate inner links and scrolling to the anch
550or
551									// Attention! Is a temporary (theme-specific) solution -
552									//            it must be placed to the theme's init script.
553									if ( $body.hasClass( 'menu_mobile_opened' ) ) {
554										$body.removeClass( 'menu_mobile_opened' );
555									}
556									$document.trigger( 'action.trx_addons_inner_links_click', [ link_obj, e ] );
557									trx_addons_document_animate_to( href );
558									e.preventDefault();
559									return false;
560								}
561							}
562						}
563					});
564			}
565
566			// Add parameters target="_blank" and rel="nofollow" to all external links
567			//------------------------------------------------------------------------
568			if (TRX_ADDONS_STORAGE['add_target_blank'] > 0) {
569				jQuery('a').filter(function() {
570					return this.hostname
571							&& this.hostname !== location.hostname
572							&& this.pathname
573							&& ['.png', '.jpg', '.gif'].indexOf( this.pathname.slice( -4 ) ) < 0;
574				}).each( function() {
575					var link = jQuery(this),
576						rel  = link.attr('rel');
577					if ( link.attr('target') != '_blank' ) {
578						link.attr('target', '_blank');
579					}
580					if ( ! rel || rel.indexOf('nofollow') == -1 ) {
581						link.attr('rel', ( rel ? rel + ' ' : '' ) + 'nofollow');
582					}
583				});
584			}
585
586			// Hide empty figcaptions
587			jQuery('figcaption').each( function() {
588				var $self = jQuery(this);
589				if ( $self.text() === '' ) {
590					$self.hide();
591				}
592			});
593
594			// Tabs
595			//------------------------------------
596			if (jQuery.ui && jQuery.ui.tabs) {
597				var $tabs = container.find('.trx_addons_tabs:not(.inited)');
598				if ( $tabs.length > 0) {
599					$tabs.each( function() {
600						var $self = jQuery(this);
601						// Get initially opened tab
602						var init = $self.data('active');
603						if (isNaN(init)) {
604							init = 0;
605							var active = $self.find('> ul > li[data-active="true"]').eq(0);
606							if (active.length > 0) {
607								init = active.index();
608								if (isNaN(init) || init < 0) init = 0;
609							}
610						} else {
611							init = Math.max(0, init);
612						}
613						// Get disabled tabs
614						var disabled = [];
615						$self.find('> ul > li[data-disabled="true"]').each( function() {
616							disabled.push(jQuery(this).index());
617						});
618						// Init tabs
619						$self.addClass('inited').tabs({
620							active: init,
621							disabled: disabled,
622							show: {
623								effect: 'fadeIn',
624								duration: 300
625							},
626							hide: {
627								effect: 'fadeOut',
628								duration: 300
629							},
630							create: function( event, ui ) {
631								if ( ui.panel.length > 0 && ! ready_busy ) {
632									$document.trigger( 'action.create_tab', [ui.panel] );
633									$document.trigger( 'action.init_hidden_elements', [ui.panel] );
634								}
635							},
636							activate: function( event, ui ) {
637								if ( ui.oldPanel.length > 0 && ! ready_busy ) {
638									$document.trigger( 'action.deactivate_tab', [ui.oldPanel] );
639								}
640								if ( ui.newPanel.length > 0 && ! ready_busy ) {
641									$document.trigger( 'action.activate_tab', [ui.newPanel] );
642									$document.trigger( 'action.init_hidden_elements', [ui.newPanel] );
643									$window.trigger( 'resize' );
644								}
645							}
646						});
647					});
648				}
649			}
650		
651		
652			// Accordion
653			//------------------------------------
654			if (jQuery.ui && jQuery.ui.accordion) {
655				var $accordion = container.find('.trx_addons_accordion:not(.inited)');
656				if ( $accordion.length > 0) {
657					$accordion.each(function () {
658						// Get headers selector
659						var accordion = jQuery(this);
660						var headers = accordion.data('headers') || 'h5';
661						// Get height style
662						var height_style = accordion.data('height-style') || 'content';
663						// Get collapsible
664						var collapsible = accordion.data('collapsible') || false;
665						// Get initially opened tab
666						var init = accordion.data('active');
667						var active = false;
668						if ( isNaN( init ) ) {
669							init = 0;
670							active = accordion.find( headers + '[data-active="true"]' ).eq(0);
671							if ( active.length > 0 ) {
672								while ( ! active.parent().hasClass( 'trx_addons_accordion' ) ) {
673									active = active.parent();
674								}
675								init = active.index();
676								if ( isNaN( init ) || init < 0 ) init = 0;
677							}
678						} else {
679							init = Math.max( 0, init );
680						}
681						// Init accordion
682						accordion.addClass('inited').accordion({
683							active: init,
684							collapsible: collapsible,
685							header: headers,
686							heightStyle: height_style,
687							create: function( event, ui ) {
688								if ( ui.panel.length > 0 && ! ready_busy ) {
689									$document.trigger( 'action.create_accordion', [ui.panel] );
690									$document.trigger( 'action.init_hidden_elements', [ui.panel] );
691								} else if ( active !== false && active.length > 0 ) {
692									// If headers and panels wrapped into div
693									active.find('>'+headers).trigger('click');
694								}
695							},
696							activate: function( event, ui ) {
697								if (ui.oldPanel.length > 0 && ! ready_busy) {
698									$document.trigger( 'action.deactivate_accordion', [ui.oldPanel] );
699								}
700								if (ui.newPanel.length > 0 && ! ready_busy) {
701									$document.trigger( 'action.activate_accordion', [ui.newPanel] );
702									$document.trigger( 'action.init_hidden_elements', [ui.newPanel] );
703									$window.trigger( 'resize' );
704								}
705							}
706						});
707					});
708				}
709			}
710		
711			// Color Picker
712			//----------------------------------------------------------------
713			var cp = container.find('.trx_addons_color_selector:not(.inited)'),
714				cp_created = false;
715			if (cp.length > 0) {
716				cp.addClass('inited').each( function() {
717					var $self = jQuery(this);
718					// Internal ColorPicker
719					if ( $self.hasClass('iColorPicker') ) {
720						if (!cp_created) {
721							trx_addons_color_picker();
722							cp_created = true;
723						}
724						trx_addons_change_field_colors($self);
725						$self
726							.on('focus', function (e) {
727								trx_addons_color_picker_show(null, jQuery(this), function(fld, clr) {
728									fld.val(clr).trigger('change');
729									trx_addons_change_field_colors(fld);
730								});
731							})
732							.on('change', function(e) {
733								trx_addons_change_field_colors(jQuery(this));
734							});
735						
736					// WP ColorPicker - Iris
737					} else if (typeof jQuery.fn.wpColorPicker != 'undefined') {
738						$self.wpColorPicker({
739							// you can declare a default color here,
740							// or in the data-default-color attribute on the input
741							//defaultColor: false,
742					
743							// hide the color picker controls on load
744							//hide: true,
745					
746							// show a group of common colors beneath the square
747							// or, supply an array of colors to customize further
748							//palettes: true,
749					
750							// a callback to fire whenever the color changes to a valid color
751							change: function(e, ui){
752								jQuery(e.target).val(ui.color).trigger('change');
753							},
754					
755							// a callback to fire when the input is emptied or an invalid color
756							clear: function(e) {
757								jQuery(e.target).prev().trigger('change');
758							}
759						});
760					}
761				});
762			}
763		
764			// Change colors of the field
765			function trx_addons_change_field_colors(fld) {
766				var clr = fld.val(),
767					hsb = trx_addons_hex2hsb(clr);
768				fld.css({
769					'backgroundColor': clr,
770					'color': hsb['b'] < 70 ? '#fff' : '#000'
771				});
772			}
773
774
775			// Range Slider
776			//------------------------------------
777			if (jQuery.ui && jQuery.ui.slider) {
778				var $range_slider = container.find('.trx_addons_range_slider:not(.inited)');
779				if ($range_slider.length > 0) {
780					$range_slider.each( function () {
781						// Get parameters
782						var range_slider = jQuery(this);
783						var linked_field = range_slider.data('linked_field');
784						if (linked_field===undefined) linked_field = range_slider.prev('input[type="hidden"]');
785						else linked_field = jQuery('#'+linked_field);
786						if (linked_field.length == 0) return;
787						var range_slider_cur = range_slider.find('> .trx_addons_range_slider_label_cur');
788						var range_slider_min = range_slider.find('> .trx_addons_range_slider_label_min');
789						var range_slider_max = range_slider.find('> .trx_addons_range_slider_label_max');
790						var range_slider_type = range_slider.data('range');
791						if (range_slider_type===undefined) range_slider_type = 'min';
792						var values = linked_field.val().split(',');
793						var minimum = range_slider.data('min');
794						if (minimum===undefined) minimum = 0;
795						var maximum = range_slider.data('max');
796						if (maximum===undefined) maximum = 0;
797						var step = range_slider.data('step');
798						if (step===undefined) step = 1;
799						// Init range slider
800						var init_obj = {
801							range: range_slider_type,
802							min: minimum,
803							max: maximum,
804							step: step,
805							slide: function(event, ui) {
806								trx_addons_range_slider_update_current_values_position(ui, range_slider_type === 'min' ? [ui.value] : ui.values);
807							},
808							change: function(event, ui) {
809								trx_addons_range_slider_update_current_values_position(ui, range_slider_type === 'min' ? [ui.value] : ui.values);
810							},
811							create: function(event, ui) {
812								trx_addons_range_slider_update_current_values_position(ui, values);
813							}
814						};
815						if (range_slider_type === true) {
816							init_obj.values = values;
817						} else {
818							init_obj.value = values[0];
819						}
820						range_slider.addClass('inited').slider(init_obj);
821
822						// Update position of labels with the current values
823						function trx_addons_range_slider_update_current_values_position(ui, cur_values) {
824							linked_field.val( cur_values.join(',') ).trigger('change');
825							for (var i=0; i < cur_values.length; i++) {
826								range_slider_cur.eq(i)
827										.html(cur_values[i])
828										.css('left', Math.max(0, Math.min(100, (cur_values[i]-minimum)*100/(maximum-minimum)))+'%');
829								if ( range_slider_type !== 'min' && range_slider_cur.eq(i).css( 'display' ) == 'none' ) {
830									if ( i == 0 ) {
831										range_slider_min.html( cur_values[i] );
832									} else {
833										range_slider_max.html( cur_values[i] );
834									}
835								}
836							}
837						}
838					});
839				}
840			}
841		
842		
843			// Select2
844			//------------------------------------
845			if (jQuery.fn && jQuery.fn.select2) {
846				container.find('.trx_addons_select2:not(.inited)').addClass('inited').select2();
847			}
848
849
850			// Video player
851			//----------------------------------------------
852
853			// Play video on hover (for desktops) or on touchstart (for mobile devices)
854			var $play_on_hover = container.find( '.trx_addons_video_hover:not(.inited)' );
855			var touchstart_just_fired = false;
856			if ( $play_on_hover.length > 0 ) {
857				$play_on_hover
858					.addClass( 'inited' )
859					.on( 'mouseenter touchstart', function(e) {
860						var $self = jQuery( this );
861						if ( ! $self.hasClass( 'trx_addons_video_hover_play' ) && ( e.type != 'touchstart' || ! touchstart_just_fired ) ) {
862							$self
863								.data( 'trx-addons-user-actions', 1 )
864								.removeClass( 'trx_addons_video_hover_pause' )
865								.addClass( 'trx_addons_video_hover_play' )
866								.find( 'video' ).get(0).play();
867							touchstart_just_fired = true;
868							setTimeout( function() {
869								touchstart_just_fired = false;
870							}, 300 );
871						}
872					} )
873					.on( 'mouseleave touchstart', function(e) {
874						var $self = jQuery( this );
875						if ( $self.hasClass( 'trx_addons_video_hover_play' ) && ( e.type != 'touchstart' || ! touchstart_just_fired ) ) {
876							$self
877								.data( 'trx-addons-user-actions', 1 )
878								.removeClass( 'trx_addons_video_hover_play' )
879								.addClass( 'trx_addons_video_hover_pause' )
880								.find( 'video' ).get(0).pause();
881							$self
882								.find( '.trx_addons_video_subtitle_text' )
883									.one( typeof window.trx_addons_transition_end != 'undefined' ? trx_addons_transition_end() : 'transitionend', function() {
884										$self.removeClass( 'trx_addons_video_hover_pause' );
885									} );
886							touchstart_just_fired = true;
887							setTimeout( function() {
888								touchstart_just_fired = false;
889							}, 300 );
890						}
891					} );
892				// Autoplay/pause video on enter/leave to the viewport (if an option "autoplay" is on)
893				var $play_on_hover_autoplay = $play_on_hover.find( 'video[data-autoplay="1"]' );
894				if ( $play_on_hover_autoplay.length > 0 ) {
895					trx_addons_intersection_observer_add( $play_on_hover_autoplay, function( item, enter ) {
896						if ( item.data( 'trx-addons-user-actions' ) ) {
897							trx_addons_intersection_observer_remove( item );
898						} else if ( enter ) {
899							item
900								.addClass( 'trx_addons_video_hover_play' )
901								.get(0).play();
902						} else {
903							item
904								.removeClass( 'trx_addons_video_hover_play' )
905								.get(0).pause();
906						}
907					} );
908				}
909			}
910
911			// Video frame 'Play' button
912			var $video_hover = container.find('.trx_addons_video_player.with_cover .video_hover:not(.inited)');
913			if ( $video_hover.length > 0 ) {
914				$video_hover
915					.addClass( 'inited' )
916					.on( 'click', function(e) {
917						var $self = jQuery( this );
918
919						// If video in the popup
920						if ( $self.hasClass( 'trx_addons_popup_link' ) ) {
921							return true;
922						}
923
924						// Replace a content of the container with the video player
925						trx_addons_insert_video_iframe( $self.parents('.trx_addons_video_player').eq(0).addClass('video_play').find('.video_embed'), $self.data('video') );
926		
927						// If video in the slide
928						var slider = $self.parents('.slider_swiper').eq(0);
929						if ( slider.length > 0 ) {
930							var id = slider.attr('id');
931							if ( typeof TRX_ADDONS_STORAGE['swipers'][id].autoplay != 'undefined' ) {
932								TRX_ADDONS_STORAGE['swipers'][id].autoplay.stop();
933								// If slider have controller - stop it too
934								id = slider.data('controller');
935								if ( id && TRX_ADDONS_STORAGE['swipers'][id+'_swiper'] ) {
936									TRX_ADDONS_STORAGE['swipers'][id+'_swiper'].autoplay.stop();
937								}
938							}
939						} else {
940							$self.fadeOut();
941						}
942		
943						e.preventDefault();
944						
945						$document.trigger( 'action.init_hidden_elements', [$self.parents('.trx_addons_video_player').eq(0)] );
946						$window.trigger('resize');
947						
948						return false;
949					})
950					.parents('.trx_addons_video_player')
951					.on( 'click', function(e) {
952						var $self = jQuery(this);
953						if ( ! $self.hasClass('video_play') ) {
954							jQuery(this).find('.video_hover').trigger('click');
955							e.preventDefault();
956							return false;
957						}
958					} );				
959			}
960
961			// Video player controller
962			var $video_controller = container.find('.trx_addons_video_list_controller_wrap:not(.inited)');
963			if ($video_controller.length > 0) {
964				// Init controller
965				$video_controller
966					.addClass('inited')
967					.on('click', '.trx_addons_video_list_controller_item > a[href="#"]', function(e) {
968
969						e.preventDefault();
970
971						var item = jQuery(this).parent(),
972							video = item.data('video'),
973							title = item.data('title'),
974							video_wrap = item.parents('.trx_addons_video_list').find('.trx_addons_video_list_video_wrap .trx_addons_video_player').parent();
975
976						if ( ! item.hasClass('trx_addons_video_list_controller_item_active') && video && video_wrap.length == 1 ) {
977							item.parent().find('.trx_addons_video_list_controller_item_active').removeClass('trx_addons_video_list_controller_item_active');
978							item.addClass('trx_addons_video_list_controller_item_active');
979							var autoplay = video_wrap.find('.with_video_autoplay');
980							if ( autoplay.length ) {
981								autoplay
982									.removeClass( 'with_video_autoplay video_autoplay_inited video_autoplay_started' )
983									.find('video_frame_controls').remove();
984								trx_addons_intersection_observer_remove( autoplay );
985								trx_addons_find_video_autoplay();
986							}
987							video_wrap
988								.fadeTo( 300, 0, function() {
989									video_wrap.height( video_wrap.height() );
990									// Replace a content of the container with the video player
991									trx_addons_insert_video_iframe( video_wrap, video );
992									// Add a title
993									if ( title ) {
994										video_wrap.append( title );
995									}
996									video_wrap.find('video').removeAttr('width').removeAttr('height');
997									$document.trigger( 'action.init_hidden_elements', [video_wrap] );
998									$window.trigger( 'resize' );
999									video_wrap.height('auto');
1000								} )
1001								.fadeTo( 300, 1, function() {
1002									if ( item.data( 'autoplay' ) > 0 && video_wrap.find( '.trx_addons_video_player .video_hover').length > 0 ) {
1003										video_wrap.find( '.trx_addons_video_player .video_hover').eq(0).trigger( 'click' );
1004									}
1005								} );
1006						}
1007
1008						return false;
1009					});
1010				// Preload cover images
1011				setTimeout( function() {
1012					$video_controller.find('[data-video]').each( function() {
1013						var video = jQuery(this).data('video');
1014						if ( video ) {
1015							var img = jQuery('img', video);
1016							if ( img.length ) {
1017								var obj = new Image();
1018								obj.src = img.attr('src');
1019							}
1020						}
1021					} );
1022				}, trx_addons_apply_filters('trx_addons_filter_video_controller_preload_images_timeout', 0) );
1023			}
1024
1025			// Video sticky
1026			$video_sticky.each( function() {
1027				
1028				var video = jQuery(this);
1029
1030				// Close button
1031				video
1032					.find( '.trx_addons_video_sticky_close:not(.inited)' )
1033					.addClass( 'inited' )
1034					.on( 'click', function( e ) {
1035
1036						e.preventDefault();
1037
1038						jQuery(this).hide();
1039
1040						trx_addons_intersection_observer_remove( video );
1041
1042						if ( _video_sticky_fade ) {
1043							video.addClass('trx_addons_video_sticky_on_fade').stop().animate({opacity:0}
1043, 300, function() {
1044								video.parents('.post_featured').removeClass( 'with_video_sticky_on' );
1045								video.height('auto').removeClass( 'trx_addons_video_sticky trx_addons_video_sticky_on trx_addons_video_sticky_on_fade' ).stop().animate({'opacity': 1}, 500);
1046								$video_sticky = jQuery('.trx_addons_video_sticky');
1047								$window.trigger('resize');
1048							});
1049						} else {
1050							video.parents('.post_featured').removeClass( 'with_video_sticky_on' );
1051							video.height('auto').removeClass('trx_addons_video_sticky trx_addons_video_sticky_on');
1052							$video_sticky = jQuery('.trx_addons_video_sticky');
1053							$window.trigger('resize');
1054						}
1055
1056						return false;
1057					} );
1058
1059				// Fix / Unfix sticky video to the bottom of the viewport (window)
1060				trx_addons_intersection_observer_add( video, function( item, enter, entry ) {
1061					var video = item,
1062						video_top = video.offset().top,
1063						video_height = video.height();
1064					if ( ! enter ) {
1065						if ( ( typeof entry != 'object' || entry.boundingClientRect.top < 0 )
1066								&& ! video.hasClass('trx_addons_video_sticky_on')
1067						) {
1068							// Stick video only if it present in .video_frame
1069							if ( video.find( '.video_frame' ).html().trim().length > 30 ) {
1070								video.parents('.post_featured').addClass( 'with_video_sticky_on' );
1071								if ( _video_sticky_fade ) {
1072									video.height( video_height ).css('opacity', 0).addClass( 'trx_addons_video_sticky_on' ).stop().animate({opacity:1}, 500);
1073								} else {
1074									video.height( video_height ).addClass( 'trx_addons_video_sticky_on' );
1075								}
1076							}
1077						}
1078					} else {
1079						if ( video.hasClass('trx_addons_video_sticky_on') && ! video.hasClass('trx_addons_video_sticky_on_fade') ) {
1080							if ( _video_sticky_fade ) {
1081								video.addClass('trx_addons_video_sticky_on_fade').stop().animate({opacity:0}
1081, 300, function() {
1082									video.parents('.post_featured').removeClass( 'with_video_sticky_on' );
1083									video.height('auto').removeClass( 'trx_addons_video_sticky_on trx_addons_video_sticky_on_fade' ).stop().animate({'opacity': 1}, 500);
1084									$window.trigger('resize');
1085								});
1086							} else {
1087								video.parents('.post_featured').removeClass( 'with_video_sticky_on' );
1088								video.height('auto').removeClass( 'trx_addons_video_sticky_on' );
1089								$window.trigger('resize');
1090							}
1091						}
1092					}
1093				} );
1094			} );
1095
1096			// Show autoplaing videos from not controlled sources
1097			$video_autoplay.each( function() {
1098				var $self = jQuery(this);
1099				if ( $self.find('iframe[src*="youtu"]').length === 0 ) {
1100					$self.find('.video_frame').addClass('video_frame_visible');
1101				}
1102			} );
1103
1104		
1105			// Popups & Panels
1106			//----------------------------------------------
1107
1108			// PrettyPhoto Engine
1109			if (TRX_ADDONS_STORAGE['popup_engine'] == 'pretty') {
1110				// Display lightbox on click on the image
1111				container
1112					.find( trx_addons_apply_filters( 'pretty-init-images',
1113							'a[href$="jpg"]:not(.inited):not([target="_blank"]):not([download])'
1114							+',a[href$="jpeg"]:not(.inited):not([target="_blank"]):not([download])'
1115							+',a[href$="png"]:not(.inited):not([target="_blank"]):not([download])'
1116							+',a[href$="gif"]:not(.inited):not([target="_blank"]):not([download])'
1117							)
1118						)
1119					.each( function() {
1120						var $self = jQuery(this);
1121						if ( ! $self.parent().hasClass('woocommerce-product-gallery__image')) {
1122							$self.attr('rel', 'prettyPhoto[slideshow]');
1123						}
1124					});
1125				var images = container.find( trx_addons_apply_filters( 'pretty-init-images-selector',
1126												'a[rel*="prettyPhoto"]'
1127												+ ':not(.inited)'
1128												+ ':not(.esgbox)'
1129												+ ':not(.fancybox)'
1130												+ ':not([target="_blank"])'
1131												+ ':not([data-rel*="pretty"])'
1132												+ ':not([rel*="magnific"])'
1133												+ ':not([data-rel*="magnific"])'
1134												+ ':not([data-elementor-lightbox-slideshow])'
1135												+ ':not([data-elementor-open-lightbox="yes"])'
1136												+ ':not([data-elementor-open-lightbox="default"])'
1137												)
1138											).addClass('inited');
1139				if ( images.length > 0 ) {
1140					try {
1141						images.prettyPhoto( trx_addons_apply_filters( 'pretty-init-images-params', {
1142							social_tools: '',
1143							theme: 'facebook',
1144							deeplinking: false
1145						} ) );
1146					} catch (e) {}
1147				}
1148			
1149			// or Magnific Popup Engine
1150			} else if (TRX_ADDONS_STORAGE['popup_engine']=='magnific' && typeof jQuery.fn.magnificPopup != 'undefined') {
1151				// Display lightbox on click on the image
1152				container
1153					.find( trx_addons_apply_filters( 'mfp-init-images',
1154							 'a[href$="jpg"]:not(.inited):not([target="_blank"]):not([download])'
1155							+',a[href$="jpeg"]:not(.inited):not([target="_blank"]):not([download])'
1156							+',a[href$="png"]:not(.inited):not([target="_blank"]):not([download])'
1157							+',a[href$="gif"]:not(.inited):not([target="_blank"]):not([download])'
1158							)
1159						)
1160					.each( function() {
1161						var $self = jQuery(this);
1162						if ( trx_addons_apply_filters( 'mfp-init-images-allow',
1163								$self.closest('.cq-dagallery').length === 0
1164									&& $self.closest('.woocommerce-product-gallery__image').length === 0
1165									&& ! $self.hasClass('prettyphoto')
1166									&& ! $self.hasClass('esgbox'),
1167								$self
1168								)
1169						) {
1170							$self.attr('rel', 'magnific');
1171						}
1172					});
1173				var images = container.find( trx_addons_apply_filters( 'mfp-init-images-selector',
1174												'a[rel*="magnific"]'
1175												+ ':not(.inited)'
1176												+ ':not(.esgbox)'
1177												+ ':not(.fancybox)'
1178												+ ':not([target="_blank"])'
1179												+ ':not([download])'
1180												+ ':not(.prettyphoto)'
1181												+ ':not([rel*="pretty"])'
1182												+ ':not([data-rel*="pretty"])'
1183												+ ':not([data-elementor-lightbox-slideshow])'
1184												+ ':not([data-elementor-open-lightbox="yes"])'
1185												+ ':not([data-elementor-open-lightbox="default"])'
1186												)
1187											).addClass('inited');
1188				if ( images.length > 0 ) {
1189					// Unbind prettyPhoto
1190					setTimeout(function() {	images.off('click.prettyphoto'); }, 100);
1191					// Bind Magnific
1192					try {
1193						images.magnificPopup( trx_addons_apply_filters( 'mfp-init-images-p
1193arams', {
1194							type: 'image',
1195							mainClass: 'mfp-img-mobile',
1196							closeOnContentClick: true,
1197							closeBtnInside: true,
1198							fixedContentPos: true,
1199							midClick: true,
1200							//removalDelay: 500, 
1201							preloader: true,
1202							tLoading: TRX_ADDONS_STORAGE['msg_magnific_loading'],
1203							tClose: TRX_ADDONS_STORAGE['msg_magnific_close'],
1204							closeMarkup: '<button title="%title%" aria-label="%title%" type="button" class="mfp-close"><span class="mfp-close-icon">&#215;</span></button>',
1205							gallery:{
1206								enabled: true
1207							},
1208							image: {
1209								tError: TRX_ADDONS_STORAGE['msg_magnific_error'],
1210								verticalFit: true,
1211								titleSrc: function(item) {
1212									var title = '',
1213										$el = typeof item.el != 'undefined' ? jQuery( item.el ) : null;
1214									if ( $el && $el.length > 0 ) {
1215										var $next = $el.next();
1216										if ( $next.length > 0 && $next.get(0).tagName == 'FIGCAPTION' ) {
1217											title = $next.text();
1218										} else if ( $el.attr( 'title' ) ) {
1219											title = $el.attr( 'title' );
1220										} else {
1221											var $img = $el.find( 'img' );
1222											if ( $img.length > 0 ) {
1223												title = $img.attr( 'alt' );
1224												if ( ! title ) {
1225													title = $img.data('caption');
1226												}
1227											}
1228										}
1229									}
1230									return title;
1231								}
1232							},
1233							zoom: {
1234								enabled: true,
1235								duration: 300,
1236								easing: 'ease-in-out',
1237								opener: function(openerElement) {
1238									// openerElement is the element on which popup was initialized, in this case its <a> tag
1239									// you don't need to add "opener" option if this code matches your needs, it's defailt one.
1240									if (!openerElement.is('img')) {
1241										if (openerElement.parents('.trx_addons_hover').find('img').length > 0)
1242											openerElement = openerElement.parents('.trx_addons_hover').find('img');
1243										else if (openerElement.find('img').length > 0)
1244											 openerElement = openerElement.find('img');
1245										else if (openerElement.siblings('img').length > 0)
1246											 openerElement = openerElement.siblings('img');
1247										else if (openerElement.parent().parent().find('img').length > 0)
1248											 openerElement = openerElement.parent().parent().find('img');
1249									}
1250									return openerElement; 
1251								}
1252							},
1253							callbacks: {
1254								beforeClose: function(){
1255									jQuery('.mfp-figure figcaption').hide();
1256									jQuery('.mfp-figure .mfp-arrow').hide();
1257								}
1258							}
1259						} ) );
1260					} catch (e) {}
1261				}
1262
1263				// Prepare links to popups & panels
1264				//----------------------------------------
1265				var on_leaving_site = [],
1266					in_page_edit_mode = $body.hasClass('elementor-editor-active')
1267										|| $body.hasClass('wp-admin')
1268										|| $body.hasClass('block-editor-page');
1269				// Init popups and panels links
1270				container.find('.sc_layouts_popup:not(.inited),.sc_layouts_panel:not(.inited)').each( function() {
1271					var $self = jQuery(this),
1272						id = $self.attr('id'),
1273						show = false;
1274					if (!id) return;
1275					var is_panel = $self.hasClass('sc_layouts_panel'),
1276						link = jQuery('a[href="#'+id+'"],' + ( is_panel ? '.trx_addons_panel_link[data-panel-id="'+id+'"]' : '.trx_addons_popup_link[data-popup-id="'+id+'"]' ) );
1277					if (link.length === 0) {
1278						$body.append('<a href="#'+id+'" class="trx_addons_hidden"></a>');
1279						link = jQuery('a[href="#'+id+'"]');
1280					}
1281					if ($self.hasClass('sc_layouts_show_on_page_load')) {
1282						show = true;
1283					} else if ($self.hasClass('sc_layouts_show_on_page_load_once') && trx_addons_get_cookie('trx_addons_show_on_page_load_once_'+id) != '1') {
1284						trx_addons_set_cookie('trx_addons_show_on_page_load_once_'+id, '1');
1285						show = true;
1286					} else if ($self.hasClass('sc_layouts_show_on_page_close') && trx_addons_get_cookie('trx_addons_show_on_page_close_'+id) != '1') {
1287						on_leaving_site.push({
1288							link: link,
1289							id: id
1290						});
1291					}
1292					if (show) {
1293						// Display popups (panels) on the page (site) load
1294						if ( ! in_page_edit_mode ) {
1295							setTimeout( function() {
1296								link.trigger('click');
1297							}, $self.data('delay') > 0 ? $self.data('delay') * 1000 : 0 );
1298						}
1299					}
1300					link
1301						.addClass(is_panel ? 'trx_addons_panel_link' : 'trx_addons_popup_link')
1302						.data('panel', $self);
1303					$self
1304						.addClass('inited')
1305						.on('click', '.sc_layouts_panel_close', function(e) {
1306							trx_addons_close_panel($self);
1307							e.preventDefault();
1308							return false;
1309						});
1310				});
1311				
1312				// Display popup when user leaving site
1313				if ( on_leaving_site.length > 0 && ! in_page_edit_mode ) {
1314					var showed = false;
1315					$window.on( 'mousemove', function(e) {
1316						if ( showed ) return;
1317						var y = typeof e.clientY != 'undefined' ? e.clientY : 999;
1318						if ( y < trx_addons_adminbar_height() + 15 ) {
1319							showed = true;
1320							on_leaving_site.forEach( function(item) {
1321								item.link.trigger('click');
1322								trx_addons_set_cookie('trx_addons_show_on_page_close_'+item.id, '1');
1323							});
1324						}
1325					} );
1326				}
1327
1328				// Display lightbox on click on the popup link
1329				container.find( trx_addons_apply_filters( 'mfp-init-popup-selector', ".trx_addons_popup_link:not(.popup_inited)" ) )
1330					.addClass('popup_inited')
1331					.magnificPopup( trx_addons_apply_filters( 'mfp-init-popup-params', {
1332						type: 'inline',
1333						focus: 'input',
1334						removalDelay: trx_addons_apply_filters('trx_addons_filter_close_popup_timeout', 0),
1335						tLoading: TRX_ADDONS_STORAGE['msg_magnific_loading'],
1336						tClose: TRX_ADDONS_STORAGE['msg_magnific_close'],
1337						closeBtnInside: true,
1338						closeMarkup: '<button title="%title%" aria-label="%title%" type="button" class="mfp-close"><span class="mfp-close-icon">&#215;</span></button>',
1339						callbacks: {
1340							// Will fire when this before popup is opened
1341							// this - is Magnific Popup object
1342							beforeAppend: function () {
1343								var $mfp = this;
1344								// Prepare content for the popup
1345								$document.trigger('action.prepare_popup_elements', [$mfp.content, $mfp]);
1346							},
1347							beforeOpen: function() {
1348								var $mfp = this;
1349								$document.trigger('action.open_popup_elements', [$mfp.content]);
1350								// Add in animation (separately popup and bg overlay)
1351								var wrap_animation_in = mfp_get_animation( $mfp, 'wrap', 'open' ),
1352									bg_animation_in   = mfp_get_animation( $mfp, 'bg', 'open' );
1353								if ( bg_animation_in ) {
1354									$mfp.bgOverlay.addClass(bg_animation_in);
1355								}
1356								if ( wrap_animation_in ) {
1357									$mfp.wrap.addClass(wrap_animation_in);
1358								}
1359							},
1360							// Will fire when this exact popup is opened
1361							// this - is Magnific Popup object
1362							open: function () {
1363								// Get saved content or store it (if first open occured)
1364								trx_addons_prepare_popup_content(this.content, true);
1365							},
1366							beforeClose: function() {
1367								var $mfp = this;
1368								$document.trigger('action.close_popup_elements', [$mfp.content]);
1369								// Add out animation (separately popup and bg overlay)
1370								var wrap_animation_in  = mfp_get_animation( $mfp, 'wrap', 'open' ),
1371									bg_animation_in    = mfp_get_animation( $mfp, 'bg', 'open' ),
1372									wrap_animation_out = mfp_get_animation( $mfp, 'wrap', 'close' ),
1373									bg_animation_out   = mfp_get_animation( $mfp, 'bg', 'close' ),
1374									delay              = wrap_animation_out 
1375															? trx_addons_apply_filters( 'mfp-init-popup-animations-duration',
1376																wrap_animation_out.indexOf('faster') != -1
1377																	? 300
1378																	: ( wrap_animation_out.indexOf('fast') != -1
1379																		? 500
1380																		: (	wrap_animation_out.indexOf('normal') != -1
1381																			? 800
1382																			: ( wrap_animation_out.indexOf('slow') != -1
1383																				? 2000
1384																				: ( wrap_animation_out.indexOf('slower') != -1
1385																					? 3000
1386																					: 1000
1387																					)
1388																				)
1389																			)
1390																		),
1391																wrap_animation_out
1392																)
1393															: 0;
1394								$mfp.st.removalDelay += delay;
1395								if ( bg_animation_out ) {
1396									setTimeout( function() {
1397										$mfp.bgOverlay.removeClass(bg_animation_in).addClass(bg_animation_out);
1398									}, $mfp.st.removalDelay - delay );
1399								}
1400								if ( wrap_animation_out ) {
1401									setTimeout( function() {
1402										$mfp.wrap.removeClass(wrap_animation_in).addClass(wrap_animation_out);
1403									}, $mfp.st.removalDelay - delay );
1404								}
1405							},
1406							close: function () {
1407								var $mfp = this;
1408								// Save and remove content before closing
1409								// if its contain video, audio or iframe
1410								trx_addons_close_panel($mfp.content);
1411							},
1412							// resize event triggers only when height is changed or layout forced
1413							resize: function () {
1414								var $mfp = this;
1415								trx_addons_resize_actions(jQuery($mfp.content));
1416							}
1417						}
1418					} ) );
1419
1420				// Return animation name for popup
1421				var mfp_get_animation = function( mfp, item, event, defa ) {
1422					var defaults = trx_addons_apply_filters( 'mfp-init-popup-animations', {
1423						'wrap_open':  'fadeIn animated fast',
1424						'wrap_close': 'fadeOut animated fast',
1425						'bg_open':    'fadeIn animated fast',
1426						'bg_close':   'fadeOut animated fast'
1427					} );
1428					return mfp.st.el.attr('data-popup-'+item+'-'+event+'-animation')
1429								? mfp.st.el.attr('data-popup-'+item+'-'+event+'-animation')
1430								: trx_addons_apply_filters( 'mfp-init-popup-'+item+'-'+event+'-animation', defa ? defa 
1430: defaults[item+'_'+event] );
1431				};
1432
1433				// Open panel on click on the panel link
1434				container.find( trx_addons_apply_filters( 'init-panel-selector', ".trx_addons_panel_link:not(.panel_inited)" ) )
1435					.addClass('panel_inited')
1436					.on('click', function(e) {
1437						var panel = jQuery(this).data('panel');
1438						if ( ! panel.hasClass( 'sc_layouts_panel_opened' ) ) {
1439							$document.trigger('action.prepare_popup_elements', [panel]);
1440							trx_addons_prepare_popup_content(panel, true);
1441							panel.addClass('sc_layouts_panel_opened');
1442							$document.trigger('action.opened_popup_elements', [panel]);
1443							if (panel.prev().hasClass('sc_layouts_panel_hide_content')) panel.prev().addClass('sc_layouts_panel_opened');
1444							$body.addClass('sc_layouts_panel_opened sc_layouts_panel_opened_' + panel.data('panel-position'));
1445							var panel_class = panel.data('panel-class');
1446							if ( panel_class ) {
1447								$body.addClass( panel_class + '_opened' );
1448							}
1449						} else {
1450							trx_addons_close_panel(panel);
1451						}
1452						e.preventDefault();
1453						return false;
1454					});
1455
1456				// Close panel on click on the modal cover
1457				container.find('.sc_layouts_panel_hide_content:not(.inited)')
1458					.addClass('inited')
1459					.on('click', function(e) {
1460						trx_addons_close_panel(jQuery(this).next());
1461						e.preventDefault();
1462						return false;
1463					});
1464
1465				// Close panel
1466				window.trx_addons_close_panel = function(panel) {
1467					if ( panel.hasClass('sc_layouts_panel') ) {
1468						$document.trigger('action.close_popup_elements', [panel]);
1469					}
1470					setTimeout( function() {
1471						panel.removeClass('sc_layouts_panel_opened');
1472						if (panel.prev().hasClass('sc_layouts_panel_hide_content')) {
1473							panel.prev().removeClass('sc_layouts_panel_opened');
1474						}
1475						$body.removeClass('sc_layouts_panel_opened sc_layouts_panel_opened_left sc_layouts_panel_opened_right sc_layouts_panel_opened_top sc_layouts_panel_opened_bottom');
1476						var panel_class = panel.data('panel-class');
1477						if ( panel_class ) {
1478							$body.removeClass( panel_class + '_opened' );
1479						}
1480						if ( panel.data('popup-content') !== undefined ) {
1481							setTimeout( function() { panel.empty(); }, 500 );
1482						}
1483					}, trx_addons_apply_filters('trx_addons_filter_close_panel_timeout', panel.hasClass('sc_layouts_panel') && panel.data('animation-delay') !== undefined ? panel.data('animation-delay') : 0, panel) );
1484				};
1485
1486				// Get saved content for panel or popup or store it (if first open occured)
1487				window.trx_addons_prepare_popup_content = function(container, autoplay) {
1488					var wrapper = jQuery(container);
1489					// Store popup content to the data-param or restore it when popup open again (second time)
1490					// if popup contains audio or video or iframe
1491					if (wrapper.data('popup-content') === undefined) {
1492						var iframe = wrapper.find('iframe');
1493						if ( wrapper.find('audio').length
1494							|| wrapper.find('video').length
1495							|| ( iframe.length
1496								&& ( ( iframe.data('src') && iframe.data('src').search(/(youtu|vimeo|daily|facebook|instagram.com)/i) > 0 )
1497									|| 
1498									 ( iframe.attr('src') && iframe.attr('src').search(/(youtu|vimeo|daily|facebook|instagram.com)/i) > 0 )
1499									)
1500								)
1501						) {
1502							wrapper.data( 'popup-content', wrapper.html() );
1503						}
1504					} else {
1505						wrapper.html( wrapper.data('popup-content') );
1506						// Remove class 'inited' to reinit elements
1507						wrapper.find('.inited').removeClass('inited');
1508					}
1509					// Replace src with data-src
1510					wrapper.find('[data-src]').each(function() {
1511						jQuery(this).attr( 'src', jQuery(this).data('src') );
1512					});
1513					// Init hidden elements
1514					$document.trigger( 'action.init_hidden_elements', [wrapper] );
1515					// Init third-party plugins in the popup
1516					$document.trigger( 'action.init_popup_elements', [wrapper] );
1517					// If popup contain embedded video - add autoplay
1518					if (autoplay) trx_addons_set_autoplay(wrapper);
1519					// If popup contain essential grid
1520					var frame = wrapper.find('.esg-grid');
1521					if ( frame.length > 0 ) {
1522						var wrappers = [".esg-tc.eec", ".esg-lc.eec", ".esg-rc.eec", ".esg-cc.eec", ".esg-bc.eec"];
1523						for (var i = 0; i < wrappers.length; i++) {
1524							frame.find(wrappers[i]+'>'+wrappers[i]).unwrap();
1525						}
1526					}
1527					// Call resize actions for the new content
1528					$window.trigger('resize');
1529				};
1530			}
1531
1532
1533			// Views counter via AJAX
1534			//--------------------------------------
1535			if ( TRX_ADDONS_STORAGE['ajax_views'] && ! TRX_ADDONS_STORAGE['post_views_counter_inited'] ) {
1536				TRX_ADDONS_STORAGE['post_views_counter_inited'] = true;
1537				$document.on( 'action.ready_trx_addons', function() {
1538					setTimeout( function() {
1539						jQuery.post( TRX_ADDONS_STORAGE['ajax_url'], {
1540							action: 'post_counter',
1541							nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
1542							post_id: TRX_ADDONS_STORAGE['post_id'],
1543							views: 1
1544						} ).done( function( response ) {
1545							var rez = {};
1546							try {
1547								rez = JSON.parse(response);
1548							} catch (e) {
1549								rez = { error: TRX_ADDONS_STORAGE['ajax_error'] };
1550								console.log(response);
1551							}
1552							if ( rez.error === '' ) {
1553								jQuery('.post_meta_single .post_meta_views .post_meta_number,.sc_layouts_title_meta .post_meta_views .post_meta_number').html(rez.counter);
1554							}
1555							$document.trigger( 'action.got_ajax_response', {
1556								action: 'post_counter',
1557								result: rez
1558							} );
1559						} );
1560					}, 10 );
1561				} );
1562			}
1563
1564
1565			// Likes counter
1566			//---------------------------------------------
1567			var $likes = container.find('a.post_meta_likes:not(.inited),a.comment_counters_likes:not(.inited)');
1568			if ($likes.length > 0) {
1569				var likes_busy = false;
1570				$likes
1571					.addClass('inited')
1572					.on('click', function(e) {
1573						if ( ! likes_busy) {
1574							likes_busy = true;
1575							var button = jQuery(this);
1576							var inc = button.hasClass('enabled') ? 1 : -1;
1577							var post_id = button.hasClass('post_meta_likes') ? button.data('postid') :  button.data('commentid');
1578							var cookie_likes = trx_addons_get_cookie(button.hasClass('post_meta_likes') ? 'trx_addons_likes' : 'trx_addons_comment_likes');
1579							if (cookie_likes === undefined || cookie_likes===null) cookie_likes = '';
1580							jQuery.post( TRX_ADDONS_STORAGE['ajax_url'], {
1581								action: button.hasClass('post_meta_likes') ? 'post_counter' : 'comment_counter',
1582								nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
1583								post_id: post_id,
1584								likes: inc
1585							}).done(function(response) {
1586								var rez = {};
1587								try {
1588									rez = JSON.parse(response);
1589								} catch (e) {
1590									rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
1591									console.log(response);
1592								}
1593								if (rez.error === '') {
1594									var counter = rez.counter;
1595									if (inc == 1) {
1596										var title = button.data('title-dislike');
1597										button.removeClass('enabled trx_addons_icon-heart-empty').addClass('disabled trx_addons_icon-heart');
1598										cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ',';
1599									} else {
1600										var title = button.data('title-like');
1601										button.removeClass('disabled trx_addons_icon-heart').addClass('enabled trx_addons_icon-heart-empty');
1602										cookie_likes = cookie_likes.replace(','+post_id+',', ',');
1603									}
1604									button.data('likes', counter).attr('title', title).find(button.hasClass('post_meta_likes') ? '.post_meta_number' : '.comment_counters_number').html(counter);
1605									trx_addons_set_cookie( button.hasClass('post_meta_likes') ? 'trx_addons_likes' : 'trx_addons_comment_likes', cookie_likes, 365 * 24 * 60 * 60 * 1000);
1606								} else {
1607									alert(TRX_ADDONS_STORAGE['msg_error_like']);
1608								}
1609								likes_busy = false;
1610								$document.trigger( 'action.got_ajax_response', {
1611									action: button.hasClass('post_meta_likes') ? 'post_counter' : 'comment_counter',
1612									result: rez
1613								});
1614							});
1615						}
1616						e.preventDefault();
1617						return false;
1618					});
1619			}
1620		
1621		
1622			// Emotions counter
1623			//---------------------------------------------
1624			var $emotions = container.find('.trx_addons_emotions:not(.inited)');
1625			if ($emotions.length > 0) {
1626				var emotions_busy = false;
1627				$emotions
1628					.addClass('inited')
1629					.on('click', '.trx_addons_emotions_item', function(e) {
1630						if (!emotions_busy) {
1631							emotions_busy = true;
1632							var button = jQuery(this);
1633							var button_active = button.parent().find('.trx_addons_emotions_active');
1634							var post_id = button.data('postid');
1635							jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
1636								action: 'post_counter',
1637								nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
1638								post_id: post_id,
1639								emotion_inc: button.data('slug'),
1640								emotion_dec: button_active.length > 0 ? button_active.data('slug') : '',
1641							}).done(function(response) {
1642								var rez = {};
1643								try {
1644									rez = JSON.parse(response);
1645								} catch (e) {
1646									rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
1647									console.log(response);
1648								}
1649								if (rez.error === '') {
1650									var cookie_likes = trx_addons_get_cookie('trx_addons_emotions'),
1651										cookie_likes_new = ',';
1652									if (cookie_likes) {
1653										cookie_likes = cookie_likes.split(',');
1654										for (var i=0; i<cookie_likes.length; i++) {
1655											if (cookie_likes[i] === '') continue;
1656											var tmp = cookie_likes[i].split('=');
1657											if (tmp[0] != post_id) cookie_likes_new += cookie_likes[i] + ',';
1658										}
1659									}
1660									cookie_likes = cookie_likes_new;
1661									if (button_active.length > 0) {
1662										button_active.removeClass('trx_addons_emotions_active');
1663									}
1664									if (button_active.length == 0 || button.data('slug') != button_active.data('slug')) {
1665										button.addClass('trx_addons_emotions_active');
1666										cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + '=' + button.data('slug') + ',';
1667									}
1668									for (var i in rez.counter) {
1669										button.parent().find('[data-slug="'+i+'"] .trx_addons_emotions_item_number').html(rez.counter[i]);
1670									}
1671									trx_addons_set_cookie('trx_addons_emotions', cookie_likes, 365 * 24 * 60 * 60 * 1000);
1672								} else {
1673									alert(TRX_ADDONS_STORAGE['msg_error_like']);
1674								}
1675								emotions_busy = false;
1676								$document.trigger( 'action.got_ajax_response', {
1677									action: 'post_counter',
1678									result: rez
1679								});
1680							});
1681						}
1682						e.preventDefault();
1683						return false;
1684					});
1685			}
1686		
1687		
1688			// Socials share
1689			//----------------------------------------------
1690			var $share_caption = container.find('.socials_share .socials_caption:not(.inited)');
1691			if ($share_caption.length > 0) {
1692				$share_caption.each(function() {
1693					jQuery(this).addClass('inited').on('click', function(e) {
1694						jQuery(this).siblings('.social_items').slideToggle();	//.toggleClass('opened');
1695						e.preventDefault();
1696						return false;
1697					});
1698				});
1699			}
1700			var $share_items = container.find('.socials_share .social_items:not(.inited)');
1701			if ($share_items.length > 0) {
1702				$share_items.each(function() {
1703					jQuery(this)
1704						.addClass('inited')
1705						.on('click', '.social_item_popup', function(e) {
1706							var url = jQuery(this).data('link');
1707							window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0');
1708							e.preventDefault();
1709							return false;
1710						})
1711						.on('click', '.social_item[data-copy-link-url]', function(e) {
1712							var $self = jQuery(this),
1713								url = $self.data('copy-link-url');
1714							if ( url != '' ) {
1715								trx_addons_copy_to_clipboard( url );
1716								var msg = $self.data('message') ? $self.data('message') : TRX_ADDONS_STORAGE['msg_copied'];
1717								if ( msg ) {
1718									$self.attr('data-tooltip-text', msg);
1719									setTimeout( function() {
1720										$self.removeAttr('data-tooltip-text');
1721									}, 3000 );
1722								}
1723							}
1724							e.preventDefault();
1725							return false;
1726						});
1727				});
1728			}
1729
1730
1731			// Banners
1732			//-----------------------------------------------
1733			$banner_placeholder.each( function() {
1734				var item = jQuery(this);
1735				if ( item.data('banner-show') == 'permanent' ) {
1736					// Show banner on page load
1737					if ( ! item.hasClass( 'inited' ) ) {
1738						item.addClass( 'inited' );
1739						setTimeout( function() {
1740							item.after( item.data( 'banner' ) );
1741							var banner = item.next();
1742							item.remove();
1743							if ( banner.hasClass( 'banner_hidden' ) ) {
1744								trx_addons_when_images_loaded( banner, function() {
1745									banner.slideDown();
1746								} );
1747							}
1748						}, item.data('banner-delay') ? item.data('banner-delay') : 0 );
1749					}
1750				} else if ( item.data('banner-show') == 'scroll' ) {
1751					// Show banner on enter in the viewport
1752					trx_addons_intersection_observer_add( item, function( item, enter ) {
1753						if ( ! item.hasClass('inited') && enter ) {
1754							item.addClass('inited');
1755							trx_addons_intersection_observer_remove( item );
1756							setTimeout( function() {
1757								item.after( item.data( 'banner' ) );
1758								var banner = item.next();
1759								item.remove();
1760								if ( banner.hasClass( 'banner_hidden' ) ) {
1761									trx_addons_when_images_loaded( banner, function() {
1762										banner.slideDown();
1763									} );
1764								}
1765							}, item.data('banner-delay') ? item.data('banner-delay') : 0 );
1766						}
1767					} );
1768				}
1769			} );
1770
1771
1772			// Widgets decoration
1773			//----------------------------------------------
1774		
1775			// Decorate nested lists in widgets and side panels
1776			container.find('.widget ul > li').each(function() {
1777				var $self = jQuery(this);
1778				if ($self.find('ul').length > 0) {
1779					$self.addClass('has_children');
1780				}
1781			});
1782		
1783			// Archive widget decoration
1784			container.find('.widget_archive a:not(.inited)').each(function() {
1785				var $self = jQuery(this).addClass('inited');
1786				var val = $self.html().split(' ');
1787				if (val.length > 1) {
1788					val[val.length-1] = '<span>' + val[val.length-1] + '</span>';
1789					$self.html(val.join(' '));
1790				}
1791			});
1792		
1793		
1794			// Menu
1795			//----------------------------------------------
1796			// Prepare menus (if menu cache is used)
1797			jQuery('.sc_layouts_menu_nav:not(.inited_cache)').each(function() {
1798				var $self = jQuery(this).addClass('inited_cache');
1799				if ($self.find('.current-menu-item').length == 0 || $body.hasClass('blog_template')) {
1800					if (TRX_ADDONS_STORAGE['menu_cache'] === undefined) TRX_ADDONS_STORAGE['menu_cache'] = [];
1801					var id = $self.attr('id');
1802					if (id === undefined) {
1803						id = ('sc_layouts_menu_nav_' + Math.random()).replace('.', '');
1804						$self.attr('id', id);
1805					}
1806					TRX_ADDONS_STORAGE['menu_cache'].push('#'+id);
1807				}
1808			});
1809			if (TRX_ADDONS_STORAGE['menu_cache'] && TRX_ADDONS_STORAGE['menu_cache'].length > 0) {
1810				// Mark the current menu item and its parent items in the cached menus
1811				var href = window.location.href;
1812				if ( href.slice(-1) == '/' ) {
1813					href = href.slice( 0, -1 );
1814				}
1815				var href2 = href.indexOf( '#' ) == -1 && href.indexOf( '?' ) == -1 ? href + '/' : '';
1816				for (var i = 0; i < TRX_ADDONS_STORAGE['menu_cache'].length; i++) {
1817					var menu = jQuery( TRX_ADDONS_STORAGE['menu_cache'][i]+':not(.prepared)' );
1818					if ( menu.length === 0 ) {
1819						continue;
1820					}
1821					menu.addClass( 'prepared' );
1822					menu.find( 'li' ).removeClass( 'current-menu-ancestor current-menu-parent current-menu-item current_page_item' );
1823					menu.find( 'a[href="'+href+'"]' + ( href2 ? ',a[href="'+href2+'"]' : '' ) ).each( function( idx ) {
1824						var li = jQuery(this).parent();
1825						li.addClass( 'current-menu-item' );
1826						if ( li.hasClass( 'menu-item-object-page' ) ) {
1827							li.addClass('current_page_item');
1828						}
1829						// Mark all parent items as 'current-menu-ancestor' and closest as 'current-menu-parent'
1830						li = li.parents( 'li' );
1831						for ( var j = 0; j < li.length; j++ ) {
1832							li.addClass( 'current-menu-ancestor' + ( j == 0 ? ' current-menu-parent' : '' ) );
1833						}
1834					} );
1835				}
1836			}
1837		
1838		
1839			// Forms
1840			//------------------------------------
1841			
1842			// Remove 'error_field' class on any key pressed in the field
1843			jQuery("form:not([data-inited-validation])")
1844				.attr('data-inited-validation', 1)
1845				.on('change', 'input,select,textarea', function() {
1846					var $self = jQuery(this),
1847						$wrap = $self.parents('.error_field');
1848					if ( $self.val() !== '' ) {
1849						if ( $self.hasClass( 'error_field' ) ) {
1850							$self.removeClass('error_field');
1851						} else if ( $wrap.length > 0 ) {
1852							$wrap.removeClass('error_field');
1853						}
1854					}
1855				});
1856		
1857			// Comment form
1858			jQuery("form#commentform:not(.inited_validation)")
1859				.addClass( 'inited_validation' )
1860				.on( 'submit', function(e) {
1861					var rez = trx_addons_comments_validate( jQuery(this) );
1862					if (!rez) {
1863						e.preventDefault();
1864					}
1865					return rez;
1866				} );
1867			
1868			// Comments form
1869			function trx_addons_comments_validate(form) {
1870				form.find('input').removeClass('error_field');
1871				var comments_args = {
1872					error_message_text: TRX_ADDONS_STORAGE['msg_validation_error'],		// Global error message text (if don't write in checked field)
1873					error_message_show: true,											// Display or not error message
1874					error_message_time: 4000,											// Error message display time
1875					error_message_class: 'trx_addons_message_box trx_addons_message_box_error',	// Class appended to error message block
1876					error_fields_class: 'error_field',									// Class appended to error fields
1877					exit_after_first_error: false,										// Cancel validation and exit after first error
1878					rules: [
1879						{
1880							field: 'comment',
1881							min_length: { value: 1, message: TRX_ADDONS_STORAGE['msg_text_empty'] }
1882						}
1883					]
1884				};
1885				if (form.find('.comments_author input[aria-required="true"]').length > 0) {
1886					comments_args.rules.push(
1887						{
1888							field: 'author',
1889							min_length: { value: 1, message: TRX_ADDONS_STORAGE['msg_name_empty']},
1890							max_length: { value: 60, message: TRX_ADDONS_STORAGE['msg_name_long']}
1891						}
1892					);
1893				}
1894				if (form.find('.comments_email input[aria-required="true"]').length > 0) {
1895					comments_args.rules.push(
1896						{
1897							field: 'email',
1898							min_length: { value: 1, message: TRX_ADDONS_STORAGE['msg_email_empty']},
1899							max_length: { value: 60, message: TRX_ADDONS_STORAGE['msg_email_long']},
1900							mask: { value: TRX_ADDONS_STORAGE['email_mask'], message: TRX_ADDONS_STORAGE['msg_email_not_val
1900id']}
1901						}
1902					);
1903				}
1904				var error = trx_addons_form_validate(form, comments_args);
1905				return !error;
1906			}
1907
1908
1909			// Show "on scroll" blocks
1910			//------------------------------------
1911			if ( $show_on_scroll.length > 0 ) {
1912				trx_addons_intersection_observer_add( $show_on_scroll );
1913			}
1914
1915
1916			// Animations
1917			//------------------------------------
1918
1919			// Disable animations on mobile
1920			if ( TRX_ADDONS_STORAGE['disable_animation_on_mobile'] && $body.hasClass('ua_mobile') ) {
1921				// jQuery('[data-animation^="animated"]').removeAttr('data-animation');
1922				jQuery('[data-post-animation^="animated"]').removeAttr('data-post-animation');
1923				jQuery('[data-hover-animation^="animated"]').removeAttr('data-hover-animation');
1924				// Update global lists
1925				$animated_elements = jQuery('[data-post-animation^="animated"]:not(.animated)');
1926				$animated_hover    = jQuery('[data-hover-animation^="animated"]:not(.animated)');
1927			}
1928
1929			// Animate elements after its enter to the viewport
1930			if ( $animated_elements.length > 0 ) {
1931				trx_addons_intersection_observer_add( $animated_elements, function( item, enter ) {
1932					if ( ! item.hasClass('inited_animation') && enter ) {
1933						item.addClass('inited_animation');
1934						trx_addons_intersection_observer_remove( item );
1935						var animation = item.data('post-animation');
1936						if ( ! animation ) animation = item.data('animation');
1937						setTimeout( function() {
1938							// Add class with animation
1939							item.addClass( animation );
1940							// Remove attribute 'data-post-animation' to prevent hiding items from 3rd-party plugins
1941							item.removeAttr('data-post-animation');
1942							// Update global list
1943							$animated_elements = jQuery('[data-post-animation^="animated"]:not(.animated)');
1944							// Generate action after element is animated
1945							$document.trigger('action.start_item_animation', [item]);
1946						}, 100 * trx_addons_random(0, 10) );
1947					}
1948				} );			
1949			}
1950
1951			// Animated hover
1952			container
1953				.find('[data-hover-animation^="animated"]')
1954				.closest('.elementor-column,.post_layout_custom')
1955				.each(function() {
1956					var $self = jQuery(this);
1957					if ($self.hasClass('hover-animation-inited')) return;
1958					$self.addClass('hover-animation-inited').hover(
1959						// Mouse in
1960						function(e) {
1961							jQuery(this).find('[data-hover-animation^="animated"]').each(function() {
1962								var obj = jQuery(this);
1963								var animation = obj.data('hover-animation');
1964								var animation_in = obj.data('animation-in');
1965								if (animation_in == undefined) animation_in = "none";
1966								var animation_in_delay = obj.data('animation-in-delay');
1967								if (animation_in_delay == undefined) animation_in_delay = 0;
1968								var animation_out = obj.data('animation-out');
1969								if (animation_out == undefined) animation_out = "none";
1970								if (animation_in != 'none') {
1971									setTimeout(function() {
1972										obj.removeClass(animation + ' ' + animation_out);
1973										obj.addClass(animation + ' ' + animation_in);
1974									}, animation_in_delay);
1975								}
1976							});
1977						},
1978						// Mouse out
1979						function(e) {
1980							jQuery(this).find('[data-hover-animation^="animated"]').each(function() {
1981								var obj = jQuery(this);
1982								var animation = obj.data('hover-animation');
1983								var animation_in = obj.data('animation-in');
1984								if (animation_in == undefined) animation_in = "none";
1985								var animation_out = obj.data('animation-out');
1986								if (animation_out == undefined) animation_out = "none";
1987								var animation_out_delay = obj.data('animation-out-delay');
1988								if (animation_out_delay == undefined) animation_out_delay = 0;
1989								if (animation_out != 'none') {
1990									setTimeout(function() {
1991										obj.removeClass(animation + ' ' + animation_in);
1992										obj.addClass(animation + ' ' + animation_out);
1993									}, animation_out_delay);
1994								}
1995							});
1996						}
1997					);
1998				});
1999
2000
2001			// Init Parallax controller
2002			//-----------------------------------
2003			if ( typeof ScrollMagic != 'undefined' ) {
2004				if ( parallax_controller === null ) {
2005					parallax_controller = new ScrollMagic.Controller( {
2006																		globalSceneOptions: {
2007																							triggerHook: "onEnter",
2008																							duration: "200%"
2009																							}
2010																		} );
2011				}
2012				// Build Parallax scenes
2013				$parallax_wrap.each( function() {
2014					var $self = jQuery( this ),
2015						id = $self.attr( 'id' ),
2016						speed = $self.data( 'parallax' ) ? Number( $self.data( 'parallax' ) ) : 0;
2017					if ( speed !== 0 && ! $self.hasClass( 'parallax_inited' ) ) {
2018						$self.addClass( 'parallax_inited' );
2019						if ( ! id ) {
2020							id = 'sc_parallax_wrap_' + ( '' + Math.random() ).replace( '.', '' );
2021							$self.attr( 'id', id );
2022						}
2023						var selector = '#' + id + ( $self.find( '> .wp-caption' ).length > 0 ? '>.wp-caption' : '' ) + '>img';
2024						new ScrollMagic
2025							.Scene( { triggerElement: '#' + id } ) 
2026							.setTween( selector, { y: speed + "%", ease: Linear.easeNone } )
2027							.addTo( parallax_controller );
2028					}
2029				});
2030			}
2031
2032
2033			// Other settings
2034			//------------------------------------
2035
2036			// Scroll to top button
2037			if ( ! $scroll_to_top.hasClass('inited') ) {
2038				$scroll_to_top
2039					.addClass('inited')
2040					.on( 'click', function(e) {
2041						jQuery('html,body').animate( {
2042							scrollTop: 0
2043						}, 'slow' );
2044						e.preventDefault();
2045						return false;
2046					} );
2047				// Scroll progress
2048				if ( $scroll_progress.length ) {
2049					$document.on( 'action.scroll_trx_addons', function() {
2050						var prc = trx_addons_document_height() > trx_addons_window_height() ? Math.min(100, Math.max(0, trx_addons_window_scroll_top() / ( trx_addons_document_height() - trx_addons_window_height() ) * 100)) : 100;
2051						if ( $scroll_progress.hasClass('trx_addons_scroll_progress_type_vertical') ) {
2052							$scroll_progress.height(prc+'%');
2053						} else if ( $scroll_progress.hasClass('trx_addons_scroll_progress_type_horizontal') ) {
2054							$scroll_progress.width(prc+'%');
2055						} else if ( $scroll_progress.hasClass('trx_addons_scroll_progress_type_box') || $scroll_progress.hasClass('trx_addons_scroll_progress_type_round') ) {
2056							var $bar = $scroll_progress.find('.trx_addons_scroll_progress_bar');
2057							if ( $bar.length === 0 ) {
2058								$scroll_progress.append( '<svg viewBox="0 0 50 50">'
2059															+ ( $scroll_progress.hasClass('trx_addons_scroll_progress_type_round')
2060																? '<circle class="trx_addons_scroll_progress_bar" cx="25" cy="25" r="22"></circle>'
2061																: '<rect class="trx_addons_scroll_progress_bar" x="3" y="3" width="44" height="44"></rect>'
2062																)
2063														+ '</svg>' );
2064								$bar = $scroll_progress.find('.trx_addons_scroll_progress_bar');
2065							}
2066							var bar_max = parseFloat( $bar.css('stroke-dasharray') );
2067							$bar.css( 'stroke-dashoffset', '' + Math.min( 1, 1 - prc / 100 ) * bar_max );
2068						}
2069					} );
2070				}
2071			}
2072
2073		} // trx_addons_ready_actions
2074
2075
2076		// Init intersection observer
2077		//----------------------------------
2078		function trx_addons_intersection_observer_init() {
2079
2080			if ( typeof TRX_ADDONS_STORAGE == 'undefined' ) return;
2081
2082			if ( typeof IntersectionObserver != 'undefined' ) {
2083				// Create observer
2084				if ( typeof TRX_ADDONS_STORAGE['intersection_observer'] == 'undefined' ) {
2085					TRX_ADDONS_STORAGE['intersection_observer'] = new IntersectionObserver( function(entries) {
2086						entries.forEach( function( entry ) {
2087							trx_addons_intersection_observer_in_out( jQuery(entry.target), entry.isIntersecting || entry.intersectionRatio > 0 ? 'in' : 'out', entry );
2088						});
2089					}, {
2090						root: null,			// avoiding 'root' or setting it to 'null' sets it to default value: viewport
2091						rootMargin: '0px',	// increase (if positive) or decrease (if negative) root area
2092						threshold: 0		// 0.0 - 1.0: 0.0 - fired when top of the object enter in the viewport
2093											//            0.5 - fired when half of the object enter in the viewport
2094											//            1.0 - fired when the whole object enter in the viewport
2095					} );
2096				}
2097			} else {
2098				// Emulate IntersectionObserver behaviour
2099				$window.on( 'scroll', function() {
2100					if ( typeof TRX_ADDONS_STORAGE['intersection_observer_items'] != 'undefined' ) {
2101						for ( var i in TRX_ADDONS_STORAGE['intersection_observer_items'] ) {
2102							if ( ! TRX_ADDONS_STORAGE['intersection_observer_items'][i] || TRX_ADDONS_STORAGE['intersection_observer_items'][i].length === 0 ) {
2103								continue;
2104							}
2105							var item = TRX_ADDONS_STORAGE['intersection_observer_items'][i],
2106								item_top = item.offset().top,
2107								item_height = item.height();
2108							trx_addons_intersection_observer_in_out( item, item_top + item_height > trx_addons_window_scroll_top() && item_top < trx_addons_window_scroll_top() + trx_addons_window_height() ? 'in' : 'out' );
2109						}
2110					}
2111				} );
2112			}
2113
2114			// Change state of the entry
2115			window.trx_addons_intersection_observer_in_out = function( item, state, entry ) {
2116				var callback = '';
2117				if ( state == 'in' ) {
2118					if ( ! item.hasClass( 'trx_addons_in_viewport' ) ) {
2119						item.addClass( 'trx_addons_in_viewport' );
2120						callback = item.data('trx-addons-intersection-callback');
2121						if ( callback ) {
2122							callback( item, true, entry );
2123						}
2124					}
2125				} else {
2126					if ( item.hasClass( 'trx_addons_in_viewport' ) ) {
2127						item.removeClass( 'trx_addons_in_viewport' );
2128						callback = item.data('trx-addons-intersection-callback');
2129						if ( callback ) {
2130							callback( item, false, entry );
2131						}
2132					}
2133				}
2134			};
2135
2136			// Add elements to the observer
2137			window.trx_addons_intersection_observer_add = function( items, c
2137allback ) {
2138				items.each( function() {
2139					var $self = jQuery( this ),
2140						id = $self.attr( 'id' );
2141					if ( ! $self.hasClass( 'trx_addons_intersection_inited' ) ) {
2142						if ( ! id ) {
2143							id = 'io-' + ( '' + Math.random() ).replace('.', '');
2144							$self.attr( 'id', id );
2145						}
2146						$self.addClass( 'trx_addons_intersection_inited' );
2147						if ( callback ) {
2148							$self.data( 'trx-addons-intersection-callback', callback );
2149						}
2150						if ( typeof TRX_ADDONS_STORAGE['intersection_observer_items'] == 'undefined' ) {
2151							TRX_ADDONS_STORAGE['intersection_observer_items'] = {};
2152						}
2153						TRX_ADDONS_STORAGE['intersection_observer_items'][id] = $self;
2154						if ( typeof TRX_ADDONS_STORAGE['intersection_observer'] !== 'undefined' ) {
2155							TRX_ADDONS_STORAGE['intersection_observer'].observe( $self.get(0) );
2156						}
2157					}
2158				} );
2159			};
2160
2161			// Remove elements from the observer
2162			window.trx_addons_intersection_observer_remove = function( items ) {
2163				items.each( function() {
2164					var $self = jQuery( this ),
2165						id = $self.attr( 'id' );
2166					if ( $self.hasClass( 'trx_addons_intersection_inited' ) ) {
2167						$self.removeClass( 'trx_addons_intersection_inited' );
2168						delete TRX_ADDONS_STORAGE['intersection_observer_items'][id];
2169						if ( typeof TRX_ADDONS_STORAGE['intersection_observer'] !== 'undefined' ) {
2170							TRX_ADDONS_STORAGE['intersection_observer'].unobserve( $self.get(0) );
2171						}
2172					}
2173				} );
2174			};
2175		}	// trx_addons_intersection_observer_init
2176
2177		
2178		// Scroll actions
2179		//==============================================
2180
2181		// Do actions when page scrolled
2182		window.trx_addons_scroll_actions = function() {
2183			// Add class to 'body' if scroll_top > 0
2184			if ( trx_addons_window_scroll_top() > 0 ) {
2185				if ( ! $body.hasClass( 'trx_addons_page_scrolled' ) ) {
2186					$body.addClass( 'trx_addons_page_scrolled' );
2187				}
2188			} else if ( $body.hasClass( 'trx_addons_page_scrolled' ) ) {
2189				$body.removeClass( 'trx_addons_page_scrolled' );
2190			}
2191			// Scroll to top button show/hide
2192			if ( $scroll_to_top.length > 0 ) {
2193				if ( trx_addons_window_scroll_top() > 100 ) {
2194					if ( ! $scroll_to_top.hasClass( 'show' ) ) {
2195						$scroll_to_top.addClass('show');
2196						$body.addClass( 'trx_addons_scroll_to_top_show' );
2197					}
2198				} else {
2199					if ( $scroll_to_top.hasClass( 'show' ) ) {
2200						$scroll_to_top.removeClass('show');
2201						$body.removeClass( 'trx_addons_scroll_to_top_show' );
2202					}
2203				}
2204			}
2205
2206			// Display scroll progress
2207			if ( ['top', 'bottom', 'fixed'].indexOf( TRX_ADDONS_STORAGE['scroll_progress'] ) >= 0 ) {
2208				trx_addons_show_scroll_progress();
2209			}
2210
2211			// Show "on scroll" blocks
2212			$show_on_scroll.each( function() {
2213				var item = jQuery(this);
2214				if ( item.hasClass( 'trx_addons_in_viewport' ) ){
2215					if ( item.offset().top < trx_addons_window_scroll_top() + trx_addons_window_height() * 0.75 ) {
2216						item.removeClass( 'trx_addons_show_on_scroll' ).addClass( 'trx_addons_showed_on_scroll' );
2217						trx_addons_intersection_observer_remove( item );
2218						// Update list of elements
2219						$show_on_scroll = jQuery('.trx_addons_show_on_scroll');
2220					}
2221				}
2222			} );
2223
2224			// Call theme/plugins specific action (if exists)
2225			//----------------------------------------------
2226			$document.trigger('action.before_scroll_trx_addons');
2227			$document.trigger('action.scroll_trx_addons');
2228			$document.trigger('action.after_scroll_trx_addons');
2229
2230			// Set flag about scroll actions are finished
2231			TRX_ADDONS_STORAGE['scroll_busy'] = false;
2232		};
2233
2234
2235		// Display scroll progress
2236		function trx_addons_show_scroll_progress() {
2237			if ( TRX_ADDONS_STORAGE['scroll_progress_status'] == undefined ) {
2238				$body.append('<div class="scroll_progress_wrap scroll_progress_'+TRX_ADDONS_STORAGE['scroll_progress']+'"><span class="scroll_progress_status"></span></div>');
2239				TRX_ADDONS_STORAGE['scroll_progress_status'] = jQuery( '.scroll_progress_wrap .scroll_progress_status' );
2240				trx_addons_get_scroll_posts();
2241				// Animate to relative page part on click
2242				TRX_ADDONS_STORAGE['scroll_progress_status'].on('click', function(e) {
2243					var prc = e.pageX / jQuery(this).parent().width();
2244					if ( TRX_ADDONS_STORAGE['scroll_posts'] != undefined && TRX_ADDONS_STORAGE['scroll_posts'].length > 0 ) {
2245						var cur_post = trx_addons_detect_current_scroll_post(),
2246							pt = cur_post.data('post-top'),
2247							ph = cur_post.data('post-height');
2248						trx_addons_document_animate_to( Math.round( ph * prc + pt - wh / 2 ) );
2249					} else {
2250						trx_addons_document_animate_to( Math.round( ( trx_addons_document_height() - trx_addons_window_height() ) * prc ) );
2251					}
2252					e.preventDefault();
2253					return false;
2254				});
2255			}
2256			var st = trx_addons_window_scroll_top(),
2257				wh = trx_addons_window_height(),
2258				new_width = '0%';
2259			if ( TRX_ADDONS_STORAGE['scroll_posts'] !== undefined && TRX_ADDONS_STORAGE['scroll_posts'].length > 0 ) {
2260				var cur_post = trx_addons_detect_current_scroll_post(),
2261					pt = cur_post.data('post-top'),
2262					ph = cur_post.data('post-height');
2263				new_width = ( st < 10 ? 0 : Math.min( 100, Math.round( ( st + wh / 2 - pt ) * 100 / ph ) ) ) + '%';
2264				TRX_ADDONS_STORAGE['scroll_progress_status'].width( new_width );
2265			} else {
2266				new_width = Math.min( 100, Math.round( st * 100 / ( trx_addons_document_height() - wh ) ) ) + '%';
2267				TRX_ADDONS_STORAGE['scroll_progress_status'].width( new_width );
2268			}
2269		}
2270
2271		function trx_addons_detect_current_scroll_post() {
2272			var cur_post = false;
2273			TRX_ADDONS_STORAGE['scroll_posts'].each( function() {
2274				var post = jQuery(this),
2275					st   = trx_addons_window_scroll_top(),
2276					wh   = trx_addons_window_height(),
2277					pt   = post.data('post-top'),
2278					ph   = post.data('post-height');
2279				if ( pt < st + wh / 2 ) {
2280					cur_post = post;
2281				}
2282			});
2283			if ( ! cur_post ) {
2284				cur_post = TRX_ADDONS_STORAGE['scroll_posts'].eq( TRX_ADDONS_STORAGE['scroll_posts'].length - 1 );
2285			}
2286			return cur_post;
2287		}
2288
2289		$document.on('action.new_post_added', trx_addons_get_scroll_posts);
2290		function trx_addons_get_scroll_posts() {
2291			TRX_ADDONS_STORAGE['scroll_posts'] = ( TRX_ADDONS_STORAGE['scroll_posts'] !== undefined && TRX_ADDONS_STORAGE['scroll_posts'].length > 0 )
2292													|| jQuery('.nav-links-single-scroll').length > 0
2293														? jQuery('.post_item_single')
2294														: false;
2295			trx_addons_get_scroll_posts_dimensions();
2296		}
2297
2298		$document.on('action.resize_trx_addons', trx_addons_get_scroll_posts_dimensions);
2299		function trx_addons_get_scroll_posts_dimensions() {
2300			if ( TRX_ADDONS_STORAGE['scroll_posts'] !== undefined && TRX_ADDONS_STORAGE['scroll_posts'].length > 0 ) {
2301				TRX_ADDONS_STORAGE['scroll_posts'].each( function() {
2302					var post = jQuery(this);
2303					post.data('post-height', post.height())
2304						.data('post-top', post.offset().top);
2305				} );
2306			}
2307		}
2308
2309
2310		// Fix columns
2311		//---------------------------------------------------------------
2312
2313		// Fix column only if css sticky behaviour is not used
2314		if ( ! $body.hasClass( 'fixed_blocks_sticky' ) ) {
2315			$document.on('action.resize_trx_addons', trx_addons_fix_column);
2316			$document.on('action.scroll_trx_addons', trx_addons_fix_column);
2317
2318			var trx_addons_fix_column = function (e, cont) {
2319
2320				if ( $fixed_columns.length === 0 ) {
2321					return;
2322				}
2323
2324				var force = e.namespace == 'resize_trx_addons';
2325
2326				$fixed_columns.each(function() {
2327					var col = jQuery(this),
2328						row = col.parent();
2329					
2330					// Exit if non-standard responsive is used for this columns
2331					if ( col.attr('class').indexOf('vc_col-lg-') != -1 || col.attr('class').indexOf('vc_col-md-') != -1 ) {
2332						return;
2333
2334					// Unfix on mobile layout (all columns are fullwidth)
2335					} else if ( trx_addons_window_width() < TRX_ADDONS_STORAGE['mobile_breakpoint_fixedcolumns_off'] ) {
2336						var old_style = col.data('old_style');
2337						if (old_style !== undefined) {
2338							col.attr('style', old_style).removeAttr('data-old_style');
2339						}
2340				
2341					} else {
2342				
2343						var col_height = col.outerHeight();
2344						var row_height = row.outerHeight();
2345						var row_top = row.offset().top;
2346			
2347						// If column shorter then content and page scrolled below the content's top
2348						if (col_height < row_height && trx_addons_window_scroll_top() + trx_addons_fixed_rows_height() > row_top) {
2349							
2350							var col_init = {
2351								'position': 'undefined',
2352								'top': 'auto',
2353								'bottom' : 'auto'
2354							};
2355							
2356							if (typeof TRX_ADDONS_STORAGE['scroll_offset_last'] == 'undefined') {
2357								TRX_ADDONS_STORAGE['col_top_last'] = row_top;
2358								TRX_ADDONS_STORAGE['scroll_offset_last'] = trx_addons_window_scroll_top();
2359								TRX_ADDONS_STORAGE['scroll_dir_last'] = 1;
2360							}
2361							var scroll_dir = trx_addons_window_scroll_top() - TRX_ADDONS_STORAGE['scroll_offset_last'];
2362							scroll_dir = scroll_dir == 0
2363											? TRX_ADDONS_STORAGE['scroll_dir_last']
2364											: ( scroll_dir > 0 ? 1 : -1 );
2365
2366							var col_big = col_height + 30 >= trx_addons_window_height() - trx_addons_fixed_rows_height(),
2367								col_top = col.offset().top;
2368
2369							if (col_top < 0) {
2370								col_top = TRX_ADDONS_STORAGE['col_top_last'];
2371							}
2372
2373
2374							// If column height greater then window height
2375							if (col_big) {
2376			
2377								// If change scrolling dir
2378								if (scroll_dir != TRX_ADDONS_STORAGE['scroll_dir_last'] && col.css('position') == 'fixed') {
2379									col_init.top = col_top - row_top;
2380									col_init.position = 'absolute';
2381			
2382								// If scrolling down
2383								} else if (scroll_dir > 0) {
2384									if (trx_addons_window_scroll_top() + trx_addons_window_height() >= row_top + row_height + 30) {
2385										col_init.bottom = 0;
2386										col_init.position = 'absolute';
2387									} else if (trx_addons_window_scroll_top() + trx_addons_window_height() >= (col.css('position') == 'absolute' ? col_top : row_top) + col_height + 30) {
2388										col_init.bottom = 30;
2389										col_init.position = 'fixed';
2390									}
2391							
2392								// If scrolling up
2393								} else {
2394									if (trx_addons_window_scroll_top() + trx_addons_fixed_rows_height() <= col_top) {
2395										col_init.top = trx_addons_fixed_rows_height();
2396										col_init.position = 'fixed';
2397									}
2398								}
2399							
2400							// If column height less then window height
2401							} else {
2402								if (trx_addons_window_scroll_top() + trx_addons_fixed_rows_height() >= row_top + row_height - col_height) {
2403									col_init.bottom = 0;
2404									col_init.position = 'absolute';
2405								} else {
2406									col_init.top = trx_addons_fixed_rows_height();
2407									col_init.position = 'fixed';
2408								}
2409							}
2410
2411							if (force && col_init.position == 'undefined' && col.css('position') == 'absolute') {
2412								col_init.position = 'absolute';
2413								if (col.css('top') != 'auto') {
2414									col_init.top = col.css('top');
2415								} else {
2416									col_init.bottom = col.css('bottom');
2417								}
2418							}
2419
2420							if (col_init.position != 'undefined') {
2421								// Insert placeholder before this column
2422								var style = col.attr('style');
2423								if ( ! style ) style = '';
2424								if ( ! col.prev().hasClass('sc_column_fixed_placeholder') ) {
2425									col.css(col_init);
2426									TRX_ADDONS_STORAGE['scroll_dir_last'] = 0;
2427									col.before('<div class="sc_column_fixed_placeholder '+col.attr('class').replace('sc_column_fixed', '')+'"'
2428												+ (col.data('col') ? ' data-col="' + col.data('col') + '"' : '')
2429												+ '></div>');
2430								}
2431								// Detect horizontal position
2432								col_init.left = col_init.position == 'fixed' ? col.prev().offset().left : col.prev().position().left;
2433								col_init.width = col.prev().width() + parseFloat(col.prev().css('paddingLeft')) + parseFloat(col.prev().css('paddingRight'));
2434								// Set position
2435								if ( force 
2436									|| col.css('position') != col_init.position 
2437									|| TRX_ADDONS_STORAGE['scroll_dir_last'] != scroll_dir
2438									|| col.width() != col_init.width
2439								) {
2440									if (col.data('old_style') === undefined) {
2441										col.attr('data-old_style', style);
2442									}
2443									col.css(col_init);
2444								}
2445							}
2446
2447							TRX_ADDONS_STORAGE['col_top_last'] = col_top;
2448							TRX_ADDONS_STORAGE['scroll_offset_last'] = trx_addons_window_scroll_top();
2449							TRX_ADDONS_STORAGE['scroll_dir_last'] = scroll_dir;
2450			
2451						} else {
2452			
2453							// Unfix when page scrolling to top
2454							var old_style = col.data('old_style');
2455							if (old_style !== undefined) {
2456								col.attr('style', old_style).removeAttr('data-old_style');
2457								if ( col.prev().hasClass('sc_column_fixed_placeholder') ) {
2458									col.prev().remove();
2459								}
2460							}
2461						}
2462					}
2463				});
2464			};
2465		}
2466
2467		// Stack sections
2468		$document.on('action.resize_trx_addons', trx_addons_stack_section);
2469		$document.on('action.scroll_trx_addons', trx_addons_stack_section);
2470		function trx_addons_stack_section(e, cont) {
2471
2472			if ( $stack_sections.length === 0 ) return;
2473
2474			var force = e.namespace == 'resize_trx_addons',
2475				wso = trx_addons_window_scroll_top() + trx_addons_fixed_rows_height();
2476
2477			$stack_sections.each( function( idx ) {
2478
2479				var row = jQuery(this),
2480					row_holder = false,
2481					row_height = 0,
2482					row_top = 0,
2483					use_sticky = $body.hasClass( 'fixed_blocks_sticky' ) && row.hasClass('sc_stack_section_effect_slide');
2484
2485				// Unfix on mobile layout (all columns are fullwidth)
2486				if ( trx_addons_window_width() < TRX_ADDONS_STORAGE['mobile_breakpoint_stacksections_off'] ) {
2487
2488					if ( row.hasClass('sc_stack_section_fixed') ) {
2489						row.removeClass('sc_stack_section_fixed').prev().remove();
2490						if ( ! use_sticky ) row.css( { top: row.data('old-top') } );
2491					}
2492			
2493				} else {
2494			
2495					// If section is fixed
2496					if ( row.hasClass('sc_stack_section_fixed') ) {
2497						row_holder = row.prev();
2498						row_height = use_sticky ? row.outerHeight() : row_holder.outerHeight();
2499						row_top    = row_holder.offset().top;
2500						// Unfix row
2501						if ( row_top > wso ) {
2502							row.removeClass('sc_stack_section_fixed');
2503							if ( ! use_sticky ) {
2504								row.css( { top: row.data('old-top') } );
2505							}
2506							if ( row.hasClass( 'sc_stack_section_effect_fade' ) ) {
2507								row.css( { 'opacity': 0 } );
2508							}
2509							row_holder.remove();
2510
2511						// Set holder height
2512						} else {
2513							if ( force ) {
2514								row_height = row.outerHeight();
2515								if ( ! use_sticky ) {
2516									row_holder.height(row_height);
2517									row.css( { top: trx_addons_fixed_rows_height() + 'px !important' } );
2518								}
2519							}
2520							if ( row.hasClass( 'sc_stack_section_effect_fade' ) ) {
2521								if ( wso - row_top <= row_height ) {
2522									row.css( { 'opacity': Math.max(0, Math.min( 1, ( wso - row_top ) / row_height ) ) } );
2523								} else {
2524									row.css( { 'opacity': 1 } );
2525								}
2526							}
2527						}
2528
2529					// If section is not fixed
2530					} else {
2531						row_top = row.offset().top;
2532						if ( row_top <= wso ) {
2533							if ( ! use_sticky ) {
2534								row_height = row.outerHeight();
2535								row
2536									.data( 'old-top', row.css('top') )
2537									.css( { top: trx_addons_fixed_rows_height() + 'px'} );
2538							}
2539							row
2540								.before('<div class="sc_stack_section_placeholder"' + ( ! use_sticky ? ' style="height:'+row_height+'px;"' : '' ) + '></div>')
2541								.addClass('sc_stack_section_fixed');
2542						}
2543					}
2544				}
2545
2546			} );
2547		}
2548
2549		// Add zoom effect to the stack sections
2550		function trx_addons_stack_section_zoom() {
2551			$stack_sections.each( function() {
2552				var targetElement = jQuery(this),
2553					zoom = targetElement.hasClass( 'sc_stack_section_zoom_on' ),
2554					transparency = targetElement.hasClass( 'sc_stack_section_transparency_on' );
2555				if ( ! zoom && ! transparency ) {
2556					return;
2557				}
2558				var triggerElement = targetElement.next();
2559				if ( ! triggerElement.length || ( triggerElement.hasClass( 'sc_stack_section_on' ) && ! triggerElement.hasClass( 'sc_stack_section_effect_slide' ) ) ) {
2560					return;
2561				}
2562				//Register Scroll Trigger library
2563				if ( ! TRX_ADDONS_STORAGE['GSAP_Plugin_ScrollTrigger'] ) {
2564					TRX_ADDONS_STORAGE['GSAP_Plugin_ScrollTrigger'] = true;
2565					gsap.registerPlugin( ScrollTrigger );
2566				}
2567				var timeline = triggerElement.data( 'stack-section-timeline' ) ? triggerElement.data( 'stack-section-timeline' ) : null;
2568				// Reinit a timeline if already inited (for example, after sliders or masonry are inited - a page content shift down)
2569				if ( timeline ) {
2570					timeline.kill();
2571				}
2572				// Init a timeline
2573				timeline = gsap.timeline( {
2574					scrollTrigger: {
2575						trigger: triggerElement,
2576						start: "top 75%",
2577						end: "top top",
2578						scrub: 1
2579					}
2580				} );
2581				var duration = 1,
2582					from = { duration: duration },
2583					to = { duration: duration };
2584				if ( zoom ) {
2585					from.scale = "1";
2586					to.scale = "0.8";
2587				}
2588				if ( transparency ) {
2589					from.opacity = "1";
2590					to.opacity = "0";
2591				}
2592				timeline.fromTo( targetElement, from, to );
2593				triggerElement.data( 'stack-section-timeline', timeline );
2594			} );
2595		}
2596		if ( $stack_sections.length && window.gsap ) {
2597			trx_addons_stack_section_zoom();
2598			$document.on( 'action.resize_trx_addons', trx_addons_stack_section_zoom );
2599		}
2600
2601
2602		// Resize actions
2603		//==============================================
2604
2605		// Do actions when window is resized
2606		window.trx_addons_resize_actions = function(cont) {
2607
2608			// Check touch device
2609			if ( trx_addons_browser_is_touch() ) {
2610				if ( ! $body.hasClass( 'ua_touch' ) ) {
2611					$body.addClass( 'ua_touch' );
2612				}
2613			} else {
2614				if ( $body.hasClass( 'ua_touch' ) ) {
2615					$body.removeClass( 'ua_touch' );
2616				}
2617			}
2618
2619			if (cont===undefined) cont = $body;
2620
2621			// Call theme/plugins specific action (if exists)
2622			$document.trigger('action.before_resize_trx_addons', [cont] );
2623			$document.trigger('action.resize_trx_addons', [cont] );
2624			$document.trigger('action.after_resize_trx_addons', [cont] );
2625		};
2626
2627		// Fit video frames to document width
2628		$document.on('action.resize_trx_addons', trx_addons_resize_video);
2629		function trx_addons_resize_video(e, cont) {
2630			// Resize tag 'video'
2631			if ( $video_tags.length > 0 ) {
2632				$video_tags.each(function() {
2633					var $self = jQuery(this),
2634						classes = $self.attr( 'class' );
2635					// If item now invisible
2636					if ( ( ! TRX_ADDONS_STORAGE['resize_tag_video'] && $self.parents('.mejs-mediaelement').length === 0 )
2637						|| $self.hasClass('trx_addons_noresize')
2638						|| classes.indexOf('_resize') > 0
2639						|| classes.indexOf('_noresize') > 0
2640						|| $self.parents('div:hidden,section:hidden,article:hidden').length > 0
2641					) {
2642						return;
2643					}
2644					var video = $self.addClass('trx_addons_resize').eq(0);
2645					var ratio = (video.data('ratio') !== undefined ? video.data('ratio').split(':') : [16,9]);
2646					ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
2647					var mejs_cont = video.parents('.mejs-video').eq(0);
2648					var mfp_cont  = video.parents( '.mfp-content' ).eq(0);
2649					var w_attr = video.data('width');
2650					var h_attr = video.data('height');
2651					if (!w_attr || !h_attr) {
2652						w_attr = video.attr('width');
2653						h_attr = video.attr('height');
2654						if ((!w_attr || !h_attr) && mejs_cont.length > 0) {
2655							w_attr = Math.ceil( mejs_cont.width() );
2656							h_attr = Math.ceil( mejs_cont.height() );
2657						}
2658						if (!w_attr || !h_attr) return;
2659						video.data({'width': w_attr, 'height': h_attr});
2660					}
2661					var percent = (''+w_attr).substr(-1) == '%';
2662					w_attr      = parseInt( w_attr, 10 );
2663					h_attr      = parseInt( h_attr, 10 );
2664					var w_real  = Math.ceil( mejs_cont.length > 0 
2665												? Math.min( percent ? 10000 : w_attr, mejs_cont.parents('div,article').eq(0).width() ) 
2666												: Math.min( percent ? 10000 : w_attr, video.parents('div,article').eq(0).width() ) 
2667										   );
2668					if ( mfp_cont.length > 0 ) {
2669						w_real  = Math.max( Math.ceil( mfp_cont.width() ), w_real );
2670					}
2671					var h_real  = Math.ceil( percent ? w_real/ratio : w_real/w_attr*h_attr );
2672					if ( parseInt( video.attr('data-last-width'), 10) == w_real ) {
2673						return;
2674					}
2675					if ( percent ) {
2676						video.height( h_real );
2677					} else if ( video.parents('.wp-video-playlist').length > 0 ) {
2678						if ( mejs_cont.length === 0 ) {
2679							video.attr({'width': w_real, 'height': h_real});
2680						}
2681					} else {
2682						video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
2683						if (mejs_cont.length > 0) {
2684							trx_addons_set_mejs_player_dimensions(video, w_real, h_real);
2685						}
2686					}
2687					video.attr('data-last-width', w_real);
2688				});
2689			}
2690
2691			// Resize tag 'iframe'
2692			if ( TRX_ADDONS_STORAGE['resize_tag_iframe'] && $iframe_tags.length > 0 ) {
2693				$iframe_tags.each(function() {
2694					var $self = jQuery(this);
2695					// If item now invisible
2696					if (   $self.addClass('trx_addons_resize').parents('div:hidden,section:hidden,article:hidden').length > 0
2697						|| $self.hasClass('trx_addons_noresize')
2698						|| $self.parent().is( 'rs-bgvideo' )
2699						|| $self.parents( 'rs-slide' ).length > 0
2700						|| document.fullscreenElement
2701						|| document.mozFullScreenElement
2702						|| document.webkitFullscreenElement
2703						|| document.msFullscreenElement
2704					) {
2705						return;
2706					}
2707					var iframe = $self.eq(0),
2708						iframe_src = iframe.attr('src') ? iframe.attr('src') : iframe.data('src');
2709					if (iframe_src === undefined || iframe_src.indexOf('soundcloud') > 0) return;
2710					var w_attr = iframe.attr('width');
2711					var h_attr = iframe.attr('height');
2712					if ( ! w_attr || ! h_attr || w_attr <= trx_addons_apply_filters( 'trx_addons_filter_noresize_iframe_width', 325 ) ) {
2713						return;
2714					}
2715					var ratio = iframe.data('ratio') !== undefined 
2716									? iframe.data('ratio').split(':') 
2717									: ( iframe.parent().data('ratio') !== undefined 
2718										? iframe.parent().data('ratio').split(':') 
2719										: ( iframe.find('[data-ratio]').length>0 
2720											? iframe.find('[data-ratio]').data('ratio').split(':') 
2721											: [w_attr, h_attr]
2722											)
2723										);
2724					ratio      = ratio.length != 2 || ratio[0] === 0 || ratio[1] === 0 ? 16 / 9 : ratio[0] / ratio[1];
2725					var percent   = ( '' + w_attr ).slice(-1) == '%';
2726					w_attr        = parseInt( w_attr, 10 );
2727					h_attr        = parseInt( h_attr, 10 );
2728					var par       = iframe.parents('div,section').eq(0),
2729						contains   = iframe.data('contains-in-parent')=='1' || iframe.hasClass('contains-in-parent'),
2730						nostretch = iframe.data('no-stretch-to-parent')=='1' || iframe.hasClass('no-stretch-to-parent'),
2731						pw        = Math.ceil( par.width() ),
2732						ph        = Math.ceil( par.height() ),
2733						w_real    = nostretch ? Math.min( w_attr, pw ) : pw,
2734						h_real    = Math.ceil( percent ? w_real/ratio : w_real/w_attr*h_attr );
2735					if ( contains && par.css('position') == 'absolute' && h_real > ph ) {
2736						h_real = ph;
2737						w_real = Math.ceil( percent ? h_real*ratio : h_real*w_attr/h_attr );
2738					}
2739					if ( parseInt(iframe.attr('data-last-width'), 10) == w_real ) return;
2740					iframe.css({'width': w_real+'px', 'height': h_real+'px'});
2741					iframe.attr('data-last-width', w_real);
2742				});
2743			}
2744		}	// trx_addons_resize_video
2745		
2746		
2747		// Set Media Elements player dimensions
2748		function trx_addons_set_mejs_player_dimensions(video, w, h) {
2749			if (mejs) {
2750				for (var pl in mejs.players) {
2751					if (mejs.players[pl].media.src == video.attr('src')) {
2752						if (mejs.players[pl].media.setVideoSize) {
2753							mejs.players[pl].media.setVideoSize(w, h);
2754						} else if (mejs.players[pl].media.setSize) {
2755							mejs.players[pl].media.setSize(w, h);
2756						}
2757						mejs.players[pl].setPlayerSize(w, h);
2758						mejs.players[pl].setControlsSize();
2759					}
2760				}
2761			}
2762		}
2763
2764
2765		// Autoplay video from YouTube
2766		//---------------------------------
2767		var initAPI = false;
2768		var initEvents = false;
2769		var process = false;
2770		var players = [];
2771		var attrs = [];
2772		var oldAPI = window.onYouTubeIframeAPIReady;
2773		var YTdeferred = jQuery.Deferred();
2774
2775		// Detect if element is in viewport
2776		jQuery.fn.isInViewport = function() {
2777			var $self = jQuery(this);
2778			var $panel = $self.data( 'sc-panel-thumb' );
2779			if ( ! $panel ) {
2780				$panel = $self.parents('.sc_panel_thumb');
2781				$self.data( 'sc-panel-thumb', $panel );
2782			}
2783			var rez = trx_addons_apply_filters( 'trx_addons_filter_element_in_viewport', $panel.length === 0 || $panel.hasClass('sc_panel_thumb_active'), $self );
2784			if ( rez ) {
2785				var elementTop = $self.offset().top;
2786				var elementBottom = elementTop + $self.outerHeight();
2787				var viewportTop = trx_addons_window_scroll_top();
2788				var viewportBottom = viewportTop + trx_addons_window_height();
2789				rez = elementTop >= viewportTop && elementTop <= viewportBottom
2790						||
2791					elementBottom >= viewportTop && elementBottom <= viewportBottom;
2792			}
2793			return rez;
2794		};
2795
2796		function embedYoutubeAPI() {
2797			if ( ! initAPI ) {
2798				var tag = document.createElement('script');
2799				tag.src = 'https://www.youtube.com/iframe_api';
2800				var firstScriptTag = document.getElementsByTagName('script')[0];
2801				firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
2802				initAPI = true;
2803			}
2804		}
2805
2806		window.onYouTubePlayerAPIReady = function() {
2807			if ( oldAPI && typeof oldAPI == 'function' ) oldAPI();
2808			YTdeferred.resolve(window.YT);
2809		};
2810
2811		function initYoutubePlayer() {
2812			if (process) return;
2813			process = true;
2814			// Load Youtube API
2815			if ( $video_autoplay_yt.length ) {
2816				embedYoutubeAPI();
2817			}
2818
2819			if ( ! initAPI ) {
2820				process = false;
2821				return;
2822			}
2823
2824			if ( typeof YTdeferred != 'undefined' ) {
2825				YTdeferred.done( function(YT) {
2826					$video_autoplay_yt.each( function() {
2827						var $self = jQuery(this);
2828						if ( $self.parents('.sc_layouts_submenu:not(.layouts_inited):not(:visible)').length ) return;
2829
2830						var $frame = $self.parents('.video_frame').eq(0),
2831							$wrap = $self.parents('.with_video_autoplay').eq(0),
2832							$sticky = $self.parents('.trx_addons_video_sticky_inner').eq(0),
2833							isInit = $wrap.hasClass('video_autoplay_inited'),
2834							isInView = $wrap.isInViewport(),
2835							id = ! isInit ? Math.random().toString(36).substr(2, 9) : $wrap.attr('data-uid');
2836
2837						if ( ! isInit ) {
2838							$self.attr( 'id', id );
2839							$wrap
2840								.addClass('video_autoplay_inited')
2841								.attr('data-uid', id);
2842							var videoID = $wrap.data('video-id');
2843							if ( ! videoID ) {
2844								var src = ( $self.data('src') ? $self.data('src') : $self.attr('src') ).split('?');
2845								videoID = src[0].substring( src[0].indexOf('/embed/') + 7 );
2846								$wrap.data('video-id', videoID);
2847							}
2848							if ( ! videoID ) return;
2849							$frame.append(
2850								'<span class="video_frame_overlay"></span>'
2851								+ '<span class="video_frame_controls">'
2852									+ '<a class="video_frame_control_stop video_frame_link" href="https://youtube.com/watch?v='+videoID+'" target="_blank"></a>'
2853									+ '<span class="video_frame_control_volume video_frame_control_volume_mute"></span>'
2854									+ '<span class="video_frame_control_state video_frame_control_state_'
2855										+ ( $self.attr( 'allow' ) && $self.attr( 'allow' ).indexOf( 'autoplay' ) >= 0 ? 'pause' : 'play' )
2856									+ '"></span>'
2857								 + '</span>'
2858							);
2859
2860							// Play/Pause video on enter/leave viewport
2861							trx_addons_intersection_observer_add( $wrap, function( item, enter ) {
2862								initYoutubePlayer();
2863							} );
2864
2865							// Play/Pause video
2866							$frame.find('.video_frame_control_state').on('click', function() {
2867								var $self = jQuery(this);
2868								$self.toggleClass('video_frame_control_state_play video_frame_control_state_pause');
2869								if ( $self.hasClass('video_frame_control_state_play') ) {
2870									$self.removeClass('video_frame_control_state_upause');
2871									if ( typeof players[id].playVideo == 'function' ) players[id].playVideo();
2872								} else {
2873									$self.addClass('video_frame_control_state_upause');
2874									if ( typeof players[id].pauseVideo == 'function' ) players[id].pauseVideo();
2875								}
2876							} );
2877
2878							// Stop video (on go to Youtube)
2879							$frame.find('.video_frame_control_stop').on('click', function() {
2880								var $self = jQuery(this);
2881								$self.siblings('.video_frame_control_state').removeClass('video_frame_control_state_play').addClass('video_frame_control_state_pause');
2882								$self.addClass('video_frame_control_state_upause');
2883								if ( typeof players[id].pauseVideo == 'function' ) players[id].pauseVideo();
2884							} );
2885
2886							// Mute/Unmute video
2887							$frame.find('.video_frame_control_volume').on('click', function() {
2888								var $self = jQuery(this);
2889								$self.toggleClass('video_frame_control_volume_mute video_frame_control_volume_unmute');
2890								if ( $self.hasClass('video_frame_control_volume_unmute') ) {
2891									if ( typeof players[id].unMute == 'function' ) players[id].unMute();
2892								} else {
2893									if ( typeof players[id].mute == 'function' ) players[id].mute();
2894								}
2895							} );
2896
2897							attrs[id] = {
2898								'videoId': videoID,
2899								'startSeconds': $self.data('video-start') || trx_addons_apply_filters( 'trx_addons_filter_youtube_autoplay_start_seconds', -1 ),
2900								'suggestedQuality': 'hd720'
2901							};
2902							if ( $self.data('video-end') ) {
2903								attrs[id]['endSeconds'] = $self.data('video-end');
2904							}
2905							players[id] = new YT.Player( this, {
2906								playerVars: {
2907									autoplay: 0,
2908									autohide: 1,
2909									modestbranding: 1,
2910									rel: 0,
2911									showinfo: 0,
2912									controls: 0,
2913									disablekb: 1,
2914									enablejsapi: 1,
2915									iv_load_policy: 3,
2916									playsinline: 1,
2917									loop: 1
2918								},
2919								events: {
2920									'onReady': function onReady(e) {
2921										//players[id].loadVideoById( attrs[id] );
2922										players[id].mute();
2923									},
2924									'onStateChange': function onStateChange(e) {
2925										if (e.data === 1) {
2926											$wrap.addClass('video_autoplay_started');
2927										} else if (e.data === 0) {
2928											if ( attrs[id].startSeconds >= 0 ) {
2929												players[id].seekTo(attrs[id].startSeconds);
2930											}
2931										}
2932									}
2933								}
2934							} );
2935							// Save a reference to the player object in the frame's data store
2936							// to allow 3rd party scripts to control the video programmatically
2937							$frame.data('video-player', players[id]);
2938						}
2939						// FadeIn video
2940						if ( isInit && isInView && ! $frame.hasClass('.video_frame_visible') ) {
2941							setTimeout( function() {
2942								$frame.fadeTo( 500, 1.0, function() {
2943									$frame.addClass('video_frame_visible');
2944								});
2945							}, trx_addons_apply_filters( 'trx_addons_filter_video_frame_timeout', 0 ) );
2946						}
2947						// Play/Pause on window scroll
2948						var control = $wrap.find('.video_frame_control_state');
2949						if ( isInit && typeof players[id].playVideo == 'function' && ! control.hasClass('video_frame_control_state_upause') && $sticky.length === 0 ) {
2950							if ( isInView && control.hasClass('video_frame_control_state_pause') ) {
2951								control.removeClass('video_frame_control_state_pause').addClass('video_frame_control_state_play');
2952								players[id].playVideo();
2953							}
2954							if ( ! isInView && control.hasClass('video_frame_control_state_play') ) {
2955								control.removeClass('video_frame_control_state_play').addClass('video_frame_control_state_pause');
2956								players[id].pauseVideo();
2957							}
2958						}
2959					} );
2960
2961				} );
2962			}
2963
2964			process = false;
2965
2966		}	// initYoutubePlayer
2967
2968		initYoutubePlayer();
2969
2970		// Init hidden and loaded elements
2971		if ( ! initEvents ) {
2972			initEvents = true;
2973			$document.on( 'action.init_hidden_elements action.got_ajax_response action.after_show_submenu action.after_hide_submenu', trx_addons_debounce( function( e ) {
2974				initYoutubePlayer();
2975			}, 50 ) );
2976			$document.on( 'action.start_item_animation', function() {
2977				setTimeout( function() {
2978					initYoutubePlayer();
2979				}, 10 );
2980			} );
2981		}
2982
2983		ready_busy = false;
2984
2985	} );	// document.ready
2986
2987
2988	// Global functions
2989	//-------------------------------------
2990
2991	// Paint arc on canvas with digits (used in the shortcodes and reviews)
2992	window.trx_addons_draw_arc_on_canvas = function(item, value) {
2993	
2994		var canvas = item.find('canvas');
2995		if (canvas.length === 0) return;
2996		
2997		var digits = canvas.next();
2998		var brd = parseInt(digits.css('border-top-width'), 10);
2999		var w = Math.ceil(digits.width()+2*brd);
3000	
3001		var needRepaint = false;
3002		if (canvas.attr('width') != w) {
3003			needRepaint = true;
3004			canvas.attr({
3005				'width': w,
3006				'height': w
3007			});
3008		}
3009	
3010		if (item.data('old-value') == value && !needRepaint) return;
3011		item.data('old-value', value);
3012		
3013		var percent = value * 100 / canvas.data('max-value');
3014		var angle = 360 * percent / 100;
3015		var Ar = angle * Math.PI / 180;
3016	
3017		var canvas_dom = canvas.get(0);
3018		var context = canvas_dom.getContext('2d');
3019		var r = (w - brd) / 2;
3020		var cx = w / 2;
3021		var cy = w / 2;
3022	
3023		context.beginPath();
3024		context.clearRect(0, 0, w, w);
3025		context.arc(cx, cy, r, 0, Ar, false);
3026		context.imageSmoothingEnabled= true;
3027		context.lineWidth = brd;
3028		context.strokeStyle = canvas.data('color');
3029		context.stroke();
3030	};
3031
3032})();

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.