1/*! jQuery navigation.js 2 Adds toggle icon for mobile navigation and dropdown animations for widescreen navigation 3 Author: Thomas W (themezee.com) 4*/ 5 6(function($) { 7 8 /**-------------------------------------------------------------- 9 # Responsive Navigation for WordPress menus 10 --------------------------------------------------------------*/ 11 $.fn.responsiveMenu = function( options ) { 12 13 if (options === undefined) options = {}; 14 15 /* Set Defaults */ 16 var defaults = { 17 menuID: "menu", 18 toggleClass: "menu-toggle", 19 toggleText: "", 20 maxWidth: "60em" 21 }; 22 23 /* Set Variables */ 24 var vars = $.extend({}, defaults, options), 25 menuID = vars.menuID, 26 toggleID = (vars.toggleID) ? vars.toggleID : vars.toggleClass, 27 toggleClass = vars.toggleClass, 28 toggleText = vars.toggleText, 29 maxWidth = vars.maxWidth, 30 $this = $(this), 31 $menu = $('#' + menuID); 32 33 34 /********************* 35 * Desktop Navigation * 36 **********************/ 37 38 /* Set and reset dropdown animations based on screen size */ 39 if(typeof matchMedia == 'function') { 40 var mq = window.matchMedia('(max-width: ' + maxWidth + ')'); 41 mq.addListener(widthChange); 42 widthChange(mq); 43 } 44 function widthChange(mq) { 45 46 if (mq.matches) { 47 48 /* Reset desktop navigation menu dropdown animation on smaller screens */ 49 $menu.find( 'ul.sub-menu' ).css( { display: 'block' } ); 50 $menu.find( 'li ul.sub-menu' ).css( { visibility: 'visible', display: 'block' } ); 51 $menu.find( 'li.menu-item-has-children' ).unbind( 'mouseenter mouseleave' ); 52 53 $menu.find( 'li.menu-item-has-children ul.sub-menu' ).each( function() { 54 $( this ).hide(); 55 $( this ).parent().find( '.submenu-dropdown-toggle' ).removeClass( 'active' ); 56 } ); 57 58 } else { 59 60 /* Add dropdown animation for desktop navigation menu */ 61 $menu.find( 'ul.sub-menu' ).css( { display: 'none' } ); 62 $menu.find( 'li.menu-item-has-children' ).hover( function() { 63 $( this ).find( 'ul:first' ).css( { visibility: 'visible', display: 'none' } ).slideDown( 300 ); 64 }, function() { 65 $( this ).find( 'ul:first' ).css( { visibility: 'hidden' } ); 66 } ); 67 68 } 69 70 } 71 72 73 /******************** 74 * Mobile Navigation * 75 *********************/ 76 77 /* Add Menu Toggle Button for mobile navigation */ 78 $this.before('<button id=\"' + toggleID + '\" class=\"' + toggleClass + '\">' + toggleText + '</button>'); 79 80 /* Add dropdown toggle for submenus on mobile navigation */ 81 $menu.find('li.menu-item-has-children').prepend('<span class=\"submenu-dropdown-toggle\"></span>'); 82 83 /* Add dropdown slide animation for mobile devices */ 84 $('#' + toggleID).on('click', function(){ 85 $menu.slideToggle(); 86 $(this).toggleClass('active'); 87 }); 88 89 /* Add dropdown animation for submenus on mobile navigation */ 90 $menu.find('li.menu-item-has-children .sub-menu').each( function () { 91 $( this ).hide(); 92 } ); 93 $menu.find('.submenu-dropdown-toggle').on('click', function(){ 94 $(this).parent().find('ul:first').slideToggle(); 95 $(this).toggleClass('active'); 96 }); 97 98 }; 99 100 101 /**-------------------------------------------------------------- 102 # Setup Navigation Menus 103 --------------------------------------------------------------*/ 104 $( document ).ready( function() { 105 106 /* Setup Main Navigation */ 107 $("#mainnav").responsiveMenu({ 108 menuID: "mainnav-menu", 109 toggleID: "mainnav-toggle", 110 toggleClass: "nav-toggle", 111 toggleText: smartline_menu_title.text, 112 maxWidth: "60em" 113 }); 114 115 /* Setup Top Navigation */ 116 $("#topnav").responsiveMenu({ 117 menuID: "topnav-menu", 118 toggleID: "topnav-toggle", 119 toggleClass: "nav-toggle", 120 toggleText: smartline_menu_title.text, 121 maxWidth: "50em" 122 }); 123 124 } ); 125 126}(jQuery));
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.