PageSourceSearch

https://www.beaufortdog.com/wp-content/themes/pets-grooming/fw/js/core.init.js

js beaufortdog.com collected 2026-10-04 01:14:37 UTC 52,254 bytes, 1,479 lines download raw bytes

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

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.