1/* 2 FlexNav.js 1.1.1 3 4 Created by Jason Weaver http://jasonweaver.name 5 Released under http://unlicense.org/ 6 7// 8*/ 9 10 11(function() { 12 var $; 13 14 $ = jQuery; 15 16 $.fn.flexNav = function(options) { 17 var $nav, breakpoint, flag, resetMenu, resizer, selector, settings, showMenu; 18 settings = $.extend({ 19 'animationSpeed': 250, 20 'transitionOpacity': true, 21 'buttonSelector': '.menu-button', 22 'hoverIntent': false, 23 'hoverIntentTimeout': 150 24 }, options); 25 $nav = $(this); 26 flag = false; 27 $nav.addClass('with-js'); 28 if (settings.transitionOpacity === true) { 29 $nav.addClass('opacity'); 30 } 31 $nav.find("li").each(function() { 32 if ($(this).has("ul").length) { 33 return $(this).addClass("item-with-ul").find("ul").hide(); 34 } 35 }); 36 if ($nav.data('breakpoint')) { 37 breakpoint = $nav.data('breakpoint'); 38 } 39 showMenu = function() { 40 if ($nav.hasClass('lg-screen') === true) { 41 if (settings.transitionOpacity === true) { 42 return $(this).find('>ul').addClass('show').stop(true, true).animate({ 43 //height: ["toggle", "swing"], 44 //opacity: "toggle" 45 }, settings.animationSpeed); 46 } else { 47 return $(this).find('>ul').addClass('show').stop(true, true).animate({ 48 //height: ["toggle", "swing"] 49 }, settings.animationSpeed); 50 } 51 } 52 }; 53 resetMenu = function() { 54 if ($nav.hasClass('lg-screen') === true && $(this).find('>ul').hasClass('show') === true) { 55 if (settings.transitionOpacity === true) { 56 return $(this).find('>ul').removeClass('show').stop(true, true).animate({ 57 // height: ["toggle", "swing"], 58 // opacity: "toggle" 59 }, settings.animationSpeed); 60 } else { 61 return $(this).find('>ul').removeClass('show').stop(true, true).animate({ 62 // height: ["toggle", "swing"] 63 }, settings.animationSpeed); 64 } 65 } 66 }; 67 resizer = function() { 68 if ($(window).width() <= breakpoint) { 69 $nav.removeClass("lg-screen").addClass("sm-screen"); 70 return $('.one-page li a').on('click', function() { 71 return $nav.removeClass('show'); 72 }); 73 } else if ($(window).width() > breakpoint) { 74 $nav.removeClass("sm-screen").addClass("lg-screen"); 75 $nav.removeClass('show'); 76 if (settings.hoverIntent === true) { 77 return $('.item-with-ul').hoverIntent({ 78 over: showMenu, 79 out: resetMenu, 80 timeout: settings.hoverIntentTimeout 81 }); 82 } else if (settings.hoverIntent === false) { 83 return $('.item-with-ul').on('mouseenter', showMenu).on('mouseleave', resetMenu); 84 } 85 } 86 }; 87 $(settings['buttonSelector']).data('navEl', $nav); 88 selector = '.item-with-ul, ' + settings['buttonSelector']; 89 $(selector).append('<span class="touch-button"><i class="navicon">▼</i></span>'); 90 selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'; 91 $(selector).on('touchstart click', function(e) { 92 var $btnParent, $thisNav, bs; 93 e.preventDefault(); 94 e.stopPropagation(); 95 bs = settings['buttonSelector']; 96 $btnParent = $(this).is(bs) ? $(this) : $(this).parent(bs); 97 $thisNav = $btnParent.data('navEl'); 98 if (flag === false) { 99 flag = true; 100 setTimeout(function() { 101 return flag = false; 102 }, 301); 103 return $thisNav.toggleClass('show'); 104 } 105 }); 106 $('.touch-button').on('touchstart click', function(e) { 107 var $sub, $touchButton; 108 e.preventDefault(); 109 e.stopPropagation(); 110 $sub = $(this).parent('.item-with-ul').find('>ul'); 111 $touchButton = $(this).parent('.item-with-ul').find('>span.touch-button'); 112 if (flag === false) { 113 flag = true; 114 setTimeout(function() { 115 return flag = false; 116 }, 301); 117 if ($nav.hasClass('lg-screen') === true) { 118 $(this).parent('.item-with-ul').siblings().find('ul.show').removeClass('show').hide(); 119 } 120 if ($sub.hasClass('show') === true) {
121 $sub.removeClass('show').slideUp(settings.animationSpeed); 122 return $touchButton.removeClass('active'); 123 } else if ($sub.hasClass('show') === false) { 124 $sub.addClass('show').slideDown(settings.animationSpeed); 125 return $touchButton.addClass('active'); 126 } 127 } 128 }); 129 130 //Set width for Mobile 131 if ( jQuery(window).width() > 767) { 132 $nav.find('.item-with-ul *').focus(function() { 133 $(this).parent('.item-with-ul').parent().find(".open").not(this).removeClass("open").hide(); 134 return $(this).parent('.item-with-ul').find('>ul').addClass("open").show(); 135 }); 136 } 137 resizer(); 138 return $(window).on('resize', resizer); 139 }; 140 141}).call(this);
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.