PageSourceSearch

https://peakart.co.uk/wp-content/themes/shopkeeper/js/scripts.js?ver=11.0

js peakart.co.uk collected 2026-10-04 13:33:47 UTC 12,959 bytes, 436 lines download raw bytes

1jQuery( function ($) {
2
3	"use strict";
4
5	// Global throttle.
6	window.gb_throttle = function(func, wait, immediate) {
7		var timeout;
8		return function() {
9			var context = this, args = arguments;
10			var later   = function() {
11				timeout = null;
12				if ( ! immediate) {
13					func.apply( context, args );
14				}
15			};
16			var callNow = immediate && ! timeout;
17			if ( ! timeout ) {
18				timeout = setTimeout( later, wait );
19			}
20			if (callNow) {
21				func.apply( context, args );
22			}
23		};
24	};
25
26	// RTL fix for wpbakery full width elements position
27	$(window).on( 'resize', function() {
28		if ($('body').hasClass("rtl")) {
29			var $elements = $('[data-vc-full-width="true"]');
30			$.each($elements, function () {
31				var $el = jQuery(this);
32				var $el_right = parseInt($el.css('right'));
33				$el.css('right', -$el_right);
34			});
35		}
36	});
37
38	//mobile menu
39
40	$(".mobile-navigation .menu-item-has-children .sub-menu").has('ul').addClass("has_children");
41
42	$(".mobile-navigation .menu-item-has-children .sub-menu").before('<div class="more"><span class="spk-icon-down-small"></span></div>');
43
44	$(".mobile-navigation").on("click", ".more", function(e) {
45		e.stopPropagation();
46
47		var submenus = $(this).parent().find(".sub-menu");
48		$.each(submenus, function(x,y){
49			$(y).find(".sub-menu").addClass("open");
50			$(y).find(".more").remove();
51		});
52
53		$(this).parent().toggleClass("current")
54						.children(".sub-menu").toggleClass("open");
55
56		$(this).parent().find('.more').html($(this).parent().find('.more').html() == '<span class="spk-icon-down-small"></span>' ? '<span class="spk-icon-up-small"></span>' : '<span class="spk-icon-down-small"></span>');
57	});
58
59	$(".mobile-navigation").on("click", "a", function(e) {
60		if($(this).attr('href') == '#' && $(this).parent('.menu-item').hasClass('menu-item-has-children')) {
61			$(this).parent().find('.more').trigger('click');
62		} else if($(this).attr('href').indexOf('#') > -1) {
63			$('#offCanvasRight1').foundation('close');
64		}
65	});
66
67	function replace_img_source(selector) {
68		var data_src = $(selector).attr('data-src');
69		$(selector).one('load', function() {
70		}).each(function() {
71			$(selector).attr('src', data_src);
72			$(selector).css("opacity", "1");
73		});
74	}
75
76	$('#products-grid li img').each(function(){
77		replace_img_source(this);
78	});
79
80	$('.related.products li img').each(function(){
81		replace_img_source(this);
82	});
83
84	$('.upsells.products li img').each(function(){
85		replace_img_source(this);
86	});
87
88	$('.add_to_cart_button').on('click',function(){
89		$(this).parents('li.animated').addClass('product_added_to_cart')
90	})
91
92	$('.add_to_wishlist').on('click',function(){
93		$(this).parents('.yith-wcwl-add-button').addClass('show_overlay');
94	})
95
96	// Login/register
97	var account_tab_list = $('.account-tab-list');
98
99	account_tab_list.on('click','.account-tab-link',function(){
100
101		if ( $('.account-tab-link').hasClass('registration_disabled') ) {
102			return false;
103		} else {
104
105			var that = $(this),
106				target = that.attr('href');
107
108			that.parent().siblings().find('.account-tab-link').removeClass('current');
109			that.addClass('current');
110
111			$('.account-forms').find($(target)).siblings().stop().fadeOut(function(){
112				$('.account-forms').find($(target)).fadeIn();
113			});
114
115			return false;
116		}
117	});
118
119	// Login/register mobile
120	$('.account-tab-link-register').on('click',function(){
121		$('.login-form').stop().fadeOut(function(){
122			$('.register-form').fadeIn();
123		})
124		return false;
125	})
126
127	$('.account-tab-link-login').on('click',function(){
128		$('.register-form').stop().fadeOut(function(){
129			$('.login-form').fadeIn();
130		})
131		return false;
132	})
133
134    // Disable fresco
135    function disable_fresco() {
136
137		if ( getbowtied_scripts_vars.product_lightbox != 1 ) {
138
139			$(".product-images-layout .fresco, .product-images-layout-mobile .fresco, .woocommerce-product-gallery__wrapper .fresco").on('click',function() {
140				return false;
141			});
142		}
143	}
144
145    disable_fresco();
146
147
148	//add fresco groups to images galleries
149	$(".gallery").each(function() {
150
151		var that = $(this);
152
153		that.find('.gallery-item').each(function(){
154
155			var this_gallery_item = $(this);
156
157			this_gallery_item.find('.fresco').attr('data-fresco-group', that.attr('id'));
158
159			if ( this_gallery_item.find('.gallery-caption').length > 0 ) {
160				this_gallery_item.find('.fresco').attr('data-fresco-caption', this_gallery_item.find('.gallery-caption').text());
161			}
162
163		});
164
165	});
166
167	function handleSelect() {
168		if ( typeof $.fn.selectWoo === 'function' ) {
169			$( '.woocommerce-ordering select.orderby' ).selectWoo({
170				minimumResultsForSearch: Infinity,
171				// allowClear: true,
172				// width: 'auto',
173				dropdownCssClass: "orderby-dropdown",
174				// dropdownAutoWidth: true
175			});
176		}
177		$('.woocommerce-ordering').css({ opacity: 1 });
178	}
179
180	handleSelect();
181
182
183	//gallery caption
184
185	$('.gallery-item').each(function(){
186
187		var that = $(this);
188
189		if ( that.find('.gallery-caption').length > 0 ) {
190			that.append('<span class="gallery-caption-trigger">i</span>')
191		}
192
193	})
194
195	$('.gallery-caption-trigger').on('mouseenter',function(){
196		$(this).siblings('.gallery-caption').addClass('show');
197	});
198
199	$('.gallery-caption-trigger').on('mouseleave',function(){
200		$(this).siblings('.gallery-caption').removeClass('show');
201	});
202
203	$('.trigger-footer-widget').on('click', function(){
204
205		var trigger = $(this).parent();
206
207		trigger.fadeOut('1000',function(){
208			trigger.remove();
209			$('.site-footer-widget-area').fadeIn();
210		});
211	});
212
213	//Language Switcher
214	$('.topbar-language-switcher').on( 'change', function(){
215		window.location = $(this).val();
216	});
217
218	$(window).on( 'resize', function(){
219
220        $('.site-search-form-wrapper-inner, .site-search .widget_search .search-form').css('margin-left',-$(window).width()/4);
221
222	});
223
224    $(window).on( 'scroll', function() {
225
226		//single post overlay -  only for large-up
227		if ( $(window).width() > 1024 ) {
228			$('.single-post-header-overlay').css('opacity', 0.3 + ($(window).scrollTop()) / (($(window).height())*1.4) );
229		}
230
231    });
232
233	$('.widget_layered_nav span.count, .widget_product_categories span.count').each(function(){
234		var count = $(this).html();
235		count = count.substring(1, count.length-1);
236		$(this).html(count);
237	})
238
239	/******************** average rating widget ****************************/
240	$('.widget_rating_filter ul li a').each(function(){
241		var count = $(this).contents().filter(function(){
242		  return this.nodeType == 3;
243		})[0].nodeValue;
244
245		$(this).contents().filter(function(){
246		  return this.nodeType == 3;
247		})[0].nodeValue = '';
248
249		count = count.slice(2,-1);
250
251		$(this).append('<span class="count">' + count + '</span>');
252	})
253
254	/********************** my account tabs by url **************************/
255	if ( ('form#register').length > 0 )
256	{
257		var hash = window.location.hash;
258		if (hash)
259		{
260			$('.account-tab-link').removeClass('current');
261			$('a[href="'+hash+'"]').addClass('current');
262
263			hash = hash.substring(1);
264			$('.account-forms > form').hide();
265			$('form#'+hash).show();
266		}
267	}
268
269	/* BACK TO TOP */
270	if( getbowtied_scripts_vars.back_to_top_button && $('.progress-wrap').length > 0 ) {
271		var progressPath = document.querySelector('.progress-wrap path');
272		var pathLength = progressPath.getTotalLength();
273		progressPath.style.transition = progressPath.style.WebkitTransition = 'none';
274		progressPath.style.strokeDasharray = pathLength + ' ' + pathLength;
275		progressPath.style.strokeDashoffset = pathLength;
276		progressPath.getBoundingClientRect();
277		progressPath.style.transition = progressPath.style.WebkitTransition = 'stroke-dashoffset 10ms linear';
278		var updateProgress = function () {
279			var scroll = $(window).scrollTop();
280			var height = $(document).height() - $(window).height();
281			var progress = pathLength - (scroll * pathLength / height);
282			progressPath.style.strokeDashoffset = progress;
283		}
284		updateProgress();
285		$(window).on( 'scroll', updateProgress );
286		var offset = 50;
287		var duration = 550;
288		$(window).on('scroll', function() {
289			if ($(this).scrollTop() > offset) {
290				$('.progress-wrap').addClass('active-progress');
291			} else {
292				$('.progress-wrap').removeClass('active-progress');
293			}
294		});
295		$('.progress-wrap').on('click', function(event) {
296			event.preventDefault();
297			$('html, body').animate({scrollTop: 0}, duration);
298			return false;
299		});
300	}
301
302	// wpbakery
303	function bs_fix_vc_full_width_row() {
304
305        var elements = $('[data-vc-full-width="true"]');
306        $.each(elements, function () {
307            var el = jQuery(this);
308            el.css('right', el.css('left')).css('left', '');
309        });
310
311    }
312
313	// Fixes rows in RTL
314    if( $('body').hasClass("rtl") ) {
315        $(document).on('vc-full-width-row', function () {
316            bs_fix_vc_full_width_row();
317        });
318    }
319
320    // Run one time because it was not firing in Mac/Firefox and Windows/Edge some times
321    if ($('body').hasClass("rtl")) {
322        bs_fix_vc_full_width_row();
323    }
324
325	// Checkout expand forms
326	$('.woocommerce-checkout').on('click', '.showlogin', function() {
327		$('form.woocommerce-form-login').toggleClass('fade');
328	});
329
330	/*$('.woocommerce-checkout').on('click', '.showcoupon, .checkout_coupon_inner .button', function() {
331		$('form.woocommerce-form-coupon').toggleClass('fade');
332	});*/
333
334	$(".vc_images_carousel").each(function() {
335		var height = $(this).find(".vc_item.vc_active").height();
336		$(this).css("height", height);
337	});
338
339	$(".vc_images_carousel").on('click', '.vc_right, .vc_left, .vc_carousel-indicators li', function(){
340
341		var that = $(this);
342
343		setTimeout(function(){
344			var height = that.parents(".vc_images_carousel").find(".vc_item.vc_active").height();
345			that.parents(".vc_images_carousel").css("height", height);
346		}, 600);
347
348
349	});
350
351	// set focus on search input field in off-canvas
352	$(document).on('click touchend', 'header .site-tools .search-button .spk-icon-search', function(){
353		setTimeout( function(){
354			$(".off-canvas .woocommerce-product-search .search-field").focus();
355		}, 800);
356	});
357
358	// When Viewport Height is equal with 768, make the minicart image smaller
359	var windowHeight 		 = $(window).height();
360	var minicart_product_img = $('.shopkeeper-mini-cart .widget.woocommerce.widget_shopping_cart .widget_shopping_cart_content .cart_list.product_list_widget li.mini_cart_item .product-item-bg');
361
362	if ( windowHeight == 768) {
363		minicart_product_img.addClass('smaller-vh');
364	} else {
365		minicart_product_img.removeClass('smaller-vh');
366	}
367
368	// If both facebook messenger and get this theme plugins exists, make them look nice
369	if ( $('#fbmsg').length ) {
370
371		if ( $('.getbowtied_get_this_theme').length ) {
372			$('#fbmsg').addClass('gbt_plugin_installed');
373		} else {
374			$('#fbmsg').removeClass('gbt_plugin_installed');
375		}
376	}
377
378	$("body.single-product form.cart").on("change", "input.qty, input.custom-qty", function() {
379        $('button.single_add_to_cart_button.ajax_add_to_cart').attr("data-quantity", this.value);
380    });
381
382	// overlay for loader on ajax add to cart and wishlist
383	$('body').on("click", ".products .ajax_add_to_cart", function() {
384		$(this).parents('.column').find('.product_thumbnail').prepend('<div class="overlay"></div>');
385	});
386	$('body').on('added_to_cart', function(){
387		$('.product_thumbnail .overlay').remove();
388	});
389
390	//progress add to cart button
391	$("button.single_add_to_cart_button.ajax_add_to_cart.progress-btn").on("click", function(e) {
392		var progressBtn = $(this);
393
394		if (!progressBtn.hasClass("active")) {
395		  progressBtn.addClass("active");
396		  setTimeout(function() {
397		  	progressBtn.addClass("check");
398		  }, 1500);
399		  setTimeout(function() {
400		  	progressBtn.removeClass("active");
401		  	progressBtn.removeClass("check");
402		  }, 3500);
403		}
404	});
405
406	//my account order add class to order header
407	$('.woocommerce-MyAccount-content .woocommerce-order-details').siblings('p').addClass('order-info');
408
409	
410	//off canvas
411	var $offCanvas_close_overlay = $('.js-off-canvas-overlay');
412	var $offCanvas_close_triggers = $('.js-off-canvas-overlay, .off-canvas .close-button');
413	
414	$('[data-toggle]').on("click", function() {
415		var $offCanvas = $('#' + $(this).data('toggle')); // Use data-toggle attribute
416
417		$offCanvas.attr('aria-hidden', 'true')
418				  .removeClass('is-closed')
419				  .addClass('is-open');
420
421		$offCanvas_close_overlay.addClass('is-visible is-closable');
422	});
423
424	$offCanvas_close_triggers.on("click", function() {
425		var $offCanvas = $('.off-canvas');
426
427		$offCanvas.attr('aria-hidden', 'false')
428				  .removeClass('is-open');
429
430		setTimeout(function() {
431			$offCanvas.addClass('is-closed');
432		}, 600);
433
434		$offCanvas_close_overlay.removeClass('is-visible is-closable');
435	});
436});

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.