PageSourceSearch

https://gomobilesolutions.com/wp-content/themes/nanosoft/assets/js/theme.js?ver=1.0.0

js gomobilesolutions.com collected 2026-10-07 14:47:06 UTC 20,361 bytes, 579 lines download raw bytes

1( function( $ ) {
2	"use strict";
3
4	var $win = $(window), $doc = $(document), $body = $('body');
5
6(function() {
7	var lastTime = 0;
8	var vendors = ['ms', 'moz', 'webkit', 'o'];
9	for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
10			window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
11			window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
12					|| window[vendors[x]+'CancelRequestAnimationFrame'];
13	}
14
15	if (!window.requestAnimationFrame)
16			window.requestAnimationFrame = function(callback, element) {
17					var currTime = new Date().getTime();
18					var timeToCall = Math.max(0, 16 - (currTime - lastTime));
19					var id = window.setTimeout(function() { callback(currTime + timeToCall); },
20							timeToCall);
21					lastTime = currTime + timeToCall;
22					return id;
23			};
24
25	if (!window.cancelAnimationFrame)
26			window.cancelAnimationFrame = function(id) {
27					clearTimeout(id);
28			};
29}());
30
31(function($) {
32
33	function Circle(pos,rad,color, ctx) {
34			var _this = this;
35
36			// constructor
37			(function() {
38					_this.pos = pos || null;
39					_this.radius = rad || null;
40					_this.color = color || null;
41			})();
42
43			this.draw = function() {
44					if(!_this.active) return;
45					ctx.beginPath();
46					ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
47					ctx.fillStyle = 'rgba(255,255,255,'+ _this.active+')';
48					ctx.fill();
49			};
50	}
51
52	// Util
53	function getDistance(p1, p2) {
54			return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
55	}
56
57	function CanvasEffect (element) {
58			this.$elm = $(element);
59			this.animateHeader = true;
60			
61			this._initHeader();
62			this._initAnimation();
63			this._initEvents();
64	}
65
66	CanvasEffect.prototype = {
67			_initHeader: function () {
68					this.width = this.$elm.outerWidth();
69					this.height = this.$elm.outerHeight();
70					this.target = {x: this.width/2, y: this.height/2};
71
72					this.canvas = this.$elm.find('canvas').get(0);
73					this.canvas.width = this.width;
74					this.canvas.height = this.height;
75					this.ctx = this.canvas.getContext('2d');
76
77					// create points
78					this.points = [];
79					for(var x = 0; x < this.width; x = x + this.width/20) {
80							for(var y = 0; y < this.height; y = y + this.height/20) {
81									var px = x + Math.random()*this.width/20;
82									var py = y + Math.random()*this.height/20;
83									var p = {x: px, originX: px, y: py, originY: py };
84
85									this.points.push(p);
86							}
87					}
88
89					// for each point find the 5 closest points
90					for(var i = 0; i < this.points.length; i++) {
91							var closest = [];
92							var p1 = this.points[i];
93							for(var j = 0; j < this.points.length; j++) {
94									var p2 = this.points[j]
95									if(!(p1 == p2)) {
96											var placed = false;
97											for(var k = 0; k < 5; k++) {
98													if(!placed) {
99															if(closest[k] == undefined) {
100																	closest[k] = p2;
101																	placed = true;
102															}
103													}
104											}
105
106											for(var k = 0; k < 5; k++) {
107													if(!placed) {
108															if(getDistance(p1, p2) < getDistance(p1, closest[k])) {
109																	closest[k] = p2;
110																	placed = true;
111															}
112													}
113											}
114									}
115							}
116							p1.closest = closest;
117					}
118
119					// assign a circle to each point
120					for(var i in this.points) {
121							var c = new Circle(this.points[i], 2+Math.random()*2, 'rgba(255,255,255,0.3)', this.ctx);
122							this.points[i].circle = c;
123					}
124			},
125
126			_initAnimation: function () {
127					this._animate();
128
129					for(var i in this.points) {
130							this._shiftPoint(this.points[i]);
131					}
132			},
133
134			_initEvents: function () {
135					if(!('ontouchstart' in window)) {
136							this.$elm.on('mousemove', this._mouseMove.bind(this));
137					}
138
139					window.addEventListener('resize', this._resize.bind(this));
140			},
141
142			_mouseMove: function (e) {
143				e.stopPropagation();
144
145				var y = e.pageY - $(e.currentTarget).offset().top
146  				var x = e.pageX - $(e.currentTarget).offset().left
147
148				this.target.x = x;
149				this.target.y = y;
150			},
151
152			_resize: function () {
153				this.width = this.$elm.outerWidth();
154				this.height = this.$elm.outerHeight();
155				this.canvas.width = this.width;
156				this.canvas.height = this.height;
157			},
158
159			_animate: function () {
160				this.ctx.clearRect(0,0,this.width,this.height);
161				for(var i in this.points) {
162						// detect points in range
163						if(Math.abs(getDistance(this.target, this.points[i])) < 4000) {
164								this.points[i].active = 0.3;
165								this.points[i].circle.active = 0.6;
166						} else if(Math.abs(getDistance(this.target, this.points[i])) < 20000) {
167								this.points[i].active = 0.1;
168								this.points[i].circle.active = 0.3;
169						} else if(Math.abs(getDistance(this.target, this.points[i])) < 40000) {
170								this.points[i].active = 0.02;
171								this.points[i].circle.active = 0.1;
172						} else {
173								this.points[i].active = 0;
174								this.points[i].circle.active = 0;
175						}
176
177						this._drawLines(this.points[i]);
178						this.points[i].circle.draw();
179				}
180					
181				window.requestAnimationFrame(this._animate.bind(this));
182			},
183
184			_shiftPoint: function (p) {
185					var self = this;
186					TweenLite.to(p, 1+1*Math.random(), {x:p.originX-50+Math.random()*100,
187							y: p.originY-50+Math.random()*100, ease:Circ.easeInOut,
188							onComplete: function() {
189									self._shiftPoint(p);
190							}});
191			},
192
193			_drawLines: function (p) {
194					if(!p.active) return;
195
196					for(var i in p.closest) {
197							this.ctx.beginPath();
198							this.ctx.moveTo(p.x, p.y);
199							this.ctx.lineTo(p.closest[i].x, p.closest[i].y);
200							this.ctx.strokeStyle = 'rgba(255,255,255,'+ p.active+')';
201							this.ctx.stroke();
202					}
203			}
204	}
205
206	$.fn['canvasEffect'] = function () {
207			return this.each(function () {
208					new CanvasEffect(this);
209			});
210    };
211})(jQuery);
212$.fn['contentGrid'] = function() {
213	return this.each(function() {
214		var $this = $(this);
215
216		$this.imagesLoaded().then(function() {
217			$this.isotope(
218				$.extend({}, $this.data('grid'), {
219					layoutMode: 'packery',
220					percentPosition: true
221				})
222			);
223		});
224	});
225};
226$.fn['contentGridFilter'] = function() {
227	return this.each(function() {
228		var targetSelector = $(this).attr('data-filter-target'),
229			target = $(targetSelector),
230			filter = $(this);
231
232		filter.on('click', 'a', function(e) {
233			e.preventDefault();
234
235			$('.active', filter).removeClass('active');
236			$(this).closest('li').addClass('active');
237
238			target.isotope({
239				filter: $( this ).parent().attr( 'data-filter' )
240			});
241		});
242	});
243};
244$.headerSticky = function() {
245	$win.on( 'scroll load', function() {
246		$win.scrollTop() > $( '#site-header' ).outerHeight()
247			? $( '.site-header-sticky' ).addClass( 'active' )
248			: $( '.site-header-sticky' ).removeClass( 'active' );
249	} );
250};
251
252$.mobileMenu = function () {
253  $('ul.menu li.menu-item-has-children, ul.menu li.page_item_has_children').each(function () {
254    var menuItem = $(this)
255    var menuToggle = $('<span class="menu-item-toggle"><span></span></span>')
256
257    menuToggle.insertAfter(menuItem.find('> a'))
258      .on('click', function () {
259        menuItem.toggleClass('menu-item-expand');
260        menuItem.nextAll().removeClass('menu-item-expand');
261        menuItem.prevAll().removeClass('menu-item-expand');
262      })
263  })
264}
265
266function NavSearch( element ) {
267	this.element = $( element );
268	this.toggler = $( '> a:first-child', this.element );
269	this.input   = $( 'input', this.element );
270
271	$doc.on( 'click', this.hide.bind( this ) );
272
273	this.toggler.on( 'click', this.toggle.bind( this ) );
274	this.element.on( 'click', function( e ) {
275		e.stopPropagation();
276	});
277
278	this.element.on( 'keydown', ( function( e ) {
279		if ( e.keyCode == 27 )
280			this.hide();
281	} ).bind( this ) );
282
283	$.each( ['transitionend', 'oTransitionEnd', 'webkitTransitionEnd'], ( function( index, eventName ) {
284		$( '> div', this.element ).on( eventName, ( function() {
285			if ( this.element.hasClass( 'active' ) )
286				this.input.get( 0 ).focus();
287		} ).bind( this ) );
288	} ).bind( this ) );
289};
290
291NavSearch.prototype = {
292	toggle: function( e ) {
293		e.preventDefault();
294		e.stopPropagation();
295
296		this.element.toggleClass( 'active' );
297	},
298
299	hide: function() {
300		this.element.removeClass( 'active' );
301	}
302};
303
304$.fn.navSearch = function( options ) {
305	return this.each( function() {
306		$( this ).data( '_navSearch', new NavSearch( this, options ) );
307	} );
308};
309
310$.fn['offCanvasToggle'] = function() {
311	return this.each(function() {
312		var activeClass = $(this).attr('data-target') + '-active';
313
314		$(this).on('click', function(e) {
315			e.preventDefault();
316			e.stopPropagation();
317			
318			$('body').toggleClass(activeClass);
319		});
320
321		$doc.on('click', function() {
322			$('body').removeClass(activeClass);
323		});
324
325		$('.off-canvas').on('click', function(e) {
326			e.stopPropagation();
327		});
328	});
329};
330
331$.fn['swiperSlider'] = function() {
332	return this.each(function() {
333		var config = $.extend({}, $(this).data('swiper'), {
334			nextButton: '.swiper-button-next',
335			prevButton: '.swiper-button-prev',
336			autoHeight: true
337		});
338
339		var slider = new Swiper(this, config);
340		var thumbs = $(this).next('.project-media-thumbs');
341
342		if (thumbs.size() > 0) {
343			var sliderThumbs = new Swiper(thumbs.get(0), {
344				spaceBetween: 10,
345				centeredSlides: true,
346				slidesPerView: 5,
347				touchRatio: 0.2
348			});
349
350			slider.params.control = sliderThumbs
351			sliderThumbs.params.control = slider
352
353			thumbs.on('click', '.swiper-slide', function() {
354				var slideIndex = $(this).index();
355				console.log(slideIndex)
356
357				slider.slideTo(slideIndex)
358				// sliderThumbs.slideTo(slideIndex)
359
360				// Remove an active class
361				thumbs.find('.swiper-slide-active').removeClass('swiper-slide-active')
362				thumbs.find('.swiper-slide:nth(' + slideIndex + ')').addClass('swiper-slide-active')
363			})
364		}
365	});
366};
367$.gotop = function() {
368	$('.go-to-top a').on('click', function() {
369		$( 'html, body' ).animate({ scrollTop: 0 });
370	});
371
372	$win.on('scroll', function() {
373		if ($win.scrollTop() > 0) $('.go-to-top').addClass('active');
374		else $('.go-to-top').removeClass('active');
375	}).on('load', function() {
376		$win.trigger('scroll');
377	});
378};
379$.fn['googleMaps'] = function() {
380	return this.each(function() {
381		var
382		elm       = $(this),
383		elmCanvas = this,
384		locations = {},
385		geocoder  = {},
386		elmConfig = $.extend({
387			locations: encodeURIComponent('[]'),
388			zoomable: 'yes',
389			zoomlevel: 15,
390			draggable: 'yes',
391			type: 'roadmap',
392			style: 'default'
393		}, elm.data('options'));
394
395		if (elmConfig.locations) {
396			elmConfig.locations = decodeURIComponent(elmConfig.locations);
397		}
398
399		try {
400			var mapStyles = {
401				'subtle-grayscale': [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]}
401,{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}],
402				'pale-dawn':        [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}],
403				'blue-warter':      [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#46bcec"},{"visibility":"on"}]}],
404				'light-monochrome': [{"featureType":"administrative.locality","elementType":"all","stylers":[{"hue":"#2c2e33"},{"saturation":7},{"lightness":19},{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":-2},{"visibility":"simplified"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"hue":"#e9ebed"},{"saturation":-90},{"lightness":-8},{"visibility":"simplified"}]},{"featureType":"transit","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":10},{"lightness":69},{"visibility":"on"}]},{"featureType":"water","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":-78},{"lightness":67},{"visibility":"simplified"}]}],
405				'shades-of-gray':   [{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}]
406			};
407
408			var mapTypes = {
409				'roadmap'  : google.maps.MapTypeId.ROADMAP,
410				'satellite': google.maps.MapTypeId.SATELLITE,
411				'hybrid'   : google.maps.MapTypeId.HYBRID,
412				'terrain'  : google.maps.MapTypeId.TERRAIN
413			};
414
415			var createMarker = function(map, location, image) {
416				return new google.maps.Marker({
417					map: map,
418					position: location,
419					icon: image
420				});
421			};
422
423			var initMaps = function (locations) {
424				if (locations.length && locations.length > 0) {
425					var centerLocation = locations.shift();
426					var map = new google.maps.Map(elmCanvas, {
427						center     : centerLocation.latlng,
428						zoom       : parseInt(elmConfig.zoomlevel || 12),
429						mapTypeId  : mapTypes[elmConfig.type || 'roadmap'],
430						scrollwheel: elmConfig.zoomable == 'yes',
431						styles     : mapStyles[elmConfig.style],
432						panControl: true,
433						scaleControl: true,
434						streetViewControl: true,
435						zoomControl: true,
436						draggable: elmConfig.draggable == 'yes'
437					});
438
439					if (centerLocation.marker != '') {
440						var centerMarker = createMarker(map, centerLocation.latlng, centerLocation.marker);
441
442						if (centerLocation.content != '') {
443							var infoWindow = new google.maps.InfoWindow({
444								content: centerLocation.content
445							});
446
447							centerMarker.addListener('click', function() {
448								infoWindow.open(map, centerMarker);
449							});
450						}
451					}
452
453					if (locations.length > 0) {
454						$.map(locations, function(location) {
455							if (location.marker != '') {
456								var marker = createMarker(map, location.latlng, location.marker);
457
458								if (location.content != '') {
459									var infoWindow = new google.maps.InfoWindow({
460										content: location.content
461									});
462
463									marker.addListener('click', function() {
464										infoWindow.open(map, marker);
465									});
466								}
467							}
468						});
469					}
470				}
471			};
472
473			var queryAddressLocations = function (locations) {
474				var geocoder = new google.maps.Geocoder();
475				var deferres = locations.map(function (location) {
476					var deferred = $.Deferred();
477
478				    geocoder.geocode({ 'address': location.address }, function (results, status) {
479				        if (status === google.maps.GeocoderStatus.OK) {
480				        	location.latlng = results[0].geometry.location;
481				            deferred.resolve(location);
482				        } 
483				    });
484
485				    return deferred.promise();
486				});
487
488				return deferres;
489			}
490
491			locations = $.parseJSON(elmConfig.locations);
492			geocoder = new google.maps.Geocoder();
493
494			var invalidLocations = locations.filter(function (location) {
495				return location.latlng === undefined;
496			});
497
498			if (invalidLocations.length > 0) {
499				$.when.apply($, queryAddressLocations(locations)).done(function () {
500					initMaps(Array.prototype.slice.apply(arguments));
501				});
502			} else {
503				initMaps(locations);
504			}
505		} catch(e) {
506		}
507	});
508};
509$(function() {
510	// Initialize the header sticky
511	$.headerSticky();
512
513	// Initialize the menu mobile
514	$.mobileMenu();
515
516	// Initialize go-to-top button
517	$.gotop();
518
519	// Initialize scroll down arrow
520	$('.content-header .down-arrow a').on('click', function() {
521		var stickyHeaderHeight = $('#site-header-sticky').height() || 0;
522		var adminbarHeight = $('#wpadminbar').height() || 0;
523		var contentOffset = $('.content-header').offset().top + $('.content-header').outerHeight();
524
525		$( 'html, body' ).animate({
526			scrollTop: contentOffset - (stickyHeaderHeight + adminbarHeight)
527		});
528	});
529
530	// Initialize the off-canvas toggler
531	$('.off-canvas-toggle').offCanvasToggle();
532
533	// Initialize the search box toggler on the
534	// navigation bar
535	$('.navigator .search-box').navSearch();
536
537	// Initialize the grid component
538	$('[data-grid]').contentGrid();
539
540	// Initialize the grid items filter
541	$('[data-filter-target]').contentGridFilter();
542
543	// Initialize swiper slider
544	$('[data-swiper]').swiperSlider();
545
546	// Initialize lightbox
547	$('[rel^="prettyPhoto"]').prettyPhoto({
548		social_tools: ''
549	});
550
551	$('[data-height]').imagesLoaded(function () {
552		$(this).matchHeight({ property: 'min-height' });
553	});
554
555	$(document).imagesLoaded(function () {
556		$('.vc_row > canvas').each(function () {
557			$(this).parent().canvasEffect();
558		});
559	});
560
561	//Fix RTL
562	$(document).ready(function () {
563		if ($('html').attr('dir') == 'rtl') {
564			$('[data-vc-full-width="true"]').each(function(i, v) {
565				$(this)
566					.css('right', -$(this).css('left'))
567					.css('left' , 'auto !important');
568			});
569		}
570	});
571});
572
573$(window).on('load', function() {
574  $('body').addClass('is-loaded');
575  $('.elm-google-maps[data-options]').googleMaps();
576});
577
578
579} ).call( this, jQuery )

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.