PageSourceSearch

https://andresbanquet.com/wp-content/themes/royal-event/fw/js/core.init.js

js andresbanquet.com collected 2026-10-09 22:41:38 UTC 58,121 bytes, 1,659 lines download raw bytes

1/* global jQuery:false */
2/* global ROYAL_EVENT_STORAGE:false */
3
4jQuery(document).ready(function() {
5	"use strict";
6	ROYAL_EVENT_STORAGE['theme_init_counter'] = 0;
7	royal_event_init_actions();
8
9	// Disable init VC prettyPhoto on the gallery images
10	window.vc_prettyPhoto = function() {};
11});
12
13jQuery(window).on('beforeunload', function() {
14	"use strict";
15	// Show preloader
16	if (jQuery.browser && !jQuery.browser.safari) jQuery('#page_preloader').css({display: 'block', opacity: 0}).animate({opacity:0.8}, 300);
17});
18
19
20// Theme init actions
21function royal_event_init_actions() {
22	"use strict";
23
24	if (ROYAL_EVENT_STORAGE['vc_edit_mode'] && jQuery('.vc_empty-placeholder').length==0 && ROYAL_EVENT_STORAGE['theme_init_counter']++ < 30) {
25		setTimeout(royal_event_init_actions, 200);
26		return;
27	}
28	
29	// Hide preloader
30	jQuery('#page_preloader').animate({opacity:0}, 500, function() { jQuery(this).css({display: 'none'}); });
31
32	// Check for Retina display
33	if (royal_event_is_retina()) {
34		royal_event_set_cookie('royal_event_retina', 1, 365);
35	}
36
37	royal_event_ready_actions();
38
39	// Add resize handlers after VC row stretch handlers on('resize.vcRowBehaviour', ...)
40	setTimeout(function() {
41		jQuery(window).on('resize.royal_event', function() {
42			royal_event_resize_actions();
43			royal_event_scroll_actions()
44		}).trigger('resize.royal_event');
45	}, 10);
46
47	// Add resize on VC action vc-full-width-row
48	jQuery(document).on('vc-full-width-row', function() {
49		royal_event_resize_actions();
50		royal_event_scroll_actions()
51	});
52
53	// Scroll handlers
54	jQuery(window).on('scroll.royal_event', function() {
55		"use strict";
56		royal_event_scroll_actions();
57	});
58}
59
60
61
62// Theme first load actions
63//==============================================
64function royal_event_ready_actions() {
65	"use strict";
66
67	// Call theme specific action (if exists)
68    //----------------------------------------------
69	if (window.royal_event_theme_ready_actions) royal_event_theme_ready_actions();
70
71
72	// Widgets decoration
73    //----------------------------------------------
74
75	// Decorate nested lists in widgets and side panels
76	jQuery('.widget ul > li').each(function() {
77		"use strict";
78		if (jQuery(this).find('ul').length > 0) {
79			jQuery(this).addClass('has_children');
80		}
81	});
82
83
84	// Archive widget decoration
85	jQuery('.widget_archive a').each(function() {
86		"use strict";
87		var val = jQuery(this).html().split(' ');
88		if (val.length > 1) {
89			val[val.length-1] = '<span>' + val[val.length-1] + '</span>';
90			jQuery(this).html(val.join(' '))
91		}
92	});
93
94
95	// Navigate on category change
96	jQuery('.widget_subcategories').on('change', 'select', function() {
97		"use strict";
98		var dropdown = jQuery(this).get(0);
99		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
100			location.href = ROYAL_EVENT_STORAGE['site_url'] + "/?cat="+dropdown.options[dropdown.selectedIndex].value;
101		}
102	});
103
104	
105	// Calendar handlers - change months
106	jQuery('.widget_calendar, .wp-block-calendar').on('click', '.month_prev a, .month_next a', function(e) {
107		"use strict";
108		var calendar = jQuery(this).parents('.wp-calendar');
109		var m = jQuery(this).data('month');
110		var y = jQuery(this).data('year');
111		var l = jQuery(this).data('letter');
112		var pt = jQuery(this).data('type');
113		jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
114			action: 'calendar_change_month',
115			nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
116			letter: l,
117			month: m,
118			year: y,
119			post_type: pt
120		}).done(function(response) {
121			var rez = {};
122			try {
123				rez = JSON.parse(response);
124			} catch (e) {
125				rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
126				console.log(response);
127			}
128			if (rez.error === '') {
129				calendar.parent().fadeOut(200, function() {
130					jQuery(this).find('.wp-calendar').remove();
131					jQuery(this).append(rez.data).fadeIn(200);
132				});
133			}
134		});
135		e.preventDefault();
136		return false;
137	});
138
139
140	// Media setup
141    //----------------------------------------------
142
143	// Video background init
144	jQuery('.video_bg').each(function() {
145		"use strict";
146		var youtube = jQuery(this).data('youtube-code');
147		if (youtube) {
148			jQuery(this).tubular({videoId: youtube});
149		}
150	});
151
152
153	// Main slider
154    //----------------------------------------------
155	jQuery('.slider_over_button,.slider_over_close').on('click', function(e) {
156		"use strict";
157		jQuery(this).parent().toggleClass('opened');
158		e.preventDefault();
159		return false;
160	});
161
162
163
164	// Menu
165    //----------------------------------------------
166	
167	// hide header mobile
168	if (jQuery('.header_mobile').length > 0) {
169		jQuery('.header_mobile .menu_main_nav a').each(function (){
170			"use strict";
171			var href = jQuery(this).attr('href');
172			if (href===undefined) return;
173			var aHref = jQuery(this).attr('href').indexOf("#");
174			if ( (aHref >= 0) && (href.length >1) ) {
175				jQuery(this).addClass('anchorClose');
176			}
177		});
178	}
179	// Clone side menu for responsive
180	"use strict";
181	if (jQuery('ul#menu_side').length > 0) {
182		jQuery('ul#menu_side').clone().removeAttr('id').removeClass('menu_side_nav').addClass('menu_side_responsive').insertAfter('ul#menu_side');
183		royal_event_show_current_menu_item(jQuery('.menu_side_responsive'), jQuery('.sidebar_outer_menu_responsive_button'));
184	}
185	if (jQuery('.header_mobile').length > 0) {
186		jQuery('.header_mobile .menu_main_nav_area ul#menu_main').removeAttr('id');
187		jQuery('.header_mobile .menu_button').on('click', function(){
188			jQuery('.header_mobile .side_wrap').toggleClass('open');
189			jQuery('.header_mobile .mask').toggleClass('show');
190			jQuery('html').toggleClass('menu_mobile_open');
191			// Fix for Safari
192			if (royal_event_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) {
193				jQuery('body').toggleClass('ios_fixed');
194			}
195		});
196		jQuery('.header_mobile .mask, .header_mobile .side_wrap .close, .anchorClose').on('click', function(){
197			jQuery('.header_mobile .side_wrap').removeClass('open');
198			jQuery('.header_mobile .mask').removeClass('show');
199			jQuery('html').removeClass('menu_mobile_open');
200			// Fix for Safari
201			if (royal_event_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) {
202				jQuery('body').removeClass('ios_fixed');
203			}
204		});
205	}
206
207	// Push menu button
208	jQuery('.menu_pushy_button').on('click', function(e){
209		"use strict";
210		jQuery('body').addClass('pushy-active').css('overflow', 'hidden');
211		jQuery('.site-overlay').fadeIn('fast');
212		e.preventDefault();
213		return false;
214	});
215	jQuery('.pushy .close-pushy,.site-overlay').on('click', function(e){
216		jQuery('body').removeClass('pushy-active').css('overflow', 'visible');
217		jQuery('.site-overlay').fadeOut('fast');
218		e.preventDefault();
219		return false;
220	});
221	
222	// Side menu widgets button
223	jQuery('.sidebar_outer_widgets_button').on('click', function(e){
224		"use strict";
225		jQuery('.sidebar_outer_widgets').slideToggle();
226		e.preventDefault();
227		return false;
228	});
229
230	// Add arrows in responsive menu
231	jQuery('.header_mobile .menu_main_nav .menu-item-has-children > a, .menu_side_responsive .menu-item-has-children > a, .menu_pushy_nav_area .menu-item-has-children > a, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories .has_children > a').prepend('<span class="open_child_menu"></span>');
232
233	// Submenu click handler for the responsive menu
234	jQuery('.header_mobile .menu_main_nav, .menu_side_responsive, .menu_pushy_nav_area, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories').on('click', 'li a,li a .open_child_menu, ul.product-categories.plain li a .open_child_menu', function(e) {
235		"use strict";
236		var is_menu_main = jQuery(this).parents('.menu_main_nav').length > 0;
237		var $a = jQuery(this).hasClass('open_child_menu') ? jQuery(this).parent() : jQuery(this);
238		if ((!is_menu_main || jQuery('body').hasClass('menu_mobile')) && ($a.parent().hasClass('menu-item-has-children') || $a.parent().hasClass('has_children'))) {
239			if ($a.siblings('ul:visible').length > 0)
240				$a.siblings('ul').slideUp().parent().removeClass('opened');
241			else {
242				jQuery(this).parents('li').siblings('li').find('ul:visible').slideUp().parent().removeClass('opened');
243				$a.siblings('ul').slideDown().parent().addClass('opened');
244			}
245		}
246		// Ignore link for parent menu items
247		if (jQuery(this).hasClass('open_child_menu') || $a.attr('href')=='#') {
248			e.preventDefault();
249			return false;
250		}
251	});
252	
253	// Init superfish menus
254	royal_event_init_sfmenu('.menu_main_nav_area ul#menu_main, ul#menu_user, ul#menu_side, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
255
256	// Slide effect for main menu
257	if (ROYAL_EVENT_STORAGE['menu_hover']=='slide_line' || ROYAL_EVENT_STORAGE['menu_hover']=='slide_box') {
258		setTimeout(function() {
259			"use strict";
260			jQuery('#menu_main').spasticNav({
261				style: ROYAL_EVENT_STORAGE['menu_hover']=='slide_line' ? 'line' : 'box',
262				color: ROYAL_EVENT_STORAGE['accent1_hover'],
263				colorOverride: false
264			});
265		}, 500);
266	}
267
268	// Show table of contents for the current page
269	if (ROYAL_EVENT_STORAGE['toc_menu'] != 'hide' && ROYAL_EVENT_STORAGE['toc_menu'] != 'no') {
270		royal_event_build_page_toc();
271	}
272
273	// One page mode for menu links (scroll to anchor)
274	jQuery('#toc, ul#menu_main li, ul#menu_user li, ul#menu_side li, ul#menu_footer li, ul#menu_pushy li').on('click', 'a', function(e) {
275		"use strict";
276		var href = jQuery(this).attr('href');
277		if (href===undefined) return;
278		var pos = href.indexOf('#');
279		if (pos < 0 || href.length == 1) return;
280		if (jQuery(href.substr(pos)).length > 0) {
281			var loc = window.location.href;
282			var pos2 = loc.indexOf('#');
283			if (pos2 > 0) loc = loc.substring(0, pos2);
284			var now = pos==0;
285			if (!now) now = loc == href.substring(0, pos);
286			if (now) {
287				royal_event_document_animate_to(href.substr(pos));
288				royal_event_document_set_location(pos==0 ? loc + href : href);
289				e.preventDefault();
290				return false;
291			}
292		}
293	});
294	
295	
296	// Store height of the top and side panels
297	ROYAL_EVENT_STORAGE['top_panel_height'] = 0;
298	ROYAL_EVENT_STORAGE['side_panel_height'] = 0;
299
300
301	// Pagination
302    //----------------------------------------------
303
304	// Page navigation (style slider)
305	jQuery('.pager_cur').on('click', function(e) {
306		"use strict";
307		jQuery('.pager_slider').slideDown(300, function() {
308			royal_event_sc_init(jQuery('.pager_slider').eq(0));
309		});
310		e.preventDefault();
311		return false;
312	});
313
314
315	// View More button
316	jQuery('#viewmore_link').on('click', function(e) {
317		"use strict";
318		if (!ROYAL_EVENT_STORAGE['viewmore_busy'] && !jQuery(this).hasClass('viewmore_empty')) {
319			jQuery(this).parent().addClass('loading');
320			ROYAL_EVENT_STORAGE['viewmore_busy'] = true;
321			jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
322				action: 'view_more_posts',
323				nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
324				page: ROYAL_EVENT_STORAGE['viewmore_page']+1,
325				data: ROYAL_EVENT_STORAGE['viewmore_data'],
326				vars: ROYAL_EVENT_STORAGE['viewmore_vars']
327			}).done(function(response) {
328				"use strict";
329				var rez = {};
330				try {
331					rez = JSON.parse(response);
332				} catch (e) {
333					rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
334					console.log(response);
335				}
336				jQuery('#viewmore_link').parent().removeClass('loading');
337				ROYAL_EVENT_STORAGE['viewmore_busy'] = false;
338				if (rez.error === '') {
339					var posts_container = jQuery('.content').eq(0);
340					if (posts_container.find('.isotope_wrap').length > 0) posts_container = posts_container.find('.isotope_wrap').eq(0);
341					if (posts_container.hasClass('isotope_wrap')) {
342						posts_container.data('last-width', 0).append(rez.data);
343						ROYAL_EVENT_STORAGE['isotope_init_counter'] = 0;
344						royal_event_init_appended_isotope(posts_container, rez.filters);
345					} else
346						jQuery('#viewmore').before(rez.data);
347
348					ROYAL_EVENT_STORAGE['viewmore_page']++;
349					if (rez.no_more_data==1) {
350						jQuery('#viewmore_link').addClass('viewmore_empty').parent().hide();
351					}
352
353					royal_event_init_post_formats();
354					royal_event_sc_init(posts_container);
355					royal_event_scroll_actions();
356				}
357			});
358		}
359		e.preventDefault();
360		return false;
361	});
362
363
364	// WooCommerce
365    //----------------------------------------------
366
367	// Change display mode
368	jQuery('.woocommerce,.woocommerce-page').on('click', '.mode_buttons a', function(e) {
369		"use strict";
370		var mode = jQuery(this).hasClass('woocommerce_thumbs') ? 'thumbs' : 'list';
371        royal_event_set_cookie('royal_event_shop_mode', mode, 365);
372		jQuery(this).siblings('input').val(mode).parents('form').get(0).submit();
373		e.preventDefault();
374		return false;
375	});
376    // Add buttons to quantity on first run
377    if (jQuery('.woocommerce div.quantity .q_inc,.woocommerce-page div.quantity .q_inc').length == 0) {
378        var woocomerce_inc_dec = '<span class="q_inc"></span><span class="q_dec"></span>';
379        jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append(woocomerce_inc_dec);
380        jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').on('click', '>span', function(e) {
381            woocomerce_inc_dec_click(jQuery(this));
382            e.preventDefault();
383            return false;
384        });
385    }
386	// Add buttons to quantity after the cart is updated
387    jQuery(document.body).on('updated_wc_div', function() {
388        if (jQuery('.woocommerce div.quantity .q_inc,.woocommerce-page div.quantity .q_inc').length == 0) {
389            jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append(woocomerce_inc_dec);
390            jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').on('click', '>span', function(e) {
391                woocomerce_inc_dec_click(jQuery(this));
392                e.preventDefault();
393                return false;
394            });
395        }
396    });
397	// Inc/Dec quantity on buttons inc/dec
398    function woocomerce_inc_dec_click(button) {
399        var f = button.siblings('input');
400		if (button.hasClass( 'q_inc' )) {
401			f.val( ( f.val() == '' ? 0 : parseInt( f.val(), 10 ) ) + 1 ).trigger( 'change' );
402		} else {
403			f.val( Math.max( 0, ( f.val() == '' ? 0 : parseInt( f.val(), 10 ) ) - 1 ) ).trigger( 'change' );
404		}
405    }
406
407    // Show cart
408	jQuery('.top_panel_middle .top_panel_cart_button, .header_mobile .top_panel_cart_button').on('click', function(e) {
409		"use strict";
410		jQuery(this).siblings('.sidebar_cart').slideToggle();
411		e.preventDefault();
412		return false;
413	});
414	// Add stretch behaviour to WooC tabs area
415	jQuery('.single-product .woocommerce-tabs')
416		.addClass('trx-stretch-width scheme_light')
417		.after('<div class="trx-stretch-width-original"></div>');
418	royal_event_stretch_width();
419
420	// Added to cart
421	jQuery( document.body ).on('added_to_cart', function() {
422		"use strict";
423		royal_event_update_cart();
424	});
425
426// Removed from cart
427	jQuery( document.body ).on( 'removed_from_cart', function (){
428		"use strict";
429		royal_event_update_cart();
430	});
431
432	// Update cart display
433	function royal_event_update_cart(){
434		// Update amount on the cart button
435		var total = jQuery('.widget_shopping_cart').eq(0).find('.total .amount').text();
436		if (total != undefined) {
437			jQuery('.top_panel_cart_button .cart_summa').text(total);
438		}
439		// Update count items on the cart button
440		var cnt = 0;
441		jQuery('.widget_shopping_cart_content').eq(0).find('.cart_list li').each(function() {
442			var q = jQuery(this).find('.quantity').html().split(' ', 2);
443			if (!isNaN(q[0]))
444				cnt += Number(q[0]);
445		});
446		var items = jQuery('.top_panel_cart_button .cart_items').eq(0).text().split(' ', 2);
447		items[0] = cnt;
448		jQuery('.top_panel_cart_button .cart_items').text(items[0]+' '+items[1]);
449		// Update data-attr on button
450		jQuery('.top_panel_cart_button').attr({
451			'data-items': cnt ? cnt : 0,
452			'data-summa': total ? total : 0
453		});
454	}
455
456
457	// Popup login and register windows
458    //----------------------------------------------
459	jQuery('.popup_link,.popup_login_link,.popup_register_link').addClass('inited').on('click', function(e){
460		var popup = jQuery(jQuery(this).attr('href'));
461		if (popup.length === 1) {
462			royal_event_hide_popup(jQuery(popup.hasClass('popup_login') ? '.popup_registration' : '.popup_login' ));
463			royal_event_show_popup(popup);
464		}
465		e.preventDefault();
466		return false;
467	});
468	jQuery('.popup_wrap').on('click', '.popup_close', function(e){
469		var popup = jQuery(this).parent();
470		if (popup.length === 1) {
471			royal_event_hide_popup(popup);
472		}
473		e.preventDefault();
474		return false;
475	});
476
477
478
479	// Bookmarks
480    //----------------------------------------------
481
482	// Add bookmark
483	jQuery('.bookmarks_add').on('click', function(e) {
484		"use strict";
485		var title = window.document.title.split('|')[0];
486		var url = window.location.href;
487		var list = royal_get_cookie('royal_bookmarks');
488		var exists = false;
489		if (list) {
490			try {
491				list = JSON.parse(list);
492			} catch (e) {}
493			if (list.length) {
494				for (var i=0; i<list.length; i++) {
495					if (list[i].url == url) {
496						exists = true;
497						break;
498					}
499				}
500			}
501		} else
502			list = new Array();
503		if (!exists) {
504			var message_popup = royal_event_message_dialog('<label for="bookmark_title">'+ROYAL_EVENT_STORAGE['strings']['bookmark_title']+'</label><br><input type="text" id="bookmark_title" name="bookmark_title" value="'+title+'">', ROYAL_EVENT_STORAGE['strings']['bookmark_add'], null,
505				function(btn, popup) {
506					"use strict";
507					if (btn != 1) return;
508					title = message_popup.find('#bookmark_title').val();
509					list.push({title: title, url: url});
510					jQuery('.bookmarks_list').append('<li><a href="'+url+'" class="bookmarks_item">'+title+'<span class="bookmarks_delete icon-cancel" title="'+ROYAL_EVENT_STORAGE['strings']['bookmark_del']+'"></span></a></li>');
511					royal_get_cookie('royal_event_bookmarks', JSON.stringify(list), {expires: 365, path: '/'});
512					setTimeout(function () {royal_event_message_success(ROYAL_EVENT_STORAGE['strings']['bookmark_added'], ROYAL_EVENT_STORAGE['strings']['bookmark_add']);}, ROYAL_EVENT_STORAGE['message_timeout']/4);
513				});
514		} else
515			royal_event_message_warning(ROYAL_EVENT_STORAGE['strings']['bookmark_exists'], ROYAL_EVENT_STORAGE['strings']['bookmark_add']);
516		e.preventDefault();
517		return false;
518	});
519
520	// Delete bookmark
521	jQuery('.bookmarks_list').on('click', '.bookmarks_delete', function(e) {
522		"use strict";
523		var idx = jQuery(this).parent().index();
524		var list = jQuery.cookie('royal_event_bookmarks');
525		if (list) {
526			try {
527				list = JSON.parse(list);
528			} catch (e) {}
529			if (list.length) {
530				list.splice(idx, 1);
531				jQuery.cookie('royal_event_bookmarks', JSON.stringify(list), {expires: 365, path: '/'});
532			}
533		}
534		jQuery(this).parent().remove();
535		e.preventDefault();
536		return false;
537	});
538
539
540	// Other settings
541    //------------------------------------
542
543	// Scroll to top button
544	jQuery('.scroll_to_top').on('click', function(e) {
545		"use strict";
546		jQuery('html,body').animate({
547			scrollTop: 0
548		}, 'slow');
549		e.preventDefault();
550		return false;
551	});
552
553	// AJAX views counter
554	if (ROYAL_EVENT_STORAGE['ajax_views_counter'] !== undefined) {
555		setTimeout(function(){
556			jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
557				action: 'post_counter',
558				nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
559				post_id: ROYAL_EVENT_STORAGE['ajax_views_counter']['post_id'],
560				views: ROYAL_EVENT_STORAGE['ajax_views_counter']['post_views']
561			});
562			}, 10);
563	}
564
565    // Show system message
566	royal_event_show_system_message();
567
568	// Init post format specific scripts
569	royal_event_init_post_formats();
570
571	// Call sc init action (if exists)
572	if (window.royal_event_sc_init_actions) royal_event_sc_init_actions();
573
574	// Init hidden elements (if exists)
575	if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(jQuery('body').eq(0));
576
577		// Contact Form 7 popup message
578		royal_rental_cf7_init();
579	
580} //end ready
581
582// Contact Form 7 popup message
583function royal_rental_cf7_init(e, container) {
584	if (container === undefined) container = jQuery('body');
585	if (container.length === undefined || container.length === 0) return;
586	
587	container.find('.wpcf7:not(.alert_inited)').each( function() {
588		var $form = jQuery(this);
589		// Decorate messages
590		$form
591			.addClass('alert_inited')
592			.on('wpcf7:submit wpcf7submit', function(e, details) {
593				var response = $form.find('.wpcf7-response-output');
594				if ( response.length ) {
595					response
596						.addClass('royal_rental_message_box')
597						.removeClass('royal_rental_message_box_info royal_rental_message_box_error royal_rental_message_box_success');
598					if ( typeof e == 'object' && typeof e.detail == 'object' && typeof e.detail.status != 'undefined' ) {
599						if ( e.detail.status == 'validation_failed' ) {
600							response.addClass('royal_rental_message_box_error');
601						} else if ( e.detail.status == 'mail_sent' ) {
602							response.addClass('royal_rental_message_box_success');
603						} else {
604							response.addClass('royal_rental_message_box_info');
605						}
606					}
607					response.fadeIn();
608				}
609			})
610			.on('click keypress change', function() {
611				$form.find('.wpcf7-response-output:visible').fadeOut();
612			} );
613		// Remove validation tip and class on any key pressed in the field
614		$form
615			.on('change', 'input,select,textarea', function() {
616				var $self = jQuery(this),
617					$wrap = $self.parents('.wpcf7-not-valid');
618				if ( $self.val() !== '' ) {
619					if ( $self.hasClass( 'wpcf7-not-valid' ) ) {
620						$self.removeClass('wpcf7-not-valid');
621					} else if ( $wrap.length > 0 ) {
622						$wrap.removeClass('wpcf7-not-valid');
623					}
624				}
625			});
626	} );
627}
628
629// Increment arrows on number input
630function royal_event_wooc_style_arrows() {
631    "use strict";
632    // Add buttons to quantity
633    jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append('<span class="q_inc"></span><span class="q_dec"></span>');
634    jQuery('.woocommerce div.quantity').on('click', '>span', function(e) {
635        var f = jQuery(this).siblings('input');
636        if (jQuery(this).hasClass('q_inc')) {
637            f.val(Math.max(0, parseInt(f.val()))+1);
638        } else {
639            f.val(Math.max(1, Math.max(0, parseInt(f.val()))-1));
640        }
641        e.preventDefault();
642        return false;
643    });
644}
645
646
647// Scroll actions
648//==============================================
649
650// Do actions when page scrolled
651function royal_event_scroll_actions() {
652	"use strict";
653	
654	// Call theme specific action (if exists)
655    //----------------------------------------------
656	var scroll_offset = jQuery(window).scrollTop();
657	var scroll_to_top_button = jQuery('.scroll_to_top');
658	var adminbar_height = Math.max(0, jQuery('#wpadminbar').height());
659
660	if (ROYAL_EVENT_STORAGE['top_panel_height'] < 1) {
661		ROYAL_EVENT_STORAGE['top_panel_height'] = Math.max(0, jQuery('.top_panel_wrap').height());
662	}
663	
664	// Scroll to top button show/hide
665	if (scroll_offset > ROYAL_EVENT_STORAGE['top_panel_height'])
666		scroll_to_top_button.addClass('show');
667	else
668		scroll_to_top_button.removeClass('show');
669	
670	// Fix/unfix top panel
671	if (!jQuery('body').hasClass('menu_mobile') && ROYAL_EVENT_STORAGE['menu_fixed']) {
672		var slider_height = 0;
673		if (jQuery('.top_panel_below .slider_wrap').length > 0) {
674			slider_height = jQuery('.top_panel_below .slider_wrap').height();
675			if (slider_height < 10) {
676				slider_height = jQuery('.slider_wrap').hasClass('.slider_fullscreen') ? jQuery(window).height() : ROYAL_EVENT_STORAGE['slider_height'];
677			}
678		}
679		if (scroll_offset <= slider_height + ROYAL_EVENT_STORAGE['top_panel_height']) {
680			if (jQuery('body').hasClass('top_panel_fixed')) {
681				jQuery('body').removeClass('top_panel_fixed');
682			}
683		} else if (scroll_offset > slider_height + ROYAL_EVENT_STORAGE['top_panel_height']) {
684			if (!jQuery('body').hasClass('top_panel_fixed') && jQuery(document).height() > jQuery(window).height()*1.5) {
685				jQuery('.top_panel_fixed_wrap').height(ROYAL_EVENT_STORAGE['top_panel_height']);
686				jQuery('.top_panel_wrap').css('marginTop', '-150px').animate({'marginTop': 0}, 500);
687				jQuery('body').addClass('top_panel_fixed');
688			}
689		}
690	}
691	
692	// Fix/unfix side panel
693	if (jQuery('.sidebar_outer').length > 0) {
694		if (ROYAL_EVENT_STORAGE['side_panel_height'] == 0)	
695			ROYAL_EVENT_STORAGE['side_panel_height'] = jQuery('.sidebar_outer_logo_wrap').outerHeight() + jQuery('.sidebar_outer_menu').outerHeight() + jQuery('.sidebar_outer_widgets').outerHeight();
696		if (scroll_offset + jQuery(window).height() > ROYAL_EVENT_STORAGE['side_panel_height'] + 100) {
697			if (jQuery('.sidebar_outer').css('position')!=='fixed') {
698				jQuery('.sidebar_outer').css({
699					'position': 'fixed',
700					'top': Math.min(0, jQuery(window).height() - ROYAL_EVENT_STORAGE['side_panel_height'] - 100) + 'px',
701				});
702			}
703		} else {
704			if (jQuery('.sidebar_outer').css('position')=='fixed') {
705				jQuery('.sidebar_outer').css({
706					'position': 'absolute',
707					'top': 0
708				});
709			}
710		}
711	}
712
713	// TOC current items
714	jQuery('#toc .toc_item').each(function() {
715		"use strict";
716		var id = jQuery(this).find('a').attr('href');
717		var pos = id.indexOf('#');
718		if (pos < 0 || id.length == 1) return;
719		var loc = window.location.href;
720		var pos2 = loc.indexOf('#');
721		if (pos2 > 0) loc = loc.substring(0, pos2);
722		var now = pos==0;
723		if (!now) now = loc == href.substring(0, pos);
724		if (!now) return;
725		var off = jQuery(id).offset().top;
726		var id_next  = jQuery(this).next().find('a').attr('href');
727		var off_next = id_next ? jQuery(id_next).offset().top : 1000000;
728		if (off < scroll_offset + jQuery(window).height()*0.8 && scroll_offset + ROYAL_EVENT_STORAGE['top_panel_height'] < off_next)
729			jQuery(this).addClass('current');
730		else
731			jQuery(this).removeClass('current');
732	});
733	
734	// Infinite pagination
735	royal_event_infinite_scroll()
736	
737	// Parallax scroll
738	royal_event_parallax_scroll();
739
740	// Call sc scroll actions (if exists)
741	if (window.royal_event_sc_scroll_actions) royal_event_sc_scroll_actions();
742}
743
744
745// Infinite Scroll
746function royal_event_infinite_scroll() {
747	"use strict";
748	if (ROYAL_EVENT_STORAGE['viewmore_busy']) return;
749	var infinite = jQuery('#viewmore.pagination_infinite');
750	if (infinite.length > 0) {
751		var viewmore = infinite.find('#viewmore_link:not(.viewmore_empty)');
752		if (viewmore.length > 0) {
753			if (jQuery(window).scrollTop() + jQuery(window).height() + 100 >= infinite.offset().top) {
754				viewmore.eq(0).trigger('click');
755			}
756		}
757	}
758}
759
760// Parallax scroll
761function royal_event_parallax_scroll(){
762    "use strict";
763	jQuery('.sc_parallax').each(function(){
764		var windowHeight = jQuery(window).height();
765		var scrollTops = jQuery(window).scrollTop();
766		var offsetPrx = Math.max(jQuery(this).offset().top, windowHeight);
767		if ( offsetPrx <= scrollTops + windowHeight ) {
768			var speed  = Number(jQuery(this).data('parallax-speed'));
769			var xpos   = jQuery(this).data('parallax-x-pos');  
770			var ypos   = Math.round((offsetPrx - scrollTops - windowHeight) * speed + (speed < 0 ? windowHeight*speed : 0));
771			jQuery(this).find('.sc_parallax_content').css('backgroundPosition', xpos+' '+ypos+'px');
772			// Uncomment next line if you want parallax video (else - video position is static)
773			jQuery(this).find('div.sc_video_bg').css('top', ypos+'px');
774		} 
775	});
776}
777
778
779
780
781
782// Resize actions
783//==============================================
784
785// Do actions when page scrolled
786function royal_event_resize_actions() {
787	"use strict";
788
789	// Call theme specific action (if exists)
790    //----------------------------------------------
791	// Reset stored value
792	ROYAL_EVENT_STORAGE['top_panel_height'] = 0;
793
794	royal_event_responsive_menu();
795	royal_event_vc_row_fullwidth_to_boxed();
796	royal_event_video_dimensions();
797	royal_event_resize_video_background();
798	royal_event_resize_fullscreen_slider();
799	royal_event_resize_alter_portfolio();
800	royal_event_stretch_width();
801
802	// Call sc resize actions (if exists)
803	if (window.royal_event_sc_resize_actions) royal_event_sc_resize_actions();
804}
805
806// Stretch area to full window width
807function royal_event_stretch_width() {
808    "use strict";
809	jQuery('.trx-stretch-width').each(function() {
810		var $el = jQuery(this);
811		var $el_full = $el.next('.trx-stretch-width-original');
812		var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 );
813		var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 );
814		var offset = 0 - $el_full.offset().left - el_margin_left;
815		var width = jQuery( window ).width();
816		if (!$el.hasClass('inited')) {
817			$el.addClass('inited invisible');
818			$el.css({
819				'position': 'relative',
820				'box-sizing': 'border-box'
821			});
822		}
823		$el.css({
824			'left': offset,
825			'width': jQuery( window ).width()
826		});
827		if ( !$el.hasClass('trx-stretch-content') ) {
828			var padding = Math.max(0, -1*offset);
829			var paddingRight = Math.max(0, width - padding - $el_full.width() + el_margin_left + el_margin_right);
830			$el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } );
831		}
832		$el.removeClass('invisible');
833	});
834}
835
836// Width vc_row when content boxed
837function royal_event_vc_row_fullwidth_to_boxed(){
838	"use strict";
839   if (jQuery('body').hasClass('body_style_boxed')) {
840       var width_body = jQuery('body').width();
841       var width_content = jQuery('.page_wrap').width();
842       var width_content_wrap = jQuery('.page_content_wrap  .content_wrap').width();
843       var indent = ( width_content - width_content_wrap ) / 2;
844	   if ( width_body > width_content ){
845		   jQuery('.vc_row[data-vc-full-width="true"]').each( function() {
846				"use strict";
847				var mrg = parseInt(jQuery(this).css('marginLeft'));
848				jQuery(this).css({
849					'width': width_content,
850					'left': -indent-mrg,
851					'padding-left': indent+mrg,
852					'padding-right': indent+mrg
853				});
854				if (jQuery(this).attr('data-vc-stretch-content')) {
855				   jQuery(this).css({
856					   'padding-left': 0,
857					   'padding-right': 0
858				   });
859				}
860		   });
861	   }
862   }
863}
864
865// Check window size and do responsive menu
866function royal_event_responsive_menu() {
867	"use strict";
868	if (royal_event_is_responsive_need(ROYAL_EVENT_STORAGE['menu_mobile'])) {
869		if (!jQuery('body').hasClass('menu_mobile')) {
870			jQuery('body').removeClass('top_panel_fixed').addClass('menu_mobile');
871			jQuery('header.top_panel_wrap ').hide();
872			jQuery('.header_mobile').show();
873			
874			jQuery('header #popup_login').attr('id', 'popup_login_1');
875			jQuery('header #popup_registration').attr('id', 'popup_registration_1');
876			jQuery('.header_mobile #popup_login_1').attr('id', 'popup_login');
877			jQuery('.header_mobile #popup_registration_1').attr('id', 'popup_registration');
878		}
879	} else {
880		if (jQuery('body').hasClass('menu_mobile')) {
881			jQuery('body').removeClass('menu_mobile');
882			jQuery('header.top_panel_wrap ').show();
883			jQuery('.header_mobile').hide();
884			
885			jQuery('header #popup_login_1').attr('id', 'popup_login');
886			jQuery('header #popup_registration_1').attr('id', 'popup_registration');
887			jQuery('.header_mobile #popup_login').attr('id', 'popup_login_1');
888			jQuery('.header_mobile #popup_registration').attr('id', 'popup_registration_1');
889		}
890	}
891	
892	if (jQuery(window).width() < 640) {
893		var pass = jQuery('.header_mobile .popup_wrap.popup_registration .registration_form > .form_right');
894		if(pass.length > 0){ 
895			jQuery('.header_mobile .popup_wrap.popup_registration .form_left .popup_form_field.email_field').after(pass);
896		}
897	}
898	else{
899		var pass = jQuery('.header_mobile .popup_wrap.popup_registration .form_left > .form_right');
900		if(pass.length > 0){ 
901			jQuery('.header_mobile .popup_wrap.popup_registration .registration_form').append(pass);
902		}
903	}
904
905	if (!jQuery('.top_panel_wrap').hasClass('menu_show')) jQuery('.top_panel_wrap').addClass('menu_show');
906	// Show widgets block on the sidebar outer (if sidebar not responsive and widgets are hidden)
907	if (jQuery('.sidebar_outer').length > 0 && jQuery('.sidebar_outer').css('position')=='absolute' && jQuery('.sidebar_outer_widgets:visible').length==0) 
908		jQuery('.sidebar_outer_widgets').show();
909	// Switch popup menu / hierarchical list on product categories list placed in sidebar
910	var cat_menu = jQuery('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
911	var sb = cat_menu.parents('.widget_area');
912	if (sb.length > 0 && cat_menu.length > 0) {
913		if (sb.width() == sb.parents('.content_wrap').width()) {
914			if (cat_menu.hasClass('inited')) {
915				cat_menu.removeClass('inited').addClass('plain').superfish('destroy');
916				cat_menu.find('ul.animated').removeClass('animated').addClass('no_animated');
917			}
918		} else {
919			if (!cat_menu.hasClass('inited')) {
920				cat_menu.removeClass('plain').addClass('inited');
921				cat_menu.find('ul.no_animated').removeClass('no_animated').addClass('animated');
922				royal_event_init_sfmenu('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
923			}
924		}
925	}
926}
927
928
929// Check if responsive menu need
930function royal_event_is_responsive_need(max_width) {
931	"use strict";
932	var rez = false;
933	if (max_width > 0) {
934		var w = window.innerWidth;
935		if (w == undefined) {
936			w = jQuery(window).width()+(jQuery(window).height() < jQuery(document).height() || jQuery(window).scrollTop() > 0 ? 16 : 0);
937		}
938		rez = max_width > w;
939	}
940	return rez;
941}
942
943
944// Fit video frames to document width
945function royal_event_video_dimensions() {
946    "use strict";
947	jQuery('.sc_video_frame').each(function() {
948		"use strict";
949		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
950		var frame  = jQuery(this).eq(0);
951		var player = frame.parent();
952		var ratio = (frame.data('ratio') ? frame.data('ratio').split(':') : (frame.find('[data-ratio]').length>0 ? frame.find('[data-ratio]').data('ratio').split(':') : [16,9]));
953		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
954		var w_attr = frame.data('width');
955		var h_attr = frame.data('height');
956		if (!w_attr || !h_attr) return;
957		var percent = (''+w_attr).substr(-1)=='%';
958		w_attr = parseInt(w_attr);
959		h_attr = parseInt(h_attr);
960		var w_real = Math.min(percent || frame.parents('.columns_wrap').length>0 ? 10000 : w_attr, frame.parents('div,article').width()),
961			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
962		if (parseInt(frame.attr('data-last-width'))==w_real) return;
963		if (percent) {
964			frame.height(h_real);
965		} else {
966			frame.css({'width': w_real+'px', 'height': h_real+'px'});
967		}
968		frame.attr('data-last-width', w_real);
969
970    });
971	jQuery('video.sc_video,video.wp-video-shortcode').each(function() {
972        "use strict";
973		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
974		var video = jQuery(this).eq(0);
975		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
976		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
977		var mejs_cont = video.parents('.mejs-video');
978		var frame = video.parents('.sc_video_frame');
979		var w_attr = frame.length>0 ? frame.data('width') : video.data('width');
980		var h_attr = frame.length>0 ? frame.data('height') : video.data('height');
981		if (!w_attr || !h_attr) {
982			w_attr = video.attr('width');
983			h_attr = video.attr('height');
984			if (!w_attr || !h_attr) return;
985			video.data({'width': w_attr, 'height': h_attr});
986		}
987		var percent = (''+w_attr).substr(-1)=='%';
988		w_attr = parseInt(w_attr);
989		h_attr = parseInt(h_attr);
990		var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()),
991			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
992		if (parseInt(video.attr('data-last-width'))==w_real) return;
993		if (mejs_cont.length > 0 && mejs) {
994			royal_event_set_mejs_player_dimensions(video, w_real, h_real);
995		}
996		if (percent) {
997			video.height(h_real);
998		} else {
999			video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
1000		}
1001		video.attr('data-last-width', w_real);
1002	});
1003	jQuery('video.sc_video_bg').each(function() {
1004		"use strict";
1005		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
1006		var video = jQuery(this).eq(0);
1007		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
1008		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1009		var mejs_cont = video.parents('.mejs-video');
1010		var container = mejs_cont.length>0 ? mejs_cont.parent() : video.parent();
1011		var w = container.width();
1012		var h = container.height();
1013		var w1 = Math.ceil(h*ratio);
1014		var h1 = Math.ceil(w/ratio);
1015		if (video.parents('.sc_parallax').length > 0) {
1016			var windowHeight = jQuery(window).height();
1017			var speed = Number(video.parents('.sc_parallax').data('parallax-speed'));
1018			var h_add = Math.ceil(Math.abs((windowHeight-h)*speed));
1019			if (h1 < h + h_add) {
1020				h1 = h + h_add;
1021				w1 = Math.ceil(h1 * ratio);
1022			}
1023		}
1024		if (h1 < h) {
1025			h1 = h;
1026			w1 = Math.ceil(h1 * ratio);
1027		}
1028		if (w1 < w) { 
1029			w1 = w;
1030			h1 = Math.ceil(w1 / ratio);
1031		}
1032		var l = Math.round((w1-w)/2);
1033		var t = Math.round((h1-h)/2);
1034		if (parseInt(video.attr('data-last-width'))==w1) return;
1035		if (mejs_cont.length > 0) {
1036			royal_event_set_mejs_player_dimensions(video, w1, h1);
1037			mejs_cont.css({
1038				'top': -t+'px'
1039			});
1040		} else
1041			video.css({
1042				'top': -t+'px'
1043			});
1044		video.attr({'width': w1, 'height': h1, 'data-last-width':w1}).css({'width':w1+'px', 'height':h1+'px'});
1045		if (video.css('opacity')==0) video.animate({'opacity': 1}, 3000);
1046	});
1047	jQuery('iframe').each(function() {
1048		"use strict";
1049		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
1050		var iframe = jQuery(this).eq(0);
1051		var ratio = (iframe.data('ratio')!=undefined ? iframe.data('ratio').split(':') : (iframe.find('[data-ratio]').length>0 ? iframe.find('[data-ratio]').data('ratio').split(':') : [16,9]));
1052		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1053		var w_attr = iframe.attr('width');
1054		var h_attr = iframe.attr('height');
1055		var frame = iframe.parents('.sc_video_frame');
1056		if (frame.length > 0) {
1057			w_attr = frame.data('width');
1058			h_attr = frame.data('height');
1059		}
1060		if (!w_attr || !h_attr) {
1061			return;
1062		}
1063		var percent = (''+w_attr).substr(-1)=='%';
1064		w_attr = parseInt(w_attr);
1065		h_attr = parseInt(h_attr);
1066		var w_real = frame.length > 0 ? frame.width() : iframe.width(),
1067			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
1068		if (parseInt(iframe.attr('data-last-width'))==w_real) return;
1069		iframe.css({'width': w_real+'px', 'height': h_real+'px'});
1070	});
1071}
1072
1073// Resize fullscreen video background
1074function royal_event_resize_video_background() {
1075	"use strict";
1076	var bg = jQuery('.video_bg');
1077	if (bg.length < 1) 
1078		return;
1079	if (ROYAL_EVENT_STORAGE['media_elements_enabled'] && bg.find('.mejs-video').length == 0)  {
1080		setTimeout(royal_event_resize_video_background, 100);
1081		return;
1082	}
1083	var video = bg.find('video');
1084	var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
1085	ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1086	var w = bg.width();
1087	var h = bg.height();
1088	var w1 = Math.ceil(h*ratio);
1089	var h1 = Math.ceil(w/ratio);
1090	if (h1 < h) {
1091		h1 = h;
1092		w1 = Math.ceil(h1 * ratio);
1093	}
1094	if (w1 < w) { 
1095		w1 = w;
1096		h1 = Math.ceil(w1 / ratio);
1097	}
1098	var l = Math.round((w1-w)/2);
1099	var t = Math.round((h1-h)/2);
1100	if (bg.find('.mejs-container').length > 0) {
1101		royal_event_set_mejs_player_dimensions(bg.find('video'), w1, h1);
1102		bg.find('.mejs-container').css({'left': -l+'px', 'top': -t+'px'});
1103	} else
1104		bg.find('video').css({'left': -l+'px', 'top': -t+'px'});
1105	bg.find('video').attr({'width': w1, 'height': h1}).css({'width':w1+'px', 'height':h1+'px'});
1106}
1107
1108// Set Media Elements player dimensions
1109function royal_event_set_mejs_player_dimensions(video, w, h) {
1110	"use strict";
1111	if (mejs) {
1112		for (var pl in mejs.players) {
1113			if (mejs.players[pl].media.src == video.attr('src')) {
1114				if (mejs.players[pl].media.setVideoSize) {
1115					mejs.players[pl].media.setVideoSize(w, h);
1116				}
1117				mejs.players[pl].setPlayerSize(w, h);
1118				mejs.players[pl].setControlsSize();
1119			}
1120		}
1121	}
1122}
1123
1124// Resize Fullscreen Slider
1125function royal_event_resize_fullscreen_slider() {
1126	"use strict";
1127	var slider_wrap = jQuery('.slider_wrap.slider_fullscreen');
1128	if (slider_wrap.length < 1) 
1129		return;
1130	var slider = slider_wrap.find('.sc_slider_swiper');
1131	if (slider.length < 1) 
1132		return;
1133	var h = jQuery(window).height() - jQuery('#wpadminbar').height() - (jQuery('body').hasClass('top_panel_above') && !jQuery('body').hasClass('.top_panel_fixed') ? jQuery('.top_panel_wrap').height() : 0);
1134	slider.height(h);
1135}
1136
1137// Resize Alter portfolio elements
1138function royal_event_resize_alter_portfolio() {
1139	"use strict";
1140	var wrap = jQuery('.isotope_wrap.inited');
1141	if (wrap.length==0) return;
1142	wrap.each(function() {
1143		"use strict";
1144		var alter = jQuery(this).find('.post_item_alter');
1145		if (alter.length==0) return;
1146		var single = alter.find('.post_featured img[data-alter-items-w="1"]').eq(0);
1147		if (single.length != 1) return;
1148		var w_real = single.width();
1149		var h_real = single.height();
1150		var space = Number(single.data('alter-item-space'));
1151		var relayout = false;
1152		alter.find('.post_featured img').each(function() {
1153			"use strict";
1154			var items_w = Number(jQuery(this).data('alter-items-w'));
1155			var items_h = Number(jQuery(this).data('alter-items-h'));
1156			if (items_h > 1) {
1157				jQuery(this).height(Math.round(items_h*h_real+(items_h-1)*(space+1)));
1158				relayout = true;
1159			} else if (items_w > 1) {
1160				jQuery(this).height(h_real);
1161				relayout = true;
1162			}
1163		});
1164		if (relayout) {
1165			jQuery(this).isotope('layout');
1166		}
1167	});
1168}
1169
1170
1171
1172
1173
1174// Navigation
1175//==============================================
1176
1177// Init Superfish menu
1178function royal_event_init_sfmenu(selector) {
1179    "use strict";
1180	jQuery(selector).show().each(function() {
1181		if (royal_event_is_responsive_need() && (jQuery(this).attr('id')=='menu_main' || jQuery(this).attr('id')=='menu_side')) return;
1182		jQuery(this).addClass('inited').superfish({
1183			delay: 500,
1184			animation: {
1185				opacity: 'show'
1186			},
1187			animationOut: {
1188				opacity: 'hide'
1189			},
1190			speed: 		ROYAL_EVENT_STORAGE['css_animation'] ? 500 : 200,
1191			speedOut:	ROYAL_EVENT_STORAGE['css_animation'] ? 500 : 200,
1192			autoArrows: false,
1193			dropShadows: false,
1194			onBeforeShow: function(ul) {
1195				if (jQuery(this).parents("ul").length > 1){
1196					var w = jQuery(window).width();  
1197					var par_offset = jQuery(this).parents("ul").offset().left;
1198					var par_width  = jQuery(this).parents("ul").outerWidth();
1199					var ul_width   = jQuery(this).outerWidth();
1200					if (par_offset+par_width+ul_width > w-20 && par_offset-ul_width > 0)
1201						jQuery(this).addClass('submenu_left');
1202					else
1203						jQuery(this).removeClass('submenu_left');
1204				}
1205				if (ROYAL_EVENT_STORAGE['css_animation']) {
1206					jQuery(this).removeClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_out']);
1207					jQuery(this).addClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_in']);
1208				}
1209			},
1210			onBeforeHide: function(ul) {
1211				if (ROYAL_EVENT_STORAGE['css_animation']) {
1212					jQuery(this).removeClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_in']);
1213					jQuery(this).addClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_out']);
1214				}
1215			}
1216		});
1217	});
1218}
1219
1220
1221// Build page TOC from the tag's id
1222function royal_event_build_page_toc() {
1223	"use strict";
1224	var toc = '', toc_count = 0;
1225	jQuery('[id^="toc_"],.sc_anchor').each(function(idx) {
1226		"use strict";
1227		var obj = jQuery(this);
1228		var id = obj.attr('id');
1229		var url = obj.data('url');
1230		var icon = obj.data('icon');
1231		if (!icon) icon = 'icon-circle-dot';
1232		var title = obj.attr('title');
1233		var description = obj.data('description');
1234		var separator = obj.data('separator');
1235		toc_count++;
1236		toc += '<div class="toc_item'+(separator=='yes' ? ' toc_separator' : '')+'">'
1237			+(description ? '<div class="toc_description">'+description+'</div>' : '')
1238			+'<a href="'+(url ? url : '#'+id)+'" class="toc_icon'+(title ? ' with_title' : '')+' '+icon+'">'+(title ? '<span class="toc_title">'+title+'</span>' : '')+'</a>'
1239			+'</div>';
1240	});
1241	if (toc_count > (ROYAL_EVENT_STORAGE['toc_menu_home'] ? 1 : 0) + (ROYAL_EVENT_STORAGE['toc_menu_top'] ? 1 : 0)) {
1242		if (jQuery('#toc').length > 0)
1243			jQuery('#toc .toc_inner').html(toc);
1244		else
1245			jQuery('body').append('<div id="toc" class="toc_'+ROYAL_EVENT_STORAGE['toc_menu']+'"><div class="toc_inner">'+toc+'</div></div>');
1246	}
1247}
1248
1249
1250// Show current page title on the responsive menu button
1251function royal_event_show_current_menu_item(menu, button) {
1252	"use strict";
1253	menu.find('a').each(function () {
1254		var menu_link = jQuery(this);
1255		if (menu_link.text() == "") {
1256			return;
1257		}
1258		if (menu_link.attr('href') == window.location.href)
1259			button.text(menu_link.text());
1260	});
1261}
1262
1263
1264
1265// Isotope
1266//=====================================================
1267
1268// First init isotope containers
1269function royal_event_init_isotope() {
1270	"use strict";
1271
1272	var all_images_complete = true;
1273
1274	// Check if all images in isotope wrapper are loaded
1275	jQuery('.isotope_wrap:not(.inited)').each(function () {
1276		"use strict";
1277		all_images_complete = all_images_complete && royal_event_check_images_complete(jQuery(this));
1278	});
1279	// Wait for images loading
1280	if (!all_images_complete && ROYAL_EVENT_STORAGE['isotope_init_counter']++ < 30) {
1281		setTimeout(royal_event_init_isotope, 200);
1282		return;
1283	}
1284
1285	// Isotope filters handler
1286	jQuery('.isotope_filters:not(.inited)').addClass('inited').on('click', 'a', function(e) {
1287		"use strict";
1288		jQuery(this).parents('.isotope_filters').find('a').removeClass('active');
1289		jQuery(this).addClass('active');
1290	
1291		var selector = jQuery(this).data('filter');
1292		jQuery(this).parents('.isotope_filters').siblings('.isotope_wrap').eq(0).isotope({
1293			filter: selector
1294		});
1295
1296		if (selector == '*')
1297			jQuery('#viewmore_link').fadeIn();
1298		else
1299			jQuery('#viewmore_link').fadeOut();
1300
1301		e.preventDefault();
1302		return false;
1303	});
1304
1305	// Init isotope script
1306	jQuery('.isotope_wrap:not(.inited)').each(function() {
1307		"use strict";
1308
1309		var isotope_container = jQuery(this);
1310
1311		// Init shortcodes
1312		if (window.royal_event_init_shortcodes) {
1313			royal_event_sc_init(isotope_container);
1314		}
1315
1316		// If in scroll container - no init isotope
1317		if (isotope_container.parents('.sc_scroll').length > 0) {
1318			isotope_container.addClass('inited').find('.isotope_item').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); });
1319			return;
1320		}
1321		
1322		// Init isotope with timeout
1323		setTimeout(function() {
1324			isotope_container.addClass('inited').isotope({
1325				itemSelector: '.isotope_item',
1326				animationOptions: {
1327					duration: 750,
1328					easing: 'linear',
1329					queue: false
1330				}
1331			});
1332	
1333			// Show elements
1334			isotope_container.find('.isotope_item').animate({opacity: 1}, 200, function () { 
1335				jQuery(this).addClass('isotope_item_show'); 
1336			});
1337			
1338			// Resize Alter portfolio elements
1339			royal_event_resize_alter_portfolio();
1340			
1341		}, 500);
1342
1343	});		
1344}
1345
1346function royal_event_init_appended_isotope(posts_container, filters) {
1347	"use strict";
1348	
1349	if (posts_container.parents('.sc_scroll_horizontal').length > 0) return;
1350	
1351	if (!royal_event_check_images_complete(posts_container) && ROYAL_EVENT_STORAGE['isotope_init_counter']++ < 30) {
1352		setTimeout(function() { royal_event_init_appended_isotope(posts_container, filters); }, 200);
1353		return;
1354	}
1355	// Add filters
1356	var flt = posts_container.siblings('.isotope_filter');
1357	for (var i in filters) {
1358		if (flt.find('a[data-filter=".flt_'+i+'"]').length == 0) {
1359			flt.append('<a href="#" class="isotope_filters_button" data-filter=".flt_'+i+'">'+filters[i]+'</a>');
1360		}
1361	}
1362	// Init shortcodes in added elements
1363	royal_event_sc_init(posts_container);
1364	// Get added elements
1365	var elems = posts_container.find('.isotope_item:not(.isotope_item_show)');
1366	// Notify isotope about added elements with timeout
1367	setTimeout(function() {
1368		posts_container.isotope('appended', elems);
1369		// Show appended elements
1370		elems.animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); });
1371	}, 500);
1372}
1373
1374
1375
1376// Post formats init
1377//=====================================================
1378
1379function royal_event_init_post_formats() {
1380	"use strict";
1381
1382	// Call theme specific action (if exists)
1383	if (window.royal_event_theme_init_post_formats) royal_event_theme_init_post_formats();
1384
1385	// MediaElement init
1386	royal_event_init_media_elements(jQuery('body'));
1387	
1388	// Isotope first init
1389	if (jQuery('.isotope_wrap:not(.inited)').length > 0) {
1390		ROYAL_EVENT_STORAGE['isotope_init_counter'] = 0;
1391		royal_event_init_isotope();
1392	}
1393
1394	// Hover Effect 'Dir'
1395	if (jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').length > 0) {
1396		jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').each(function() {
1397			jQuery(this).addClass('inited').hoverdir();
1398		});
1399	}
1400
1401	// Popup init
1402	if (ROYAL_EVENT_STORAGE['popup_engine'] == 'pretty') {
1403		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'prettyPhoto[slideshow]');
1404		var images = jQuery("a[rel*='prettyPhoto']:not(.inited):not(.esgbox):not([data-rel*='pretty']):not([rel*='magnific']):not([data-rel*='magnific'])").addClass('inited');
1405		try {
1406			images.prettyPhoto({
1407				social_tools: '',
1408				theme: 'facebook',
1409				deeplinking: false
1410			});
1411		} catch (e) {};
1412	} else if (ROYAL_EVENT_STORAGE['popup_engine']=='magnific') {
1413		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").each(function() {
1414			if (!jQuery(this).parent().hasClass('woocommerce-product-gallery__image'))
1415				jQuery(this).attr('rel', 'magnific');
1416		});
1417		var images = jQuery("a[rel*='magnific']:not(.inited):not(.esgbox):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])").addClass('inited');
1418		try {
1419			images.magnificPopup({
1420				type: 'image',
1421				mainClass: 'mfp-img-mobile',
1422				closeOnContentClick: true,
1423				closeBtnInside: true,
1424				fixedContentPos: true,
1425				midClick: true,
1426				preloader: true,
1427				tLoading: ROYAL_EVENT_STORAGE['strings']['magnific_loading'],
1428				gallery:{
1429					enabled: true
1430				},
1431				image: {
1432					tError: ROYAL_EVENT_STORAGE['strings']['magnific_error'],
1433					verticalFit: true
1434				}
1435			});
1436		} catch (e) {};
1437	}
1438
1439
1440	// Add hover icon to products thumbnails
1441	jQuery(".post_item_product .product .images a.woocommerce-main-image:not(.hover_icon)").addClass('hover_icon hover_icon_view');
1442
1443
1444	// Likes counter
1445	if (jQuery('.post_counters_likes:not(.inited)').length > 0) {
1446		jQuery('.post_counters_likes:not(.inited)')
1447			.addClass('inited')
1448			.on('click', function(e) {
1449				var button = jQuery(this);
1450				var inc = button.hasClass('enabled') ? 1 : -1;
1451				var post_id = button.data('postid');
1452				var likes = Number(button.data('likes'))+inc;
1453				var cookie_likes = royal_event_get_cookie('royal_event_likes');
1454				if (cookie_likes === undefined || cookie_likes===null) cookie_likes = '';
1455				jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
1456					action: 'post_counter',
1457					nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
1458					post_id: post_id,
1459					likes: likes
1460				}).done(function(response) {
1461					var rez = {};
1462					try {
1463						rez = JSON.parse(response);
1464					} catch (e) {
1465						rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
1466						console.log(response);
1467					}
1468					if (rez.error === '') {
1469						if (inc == 1) {
1470							var title = button.data('title-dislike');
1471							button.removeClass('enabled').addClass('disabled');
1472							cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ',';
1473						} else {
1474							var title = button.data('title-like');
1475							button.removeClass('disabled').addClass('enabled');
1476							cookie_likes = cookie_likes.replace(','+post_id+',', ',');
1477						}
1478						button.data('likes', likes).attr('title', title).find('.post_counters_number').html(likes);
1479						royal_event_set_cookie('royal_event_likes', cookie_likes, 365);
1480					} else {
1481						royal_event_message_warning(ROYAL_EVENT_STORAGE['strings']['error_like']);
1482					}
1483				});
1484				e.preventDefault();
1485				return false;
1486			});
1487	}
1488
1489	// Social share links
1490	if (jQuery('.sc_socials_share:not(.inited)').length > 0) {
1491		jQuery('.sc_socials_share:not(.inited)').each(function() {
1492			"use strict";
1493			jQuery(this).addClass('inited').on('click', '.social_item_popup > a.social_icons', function(e) {
1494				"use strict";
1495				var url = jQuery(this).data('link');
1496				window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0');
1497				e.preventDefault();
1498				return false;
1499			});
1500		});
1501	}
1502
1503	// Add video on thumb click
1504	if (jQuery('.sc_video_play_button:not(.inited)').length > 0) {
1505		jQuery('.sc_video_play_button:not(.inited)').each(function() {
1506			"use strict";
1507			jQuery(this)
1508				.addClass('inited')
1509				.animate({opacity: 1}, 1000)
1510				.on('click', function (e) {
1511					"use strict";
1512					if (!jQuery(this).hasClass('sc_video_play_button')) return;
1513					var video = jQuery(this).removeClass('sc_video_play_button hover_icon hover_icon_play').data('video');
1514					if (video!=='') {
1515						jQuery(this).empty().html(video);
1516						royal_event_video_dimensions();
1517						var video_tag = jQuery(this).find('video');
1518						var w = video_tag.width();
1519						var h = video_tag.height();
1520						royal_event_init_media_elements(jQuery(this));
1521						// Restore WxH attributes, because Chrome broke it!
1522						jQuery(this).find('video').css({'width':w, 'height': h}).attr({'width':w, 'height': h});
1523					}
1524					e.preventDefault();
1525					return false;
1526				});
1527		});
1528	}
1529}
1530
1531
1532function royal_event_init_media_elements(cont) {
1533    "use strict";
1534	if (ROYAL_EVENT_STORAGE['media_elements_enabled'] && cont.find('audio,video').length > 0) {
1535		if (window.mejs) {
1536			if (typeof window.mejs.MepDefaults != 'undefined') window.mejs.MepDefaults.enableAutosize = false;
1537			if (typeof window.mejs.MediaElementDefaults != 'undefined') window.mejs.MediaElementDefaults.enableAutosize = false;
1538			cont.find('audio:not(.wp-audio-shortcode),video:not(.wp-video-shortcode)').each(function() {
1539				if (jQuery(this).parents('.mejs-mediaelement').length == 0
1540					&& jQuery(this).parents('figure.wp-block-media-text__media').length == 0				
1541					&& jQuery( this ).parents( '.wp-block-video' ).length == 0
1542					&& ! jQuery( this ).hasClass( 'wp-block-cover__video-background' )) {
1543					var media_tag = jQuery(this);
1544					var settings = {
1545						enableAutosize: true,
1546						videoWidth: -1,		// if set, overrides <video width>
1547						videoHeight: -1,	// if set, overrides <video height>
1548						audioWidth: '100%',	// width of audio player
1549						audioHeight: 30,	// height of audio player
1550						success: function(mejs) {
1551							var autoplay, loop;
1552							if ( 'flash' === mejs.pluginType ) {
1553								autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
1554								loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
1555								autoplay && mejs.addEventListener( 'canplay', function () {
1556									mejs.play();
1557								}, false );
1558								loop && mejs.addEventListener( 'ended', function () {
1559									mejs.play();
1560								}, false );
1561							}
1562							media_tag.parents('.sc_audio,.sc_video').addClass('inited sc_show');
1563						}
1564					};
1565					jQuery(this).mediaelementplayer(settings);
1566				}
1567			});
1568		} else
1569			setTimeout(function() { royal_event_init_media_elements(cont); }, 400);
1570	}
1571}
1572
1573
1574
1575
1576
1577
1578// Popups and system messages
1579//==============================================
1580
1581// Show system message (bubble from previous page)
1582function royal_event_show_system_message() {
1583    "use strict";
1584	if (ROYAL_EVENT_STORAGE['system_message'] && ROYAL_EVENT_STORAGE['system_message']['message']) {
1585		if (ROYAL_EVENT_STORAGE['system_message']['status'] == 'success')
1586			royal_event_message_success(ROYAL_EVENT_STORAGE['system_message']['message'], ROYAL_EVENT_STORAGE['system_message']['header']);
1587		else if (ROYAL_EVENT_STORAGE['system_message']['status'] == 'info')
1588			royal_event_message_info(ROYAL_EVENT_STORAGE['system_message']['message'], ROYAL_EVENT_STORAGE['system_message']['header']);
1589		else if (ROYAL_EVENT_STORAGE['system_message']['status'] == 'error' || ROYAL_EVENT_STORAGE['system_message']['status'] == 'warning')
1590			royal_event_message_warning(ROYAL_EVENT_STORAGE['system_message']['message'], ROYAL_EVENT_STORAGE['system_message']['header']);
1591	}
1592}
1593
1594// Toggle popups
1595function royal_event_toggle_popup(popup) {
1596    "use strict";
1597	if (popup.css('display')!='none')
1598		royal_event_hide_popup(popup);
1599	else
1600		royal_event_show_popup(popup);
1601}
1602
1603// Show popups
1604function royal_event_show_popup(popup) {
1605    "use strict";
1606	if (popup.css('display')=='none') {
1607		if (false && ROYAL_EVENT_STORAGE['css_animation'])
1608			popup.show().removeClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_out']).addClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_in']);
1609		else
1610			popup.slideDown();
1611	}
1612}
1613
1614// Hide popups
1615function royal_event_hide_popup(popup) {
1616    "use strict";
1617	if (popup.css('display')!='none') {
1618		if (false && ROYAL_EVENT_STORAGE['css_animation'])
1619			popup.removeClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_in']).addClass('animated fast '+ROYAL_EVENT_STORAGE['menu_animation_out']).delay(500).hide();
1620		else
1621			popup.fadeOut();
1622	}
1623}
1624
1625
1626
1627// Table cart Woo /***/
1628jQuery(document).ready(function () {
1629    "use strict";
1630    jQuery('.shop_table thead .product-remove').remove();
1631    jQuery('.shop_table thead .product-thumbnail').remove();
1632    jQuery('.shop_table thead .product-name').attr('colspan', 3);
1633});
1634
1635// VC_ROW /***/
1636jQuery(document).ready(function () {
1637    "use strict";
1638    jQuery('.vc_row[class*="vc_custom_"]').each(function() {
1639        if(((jQuery(this).css('background-color') != jQuery('body').css('background-color')) && (jQuery(this).css('background-color') != 'rgba(0, 0, 0, 0)' )) || (jQuery(this).css('background-image') != 'none')){
1640            jQuery(this).addClass('with-custom-background');
1641        }
1642    });
1643});
1644
1645// Scroll to top /***/
1646jQuery(document).ready(function () {
1647    "use strict";
1648    jQuery('.scroll_to_top_in_footer .scroll_to_top').appendTo(jQuery('.page_content_wrap + footer'));
1649});
1650
1651// Smooth transition /***/
1652jQuery(document).ready(function(){
1653    "use strict";
1654    jQuery('.slider_scroll_down').on("click", function (event) {
1655        event.preventDefault();
1656        var top  = jQuery('.page_content_wrap').offset().top;
1657        jQuery('body,html').animate({scrollTop: top}, 1000);
1658    });
1659});

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.