PageSourceSearch

https://freshmuseum.com/templates/definity/assets/js/main.js

js freshmuseum.com collected 2026-10-01 14:14:16 UTC 20,923 bytes, 887 lines download raw bytes

1(function($){
2	'use strict';
3
4/* --------------------------------------------------
5	Initialization
6-------------------------------------------------- */
7
8    // Initialize all functions when the document is ready.
9	$(document).ready(function(){
10
11		initNavbar();
12		initScroller();
13		initCountCirc();
14		initCountCircMin();
15		initCountNbr();
16		initCountMin();
17		initSliders();
18		initGallery();
19		initAnimation();
20		initVideoBg();
21		initKenburns();
22		initCountdown();
23
24		if ( document.getElementById('shop-slider-range') ) {
25			initRangeSlider();
26		}
27
28		// Parallax disabled for mobile screens
29		if ($(window).width() >= 1260) {
30			initParallax();
31
32			$(window).stellar({
33				hideDistantElements: false
34			});
35		}
36
37	});
38
39	// Initialize functions after elements are loaded.
40	$(window).load(function() {
41
42		// Preloader
43		$('.preloader img').fadeOut(); // will first fade out the loading animation
44		$('.preloader').delay(350).fadeOut('slow', function() {
45
46		});
47
48		initPortfolio();
49		initBlogMasonry();
50
51	});
52
53
54/* --------------------------------------------------
55	Navigation | Navbar
56-------------------------------------------------- */
57	
58	function initNavbar(){
59
60		// Sticky Nav & Transparent Background
61		$(window).scroll(function(){
62			
63			if ($(window).scrollTop() > 20) {
64				$('nav').removeClass('navbar-trans', 300);
65				$('nav').removeClass('navbar-trans-dark');
66				$('nav').addClass('navbar-small', 300);
67			}
68			else {
69				$('nav:not(.mobile-nav)').addClass('navbar-trans', 300);
70				$('nav').removeClass('navbar-small', 300);
71
72				if ($('nav').hasClass('trans-helper')) {
73					$('nav:not(.mobile-nav)').addClass('navbar-trans-dark');
74				}
75			}
76
77			$('nav:not(.navbar-fixed-top)').removeClass('navbar-trans navbar-small navbar-trans-dark');
78
79		});
80
81
82		// Nav on mobile screens
83		$(window).resize(function() {
84	        if ($(window).width() <= 1259) {
85				$('nav').addClass('mobile-nav');		        
86		    } else {
87		    	$('nav').removeClass('mobile-nav');
88		    }
89
90    		if ($('nav').hasClass('mobile-nav')) {
91    			$('nav').removeClass('navbar-trans');
92    			$('nav').removeClass('navbar-trans-dark');
93    		} else {
94    			if ($(window).width() >= 1259 && $(window).top) {
95    				$('nav').addClass('navbar-trans');
96    			}
97    		}
98
99    		// Remove dropdown open on hover for small screens
100    		if ($('nav').hasClass('mobile-nav')) {
101
102    			$('.dropdown-toggle').on('mouseover', function(e){    
103    			        e.preventDefault();
104
105    			        $('.dropdown').removeClass('open');
106
107    			    e.stopPropagation();
108    			});
109    		}
110
111    		// Close mobile menu when clicked link
112    		// var isNotDropdown = $('nav:not(.mobile-nav)');
113
114    		if (!$('.nav a').hasClass('dropdown-toggle')) {
115
116    			$('.nav a').on('click', function(){ 
117			        if($('.navbar-toggle').css('display') !='none'){
118			            $(".navbar-toggle").trigger( "click" );
119			        }
120			    });
121
122    		}
123
124	    }).resize();
125
126		// Bugfix for iOS not scrolling on open menu
127	    $(".navbar-collapse").css({ maxHeight: $(window).height() - $(".navbar-header").height() + "px" });
128
129
130	} // initNavbar
131
132
133
134/* --------------------------------------------------
135	Scroll Nav
136-------------------------------------------------- */
137
138	function initScroller () {
139
140		$('#navbar').localScroll({
141			easing: 'easeInOutExpo'
142		});
143
144		$('#page-top').localScroll({
145			easing: 'easeInOutExpo'
146		});	
147	} // initScroller
148
149
150
151
152/* --------------------------------------------------
153	Parallax
154-------------------------------------------------- */
155
156	
157	function initParallax () {
158
159		var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
160
161		if (!isSafari) {
162			$(".main-op").parallax("50%", 0.2);
163			$(".number-counters").parallax("50%", 0.2);
164			$(".cirlce-counters").parallax("50%", 0.3);
165			$(".client-list-parallax").parallax("50%", 0.4);
166			$(".ft-slider-parallax").parallax("50%", 0.4);
167			$(".testimonials-parallaxx").parallax("50%", 0.4);
168			$(".twitter-slider").parallax("50%", 0.4);
169			$(".login-2").parallax("50%", 0.2);
170		}		
171	}
172
173
174
175/* --------------------------------------------------
176	Counters Circles
177-------------------------------------------------- */
178
179	function initCountCirc() {
180		
181		var hasCircles = $('#skillsCircles').hasClass('circles-counters');
182
183		if (hasCircles) {
184
185			var waypoint = new Waypoint({
186			  element: document.getElementById('skillsCircles'),
187			  handler: function() {
188
189			    	var options = {
190					  useEasing : true,
191					  separator : ''
192					};
193					
194					$('.chart').easyPieChart({
195						size: '150',
196						lineWidth: 2,
197						lineCap: 'square',
198						trackColor: '',
199					    barColor: '#f8f8f8',
200					    scaleColor: false,
201					    easing: 'easeOutBack',
202					    animate: {
203					    	duration: 1600,
204					    	enabled: true 
205					    }
206					});
207					// init only once
208					this.destroy();
209				},
210				offset: '80%',
211			});
212
213		}
214
215	} // initCountCirc
216
217
218
219	function initCountCircMin() {
220		
221		var hasCircles = $('#skillsCirclesMin').hasClass('circles-counters-dark-bg');
222
223		if (hasCircles) {
224
225			var waypoint = new Waypoint({
226			  element: document.getElementById('skillsCirclesMin'),
227			  handler: function() {
228
229			    	var options = {
230					  useEasing : true,
231					  separator : ''
232					};
233					
234					$('.chart').easyPieChart({
235						size: '150',
236						lineWidth: 2,
237						lineCap: 'square',
238						trackColor: '',
239					    barColor: '#f8f8f8',
240					    scaleColor: false,
241					    easing: 'easeOutBack',
242					    animate: {
243					    	duration: 1600,
244					    	enabled: true 
245					    }
246					});
247					// init only once
248					this.destroy();
249				},
250				offset: '80%',
251			});
252
253		}
254
255	} // initCountCirc
256
257
258
259
260/* --------------------------------------------------
261	Number Counters
262-------------------------------------------------- */
263
264	function initCountNbr () {
265
266		var hasCounters = $('#counters').hasClass('count-wrapper');
267
268		if (hasCounters) {
269
270			var waypoint = new Waypoint({
271			  element: document.getElementById('counters'),
272			  handler: function() {
273
274			    	var options = {
275						useEasing : true,
276						useGrouping : true, 
277						separator : ','
278					};
279					// Counter 1
280					var counter1 = new CountUp('count-1', 0, 467, 0, 3, options);
281					counter1.start();
282					// Counter 2
283					var counter2 = new CountUp('count-2', 0, 2835, 0, 3, options);
284					counter2.start();
285					// Counter 3
286					var counter3 = new CountUp('count-3', 0, 46930, 0, 3, options);
287					counter3.start();
288					// Counter 4
289					var counter4 = new CountUp('count-4', 0, 102890, 0, 3, options);
290					counter4.start();
291					// init only once
292					this.destroy();
293				},
294				offset: '80%',
295			});
296
297		}
298		
299
300	} // initCountNbr
301
302
303
304	function initCountMin () {
305
306		var hasCounters = $('#counters-min').hasClass('nbr-wrapper');
307
308		if (hasCounters) {
309
310			var waypoint = new Waypoint({
311			  element: document.getElementById('counters-min'),
312			  handler: function() {
313
314			    	var options = {
315					  useEasing : true,
316					  separator : ''
317					};
318					// Counter 1
319					var counter1 = new CountUp('count-min-1', 0, 675, 0, 3, options);
320					counter1.start();
321					// Counter 2
322					var counter2 = new CountUp('count-min-2', 0, 1457, 0, 3, options);
323					counter2.start();
324					// Counter 3
325					var counter3 = new CountUp('count-min-3', 0, 471, 0, 3, options);
326					counter3.start();
327					// Counter 4
328					var counter4 = new CountUp('count-min-4', 0, 753, 0, 3, options);
329					counter4.start();
330					// init only once
331					this.destroy();
332				},
333				offset: '80%',
334			});
335
336		}
337		
338
339	} // initCountMin
340
341
342
343/* --------------------------------------------------
344	Sliders
345-------------------------------------------------- */
346	
347	function initSliders() {
348
349		// Features Slider
350		$('.ft-slider').slick({
351			autoplay: true,
352			autoplaySpeed: 4000,
353			slidesToShow: 3,
354			slidesToScroll: 1,
355			dots: false,
356			arrows: true,
357			prevArrow: '<button type="button" class="info-slider-nav slick-prev"><i class="fa fa-long-arrow-left"></i></button>',
358			nextArrow: '<button type="button" class="info-slider-nav slick-next"><i class="fa fa-long-arrow-right"></i></button>',
359			responsive: [
360			    {
361			      breakpoint: 999,
362			      settings: {
363			        slidesToShow: 2,
364			        slidesToScroll: 2,
365			        infinite: true,
366			      }
367			    },
368			    {
369			      breakpoint: 770,
370			      settings: {
371			        slidesToShow: 1,
372			        slidesToScroll: 1
373			      }
374			    }
375			  ]
376		});
377
378		// Testimonials Sliders
379		$('.t-slider').slick({
380			autoplay: false,
381			autoplaySpeed: 4000,
382			slidesToShow: 1,
383			slidesToScroll: 1,
384			dots: false,
385			arrows: true,
386			prevArrow: '<button type="button" class="t-slider-nav slick-prev"><span class="linea-arrows-slim-left"></span></button>',
387			nextArrow: '<button type="button" class="t-slider-nav slick-next"><span class="linea-arrows-slim-right"></span></button>',
388		});
389
390		// Brands/Clients Slider
391		$('.clients-slider').slick({
392			autoplay: true,
393			autoplaySpeed: 4000,
394			slidesToShow: 5,
395			slidesToScroll: 1,
396			dots: false,
397			arrows: false,
398			responsive: [
399			    {
400			      breakpoint: 999,
401			      settings: {
402			        slidesToShow: 3,
403			        slidesToScroll: 2,
404			        infinite: true,
405			      }
406			    },
407			    {
408			      breakpoint: 770,
409			      settings: {
410			        slidesToShow: 2,
411			        slidesToScroll: 1
412			      }
413			    },
414			    {
415			      breakpoint: 599,
416			      settings: {
417			        slidesToShow: 1,
418			        slidesToScroll: 1
419			      }
420			    }
421			]
422		});
423
424		// Portfolio Single Slider
425		$('.single-img-slider').slick({
426			autoplay: true,
427			autoplaySpeed: 4000,
428			slidesToShow: 1,
429			slidesToScroll: 1,
430			adaptiveHeight: true,
431			dots: false,
432			arrows: true,
433			prevArrow: '<button type="button" class="slider-nav sl-prev"><span class="linea-arrows-slim-left"></span></button>',
434			nextArrow: '<button type="button" class="slider-nav sl-next"><span class="linea-arrows-slim-right"></span></button>',
435		});
436
437		// Centered Gallery
438		$('.centered-gallery').slick({
439			centerMode: true,
440			  centerPadding: '60px',
441			  slidesToShow: 3,
442			  responsive: [
443			    {
444			      breakpoint: 768,
445			      settings: {
446			        arrows: false,
447			        centerMode: true,
448			        centerPadding: '40px',
449			        slidesToShow: 3
450			      }
451			    },
452			    {
453			      breakpoint: 480,
454			      settings: {
455			        arrows: false,
456			        centerMode: true,
457			        centerPadding: '40px',
458			        slidesToShow: 1
459			      }
460			    }
461			  ]
462		});
463
464		// Full Screen Hero Slider
465		$('.fs-slider').slick({
466			slidesToShow: 1,
467			slidesToScroll: 1,
468			useCSS: true,
469			fade: true,
470			dots: false,
471			arrows: true,
472			prevArrow: '<button type="button" class="slick-prev"><span class="linea-arrows-slim-left"></span></button>',
473			nextArrow: '<button type="button" class="slick-next"><span class="linea-arrows-slim-right"></span></button>',
474			autoplay: true,
475			autoplaySpeed: 4000,
476		});
477
478		// Full Width Hero Slider
479		$('.fw-slider').slick({
480			slidesToShow: 1,
481			slidesToScroll: 1,
482			fade: true,
483			dots: false,
484			arrows: true,
485			prevArrow: '<button type="button" class="slick-prev"><span class="linea-arrows-slim-left"></span></button>',
486			nextArrow: '<button type="button" class="slick-next"><span class="linea-arrows-slim-right"></span></button>',
487			autoplay: true,
488			autoplaySpeed: 4000,
489		});
490
491		// Text Slider
492		$('.text-slider').slick({
493			slidesToShow: 1,
494			slidesToScroll: 1,
495			adaptiveHeight: true,
496			speed: 300,
497			fade: true,
498			dots: false,
499			arrows: true,
500			prevArrow: '<button type="button" class="slick-prev"><span class="linea-arrows-slim-left"></span></button>',
501			nextArrow: '<button type="button" class="slick-next"><span class="linea-arrows-slim-right"></span></button>',
502			autoplay: true,
503			autoplaySpeed: 4000,
504		});
505
506		// Shop Product Slider
507		$('.shop-p-slider').slick({
508			slidesToShow: 1,
509			slidesToScroll: 1,
510			adaptiveHeight: true,
511			speed: 300,
512			// fade: false,
513			dots: false,
514			arrows: true,
515			prevArrow: '<button type="button" class="shop-p-slider-nav shop-p-slider-nav-left"><span class="linea-arrows-slim-left"></span></button>',
516			nextArrow: '<button type="button" class="shop-p-slider-nav shop-p-slider-nav-right"><span class="linea-arrows-slim-right"></span></button>',
517			autoplay: false,
518		});
519
520		// Shop Product Single - Slider
521		$('.prod_single_img_slider').slick({
522			slidesToShow: 1,
523			slidesToScroll: 1,
524			adaptiveHeight: true,
525			speed: 300,
526			// fade: false,
527			infinite: true,
528			dots: true,
529			arrows: true,
530			prevArrow: '<button type="button" class="shop-p-slider-nav shop-p-slider-nav-left"><span class="linea-arrows-slim-left"></span></button>',
531			nextArrow: '<button type="button" class="shop-p-slider-nav shop-p-slider-nav-right"><span class="linea-arrows-slim-right"></span></button>',
532			autoplay: false,
533			accessibility: false,
534			customPaging: function (slider, i) {
535	            return '<a href="#">' + $('.prod_single_thumbs_slider li:nth-child(' + (i + 1) + ')').html() + '</a>';
536	        }
537		});
538
539	} // initSliders
540
541
542
543/* --------------------------------------------------
544	Portfolio
545-------------------------------------------------- */
546	
547	function initPortfolio () {
548
549		// Filters
550		$('.portfolio-filters a').click(function (e) {
551			  e.preventDefault();
552
553			  $('li').removeClass('active');
554			  $(this).parent().addClass('active');
555		});
556
557		
558		// Full Width Gallery (3 columns)
559		function pfolio3colFW () {
560			
561			var $container = $('#pfolio');
562			// init
563			$container.isotope({
564				// options
565				itemSelector: '.portfolio-item',
566			});
567
568			// Filter items
569			$('#pfolio-filters').on( 'click', 'a', function() {
570				var filterValue = $(this).attr('data-filter');
571				$container.isotope({ filter: filterValue });
572			});
573
574		} // fwNogap3col
575
576
577		function pfolioMasonry () {
578			
579			var $container = $('.pfolio-items');
580			// init
581			$container.isotope({
582				// options
583				itemSelector: '.p-item',
584			    percentPosition: true,
585			    layoutMode: 'packery',
586			    masonry: {
587			      columnWidth: '.grid-sizer'
588			    }				
589			});
590
591			// Filter items
592			$('#pfolio-filters').on( 'click', 'a', function() {
593				var filterValue = $(this).attr('data-filter');
594				$container.isotope({ filter: filterValue });
595			});
596
597		}
598
599
600		pfolio3colFW();
601		pfolioMasonry();
602
603	} // initPortfolio
604
605
606
607/* --------------------------------------------------
608	Light Gallery
609-------------------------------------------------- */
610
611	function initGallery () {
612
613		// Image Lightbox
614		var hasPopup = $('a').hasClass('open-gallery');
615
616		if (hasPopup) {
617
618			$('.open-gallery').magnificPopup({
619				type:'image',
620				gallery: {
621				    enabled: true
622				  }
623			});
624			
625		}
626
627
628		// Footer Gallery Lightbox
629		var hasFtPopup = $('a').hasClass('gallery-widget-lightbox');
630
631		if (hasFtPopup) {
632
633			$('.gallery-widget-lightbox').magnificPopup({
634				type:'image',
635				gallery: {
636				    enabled: true
637				  }
638			});
639
640		}
641
642		// Video Lightbox
643		var hasVideoPopup = $('a').hasClass('popup-video');
644
645		if (hasVideoPopup) {
646
647			$('.popup-video').magnificPopup({
648	          	disableOn: 700, 
649	         	type: 'iframe',
650	          	mainClass: 'mfp-fade',
651	          	removalDelay: 160,
652	          	preloader: false,
653
654	          	fixedContentPos: false
655			});
656
657		}
658
659	} // initGallery
660
661
662
663
664/* --------------------------------------------------
665	Blog Masonry Layout
666-------------------------------------------------- */
667
668	function initBlogMasonry () {
669
670		var $container = $('.blog-container');
671			// init
672			$container.isotope({
673				// options
674				itemSelector: '.blog-selector',
675				percentPosition: true
676			});
677	}
678	
679
680
681
682/* --------------------------------------------------
683  Contact Pages
684-------------------------------------------------- */
685
686	$('.show-map').on('click', function(e){
687	  e.preventDefault();
688	  $('.contact-info-wrapper').toggleClass('map-open');
689	  $('.show-info-link').toggleClass('info-open');
690	});
691
692	$('.show-info-link').on('click', function(e){
693	  e.preventDefault();
694	  $('.contact-info-wrapper').toggleClass('map-open');
695	  $(this).toggleClass('info-open');
696	});
697
698
699
700/* --------------------------------------------------
701	Animation
702-------------------------------------------------- */
703
704	function initAnimation () {
705		
706		new WOW().init();
707
708	}
709
710
711
712
713/* --------------------------------------------------
714	Video Background
715-------------------------------------------------- */
716
717	function initVideoBg () {
718
719		var hasBgVideo = $('#fs-video-one-bg').hasClass('player');
720		var hasFwBgVideo = $('#fw-video-one-bg').hasClass('player');
721		var hasSecBgVideo = $('#section-video').hasClass('player');
722
723		if (hasBgVideo || hasFwBgVideo || hasSecBgVideo) {
724
725			$('.player').YTPlayer();
726
727		}
728		
729
730	}
731
732
733
734/* --------------------------------------------------
735	Ken Burns Slider
736-------------------------------------------------- */
737	function initKenburns () {
738		
739		var hasKenburns = $('.kenburn-hero')[0];
740
741		if (hasKenburns) {
742			var w_height = $(window).height();
743			var w_width = $(window).width();
744
745			$('.kenburns').attr('width', w_width);
746			$('.kenburns').attr('height', w_height);
747			$('.kenburns').kenburns({
748				images: ['http://placehold.it/2440x1578',
749						'http://placehold.it/2440x1578/999/eee',
750						'http://placehold.it/2440x1578/ccc/111'
751						],
752				frames_per_second: 30,
753				display_time: 5000,
754				fade_time: 1000,
755				zoom: 1.1,
756				background_color:'#000000'
757			});
758		}
759
760	} // initKenburns
761
762
763
764/* --------------------------------------------------
765	Coming Soon - Countdown
766-------------------------------------------------- */
767
768	function initCountdown () {
769
770		var hasCountdown = $('#cs-timer').hasClass('cs-timer');
771
772		if (hasCountdown) {
773
774			// Add end date here (current: 2017/01/01) from witch the timer will countdown.
775			$('#cs-timer').countdown('2017/01/01', function(event) {
776			    $(this).html(event.strftime('<div class="item"><span class="nbr-timer">%D</span><span class="title-timer">Days<span></div><div class="item"><span class="nbr-timer">%H</span><span class="title-timer">Hours<span></div><div class="item"><span class="nbr-timer">%M</span><span class="title-timer">Minutes<span></div><div class="item"><span class="nbr-timer">%S</span><span class="title-timer">Seconds<span></div>'));
777			  });
778
779		}
780
781	}
782
783
784
785/* --------------------------------------------------
786	Shop Price Filter - (range slider)
787-------------------------------------------------- */
788	function initRangeSlider () {
789
790		$( "#shop-slider-range" ).slider({
791			range: true,
792			min: 100,
793			max: 750,
794			values: [ 121, 721 ], // starting values
795			slide: function( event, ui ) {
796				$( "#shop-slider-range-amount" ).val( "$" + ui.values[ 0 ] + " TO $" + ui.values[ 1 ] );
797			}
798		});
799		$( "#shop-slider-range-amount" ).val( "$" + $( "#shop-slider-range" ).slider( "values", 0 ) +
800			" TO $" + $( "#shop-slider-range" ).slider( "values", 1 ) );
801
802	} // initRangeSlider
803
804
805
806})(jQuery);
807
808
809
810/* --------------------------------------------------
811	Contact Form JS Validation & AJAX call 
812-------------------------------------------------- */
813$(function() {
814
815//	Regular Expressions
816var expEmail = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[_a-z0-9-]+(\.[_a-z0-9-]+)*(\.[a-z]{2,4})$/;
817var	expLettersOnly = /^[A-Za-z ]+$/;
818
819//	Checks if a field has the correct length
820function validateLength ( fieldValue, minLength ) {
821	return ( $.trim( fieldValue ).length > minLength );
822}
823
824//	Validate form on typing
825$( '.form-ajax' ).on( 'keyup', 'input.validate-locally', function() {
826	validateField( $(this) );
827});
828
829//	AJAX call
830$( '.form-ajax' ).submit(function(e) {
831	e.preventDefault();
832	var $this = $( this ),
833			action = $this.attr( 'action' );
834
835	// The AJAX requrest
836	$.post(
837			action,
838			$this.serialize(),
839			function( data ) {
840				$( '.ajax-message' ).html( data );
841			}
842	);
843});
844
845//	Validates the fileds
846function validateField ( field ) {
847	var errorText = "",
848			error = false,
849			value = field.val(),
850			siblings = field.siblings( ".alert-error" );
851
852	// Test the name field
853	if ( field.attr("name") === "name" ) {
854		if ( !validateLength( value, 2 ) ) {
855					error = true;
856					errorText += '<i class="fa fa-info-circle"></i> The name is too short!<br>';
857					$('input[name="name"]').addClass('input-error');
858		} else {
859			$('input[name="name"]').removeClass('input-error');
860		}
861
862		if ( !expLettersOnly.test( value ) ) {
863					error = true;
864					errorText += '<i class="fa fa-info-circle"></i> The name can contain only letters and spaces!<br>';
865					$('input[name="name"]').addClass('input-error-2');
866		} else {
867			$('input[name="name"]').removeClass('input-error-2');
868		}
869	}
870
871	// Test the email field
872	if ( field.attr("name") === "email" ) {
873		if ( !expEmail.test( value ) ) {
874					error = true;
875					errorText += '<i class="fa fa-info-circle"></i> Enter correct email address!<br>';
876					$('input[name="email"]').addClass('input-error');
877		} else {
878			$('input[name="email"]').removeClass('input-error');
879		}
880	}
881
882	// Display the errors
883	siblings.html( errorText );
884
885	}
886
887});

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.