1/****************************** 2 Mantra theme frontend.js 3*******************************/ 4 5jQuery(document).ready(function() { 6 7 /* Standard menu touch support for tablets */ 8 var custom_event = ('ontouchstart' in window) ? 'touchstart' : 'click'; /* check touch support */ 9 var ios = /iPhone|iPad|iPod/i.test(navigator.userAgent); 10 jQuery( '#access .menu > ul > li a' ).on( 'click', function(e){ 11 var $link_id = jQuery(this).attr('href'); 12 if (jQuery(this).closest('#access').data('clicked') == $link_id) { 13 /* second touch */ 14 jQuery(this).closest('#access').data('clicked', null); 15 } else { 16 /* first touch */ 17 if (custom_event != 'click' && !ios && (jQuery(this).parent().children('ul').length >0)) { e.preventDefault(); } 18 jQuery(this).closest('#access').data('clicked', $link_id); 19 jQuery(this).next('.sub-menu').slideDown(); 20 } 21 }); 22 23 /* Back to top button animation */ 24 jQuery(function() { 25 jQuery(window).on('scroll',function() { 26 var x=jQuery(this).scrollTop(); 27 28 if(x != 0) { 29 jQuery('#toTop').addClass('showtop') 30 } else { 31 jQuery('#toTop').removeClass('showtop'); 32 } 33 34 }); 35 jQuery('#toTop').on('click',function() { jQuery('body,html').animate({scrollTop:0},800); }); 36 }); 37 38 39 /* Menu animation */ 40 jQuery("#access ul ul").css({display: "none"}); /* Opera Fix */ 41 jQuery("#access").removeClass("jssafe"); /* JS failsafe */ 42 jQuery("#access .menu ul li").hoverIntent({ 43 over: function(){jQuery(this).children("ul").fadeIn(300);}, 44 out: function(){ jQuery(this).children('ul').fadeOut();}, 45 timeout:300} 46 ); 47 48 49 /* detect and apply custom class for safari */ 50 if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { 51 jQuery('body').addClass('safari'); 52 } 53 54 /* Add custom borders to images */ 55 jQuery("img.alignnone, img.alignleft, img.aligncenter, img.alignright").addClass(mantra_options.image_class); 56 57 58}); 59/* end document.ready */ 60 61jQuery(window).on('load', function() { 62 mantra_mobilemenu_init(); 63}); 64 65/* Mobile Menu v2 */ 66function mantra_mobilemenu_init() { 67 var state = false; 68 jQuery("#nav-toggle").on('click',function(){ 69 jQuery("#access").slideToggle(function(){ if (state) {jQuery(this).removeAttr( 'style' )}; state = ! state; } ); 70 }); 71} 72 73/* Columns equalizer, used if at least one sidebar has a bg color */ 74function mantra_equalizeHeights(){ 75 var h1 = jQuery("#primary").height(); 76 var h2 = jQuery("#secondary").height(); 77 var h3 = jQuery("#content").height(); 78 var max = Math.max(h1,h2,h3); 79 if (h1<max) { jQuery("#primary").height(max); }; 80 if (h2<max) { jQuery("#secondary").height(max); }; 81} 82 83function makeDoubleDelegate(function1, function2) { 84// concatenate functions 85 return function() { if (function1) function1(); if (function2) function2(); } 86} 87 88function mantra_onload() { 89 if ( mantra_options.responsive == 1 ) { 90 /* Add responsive videos */ 91 if (jQuery(window).width() < 800) jQuery(".entry-content").fitVids(); 92 } 93 if ( mantra_options.equalizesidebars = 1 ) { 94 /* Check if sidebars have user colors and if so equalize their heights */ 95 mantra_equalizeHeights(); 96 } 97}; // mantra_onload 98 99// make sure not to lose previous onload events 100window.onload = makeDoubleDelegate(window.onload, mantra_onload ); 101 102/*! 103* FitVids 1.0 104* 105* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 106* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 107* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 108* 109* Date: Thu Sept 01 18:00:00 2011 -0500 110*/ 111 112(function( $ ){ 113 114 $.fn.fitVids = function( options ) { 115 var settings = { 116 customSelector: null 117 } 118 119 var div = document.createElement('div'), 120 ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0]; 121 122 div.className = 'fit-vids-style'; 123 div.innerHTML = '­<style> .fluid-width-video-wrapper { width: 100%; position: relative; padding: 0; } .fluid-width-video-wrapper iframe, .fluid-width-video-wrapper object, .fluid-width-video-wrapper embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style>'; 124 125 ref.parentNode.insertBefore(div,ref); 126 127 if ( options ) { 128 $.extend( settings, options ); 129 } 130 131 return this.each(function(){ 132 var selectors = [ 133 "iframe[src*='player.vimeo.com']", 134 "iframe[src*='www.youtube.com']", 135 "iframe[src*='www.kickstarter.com']", 136 "object", 137 "embed" 138 ]; 139 140 if (settings.customSelector) { 141 selectors.push(settings.customSelector); 142 } 143 144 var $allVideos = $(this).find(selectors.join(',')); 145 146 $allVideos.each(function(){ 147 var $this = $(this); 148 if (this.tagName.toLowerCase() == 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } 149 var height = this.tagName.toLowerCase() == 'object' ? $this.attr('height') : $this.height(), 150 aspectRatio = height / $this.width(); 151 if(!$this.attr('id')){ 152 var videoID = 'fitvid' + Math.floor(Math.random()*999999); 153 $this.attr('id', videoID); 154 } 155 $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%"); 156 $this.removeAttr('height').removeAttr('width'); 157 }); 158 }); 159 160 } 161}
161)( jQuery ); 162 163 164/*! 165 * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ 166 * http://cherne.net/brian/resources/jquery.hoverIntent.html 167 * 168 * You may use hoverIntent under the terms of the MIT license. 169 * Copyright 2007, 2013 Brian Cherne 170 */ 171(function(e){e.fn.hoverIntent=function(t,n,r){var i={interval:100,sensitivity:7,timeout:0};if(typeof t==="object"){i=e.extend(i,t)}else if(e.isFunction(n)){i=e.extend(i,{over:t,out:n,selector:r})}else{i=e.extend(i,{over:t,out:t,selector:n})}var s,o,u,a;var f=function(e){s=e.pageX;o=e.pageY};var l=function(t,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if(Math.abs(u-s)+Math.abs(a-o)<i.sensitivity){e(n).off("mousemove.hoverIntent",f);n.hoverIntent_s=1;return i.over.apply(n,[t])}else{u=s;a=o;n.hoverIntent_t=setTimeout(function(){l(t,n)},i.interval)}};var c=function(e,t){t.hoverIntent_t=clearTimeout(t.hoverIntent_t);t.hoverIntent_s=0;return i.out.apply(t,[e])};var h=function(t){var n=jQuery.extend({},t);var r=this;if(r.hoverIntent_t){r.hoverIntent_t=clearTimeout(r.hoverIntent_t)}if(t.type=="mouseenter"){u=n.pageX;a=n.pageY;e(r).on("mousemove.hoverIntent",f);if(r.hoverIntent_s!=1){r.hoverIntent_t=setTimeout(function(){l(n,r)},i.interval)}}else{e(r).off("mousemove.hoverIntent",f);if(r.hoverIntent_s==1){r.hoverIntent_t=setTimeout(function(){c(n,r)},i.timeout)}}};return this.on({"mouseenter.hoverIntent":h,"mouseleave.hoverIntent":h},i.selector)}})(jQuery) 172 173 174/* Returns the version of Internet Explorer or a -1 175 * (indicating the use of another browser). 176 */ 177function getInternetExplorerVersion() 178{ 179 var rv = -1; /* Return value assumes failure. */ 180 if (navigator.appName == 'Microsoft Internet Explorer') 181 { 182 var ua = navigator.userAgent; 183 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); 184 if (re.exec(ua) != null) 185 rv = parseFloat( RegExp.$1 ); 186 } 187 return rv; 188} 189
190/*FIN*/
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.