PageSourceSearch

https://www.cantinalamarchesa.it/wp-content/themes/jardiwinery/fw/js/core.init.js

js cantinalamarchesa.it collected 2026-10-06 09:26:08 UTC 57,238 bytes, 1,556 lines download raw bytes

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

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.