PageSourceSearch

https://jessicasimien.com/wp-content/themes/mts_splash/js/customscript.js

js jessicasimien.com collected 2026-09-24 20:10:55 UTC 8,274 bytes, 252 lines download raw bytes

1jQuery.fn.exists = function(callback) {
2  var args = [].slice.call(arguments, 1);
3  if (this.length) {
4	callback.call(this, args);
5  }
6  return this;
7};
8
9/*----------------------------------------------------
10/* Show/hide Scroll to top
11/*--------------------------------------------------*/
12jQuery(document).ready(function($) {
13	//move-to-top arrow
14	jQuery("body").prepend("<a id='move-to-top' class='animate ' href='#blog'><i class='fa fa-chevron-up'></i></a>");
15	
16	var scrollDes = 'html,body';  
17	/*Opera does a strange thing if we use 'html' and 'body' together so my solution is to do the UA sniffing thing*/
18	if(navigator.userAgent.match(/opera/i)){
19		scrollDes = 'html';
20	}
21	//show ,hide
22	jQuery(window).scroll(function () {
23		if (jQuery(this).scrollTop() > 160) {
24			jQuery('#move-to-top').addClass('filling').removeClass('hiding');
25		} else {
26			jQuery('#move-to-top').removeClass('filling').addClass('hiding');
27		}
28	});
29});
30
31
32/*----------------------------------------------------
33/* Make all anchor links smooth scrolling
34/*--------------------------------------------------*/
35jQuery(document).ready(function($) {
36 // scroll handler
37  var scrollToAnchor = function( id, event ) {
38	// grab the element to scroll to based on the name
39	var elem = $("a[name='"+ id +"']");
40	// if that didn't work, look for an element with our ID
41	if ( typeof( elem.offset() ) === "undefined" ) {
42	  elem = $("#"+id);
43	}
44	// if the destination element exists
45	if ( typeof( elem.offset() ) !== "undefined" ) {
46	  // cancel default event propagation
47	  event.preventDefault();
48
49	  // do the scroll
50	  // also hide mobile menu
51	  var scroll_to = elem.offset().top;
52	  $('html, body').removeClass('mobile-menu-active').animate({
53			  scrollTop: scroll_to
54	  }, 600, 'swing', function() { if (scroll_to > 46) window.location.hash = id; } );
55	}
56  };
57  // bind to click event
58  $("a").click(function( event ) {
59	// only do this if it's an anchor link
60	var href = $(this).attr("href");
61	if ( href && href.match("#") && href !== '#' ) {
62	  // scroll to the location
63	  var parts = href.split('#'),
64		url = parts[0],
65		target = parts[1];
66	  if ((!url || url == window.location.href.split('#')[0]) && target)
67		scrollToAnchor( target, event );
68	}
69  });
70});
71
72/*----------------------------------------------------
73/* Responsive Navigation
74/*--------------------------------------------------*/
75if (mts_customscript.responsive && mts_customscript.nav_menu != 'none') {
76	jQuery(document).ready(function($){
77		$('.secondary-navigation').append('<div id="mobile-menu-overlay" />');
78		// merge if two menus exist
79		if (mts_customscript.nav_menu == 'both' && !$('.navigation.mobile-only').length) {
80			$('.navigation').not('.mobile-menu-wrapper').find('.menu').clone().appendTo('.mobile-menu-wrapper').hide();
81		}
82	
83		$('.toggle-mobile-menu').click(function(e) {
84			e.preventDefault();
85			e.stopPropagation();
86			$('body').toggleClass('mobile-menu-active');
87
88			if ( $('body').hasClass('mobile-menu-active') ) {
89				if ( $(document).height() > $(window).height() ) {
90					var scrollTop = ( $('html').scrollTop() ) ? $('html').scrollTop() : $('body').scrollTop();
91					$('html').addClass('noscroll').css( 'top', -scrollTop );
92				}
93				$('#mobile-menu-overlay').fadeIn();
94			} else {
95				var scrollTop = parseInt( $('html').css('top') );
96				$('html').removeClass('noscroll');
97				$('html,body').scrollTop( -scrollTop );
98				$('#mobile-menu-overlay').fadeOut();
99			}
100		});
101	}).on('click', function(event) {
102
103		var $target = jQuery(event.target);
104		if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) ||  $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles
105			return;
106		}
107		jQuery('body').removeClass('mobile-menu-active');
108		jQuery('html').removeClass('noscroll');
109		jQuery('#mobile-menu-overlay').fadeOut();
110	});
111}
112
113/*----------------------------------------------------
114/*  Dropdown menu
115/* ------------------------------------------------- */
116jQuery(document).ready(function($) {
117	
118	function mtsDropdownMenu() {
119		var wWidth = $(window).width();
120		if(wWidth > 865) {
121			$('.navigation ul.sub-menu, .navigation ul.children').hide();
122			var timer;
123			var delay = 100;
124			$('.navigation li').hover( 
125			  function() {
126				var $this = $(this);
127				timer = setTimeout(function() {
128					$this.children('ul.sub-menu, ul.children').slideDown('fast');
129				}, delay);
130				
131			  },
132			  function() {
133				$(this).children('ul.sub-menu, ul.children').hide();
134				clearTimeout(timer);
135			  }
136			);
137		} else {
138			$('.navigation li').unbind('hover');
139			$('.navigation li.active > ul.sub-menu, .navigation li.active > ul.children').show();
140		}
141	}
142
143	mtsDropdownMenu();
144
145	$(window).resize(function() {
146		mtsDropdownMenu();
147	});
148});
149
150/*---------------------------------------------------
151/*  Vertical menus toggles
152/* -------------------------------------------------*/
153jQuery(document).ready(function($) {
154
155	$('.widget_nav_menu, .navigation .menu').addClass('toggle-menu');
156	$('.toggle-menu ul.sub-menu, .toggle-menu ul.children').addClass('toggle-submenu');
157	$('.toggle-menu ul.sub-menu').parent().addClass('toggle-menu-item-parent');
158
159	$('.toggle-menu .toggle-menu-item-parent').append('<span class="toggle-caret"><i class="fa fa-plus"></i></span>');
160
161	$('.toggle-caret').click(function(e) {
162		e.preventDefault();
163		$(this).parent().toggleClass('active').children('.toggle-submenu').slideToggle('fast');
164	});
165});
166
167/*----------------------------------------------------
168/* Social button scripts
169/*---------------------------------------------------*/
170jQuery(document).ready(function($){
171	(function(d, s) {
172	  var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
173		if (d.getElementById(id)) {return;}
174		js = d.createElement(s); js.src = url; js.id = id;
175		fjs.parentNode.insertBefore(js, fjs);
176	  };
177	jQuery('span.facebookbtn, span.facebooksharebtn, .facebook_like').exists(function() {
178	  load('https://connect.facebook.net/en_US/all.js#xfbml=1&version=v2.8', 'fbjssdk');
179	});
180	jQuery('span.gplusbtn').exists(function() {
181	  load('https://apis.google.com/js/plusone.js', 'gplus1js');
182	});
183	jQuery('span.twitterbtn').exists(function() {
184	  load('https://platform.twitter.com/widgets.js', 'tweetjs');
185	});
186	jQuery('span.linkedinbtn').exists(function() {
187	  load('https://platform.linkedin.com/in.js', 'linkedinjs');
188	});
189	jQuery('span.pinbtn').exists(function() {
190	  load('https://assets.pinterest.com/js/pinit.js', 'pinterestjs');
191	});
192	jQuery('span.stumblebtn').exists(function() {
193	  load('https://platform.stumbleupon.com/1/widgets.js', 'stumbleuponjs');
194	});
195	}(document, 'script'));
196});
197
198/*----------------------------------------------------
199/* Lazy load avatars
200/*---------------------------------------------------*/
201jQuery(document).ready(function($){
202	var lazyloadAvatar = function(){
203		$('.comment-author .avatar').each(function(){
204			var distanceToTop = $(this).offset().top;
205			var scroll = $(window).scrollTop();
206			var windowHeight = $(window).height();
207			var isVisible = distanceToTop - scroll < windowHeight;
208			if( isVisible ){
209				var hashedUrl = $(this).attr('data-src');
210				if ( hashedUrl ) {
211					$(this).attr('src',hashedUrl).removeClass('loading');
212				}
213			}
214		});
215	};
216	if ( $('.comment-author .avatar').length > 0 ) {
217		$('.comment-author .avatar').each(function(i,el){
218			$(el).attr('data-src', el.src).removeAttr('src').addClass('loading');
219		});
220		$(function(){
221			$(window).scroll(function(){
222				lazyloadAvatar();
223			});
224		});
225		lazyloadAvatar();
226	}
227});
228
229/*----------------------------------------------------
230/* Grid
231/*--------------------------------------------------*/
232jQuery(document).ready(function($) {
233jQuery('#grid').click(function() {
234		jQuery(this).addClass('active');
235		jQuery('#list').removeClass('active');
236		jQuery('.excerpt').fadeOut(300, function() {
237			jQuery(this).addClass('grid').fadeIn(300);
238			jQuery.cookie('selected_layout', 'grid', { expires: 7, path: '/' });
239		});
240		return false;
241	});
242	
243	jQuery('#list').click(function() {
244		jQuery(this).addClass('active');
245		jQuery('#grid').removeClass('active');
246		jQuery('.excerpt').fadeOut(300, function() {
247			jQuery(this).removeClass('grid').fadeIn(300);
248			jQuery.cookie('selected_layout', 'list', { expires: 7, path: '/' });
249		});
250		return false;
251	});
252});

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.