PageSourceSearch

https://whitewaterchallengers.com/wp-content/themes/kayaking/fw/js/core.init.js

js whitewaterchallengers.com collected 2026-09-24 09:49:37 UTC 61,447 bytes, 1,712 lines download raw bytes

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

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.