diff options
Diffstat (limited to 'themes/mantra/resources/js/frontend.js')
-rw-r--r-- | themes/mantra/resources/js/frontend.js | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/themes/mantra/resources/js/frontend.js b/themes/mantra/resources/js/frontend.js index 391a5550..e32300f4 100644 --- a/themes/mantra/resources/js/frontend.js +++ b/themes/mantra/resources/js/frontend.js @@ -1,79 +1,77 @@ /****************************** - Mantra Theme - custom scripting - (c) Cryout Creations - www.cryoutcreations.eu + Mantra theme frontend.js *******************************/ - 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('ul').length >0)) {e.preventDefault();} - jQuery(this).parent().data('clicked', $link_id); - } + /* 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).closest('#access').data('clicked') == $link_id) { + /* second touch */ + jQuery(this).closest('#access').data('clicked', null); + } else { + /* first touch */ + if (custom_event != 'click' && !ios && (jQuery(this).parent().children('ul').length >0)) { e.preventDefault(); } + jQuery(this).closest('#access').data('clicked', $link_id); + jQuery(this).next('.sub-menu').slideDown(); + } }); -/* Back to top button animation */ -jQuery(function() { - jQuery(window).scroll(function() { - var x=jQuery(this).scrollTop(); + /* Back to top button animation */ + jQuery(function() { + jQuery(window).on('scroll',function() { + var x=jQuery(this).scrollTop(); - if(x != 0) { - jQuery('#toTop').addClass('showtop') - } else { - jQuery('#toTop').removeClass('showtop'); - } + if(x != 0) { + jQuery('#toTop').addClass('showtop') + } else { + jQuery('#toTop').removeClass('showtop'); + } + }); + jQuery('#toTop').on('click',function() { jQuery('body,html').animate({scrollTop:0},800); }); }); - jQuery('#toTop').click(function() { jQuery('body,html').animate({scrollTop:0},800); }); -}); -/* Menu animation */ -jQuery("#access ul ul").css({display: "none"}); /* Opera Fix */ -jQuery("#access").removeClass("jssafe"); /* JS failsafe */ -jQuery("#access .menu ul li").hoverIntent({ - over: function(){jQuery(this).children("ul").fadeIn(300);}, - out: function(){ jQuery(this).children('ul').fadeOut();}, - timeout:300} -); + /* Menu animation */ + jQuery("#access ul ul").css({display: "none"}); /* Opera Fix */ + jQuery("#access").removeClass("jssafe"); /* JS failsafe */ + jQuery("#access .menu ul li").hoverIntent({ + over: function(){jQuery(this).children("ul").fadeIn(300);}, + out: function(){ jQuery(this).children('ul').fadeOut();}, + timeout:300} + ); -/* detect and apply custom class for safari */ -if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { - jQuery('body').addClass('safari'); -} + /* detect and apply custom class for safari */ + if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { + jQuery('body').addClass('safari'); + } -/* Add custom borders to images */ -jQuery("img.alignnone, img.alignleft, img.aligncenter, img.alignright").addClass(mantra_options.image_class); + /* Add custom borders to images */ + jQuery("img.alignnone, img.alignleft, img.aligncenter, img.alignright").addClass(mantra_options.image_class); }); /* end document.ready */ +jQuery(window).on('load', function() { + mantra_mobilemenu_init(); +}); + /* Mobile Menu v2 */ function mantra_mobilemenu_init() { var state = false; - jQuery("#nav-toggle").click(function(){ + jQuery("#nav-toggle").on('click',function(){ jQuery("#access").slideToggle(function(){ if (state) {jQuery(this).removeAttr( 'style' )}; state = ! state; } ); }); } -jQuery(window).load(function() { - mantra_mobilemenu_init(); -}); - /* Columns equalizer, used if at least one sidebar has a bg color */ -function equalizeHeights(){ +function mantra_equalizeHeights(){ var h1 = jQuery("#primary").height(); var h2 = jQuery("#secondary").height(); var h3 = jQuery("#content").height(); @@ -94,7 +92,7 @@ function mantra_onload() { } if ( mantra_options.equalizesidebars = 1 ) { /* Check if sidebars have user colors and if so equalize their heights */ - equalizeHeights(); + mantra_equalizeHeights(); } }; // mantra_onload @@ -188,3 +186,5 @@ function getInternetExplorerVersion() } return rv; } + +/*FIN*/
\ No newline at end of file |