PageSourceSearch

https://andresbanquet.com/wp-content/plugins/trx_utils/shortcodes/theme.shortcodes.js

js andresbanquet.com collected 2026-10-09 22:41:45 UTC 45,851 bytes, 1,331 lines download raw bytes

1// Init actions
2function royal_event_sc_init_actions() {
3	"use strict";
4	setTimeout(function() {
5		royal_event_sc_animation();
6	}, 600);
7	
8	// MenuItems - init once
9	jQuery('body')
10		.on('click', '.show_popup_menuitem', function(e) {
11			"use strict";
12			royal_event_menuitems_show_popup(jQuery(this));
13			e.preventDefault();
14			return false;
15		})
16		.on('click', '.close_menuitem, .popup_menuitem', function(e) {
17			"use strict";
18			var target = jQuery(e.target);
19			if (target.hasClass('popup_menuitem') || target.hasClass('close_menuitem') || target.parent().hasClass('close_menuitem')) {
20				royal_event_menuitems_hide_popup();
21				e.preventDefault();
22				return false;
23			}
24		});
25
26	// Init sc in container
27	royal_event_sc_init(jQuery('body').eq(0));
28}
29
30
31// Resize actions
32function royal_event_sc_resize_actions() {
33	"use strict";
34	royal_event_sc_sliders_resize();
35	royal_event_sc_equal_height();
36}
37
38
39// Scroll actions
40function royal_event_sc_scroll_actions() {
41	"use strict";
42	royal_event_sc_animation();
43}
44
45
46// Animation
47function royal_event_sc_animation() {
48	jQuery('[data-animation^="animated"]:not(.animated)').each(function() {
49		"use strict";
50		if (jQuery(this).offset().top < jQuery(window).scrollTop() + jQuery(window).height())
51			jQuery(this).addClass(jQuery(this).data('animation'));
52	});
53}
54
55
56// Shortcodes init
57function royal_event_sc_init(container) {
58
59	// Accordion
60	if (container.find('.sc_accordion:not(.inited)').length > 0) {
61		container.find(".sc_accordion:not(.inited)").each(function () {
62			"use strict";
63			var init = jQuery(this).data('active');
64			if (isNaN(init)) init = 0;
65			else init = Math.max(0, init);
66			jQuery(this)
67				.addClass('inited')
68				.accordion({
69					active: init,
70					heightStyle: "content",
71					header: "> .sc_accordion_item > .sc_accordion_title",
72					create: function (event, ui) {
73						"use strict";
74						royal_event_sc_init(ui.panel);
75						if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(ui.panel);
76						ui.header.each(function () {
77							"use strict";
78							jQuery(this).parent().addClass('sc_active');
79						});
80					},
81					activate: function (event, ui) {
82						"use strict";
83						royal_event_sc_init(ui.newPanel);
84						if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(ui.newPanel);
85						ui.newHeader.each(function () {
86							"use strict";
87							jQuery(this).parent().addClass('sc_active');
88						});
89						ui.oldHeader.each(function () {
90							"use strict";
91							jQuery(this).parent().removeClass('sc_active');
92						});
93					}
94				});
95		});
96	}
97
98	// Blogger: style Polaroid
99	if (container.find('.sc_blogger.layout_polaroid .photostack:not(.inited)').length > 0) {
100		container.find(".sc_blogger.layout_polaroid .photostack:not(.inited)").each(function () {
101			"use strict";
102			var obj = jQuery(this);
103			var id = obj.attr('id');
104			if (id == undefined) {
105				id = 'photostack_'+Math.random();
106				id = id.replace('.', '');
107				obj.attr('id', id);
108			}
109			setTimeout(function() {
110				"use strict";
111				obj.addClass('inited').parent().height("auto");
112				new Photostack( obj.get(0), {
113					callback: function( item ) {
114					}
115				} );
116			}, 10);
117		});
118	}
119
120	// Blogger: Scroll horizontal
121	if (container.find('.sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)').length > 0) {
122		container.find(".sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)").each(function () {
123			"use strict";
124			var obj = jQuery(this);
125			var width = 0;
126			obj.find('.isotope_item').each(function(){
127				"use strict";
128				width += jQuery(this).outerWidth();
129			});
130			obj.addClass('inited').width(width);
131		});
132	}
133
134	// Form
135	if (container.find('.sc_form:not(.inited) form').length > 0) {
136		container.find(".sc_form:not(.inited) form").each(function() {
137			"use strict";
138			jQuery(this).addClass('inited');
139			jQuery(this).submit(function(e) {
140				"use strict";
141				royal_event_sc_form_validate(jQuery(this));
142				e.preventDefault();
143				return false;
144			});
145			if (jQuery(this).find('.js__datepicker').length > 0) {
146				jQuery(this).find('.js__datepicker').pickadate({
147					// Work-around for some mobile browsers clipping off the picker.
148					onOpen: function() {
149						"use strict";
150						jQuery('pre').css('overflow', 'hidden');
151						},
152					onClose: function() {
153						"use strict";
154						jQuery('pre').css('overflow', '');
155					},
156					monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' ],
157					showMonthsShort: true,
158					format: 'dd.mm.yyyy',
159					formatSubmit: 'yyyy-mm-dd',
160					min: true
161				});
162			}
163			if (jQuery(this).find('.js__timepicker').length > 0) {
164				jQuery(this).find('.js__timepicker').pickatime();
165			}
166		});
167	}
168
169	//Countdown
170	if (container.find('.sc_countdown:not(.inited)').length > 0) {
171		container.find('.sc_countdown:not(.inited)')
172			.each(function () {
173				"use strict";
174				jQuery(this).addClass('inited');
175				var id = jQuery(this).attr('id');
176				var curDate = new Date(); 
177				var curDateTimeStr = curDate.getFullYear()+'-'+(curDate.getMonth()<9 ? '0' : '')+(curDate.getMonth()+1)+'-'+(curDate.getDate()<10 ? '0' : '')+curDate.getDate()
178					+' '+(curDate.getHours()<10 ? '0' : '')+curDate.getHours()+':'+(curDate.getMinutes()<10 ? '0' : '')+curDate.getMinutes()+':'+(curDate.getSeconds()<10 ? '0' : '')+curDate.getSeconds(); 
179				var interval = 1;	//jQuery(this).data('interval');
180				var endDateStr = jQuery(this).data('date');
181				var endDateParts = endDateStr.split('-');
182				var endTimeStr = jQuery(this).data('time');
183				var endTimeParts = endTimeStr.split(':');
184				if (endTimeParts.length < 3) endTimeParts[2] = '00';
185				var endDateTimeStr = endDateStr+' '+endTimeStr;
186				if (curDateTimeStr < endDateTimeStr) {
187					jQuery(this).find('.sc_countdown_placeholder').countdown({
188						until: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 
189						tickInterval: interval,
190						onTick: royal_event_countdown
191					}); 
192				} else {
193					jQuery(this).find('.sc_countdown_placeholder').countdown({
194						since: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 
195						tickInterval: interval,
196						onTick: royal_event_countdown
197					}); 
198				}
199			});
200	}
201
202	// Googlemap init
203	if (container.find('.sc_googlemap:not(.inited)').length > 0 && window.royal_event_googlemap_init ) {
204		container.find('.sc_googlemap:not(.inited)')
205			.each(function () {
206				"use strict";
207				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
208				var map = jQuery(this).addClass('inited');
209				var map_id		= map.attr('id');
210				var map_zoom	= map.data('zoom');
211				var map_style	= map.data('style');
212				var map_markers = [];
213				map.find('.sc_googlemap_marker').each(function() {
214					"use strict";
215					var marker = jQuery(this);
216					map_markers.push({
217						point:			marker.data('point'),
218						address:		marker.data('address'),
219						latlng:			marker.data('latlng'),
220						description:	marker.data('description'),
221						title:			marker.data('title')
222					});
223				});
224				royal_event_googlemap_init( jQuery('#'+map_id).get(0), {style: map_style, zoom: map_zoom, markers: map_markers});
225			});
226	}
227
228	// Infoboxes
229	if (container.find('.sc_infobox.sc_infobox_closeable:not(.inited)').length > 0) {
230		container.find('.sc_infobox.sc_infobox_closeable:not(.inited)')
231			.addClass('inited')
232			.on('click', function (e) {
233				"use strict";
234				jQuery(this).slideUp();
235				e.preventDefault();
236				return false;
237			});
238	}
239
240	// Intro
241	if (container.find('.sc_intro[data-href]:not(.inited)').length > 0) {
242		container.find('.sc_intro[data-href]:not(.inited)')
243			.addClass('inited')
244			.on('click', function (e) {
245				"use strict";
246				var link = jQuery(this).data('href');
247				window.location.href = link;
248				e.preventDefault();
249				return false;
250			});
251	}
252
253	// Matches
254	if (container.find('.sc_matches:not(.inited)').length > 0) {
255		container.find('.sc_matches:not(.inited)')
256			.each(function () {
257				"use strict";
258				jQuery(this).find('.sc_matches_next .sc_matches_list .sc_match').on('click', function () {
259					"use strict";
260					jQuery(this).parents('.sc_matches').find('.sc_matches_current .sc_match').hide();
261					var item = jQuery(this).data('item');
262					jQuery(item).fadeIn();
263				});
264			});
265	}
266
267	// Matches & Players: Sort players by points
268	if (container.find('.sc_players_table:not(.inited)').length > 0) {
269		container.find('.sc_players_table:not(.inited)')
270			.addClass('inited')
271			.on('click', '.sort', function (e) {
272				"use strict";
273				var table = jQuery(this).parents('.sc_players_table');
274				var id = jQuery(table).attr('id')
275				var sort = jQuery(table).data('sort') == 'asc' ? 'desc' : 'asc';
276				jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
277					action: 'sort_by_points',
278					nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
279					sort: sort,
280					table: ROYAL_EVENT_STORAGE['ajax_' + id]
281				}).done(function(response) {
282					var rez = {};
283					try {
284						rez = JSON.parse(response);
285					} catch (e) {
286						rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
287						console.log(response);
288					}
289					if (rez.error === '') { 
290						table
291							.data('sort', sort)
292							.find('.sc_table')
293								.after(rez.data)
294								.remove();
295						royal_event_select_players_category(jQuery(table).find('.sc_players_table_category select'));		
296					}
297				});
298				e.preventDefault();
299				return false;
300			});
301	}
302	
303	// Matches & Players: Select category in the points table
304	if (container.find('.sc_players_table_category:not(.inited)').length > 0) {
305		container.find('.sc_players_table_category:not(.inited)')
306			.addClass('inited')
307			.on('change', function () {
308				"use strict";
309				royal_event_select_players_category(jQuery(this));		
310			});
311	}
312
313	// Popup links
314	if (container.find('.sc_popup_link:not(.inited)').length > 0) {
315		container.find('.sc_popup_link:not(.inited)').each(function() {
316			var popup_id = jQuery(this).attr('href');
317			jQuery(this)
318				.addClass('inited')
319				.magnificPopup({
320					type: 'inline',
321					removalDelay: 500,
322					midClick: true,
323					callbacks: {
324						beforeOpen: function () {
325							this.st.mainClass = 'mfp-zoom-in';
326						},
327						open: function() {
328							"use strict";
329							royal_event_sc_init(jQuery(popup_id));
330							royal_event_resize_actions();
331							if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(jQuery(popup_id));
332						},
333						close: function() {}
334					}
335				});
336		});
337	}
338
339	// Recent news widget and sc
340	if (container.find('.sc_recent_news_header_category_item_more:not(.inited)').length > 0) {
341		container.find('.sc_recent_news_header_category_item_more:not(.inited)').each(function() {
342			"use strict";
343			jQuery(this)
344				.addClass('inited')
345				.on('click', function(e) {
346					"use strict";
347					jQuery(this).toggleClass('opened').find('.sc_recent_news_header_more_categories').slideToggle();
348					e.preventDefault();
349					return false;
350				});
351		});
352	}
353
354	// Search form
355	if (container.find('.search_wrap:not(.inited)').length > 0) {
356		container.find('.search_wrap:not(.inited)').each(function() {
357			"use strict";
358			jQuery(this)
359				.addClass('inited')
360				.on('click', '.search_submit', function(e) {
361					"use strict";
362					var search_wrap = jQuery(this).parents('.search_wrap');
363					if (!search_wrap.hasClass('search_state_fixed')) {
364						if (search_wrap.hasClass('search_state_opened')) {
365							if (search_wrap.find('.search_field').val() != '')
366								search_wrap.find('form').get(0).submit();
367							else
368								search_wrap.removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut();
369						} else
370							search_wrap.removeClass('search_state_closed').addClass('search_state_opened').find('.search_field').get(0).focus();
371					} else {
372						if (search_wrap.find('.search_field').val() != '')
373							search_wrap.find('form').get(0).submit();
374						else {
375							search_wrap.find('.search_field').val('');
376							search_wrap.find('.search_results').fadeOut();
377						}
378					}
379					e.preventDefault();
380					return false;
381				})
382				.on('click', '.search_close', function(e) {
383					"use strict";
384					jQuery(this).parents('.search_wrap').removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut();
385					e.preventDefault();
386					return false;
387				})
388				.on('click', '.search_results_close', function(e) {
389					"use strict";
390					jQuery(this).parent().fadeOut();
391					e.preventDefault();
392					return false;
393				})
394				.on('click', '.search_more', function(e) {
395					"use strict";
396					if (jQuery(this).parents('.search_wrap').find('.search_field').val() != '')
397						jQuery(this).parents('.search_wrap').find('form').get(0).submit();
398					e.preventDefault();
399					return false;
400				})
401				.on('blur', '.search_field', function(e) {
402					if (jQuery(this).val() == '' && !jQuery(this).parents('.search_wrap').hasClass('search_state_fixed'))
403						jQuery(this).parents('.search_wrap').removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut();
404				});
405			
406			if (jQuery(this).hasClass('search_ajax')) {
407				var ajax_timer = null;
408				jQuery(this).find('.search_field').keyup(function(e) {
409					"use strict";
410					var search_field = jQuery(this);
411					var s = search_field.val();
412					if (ajax_timer) {
413						clearTimeout(ajax_timer);
414						ajax_timer = null;
415					}
416					if (s.length >= ROYAL_EVENT_STORAGE['ajax_search_min_length']) {
417						ajax_timer = setTimeout(function() {
418							"use strict";
419							jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
420								action: 'ajax_search',
421								nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
422								text: s
423							}).done(function(response) {
424								"use strict";
425								clearTimeout(ajax_timer);
426								ajax_timer = null;
427								var rez = {};
428								try {
429									rez = JSON.parse(response);
430								} catch (e) {
431									rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
432									console.log(response);
433								}
434								if (rez.error === '') {
435									search_field.parents('.search_ajax').find('.search_results_content').empty().append(rez.data);
436									search_field.parents('.search_ajax').find('.search_results').fadeIn();
437								} else {
438									royal_event_message_warning(ROYAL_EVENT_STORAGE['strings']['search_error']);
439								}
440							});
441						}, ROYAL_EVENT_STORAGE['ajax_search_delay']);
442					}
443				});
444			}
445		});
446	}
447
448	
449	// Section Pan init
450	if (container.find('.sc_pan:not(.inited_pan)').length > 0) {
451		container.find('.sc_pan:not(.inited_pan)')
452			.each(function () {
453				"use strict";
454				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
455				var pan = jQuery(this).addClass('inited_pan');
456				var cont = pan.parent();
457				cont.mousemove(function(e) {
458					"use strict";
459					var anim = {};
460					var tm = 0;
461					var pw = pan.width(), ph = pan.height();
462					var cw = cont.width(), ch = cont.height();
463					var coff = cont.offset();
464					if (pan.hasClass('sc_pan_vertical'))
465						pan.css('top', -Math.floor((e.pageY - coff.top) / ch * (ph-ch)));
466					if (pan.hasClass('sc_pan_horizontal'))
467						pan.css('left', -Math.floor((e.pageX - coff.left) / cw * (pw-cw)));
468				});
469				cont.mouseout(function(e) {
470					"use strict";
471					pan.css({'left': 0, 'top': 0});
472				});
473			});
474	}
475
476	// Scroll
477	if (container.find('.sc_scroll:not(.inited)').length > 0) {
478		container.find('.sc_scroll:not(.inited)')
479			.each(function () {
480				"use strict";
481				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
482				ROYAL_EVENT_STORAGE['scroll_init_counter'] = 0;
483				royal_event_sc_init_scroll_area(jQuery(this));
484			});
485	}
486
487
488	// Swiper Slider
489	if (container.find('.sc_slider_swiper:not(.inited)').length > 0) {
490		container.find('.sc_slider_swiper:not(.inited)')
491			.each(function () {
492				"use strict";
493				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
494				//if (jQuery(this).parents('.isotope_wrap:not(.inited)').length > 0) return;
495				jQuery(this).addClass('inited');
496				royal_event_sc_slider_autoheight(jQuery(this));
497				if (jQuery(this).parents('.sc_slider_pagination_area').length > 0) {
498					jQuery(this).parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item').eq(0).addClass('active');
499				}
500				var id = jQuery(this).attr('id');
501				if (id == undefined) {
502					id = 'swiper_'+Math.random();
503					id = id.replace('.', '');
504					jQuery(this).attr('id', id);
505				}
506				jQuery(this).addClass(id);
507				jQuery(this).find('.slides .swiper-slide').css('position', 'relative');
508				var width = jQuery(this).width();
509				if (width == 0) width = jQuery(this).parent().width();
510				var spv = jQuery(this).data('slides-per-view');
511				if (spv == undefined) spv = 1;
512				var min_width = jQuery(this).data('slides-min-width');
513				if (min_width == undefined) min_width = 50;
514				if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width));
515				var space = jQuery(this).data('slides-space');
516				if (space == undefined) space = 0;
517				if (ROYAL_EVENT_STORAGE['swipers'] === undefined) ROYAL_EVENT_STORAGE['swipers'] = {};
518				ROYAL_EVENT_STORAGE['swipers'][id] = new Swiper('.'+id, {
519					calculateHeight: !jQuery(this).hasClass('sc_slider_height_fixed'),
520					resizeReInit: true,
521					autoResize: true,
522					loop: true,
523					grabCursor: true,
524			        nextButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_next' : false,
525			        prevButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_prev' : false,
526					pagination: jQuery(this).hasClass('sc_slider_pagination') ? '#'+id+' .sc_slider_pagination_wrap' : false,
527				    paginationClickable: true,
528					autoplay: jQuery(this).hasClass('sc_slider_noautoplay') ? false : (isNaN(jQuery(this).data('interval')) ? 7000 : jQuery(this).data('interval')),
529					autoplayDisableOnInteraction: false,
530					initialSlide: 0,
531					slidesPerView: spv,
532					loopedSlides: spv,
533					spaceBetween: space,
534					speed: 600,
535					// Autoheight on start
536					onFirstInit: function (slider){
537						"use strict";
538						var cont = jQuery(slider.container);
539						if (!cont.hasClass('sc_slider_height_auto')) return;
540						var li = cont.find('.swiper-slide').eq(1);
541						var h = li.data('height_auto');
542						if (h > 0) {
543							var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom'));
544							li.height(h);
545							cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
546							cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
547						}
548					},
549					// Autoheight on slide change
550					onSlideChangeStart: function (slider){
551						"use strict";
552						var cont = jQuery(slider.container);
553						if (!cont.hasClass('sc_slider_height_auto')) return;
554						var idx = slider.activeIndex;
555						var li = cont.find('.swiper-slide').eq(idx);
556						var h = li.data('height_auto');
557						if (h > 0) {
558							var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom'));
559							li.height(h);
560							cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
561							cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
562						}
563					},
564					// Change current item in 'full' or 'over' pagination wrap
565					onSlideChangeEnd: function (slider, dir) {
566						"use strict";
567						var cont = jQuery(slider.container);
568						if (cont.parents('.sc_slider_pagination_area').length > 0) {
569							var li = cont.parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item');
570							var idx = slider.activeIndex > li.length ? 0 : slider.activeIndex-1;
571							royal_event_sc_change_active_pagination_in_slider(cont, idx);
572						}
573					}
574				});
575				
576				jQuery(this).data('settings', {mode: 'horizontal'});		// VC hook
577				
578				var curSlide = jQuery(this).find('.slides').data('current-slide');
579				if (curSlide > 0)
580					ROYAL_EVENT_STORAGE['swipers'][id].slideTo(curSlide-1);
581
582				royal_event_sc_prepare_slider_navi(jQuery(this));
583
584			});
585			
586		// Check slides per view
587		royal_event_sc_sliders_resize();
588	}
589
590	//Skills init
591	if (container.find('.sc_skills_item:not(.inited)').length > 0) {
592		royal_event_sc_init_skills(container);
593		jQuery(window).scroll(function () { royal_event_sc_init_skills(container); });
594	}
595	//Skills type='arc' init
596	if (container.find('.sc_skills_arc:not(.inited)').length > 0) {
597		royal_event_sc_init_skills_arc(container);
598		jQuery(window).scroll(function () { royal_event_sc_init_skills_arc(container); });
599	}
600
601	// Tabs
602	if (container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').length > 0) {
603		container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').each(function () {
604			"use strict";
605			var init = jQuery(this).data('active');
606			if (isNaN(init)) init = 0;
607			else init = Math.max(0, init);
608			jQuery(this)
609				.addClass('inited')
610				.tabs({
611					active: init,
612					show: {
613						effect: 'fadeIn',
614						duration: 300
615					},
616					hide: {
617						effect: 'fadeOut',
618						duration: 300
619					},
620					create: function (event, ui) {
621						"use strict";
622						royal_event_sc_init(ui.panel);
623						if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(ui.panel);
624					},
625					activate: function (event, ui) {
626						"use strict";
627						royal_event_sc_init(ui.newPanel);
628						if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(ui.newPanel);
629					}
630				});
631		});
632	}
633	if (container.find('.sc_tabs.no_jquery_ui:not(.inited)').length > 0) {
634		container.find('.sc_tabs.no_jquery_ui:not(.inited)').each(function () {
635			"use strict";
636			jQuery(this)
637				.addClass('inited')
638				.on('click', '.sc_tabs_titles li a', function(e) {
639					"use strict";
640					if (!jQuery(this).parent().hasClass('sc_tabs_active')) {
641						var id_act = jQuery(this).parent().siblings('.sc_tabs_active').find('a').attr('href');
642						var id = jQuery(this).attr('href');
643						jQuery(this).parent().addClass('sc_tabs_active').siblings().removeClass('sc_tabs_active');
644						jQuery(id_act).fadeOut(function() {
645							"use strict";
646							jQuery(id).fadeIn(function() {
647								"use strict";
648								royal_event_sc_init(jQuery(this));
649								if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(jQuery(this));
650							});
651						});
652					}
653					e.preventDefault();
654					return false;
655				});
656			jQuery(this).find('.sc_tabs_titles li').eq(0).addClass('sc_tabs_active');
657			jQuery(this).find('.sc_tabs_content').eq(0).fadeIn(function() {
658				"use strict";
659				royal_event_sc_init(jQuery(this));
660				if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(jQuery(this));
661			});
662		});
663	}
664
665	// Toggles
666	if (container.find('.sc_toggles .sc_toggles_title:not(.inited)').length > 0) {
667		container.find('.sc_toggles .sc_toggles_title:not(.inited)')
668			.addClass('inited')
669			.on('click', function () {
670				"use strict";
671				jQuery(this).toggleClass('ui-state-active').parent().toggleClass('sc_active');
672				jQuery(this).parent().find('.sc_toggles_content').slideToggle(300, function () { 
673					"use strict";
674					royal_event_sc_init(jQuery(this).parent().find('.sc_toggles_content')); 
675					if (window.royal_event_init_hidden_elements) royal_event_init_hidden_elements(jQuery(this).parent().find('.sc_toggles_content'));
676				});
677			});
678	}
679
680	//Zoom
681	if (container.find('.sc_zoom:not(.inited)').length > 0) {
682		container.find('.sc_zoom:not(.inited)')
683			.each(function () {
684				"use strict";
685				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
686				jQuery(this).addClass('inited');
687				jQuery(this).find('img').elevateZoom({
688					zoomType: "lens",
689					lensShape: "round",
690					lensSize: 200,
691					lensBorderSize: 4,
692					lensBorderColour: '#ccc'
693				});
694			});
695	}
696
697}
698
699
700
701// Scrolled areas
702function royal_event_sc_init_scroll_area(obj) {
703	"use strict";
704
705	// Wait for images loading
706	if (!royal_event_check_images_complete(obj) && ROYAL_EVENT_STORAGE['scroll_init_counter']++ < 30) {
707		setTimeout(function() { royal_event_sc_init_scroll_area(obj); }, 200);
708		return;
709	}
710
711	// Start init scroll area
712	obj.addClass('inited');
713
714	var id = obj.attr('id');
715	if (id == undefined) {
716		id = 'scroll_'+Math.random();
717		id = id.replace('.', '');
718		obj.attr('id', id);
719	}
720	obj.addClass(id);
721
722	var parent_obj = obj.parent();
723	var parent_id  = parent_obj.attr('id');
724	if (parent_id == undefined) {
725		parent_id = 'scroll_wrap_'+Math.random();
726		parent_id = parent_id.replace('.', '');
727		parent_obj.attr('id', parent_id);
728	}
729	parent_obj.addClass(parent_id);
730
731	var bar = obj.find('#'+id+'_bar');
732	if (bar.length > 0 && !bar.hasClass(id+'_bar')) {
733		bar.addClass(id+'_bar');
734	}
735	
736	// Correct wrapper width (if scroll dir = horizontal)
737	if (obj.hasClass('sc_scroll_horizontal')) {
738		obj.find('.sc_scroll_wrapper > .sc_scroll_slide').css('width', 'auto');
739		obj.find('.sc_scroll_wrapper').css('width', obj.find('.sc_scroll_wrapper > .sc_scroll_slide').width()+10);
740		obj.find('.sc_scroll_wrapper > .sc_scroll_slide').css('width', '100%')
741	}
742
743	// Init Swiper with scroll plugin
744	if (ROYAL_EVENT_STORAGE['swipers'] === undefined) ROYAL_EVENT_STORAGE['swipers'] = {};
745	ROYAL_EVENT_STORAGE['swipers'][id] = new Swiper('.'+id, {
746		calculateHeight: false,
747		resizeReInit: true,
748		autoResize: true,
749		freeMode: true,
750		freeModeFluid: true,
751		grabCursor: true,
752		mode: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal',
753		direction: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal',
754		slidesPerView: obj.hasClass('sc_scroll') ? 'auto' : 1,
755        nextButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_next' : false,
756        prevButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_prev' : false,
757        scrollbar: '.'+id+'_bar',
758        scrollbarHide: true,
759	})
760	
761	// VC hook
762	obj.data('settings', {mode: 'horizontal'});
763}
764
765
766// Slider navigation
767function royal_event_sc_prepare_slider_navi(slider) {
768	"use strict";
769	var navi = null;
770	
771	// Prev / Next
772	// Remove condition in the line below if you need add click handler to next/prev buttons
773	if (false) {
774		navi = slider.find('> .sc_slider_controls_wrap, > .sc_scroll_controls_wrap');
775		if (navi.length == 0) navi = slider.siblings('.sc_slider_controls_wrap,.sc_scroll_controls_wrap');
776		if (navi.length > 0) {
777			navi.on('click', '.sc_slider_prev,.sc_scroll_prev', function(e) {
778				var swiper = jQuery(this).parents('.swiper-slider-container');
779				if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container');
780				var id = swiper.attr('id');
781				ROYAL_EVENT_STORAGE['swipers'][id].slidePrev();
782				e.preventDefault();
783				return false;
784			})
785			.on('click', '.sc_slider_next,.sc_scroll_next', function(e){
786				var swiper = jQuery(this).parents('.swiper-slider-container');
787				if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container');
788				var id = swiper.attr('id');
789				ROYAL_EVENT_STORAGE['swipers'][id].slideNext();
790				e.preventDefault();
791				return false;
792			});
793		}
794	}
795
796	// Pagination with slide's title
797	navi = slider.siblings('.sc_slider_pagination');
798	if (navi.length > 0) {
799		navi.on('click', '.post_item', function(e){
800			var swiper = jQuery(this).parents('.sc_slider_pagination_area').find('.swiper-slider-container');
801			var id = swiper.attr('id');
802			ROYAL_EVENT_STORAGE['swipers'][id].slideTo(jQuery(this).index()+1);
803			e.preventDefault();
804			return false;
805		});
806	}
807}
808
809// Sliders: Pagination
810function royal_event_sc_change_active_pagination_in_slider(slider, idx) {
811	"use strict";
812	var pg = slider.parents('.sc_slider_pagination_area').find('.sc_slider_pagination');
813	if (pg.length==0) return;
814	pg.find('.post_item').removeClass('active').eq(idx).addClass('active');
815	var h = pg.height();
816	var off = pg.find('.active').offset().top - pg.offset().top;
817	var off2 = pg.find('.sc_scroll_wrapper').offset().top - pg.offset().top;
818	var h2  = pg.find('.active').height();
819	if (off < 0) {
820		pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, 0px, 0px)', 'transition-duration': '0.3s'});
821	} else if (h <= off+h2) {
822		pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, -'+(Math.abs(off2)+off-h/4)+'px, 0px)', 'transition-duration': '0.3s'});
823	}
824}
825
826// Sliders: Autoheight
827function royal_event_sc_slider_autoheight(slider) {
828	"use strict";
829	if (slider.hasClass('.sc_slider_height_auto')) {
830		slider.find('.swiper-slide').each(function() {
831			"use strict";
832			if (jQuery(this).data('height_auto') == undefined) {
833				jQuery(this).attr('data-height_auto', jQuery(this).height());
834			}
835		});
836	}
837}
838
839// Sliders: Resize
840function royal_event_sc_sliders_resize() {
841	"use strict";
842	var slider = arguments[0]!==undefined ? arguments[0] : '.sc_slider_swiper.inited';
843	var resize = arguments[1]!==undefined ? arguments[1] : true;
844
845	jQuery(slider).each(function() {
846		"use strict";
847		var id = jQuery(this).attr('id');
848		var width = jQuery(this).width();
849		var last_width = jQuery(this).data('last-width');
850		if (isNaN(last_width)) last_width = 0;
851		
852		// Change slides_per_view
853		if (last_width==0 || last_width!=width) {
854			var spv = jQuery(this).data('slides-per-view');
855			if (spv == undefined) spv = 1;
856			var min_width = jQuery(this).data('slides-min-width');
857			if (min_width == undefined) min_width = 50;
858			if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width));
859			jQuery(this).data('last-width', width);
860			if (ROYAL_EVENT_STORAGE['swipers'][id].params.slidesPerView != spv) {
861				ROYAL_EVENT_STORAGE['swipers'][id].params.slidesPerView = spv;
862				ROYAL_EVENT_STORAGE['swipers'][id].params.loopedSlides = spv;
863				//ROYAL_EVENT_STORAGE['swipers'][id].reInit();
864			}
865			ROYAL_EVENT_STORAGE['swipers'][id].onResize();
866		}
867		
868		// Resize slider
869		if ( resize && !jQuery(this).hasClass('sc_slider_height_fixed') ) {
870			var h = 0;
871			if ( jQuery(this).find('.swiper-slide > img').length > 0 ) {
872				jQuery(this).find('.swiper-slide > img').each(function() {
873					"use strict";
874					if (jQuery(this).height() > h) h = jQuery(this).height();
875				});
876				jQuery(this).height(h);
877			} else if ( jQuery(this).find('.swiper-slide').css('backgroundImage')!='none' ) {
878				h = Math.floor(width/16*9);
879				jQuery(this).height(h).find('.swiper-slide').height(h);
880			}
881		}
882	});
883	
884	// Resize slider pagination area
885	jQuery('.sc_slider_pagination_area').each(function() {
886		"use strict";
887		var h = jQuery(this).find('.sc_slider').height();
888		if (h) {
889			jQuery(this).height(h);
890			jQuery(this).find('.sc_slider_pagination').height(h);
891			jQuery(this).find('.sc_slider_pagination .sc_scroll_vertical').height(h);
892		}
893	});
894}
895
896// Equal height for items in the row
897function royal_event_sc_equal_height() {
898	"use strict";
899	jQuery('[data-equal-height]').each(function() {
900		"use strict";
901		var eh_wrap = jQuery(this);
902		var eh_items_selector = eh_wrap.data('equal-height');
903		if (eh_items_selector) {
904			var max_h = 0;
905			var items = [];
906			var row_y = 0;
907			var i=0;
908			eh_wrap.find(eh_items_selector).each(function() {
909				"use strict";
910				var el = jQuery(this);
911				el.height('auto');
912				var el_height = el.height();
913				var el_offset = el.offset().top;
914				if (row_y == 0) row_y = el_offset;
915				if (row_y < el_offset) {
916					if (items.length > 0) {
917						if (max_h > 0) {
918							for (i=0; i<items.length; i++)
919								items[i].height(max_h);
920						}
921						items = [];
922						max_h = 0;
923					}
924					row_y = el_offset;
925				}
926				if (el_height > max_h) max_h = el_height;
927				items.push(el);
928			});
929			if (items.length > 0 && max_h > 0) {
930				for (i=0; i<items.length; i++)
931					items[i].height(max_h);
932			}
933		}
934	});
935}
936
937
938// Skills init
939function royal_event_sc_init_skills(container) {
940	"use strict";
941	if (arguments.length==0) var container = jQuery('body');
942	var scrollPosition = jQuery(window).scrollTop() + jQuery(window).height();
943
944	container.find('.sc_skills_item:not(.inited)').each(function () {
945		"use strict";
946		var skillsItem = jQuery(this);
947		var scrollSkills = skillsItem.offset().top;
948		if (scrollPosition > scrollSkills) {
949			skillsItem.addClass('inited');
950			var skills = skillsItem.parents('.sc_skills').eq(0);
951			var type = skills.data('type');
952			var total = (type=='pie' && skills.hasClass('sc_skills_compact_on')) ? skillsItem.find('.sc_skills_data .pie') : skillsItem.find('.sc_skills_total').eq(0);
953			var start = parseInt(total.data('start'));
954			var stop = parseInt(total.data('stop'));
955			var maximum = parseInt(total.data('max'));
956			var startPercent = Math.round(start/maximum*100);
957			var stopPercent = Math.round(stop/maximum*100);
958			var ed = total.data('ed');
959			var duration = parseInt(total.data('duration'));
960			var speed = parseInt(total.data('speed'));
961			var step = parseInt(total.data('step'));
962			if (type == 'bar') {
963				var dir = skills.data('dir');
964				var count = skillsItem.find('.sc_skills_count').eq(0);
965				if (dir=='horizontal')
966					count.css('width', startPercent + '%').animate({ width: stopPercent + '%' }, duration);
967				else if (dir=='vertical')
968					count.css('height', startPercent + '%').animate({ height: stopPercent + '%' }, duration);
969				royal_event_sc_animate_skills_counter(start, stop, speed-(dir!='unknown' ? 5 : 0), step, ed, total);
970			} else if (type == 'counter') {
971				royal_event_sc_animate_skills_counter(start, stop, speed - 5, step, ed, total);
972			} else if (type == 'pie') {
973				var steps = parseInt(total.data('steps'));
974				var bg_color = total.data('bg_color');
975				var border_color = total.data('border_color');
976				var cutout = parseInt(total.data('cutout'));
977				var easing = total.data('easing');
978				var options = {
979					segmentShowStroke: true,
980					segmentStrokeColor: border_color,
981					segmentStrokeWidth: 1,
982					percentageInnerCutout : cutout,
983					animationSteps: steps,
984					animationEasing: easing,
985					animateRotate: true,
986					animateScale: false,
987				};
988				var pieData = [];
989				total.each(function() {
990					"use strict";
991					var color = jQuery(this).data('color');
992					var stop = parseInt(jQuery(this).data('stop'));
993					var stopPercent = Math.round(stop/maximum*100);
994					pieData.push({
995						value: stopPercent,
996						color: color
997					});
998				});
999				if (total.length == 1) {
1000					royal_event_sc_animate_skills_counter(start, stop, Math.round(1500/steps), step, ed, total);
1001					pieData.push({
1002						value: 100-stopPercent,
1003						color: bg_color
1004					});
1005				}
1006				var canvas = skillsItem.find('canvas');
1007				canvas.attr({width: skillsItem.width(), height: skillsItem.width()}).css({width: skillsItem.width(), height: skillsItem.height()});
1008				new Chart(canvas.get(0).getContext("2d")).Doughnut(pieData, options);
1009			}
1010		}
1011	});
1012}
1013
1014// Skills counter animation
1015function royal_event_sc_animate_skills_counter(start, stop, speed, step, ed, total) {
1016	"use strict";
1017	start = Math.min(stop, start + step);
1018	total.text(start+ed);
1019	if (start < stop) {
1020		setTimeout(function () {
1021			royal_event_sc_animate_skills_counter(start, stop, speed, step, ed, total);
1022		}, speed);
1023	}
1024}
1025
1026// Skills arc init
1027function royal_event_sc_init_skills_arc(container) {
1028	"use strict";
1029	if (arguments.length==0) var container = jQuery('body');
1030	container.find('.sc_skills_arc:not(.inited)').each(function () {
1031		var arc = jQuery(this);
1032		arc.addClass('inited');
1033		var items = arc.find('.sc_skills_data .arc');
1034		var canvas = arc.find('.sc_skills_arc_canvas').eq(0);
1035		var legend = arc.find('.sc_skills_legend').eq(0);
1036		var w = Math.round(arc.width() - legend.width());
1037		var c = Math.floor(w/2);
1038		var o = {
1039			random: function(l, u){
1040				"use strict";
1041				return Math.floor((Math.random()*(u-l+1))+l);
1042			},
1043			diagram: function(){
1044				"use strict";
1045				var r = Raphael(canvas.attr('id'), w, w),
1046					hover = Math.round(w/2/items.length),
1047					rad = hover,
1048					step = Math.round(((w-20)/2-rad)/items.length),
1049					stroke = Math.round(w/9/items.length),
1050					speed = 400;
1051				
1052				
1053				r.circle(c, c, Math.round(w/2)).attr({ stroke: 'none', fill: ROYAL_EVENT_STORAGE['theme_bg_color'] ? ROYAL_EVENT_STORAGE['theme_bg_color'] : '#ffffff' });
1054				
1055				var title = r.text(c, c, arc.data('caption')).attr({
1056					font: Math.round(rad*0.75)+'px "'+ROYAL_EVENT_STORAGE['theme_font']+'"',
1057					fill: ROYAL_EVENT_STORAGE['theme_color'] ? ROYAL_EVENT_STORAGE['theme_color'] : '#909090'
1058				}).toFront();
1059				
1060				rad -= Math.round(step/2);
1061
1062				r.customAttributes.arc = function(value, color, rad){
1063					"use strict";
1064					var v = 3.6 * value,
1065						alpha = v == 360 ? 359.99 : v,
1066						rand = o.random(91, 240),
1067						a = (rand-alpha) * Math.PI/180,
1068						b = rand * Math.PI/180,
1069						sx = c + rad * Math.cos(b),
1070						sy = c - rad * Math.sin(b),
1071						x = c + rad * Math.cos(a),
1072						y = c - rad * Math.sin(a),
1073						path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]];
1074					return { path: path, stroke: color }
1075				}
1076				
1077				items.each(function(i){
1078					"use strict";
1079					var t = jQuery(this), 
1080						color = t.find('.color').val(),
1081						value = t.find('.percent').val(),
1082						text = t.find('.text').text();
1083					
1084					rad += step;
1085					var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': stroke });
1086					
1087					z.mouseover(function(){
1088						"use strict";
1089						this.animate({ 'stroke-width': hover, opacity: .75 }, 1000, 'elastic');
1090						if (Raphael.type != 'VML') //solves IE problem
1091							this.toFront();
1092						title.stop().animate({ opacity: 0 }, speed, '>', function(){
1093							this.attr({ text: (text ? text + '\n' : '') + value + '%' }).animate({ opacity: 1 }, speed, '<');
1094						});
1095					}).mouseout(function(){
1096						"use strict";
1097						this.stop().animate({ 'stroke-width': stroke, opacity: 1 }, speed*4, 'elastic');
1098						title.stop().animate({ opacity: 0 }, speed, '>', function(){
1099							title.attr({ text: arc.data('caption') }).animate({ opacity: 1 }, speed, '<');
1100						});	
1101					});
1102					
1103				});
1104				
1105			}
1106		}
1107		o.diagram();
1108	});
1109}
1110
1111
1112// Countdown update
1113function royal_event_countdown(dt) {
1114	"use strict";
1115	var counter = jQuery(this).parent();
1116	for (var i=3; i<dt.length; i++) {
1117		var v = (dt[i]<10 ? '0' : '') + dt[i];
1118		counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').addClass('hide');
1119		for (var ch=v.length-1; ch>=0; ch--) {
1120			counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').eq(ch+(i==3 && v.length<3 ? 1 : 0)).removeClass('hide').text(v.substr(ch, 1));
1121		}
1122	}
1123}
1124
1125
1126// Contact form handlers
1127function royal_event_sc_form_validate(form){
1128	"use strict";
1129	var url = form.attr('action');
1130	if (url == '') return false;
1131	form.find('input').removeClass('error_fields_class');
1132	var error = false;
1133	var form_custom = form.data('formtype')=='form_custom';
1134	if (!form_custom) {
1135	
1136		var rules = [], rule = {};
1137
1138		if (form.find('[name="username"]').length > 0) {
1139			rule = {
1140				field: "username",
1141				max_length: { value: 60, message: ROYAL_EVENT_STORAGE['strings']['name_long'] }
1142			};
1143			if (form.find('[name="username"][aria-required="true"]').length > 0)
1144				rule['min_length'] = { value: 1, message: ROYAL_EVENT_STORAGE['strings']['name_empty'] };
1145			rules.push(rule);
1146		}
1147		
1148		if (form.find('[name="email"]').length > 0) {
1149			rule = {
1150				field: "email",
1151				max_length: { value: 60, message: ROYAL_EVENT_STORAGE['strings']['email_long'] },
1152				mask: { value: ROYAL_EVENT_STORAGE['email_mask'], message: ROYAL_EVENT_STORAGE['strings']['email_not_val
1152id'] }
1153			};
1154			if (form.find('[name="email"][aria-required="true"]').length > 0)
1155				rule['min_length'] = { value: 7, message: ROYAL_EVENT_STORAGE['strings']['email_empty'] };
1156			rules.push(rule);
1157		}
1158		
1159		if (form.find('[name="subject"]').length > 0) {
1160			rule = {
1161				field: "subject",
1162				max_length: { value: 100, message: ROYAL_EVENT_STORAGE['strings']['subject_long'] }
1163			};
1164			if (form.find('[name="subject"][aria-required="true"]').length > 0)
1165				rule['min_length'] = { value: 1, message: ROYAL_EVENT_STORAGE['strings']['subject_empty'] };
1166			rules.push(rule);
1167		}
1168
1169		if (form.find('[name="message"]').length > 0) {
1170			rule = {
1171				field: "message",
1172				max_length: { value: ROYAL_EVENT_STORAGE['contacts_maxlength'], message: ROYAL_EVENT_STORAGE['strings']['text_long'] }
1173			};
1174			if (form.find('[name="message"][aria-required="true"]').length > 0)
1175				rule['min_length'] = { value: 1, message: ROYAL_EVENT_STORAGE['strings']['text_empty'] };
1176			rules.push(rule);
1177		}
1178
1179		error = royal_event_form_validate(form, {
1180			error_message_show: true,
1181			error_message_time: 4000,
1182			error_message_class: "sc_infobox sc_infobox_style_error",
1183			error_fields_class: "error_fields_class",
1184			exit_after_first_error: false,
1185			rules: rules
1186		});
1187	}
1188	if (!error && url!='#') {
1189		jQuery.post(url, {
1190			action: "send_form",
1191			nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
1192			type: form.data('formtype'),
1193			data: form.serialize()
1194		}).done(function(response) {
1195			"use strict";
1196			var rez = {};
1197			try {
1198				rez = JSON.parse(response);
1199			} catch (e) {
1200				rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] };
1201				console.log(response);
1202			}
1203			var result = form.find(".result").toggleClass("sc_infobox_style_error", false).toggleClass("sc_infobox_style_success", false);
1204			if (rez.error === '') {
1205				form.get(0).reset();
1206				result.addClass("sc_infobox_style_success").html(ROYAL_EVENT_STORAGE['strings']['send_complete']);
1207				var return_url = form.find('input[name="return_url"]');
1208				if (return_url.length > 0 && return_url.val()!='') {
1209					setTimeout(function() {
1210						"use strict";
1211						window.location.href = return_url.val();
1212					}, 3300);
1213				}
1214			} else {
1215				result.addClass("sc_infobox_style_error").html(ROYAL_EVENT_STORAGE['strings']['send_error'] + ' ' + rez.error);
1216			}
1217			result.fadeIn().delay(3000).fadeOut();
1218		});
1219	}
1220	return !error;
1221}
1222
1223
1224
1225// Get players by category
1226function royal_event_select_players_category(sel) {
1227	var value = sel.find(':selected').data('cat');
1228	var table = sel.parents('.sc_players_table');
1229	if (value == 'all') 
1230		jQuery(table).find('.sc_table tr:nth-child(n+2)').show();
1231	else {
1232		jQuery(table).find('.sc_table tr:nth-child(n+2)').hide();
1233		jQuery(table).find('.sc_table tr').each(function() { 
1234			var cat = jQuery(this).data('cat'); 
1235			if (cat != null && cat.indexOf(value)!=-1)
1236			   jQuery(this).show();
1237		});
1238	}
1239}
1240
1241
1242
1243// Display menuitem in the popup
1244function royal_event_menuitems_show_popup(obj) {
1245	"use strict";
1246	
1247	// First init vars
1248	if (typeof ROYAL_EVENT_STORAGE['menuitem_load'] == 'undefined') {
1249		ROYAL_EVENT_STORAGE['menuitem_load'] = false;
1250		ROYAL_EVENT_STORAGE['menuitems_list'] = [];
1251
1252	// If busy - return
1253	} else if ( ROYAL_EVENT_STORAGE['menuitem_load'] ) {
1254		return;
1255	}
1256	
1257	// Show preloader
1258	jQuery('#page_preloader').data('bg-color', jQuery('#page_preloader').css('background-color')).css({display: 'block', opacity: 0, backgroundColor: 'transparent'}).animate({opacity:0.8}, 300);
1259
1260	// Get items list on first click
1261	if (ROYAL_EVENT_STORAGE['menuitems_list'].length == 0) {
1262		var menuitems_list_id = obj.parents('.sc_menuitems').attr("id");
1263		ROYAL_EVENT_STORAGE['menuitems_list'] = ROYAL_EVENT_STORAGE['menuitems'][menuitems_list_id].split(",");
1264	}
1265	
1266	var menuitem_id = obj.attr('data-href');
1267
1268	ROYAL_EVENT_STORAGE['menuitem_load'] = true;
1269	
1270	jQuery.post(ROYAL_EVENT_STORAGE['ajax_url'], {
1271		action: 'ajax_menuitem',
1272		nonce: ROYAL_EVENT_STORAGE['ajax_nonce'],
1273		text: menuitem_id
1274	}).done(function(response) {
1275		"use strict";
1276		ROYAL_EVENT_STORAGE['menuitem_load'] = false;
1277		var rez = {};
1278		try {
1279			rez = JSON.parse(response);
1280		} catch (e) {
1281			rez = { error: ROYAL_EVENT_STORAGE['ajax_error'] + '<br>' + response };
1282		}
1283		jQuery('#page_preloader').animate({opacity:0}
1283, 500, function() { jQuery(this).css({display: 'none', backgroundColor: jQuery(this).data('bg-color')}); });
1284		if (rez.error === '') {
1285			var delay = 0;
1286			// Create popup
1287			if (jQuery('.popup_menuitem').length == 0) {
1288				jQuery('body').append('<div id="overlay"></div><div class="popup_menuitem"></div>');
1289				jQuery('#overlay').fadeIn(500);
1290			} else {
1291				delay = 500;
1292				jQuery('.popup_menuitem').fadeOut(delay);
1293			}
1294			// Add new content in the popup
1295			setTimeout(function() {
1296				jQuery('.popup_menuitem').html(rez.data);
1297				jQuery('.popup_menuitem .sc_menuitems_wrap').append("<a class='close_menuitem' href='#'><span class='icon-cancel'></span></a>");
1298				if ( ROYAL_EVENT_STORAGE['menuitems_list'].length > 1 ) {
1299					var idx = 0;
1300					for (var i=0; i<ROYAL_EVENT_STORAGE['menuitems_list'].length; i++ ) {
1301						if ( ROYAL_EVENT_STORAGE['menuitems_list'][i] === menuitem_id ) {
1302							idx = i;
1303							break;
1304						}
1305					}
1306					var prev = (idx - 1 + ROYAL_EVENT_STORAGE['menuitems_list'].length) % ROYAL_EVENT_STORAGE['menuitems_list'].length;
1307					var next = (idx + 1) % ROYAL_EVENT_STORAGE['menuitems_list'].length;
1308					jQuery('.popup_menuitem .sc_menuitems_wrap .sc_menuitem_content').append(
1309						  "<a class='prev_menuitem prevnext_menuitem show_popup_menuitem' data-href='"+ROYAL_EVENT_STORAGE['menuitems_list'][prev]+"'  href='#'><span class='icon-left'></span></a>"
1310						+ "<a class='next_menuitem prevnext_menuitem show_popup_menuitem' data-href='"+ROYAL_EVENT_STORAGE['menuitems_list'][next]+"'  href='#'><span class='icon-right'></span></a>"
1311					);
1312				}
1313				jQuery('.popup_menuitem').fadeIn(500);
1314			}, delay);
1315		} else {
1316			royal_event_message_warning(ROYAL_EVENT_STORAGE['strings']['search_error']);
1317		}
1318	});	
1319}
1320
1321// Hide popup with menuitem
1322function royal_event_menuitems_hide_popup() {
1323	"use strict";
1324	jQuery('#overlay').fadeOut();
1325	jQuery('.popup_menuitem').fadeOut(function() {
1326		ROYAL_EVENT_STORAGE['menuitem_load'] = false;
1327		ROYAL_EVENT_STORAGE['menuitems_list'] = [];
1328		jQuery('#overlay').remove();
1329		jQuery(this).remove();
1330	});
1331}

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.