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