/* * Tempera Theme custom frontend scripting * http://www.cryoutcreations.eu/ * * Copyright 2013-14, Cryout Creations * Free to use and abuse under the GPL v3 license. */ jQuery(document).ready(function() { /* Standard menu touch support for tablets */ var custom_event = ('ontouchstart' in window) ? 'touchstart' : 'click'; // check touch support var ios = /iPhone|iPad|iPod/i.test(navigator.userAgent); jQuery('#access .menu > ul > li a').on('click', function(e){ var $link_id = jQuery(this).attr('href'); if (jQuery(this).parent().data('clicked') == $link_id) { // second touch jQuery(this).parent().data('clicked', null); } else { // first touch if (custom_event != 'click' && !ios && (jQuery(this).parent().children('.sub-menu').length >0)) {e.preventDefault();} jQuery(this).parent().data('clicked', $link_id); } }); /* Back to top button animation */ var offset = 500; var duration = 500; jQuery(window).scroll(function() { if (jQuery(this).scrollTop() > offset) { jQuery('#toTop').css({'margin-left':''+cryout_toTop_offset+'px','opacity':1}); jQuery('#toTop').css({'margin-right':''+cryout_toTop_offset+'px','opacity':1}); } else { jQuery('#toTop').css({'margin-left':''+(cryout_toTop_offset+150)+'px','opacity':0}); jQuery('#toTop').css({'margin-right':''+(cryout_toTop_offset+150)+'px','opacity':0}); } }); jQuery('#toTop').click(function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop: 0}, duration); return false; }); /* Menu animation */ jQuery("#access ul ul").css({display: "none"}); /* Opera Fix */ jQuery("#access > .menu ul li > a:not(:only-child)").attr("aria-haspopup","true");/* IE10 mobile Fix */ jQuery("#access li").hover(function(){ jQuery(this).find('ul:first').stop(); jQuery(this).find('ul:first').css({opacity: "0",marginTop:"50px"}).css({visibility: "visible",display: "block",overflow:"visible"}).animate({"opacity":"1",marginTop:"-=50"},{queue:false}); },function(){ jQuery(this).find('ul:first').css({visibility: "visible",display: "block",overflow:"visible"}).animate({marginTop:"+=50"}, {queue:false}).fadeOut(); }); /* Social Icons Animation */ jQuery(".socialicons").append('
'); jQuery(".socialicons").hover(function(){ jQuery(this).find(".socials-hover").animate({"width":"26px","height":"26px","top":"2px","left":"2px"},{queue:false,duration:250}); },function() { jQuery(this).find(".socials-hover").animate({"width":"0px","height":"0px","top":"50%","left":"50%"},{queue:false,duration:250, complete: function() { /*jQuery(this).css({bottom:"-30px"});*/ } }); } ); /* Detect and apply custom class for Safari */ if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { jQuery('body').addClass('safari'); } }); /* end document.ready */ /* Mobile Menu v2 */ function tempera_mobilemenu_init() { var state = false; jQuery("#nav-toggle").click(function(){ jQuery("#access").slideToggle(function(){ if (state) {jQuery(this).removeAttr( 'style' )}; state = ! state; } ); }); } /* Columns equalizer, used if at least one sidebar has a bg color */ function equalizeHeights(){ var h1 = jQuery("#primary").height(); var h2 = jQuery("#secondary").height(); var h3 = jQuery("#content").height(); var max = Math.max(h1,h2,h3); if (h1').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%"); $this.removeAttr('height').removeAttr('width'); }); }); }; })( jQuery ); /* Returns the version of Internet Explorer or a -1 (indicating the use of another browser). */ function getInternetExplorerVersion() { var rv = -1; /* assume not IE. */ if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; }