PageSourceSearch

https://www.clickcover.co.nz/edit/template.core.js

js clickcover.co.nz collected 2026-10-04 21:44:17 UTC 16,424 bytes, 743 lines download raw bytes

1// JavaScript Document
2
3
4	// Check for jQuery
5	jQuery.exists = function(selector) {return ($(selector).length > 0);};
6	//
7	var messagewait = false;
8	var webSize     = 'full';
9	var browser     = 'Other';
10	var scrolling   = false;
11	
12	
13	// reCaptcha options
14	var RecaptchaOptions = {
15		theme: 'custom',
16		custom_theme_widget: 'recaptcha_widget'
17	};
18
19
20	$(document).ready(function() {
21		"use strict";
22		
23		// Get websize
24		get_web_size();
25		
26		// Get browser
27		get_browser();
28		
29		// Set up smooth scroll in edge
30		if(browser === 'Edge' && $.scrollSpeed) {
31			//
32			jQuery.scrollSpeed(120,900);
33		}
34		
35		// Resize event
36		$(window).resize(function() {
37			
38			// Get winodw size
39			get_web_size();
40			
41			// Refresh parallax calculations
42			/*$('.background.parallax').each(function() {
43				//
44				var bgobj = $(this);
45				parallax(bgobj,true);
46			});*/
47		});
48		
49		
50		// Show element that need javascript
51		$(".js-show").show();
52		
53		
54		// Animated anchor scrolling
55		$('a[href*="#"]').on('click',function(event) {
56	
57			var hashVal = this.hash.substr(1);
58			var target  = $('a[name="'+hashVal+'"]');
59			
60			if($(target).length > 0) {
61				
62				event.preventDefault();
63				
64				//
65				var scroll = $(window).scrollTop();
66				var max    = $(document).height()-$(window).height();
67				var top    = ($(target).offset().top > max) ? max : $(target).offset().top;
68				
69				//
70				var scrollSpeed = parseInt((top-scroll)/1.5);
71				if(scrollSpeed < 0) {scrollSpeed = scrollSpeed*-1;}
72				
73				//	
74				$('html, body').stop().animate({
75					'scrollTop': top
76					
77				},scrollSpeed,'swing',function() {
78					//
79					window.location.hash = hashVal;
80				});
81			}
82		});
83		
84		
85		// Back link
86		$(".backlink").on("click",function(event) {
87			
88			event.preventDefault();
89			
90			history.go(-1);
91			return false;
92		});
93		
94		
95		// Search box script
96		$("#search-box #search-box-input").addClass("search-off");
97		$("#search-box #search-box-input").focus(function() {
98			//
99			var curText     = $(this).val();
100			var defaultText = $(this).data("default");
101			
102			if(curText === defaultText) {
103				//
104				$(this).val("");
105				$(this).removeClass("search-off");
106			}
107		}).blur(function() {
108			//
109			var curText     = $(this).val();
110			var defaultText = $(this).data("default");
111			
112			if(curText === "") {
113				//
114				$(this).val(defaultText);
115				$(this).addClass("search-off");
116			}
117		});
118		
119		
120		// Send password in cart
121		$(".checkout-send-pass").click(function() {
122			var passEmail = $(this).attr("rel");
123			
124			$.ajax({  
125				type: "POST",  
126				url: "../edit/shop/cart.ajax.php?sendpassword=1&email="+passEmail,    
127				success: function(data) { 
128					if(data) {
129						$(".pass-changer").html('<div class="colour green">'+data+'</div>');
130					}
131				} 
132			});
133		});
134		
135		
136		// Mobile menu
137		$("#mobile-menu a").click(function(event) {
138			
139			//
140			event.preventDefault();
141			
142			$("#mobile-navigation").stop();
143			$('main, #footer, #base').stop();
144			
145			if($("#container1").hasClass("active")) {
146				
147				$("#mobile-navigation").fadeOut();
148				$('main, #footer, #base').fadeIn();
149				
150				$('#nav-icon').toggleClass('open');
151				$("#container1").toggleClass('active');
152			}
153			else {
154				
155				$("#mobile-navigation").fadeIn();
156				$('main, #footer, #base').fadeOut();
157				
158				$('#nav-icon').toggleClass('open');
159				$("#container1").toggleClass('active');
160			}
161		});
162		
163		
164		// Open images in magnific popup
165		if($.fn.magnificPopup) {
166			//
167			$('a.lightboximage').magnificPopup({
168				type:'image'
169			});
170		}
171		
172		// Open images in colorbox
173		else if($.fn.colorbox) { 
174			//
175			$("a[class=\'lightboximage\']").colorbox({photo:true},function(){ 
176				var titleheight = $("#cboxTitle").height(); 
177				$("#colorbox").height($("#colorbox").height() + titleheight); 
178				$("#cboxWrapper").height($("#cboxWrapper").height() + titleheight); 
179				$("#cboxMiddleLeft").height($("#cboxMiddleLeft").height() + titleheight); 
180				$("#cboxMiddleRight").height($("#cboxMiddleRight").height() + titleheight); 
181				$("#cboxContent").height($("#cboxContent").height() + titleheight); 
182				$("#cboxLoadedContent").height($("#cboxLoadedContent").height() + titleheight); 
183			});
184		}
185		
186		
187		// Check for date field and create fallback
188		if(!Modernizr.inputtypes.date) {
189			//
190			var dateInputs = $('input[type="date"]');
191			//
192			if($(dateInputs).length > 0) {
193				$(dateInputs).each(function() {
194					$(this).datepicker({dateFormat:"d M yy"});
195				});
196			}
197		}
198		
199		
200		// Hide site messages
201		$(document).on("click","#site-messages .close-msg",function() {
202
203			var msgId = $(this).closest(".error-message").attr("id");
204			hide_site_message(msgId);
205		});
206		
207		
208		if($.fn.lazyload) {
209			
210			$("img.lazy").show();
211			
212			// Lazy load images
213			$("img.lazy").lazyload({
214				effect: "fadeIn",
215				load : function() {
216					//
217				}
218			}).removeClass("lazy");
219		}
220		
221		
222		// Open all youtube and vimeo links in popup (Remove "&& false" to enable)
223		if($.fn.magnificPopup && false) {
224			//
225			$('a[href*="youtube.com/watch"]').magnificPopup({
226				type:'iframe',
227				iframe: {
228					patterns: {
229						youtube: {
230							index: 'youtube.com/', 
231							id: function(url) { 
232								//
233								return qs(url,'v'); 
234							},
235							src: '//www.youtube.com/embed/%id%?controls=0&modestbranding=1&rel=0&showinfo=0&color=white&autoplay=1' 
236						}
237					}
238				}
239			});
240			
241			//
242			$('a[href*="vimeo.com/"]').magnificPopup({
243				type:'iframe',
244				iframe: {
245					patterns: {
246						vimeo: {
247							index: 'vimeo.com/', 
248							id: function(url) { 
249								//
250								if(url.indexOf('external') > -1) {
251									return 'external/' + url.substr(url.lastIndexOf('/')+1, url.length);
252								} 
253								else {
254									return 'video/' + url.substr(url.lastIndexOf('/')+1, url.length);
255								}
256							},
257							src: '//player.vimeo.com/%id%?autoplay=1' 
258						}
259					}
260				}
261			});
262		}
263		
264		
265		// Convert svg image to svg path
266		$('.svg-with-path img[src*=svg]').each(function() {
267			//
268            var $img     = $(this);
269            var imgID    = $img.attr('id');
270            var imgClass = $img.attr('class');
271            var imgURL   = $img.attr('src');
272			
273			// Get SVG data
274            $.get(imgURL,function(data) {
275				
276                // Get the SVG tag, ignore the rest
277                var $svg = $(data).find('svg');
278
279                // Add replaced image's ID to the new SVG
280                if(typeof imgID !== 'undefined') {
281					//
282                    $svg = $svg.attr('id',imgID);
283                }
284				
285                // Add replaced image's classes to the new SVG
286                if(typeof imgClass !== 'undefined') {
287					//
288                    $svg = $svg.attr('class',imgClass+' replaced-svg');
289                }
290
291                // Remove any invalid XML tags as per http://validator.w3.org
292                $svg = $svg.removeAttr('xmlns:a');
293
294                // Replace image with new SVG
295                $img.replaceWith($svg);
296
297            },'xml');
298		});
299		
300		
301		// Address finder setup
302		if($(".address-finder").length > 0) {
303			
304			// Load address finder api
305			$.getScript('https://api.addressfinder.io/assets/v3/widget.js',function() {
306				
307				// Add widget to address-finder class
308				var widget = new AddressFinder.Widget(
309					$(".address-finder")[0],
310					$(".address-finder-key").data("key"),
311					'NZ',{
312						byline: false,
313						//manual_style: true
314					}
315				);
316				
317				// Get results
318				widget.on('result:select',function(fullAddress,metaData) {
319					
320					// Populate selected variable
321					var selected = new AddressFinder.NZSelectedAddress(fullAddress, metaData);
322					
323					// Build address
324					var address = "";
325					address += selected.address_line_1();
326					address += selected.address_line_2();
327					address += selected.suburb();
328					address += selected.city();
329					address += selected.postcode();
330					
331					alert(address);
332				});
333			});
334		}
335		
336		
337		// Check for waypoint class
338		if($.fn.waypoint) {
339			
340			// Set waypoints as active
341			$("html").addClass("waypoints-active");
342			
343			//
344			$(".waypoint").each(function() {
345				//
346				var $element = $(this);
347				var offset = $element.data("waypoint-offset");
348				
349				// Check for offset
350				if(offset === undefined) {
351					//
352					offset = '70%';	
353				}
354				
355				$element.waypoint({
356					handler: function(direction) {
357						//
358						if(direction === 'down') {
359							//
360							$element.addClass("waypoint-down");
361							$element.addClass("waypoint-on");
362						}
363						else {
364							//
365							$element.addClass("waypoint-up");
366							$element.removeClass("waypoint-on");
367						}
368					},
369					offset: offset
370				});
371			});
372		}
373		
374		
375		// Check for number counter plugin
376		if($.fn.numbercounter) {
377			//
378			$(".number-counter").numbercounter({
379	 			duration: 	5000,
380	 			easing: 	'easeOutQuad',
381	 			before:		function() {},
382	 			complete: 	function() {},
383	 		});
384		}
385		
386		
387		// Check for match height class (matchheight)
388		if($.fn.matchHeight && $(".matchheight").length > 0) {
389			//
390			$(".matchheight").matchHeight({
391				byRow: true,
392				property: "height"
393			});
394		}
395		
396		
397		// Check for collapsable elements
398		if($(".collapser").length > 0) {		
399			
400			// Collapse containers
401			$(".collapser").addClass("collapsed");
402			$(".collapsable").hide();
403			
404			// Show any that start shown
405			$(".collapser.show").each(function(event) {
406				
407				collapse_expand($(this),false,0);
408			});
409			
410			// On expandable clicked
411			$("body").on("click",".collapser",function(event) {
412				
413				collapse_expand($(this),event,500);
414			});
415		}
416		
417		
418		// Bacground image
419		if($(".background-image").length > 0) {
420			
421			// Backgrounds
422			$(".background-image").backgroundimage();	
423		}
424		
425		
426		// Force initial scroll and resize
427		{
428			setTimeout(function() {
429				$(window,"html,body").scroll();
430				if(browser !== "IE") {window.dispatchEvent(new Event('resize'));}
431			},100);
432		}
433		
434		// Manually add wf-active if 3 seconds passed
435		{
436			setTimeout(function() {
437				$("html").addClass("wf-active");
438			},3000);
439		}
440	});
441	
442	
443	// Collapsable content
444	function collapse_expand(obj,event,spd) {
445		"use strict";
446		
447		//
448		if(event !== false) {
449			event.preventDefault();
450		}
451		
452		var element = obj;
453		
454		// Parent
455		var parent = $(element).closest(".collapse-holder");
456		parent = (parent === undefined) ? $(element).closest(".layout") : parent;
457		
458		// Get speed
459		var speed = $(element).data("speed");
460		speed = (speed === undefined) ? spd : parseInt(speed);
461		
462		// Get if accordian
463		var accordion = $(element).data("accordion");
464		accordion = (accordion === undefined) ? false : true;
465		
466		// Collapse all others
467		if(accordion) {
468			
469			//
470			$(parent).find(".collapser").each(function() {
471				//
472				if($(this).is($(element))) {}
473				else {
474					//
475					$(this).removeClass("uncollapsed");
476					$(this).addClass("collapsed");	
477					//
478					$(this).next(".collapsable").slideUp({
479						duration: parseInt(speed), 
480						//easing: 'easeOutQuart'
481						});
482				}
483			});
484		}
485		
486		// Expand
487		if($(element).hasClass("collapsed")) {
488			//
489			$(element).removeClass("collapsed");
490			$(element).addClass("uncollapsed");
491			
492			// Slide down collapse
493			$(element).nextAll(".collapsable").eq(0).slideDown({
494				duration: speed, 
495				//easing: 'easeOutQuart'
496				});
497		}
498		
499		// Collapse
500		else {
501			//
502			$(element).removeClass("uncollapsed");
503			$(element).addClass("collapsed");
504			
505			// Slide up collapse
506			$(element).nextAll(".collapsable").eq(0).slideUp({
507				duration: parseInt(speed), 
508				//easing: 'easeOutQuart'
509				});
510		}
511	}
512	
513	
514	// Generic ajax function (ajax starting point)
515	function generic_ajax() {
516		"use strict";
517		
518		if(true) {
519			// Run ajax call
520			$.ajax({
521				type: "GET",
522				url: pageRelativity+'edit/template.ajax.php',
523				dataType: "jsonp",
524				jsonp: "callback",
525				timeout: 5000,
526				data: {
527					type: 'ajax',
528					relative: pageRelativity
529				},
530				success: function(data) {
531					// If data
532					if(data.results) {
533						// 
534						alert(data.results);
535					}
536				},
537				error: function(request, status, error) {
538					//
539					alert(request.responseText);
540				}
541			});
542		}
543	}
544	
545	
546	// Update cart summary
547	function updateCartSummery() {
548		"use strict";
549		
550		// Change inner cart summary
551		$("#shopping-cart-summery-inner").slideUp(350,function() {
552			
553			//
554			$.ajax({
555				type: "POST",  
556				url: pageRelativity+"edit/shop/cart.ajax.php?update=1&relative="+pageRelativity,  
557				data: "",  
558				success: function(data) { 
559				
560					if(data) {
561						// Format text with holder
562						var htmlText = data;
563						
564						// hide / show / append
565						$("#shopping-cart-summery").html("");
566						$("#shopping-cart-summery").append(htmlText);
567						$("#shopping-cart-summery").show();
568						
569						$("#shopping-cart-summery .shopping-cart-none").remove("");
570						$("#shopping-cart-proceed").show();
571						
572						$("#shopping-cart-summery-inner").slideDown(350);
573					}
574				} 
575			});
576		});
577	}
578	
579	
580	// Hide website message
581	function hide_site_message(msgId) {
582		"use strict";
583		
584		// hide message
585		$("#"+msgId).slideUp(400,"easeInBack");
586		
587		var hideString = "hideid="+msgId;
588		$.ajax({  
589			type: "POST",  
590			url: pageRelativity+"edit/core/core_functions/messaging.inc.php?remove-message=1",  
591			data: hideString,  
592			success: function(data) { 
593				if(data) {
594					//alert(data);
595				}
596			} 
597		});
598	}
599	
600	
601	// Update website message
602	function update_messages() {
603		"use strict";
604		
605		//
606		$.ajax({  
607			type: "POST",  
608			url: pageRelativity+"edit/shop/cart.ajax.php?getmessages=1",    
609			success: function(data) { 
610				if(data) {
611					$("#site-messages").html(data);
612					$("#site-messages").slideDown(400);//,"easeOutSine"
613					clearInterval(messagewait);
614					messagewait = setInterval(hide_messages, 6000);
615				}
616				else {
617					
618				}
619			} 
620		});
621	}
622	
623	
624		function hide_messages() {
625			"use strict";
626			
627			// hide message
628			$("#site-messages").slideUp(400);//,"easeInBack"
629		
630			clearInterval(messagewait);
631		}
632	
633	
634	// Get viewport size
635	function get_web_size() {
636		"use strict";
637		
638		var docWidth = window.innerWidth;
639		var viewPort = $('meta[name="viewport"]');
640		
641		
642		// Set webSize to body element
643		$("body").data("websize",webSize);
644	}
645	
646	
647	// Basic browser detection
648	function get_browser() {
649		"use strict";
650		
651		var ua = window.navigator.userAgent;
652		var msie    = ua.indexOf('MSIE ');
653		var trident = ua.indexOf('Trident/');
654		var edge    = ua.indexOf('Edge/');
655		
656		// IE
657		if(parseInt(msie) > 0 || parseInt(trident) > 0) {
658			//
659			browser = 'IE';
660		}
661		// Edge
662		else if(parseInt(edge) > 0) {
663			//
664			browser = 'Edge';
665		}
666		// Other
667		else {
668			//
669			browser = 'Other';
670		}
671		
672		// Set browser to body element
673		$("body").data("browser",browser);
674	}
675	
676	
677	// Get query value from url and key
678	function qs(url,key) {
679		"use strict";
680		
681		url = url.split("?");
682		url = "?"+url[1];
683		key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx control chars
684		var match = url.match(new RegExp("[?&]" + key + "=([^&]+)(&|$)"));
685		return match && decodeURIComponent(match[1].replace(/\+/g, " "));
686	}
687	
688	
689	// FlexSlider Video functions
690	function vidAddEvent(element,eventName,callback) {
691		"use strict";
692		
693		//
694		if(element.addEventListener) {
695			element.addEventListener(eventName,callback,false)
696		} 
697		else {
698			element.attachEvent(eventName,callback,false);
699		}
700	}
701	
702	function vidReady(player_id) {
703		"use strict";
704		
705		//
706		var froogaloop = $f(player_id);
707		
708		froogaloop.addEvent('play',function(data) {
709			$('.flexslider').flexslider("pause");
710		});
711		
712		froogaloop.addEvent('pause',function(data) {
713			$('.flexslider').flexslider("play");
714		});
715	}
716	
717	
718	(function() {
719		"use strict";
720		
721		var lastTime = 0;
722		var vendors = ['ms', 'moz', 'webkit', 'o'];
723		for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
724			window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
725			window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] 
726									   || window[vendors[x]+'CancelRequestAnimationFrame'];
727		}
728	 
729		if (!window.requestAnimationFrame)
730			window.requestAnimationFrame = function(callback, element) {
731				var currTime = new Date().getTime();
732				var timeToCall = Math.max(0, 16 - (currTime - lastTime));
733				var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 
734				  timeToCall);
735				lastTime = currTime + timeToCall;
736				return id;
737			};
738	 
739		if (!window.cancelAnimationFrame)
740			window.cancelAnimationFrame = function(id) {
741				clearTimeout(id);
742			};
743	}());

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.