1/* 2 FlexNav.js 1.3.3 3 4 Created by Jason Weaver http://jasonweaver.name 5 Released under http://unlicense.org/ 6 Modifié par Fabrice DÃMARAIS: 7 - Option pour définir le point de rupture entre pc et mobile (breakpoint) 8 - Option pour choisir si le menu apparait au clique sur pc (click) 9 - Option pour choisir si les sous menus s'affichent au survol ou si il apparaisent déjà dépliés (hideChild) 10 - Option pour choisir si on affiche un niveau de sous-navigation ou tous sur pc (oneChild) 11 12// 13*/ 14 15 16(function() { 17 var $; 18 19 $ = jQuery; 20 21 $.fn.flexNav = function(options) { 22 var $nav, $top_nav_items, breakpoint, count, nav_percent, nav_width, resetMenu, resizer, settings, showMenu, toggle_selector, touch_selector; 23 settings = $.extend({ 24 'animationSpeed': 250, 25 'transitionOpacity': true, 26 'buttonSelector': '.menu-button', 27 'hoverIntent': false, 28 'hoverIntentTimeout': 150, 29 'calcItemWidths': false, 30 'hover': false, 31 'click': false, 32 'hideChild': true, 33 'oneChild': true, 34 'breakpoint': 992 35 }, options); 36 $nav = $(this); 37 $nav.addClass('with-js'); 38 if (settings.transitionOpacity === true) { 39 $nav.addClass('opacity'); 40 } 41 42 if (!settings.hideChild) { 43 $nav.children("li").each(function() { 44 if ($(this).has("ul").length) { 45 return $(this).addClass("item-with-ul").children("ul").hide(); 46 } 47 }); 48 }else { 49 $nav.find("li").each(function() { 50 if ($(this).has("ul").length) { 51 return $(this).addClass("item-with-ul").find("ul").hide(); 52 } 53 }); 54 } 55 56 if (settings.calcItemWidths === true) { 57 $top_nav_items = $nav.find('>li'); 58 count = $top_nav_items.length; 59 nav_width = 100 / count; 60 nav_percent = nav_width + "%"; 61 } 62 breakpoint = settings.breakpoint; 63 showMenu = function() { 64 if ($nav.hasClass('lg-screen') === true && settings.hover === true) { 65 if (settings.transitionOpacity === true) { 66 return $(this).find('>ul').addClass('flexnav-show').stop(true, true).animate({ 67 height: ["toggle", "swing"], 68 opacity: "toggle" 69 }, settings.animationSpeed); 70 } else { 71 return $(this).find('>ul').addClass('flexnav-show').stop(true, true).animate({ 72 height: ["toggle", "swing"] 73 }, settings.animationSpeed); 74 } 75 } 76 }; 77 resetMenu = function() { 78 if ($nav.hasClass('lg-screen') === true && $(this).find('>ul').hasClass('flexnav-show') === true && settings.hover === true) { 79 if (settings.transitionOpacity === true) { 80 return $(this).find('>ul').removeClass('flexnav-show').stop(true, true).animate({ 81 height: ["toggle", "swing"], 82 opacity: "toggle" 83 }, settings.animationSpeed); 84 } else { 85 return $(this).find('>ul').removeClass('flexnav-show').stop(true, true).animate({ 86 height: ["toggle", "swing"] 87 }, settings.animationSpeed); 88 } 89 } 90 }; 91 resizer = function() { 92 var selector; 93 if ($(window).width() <= breakpoint) { 94 $nav.removeClass("lg-screen").addClass("sm-screen"); 95 if (settings.calcItemWidths === true) { 96 $top_nav_items.css('width', '100%'); 97 } 98 selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'; 99 $(selector).removeClass('active'); 100 return $('.one-page li a').on('click', function() { 101 return $nav.removeClass('flexnav-show'); 102 }); 103 } else if ($(window).width() > breakpoint) { 104 $nav.removeClass("sm-screen").addClass("lg-screen"); 105 if (settings.calcItemWidths === true) { 106 $top_nav_items.css('width', nav_percent); 107 } 108 $nav.removeClass('flexnav-show').find('.item-with-ul').off(); 109 if (settings.hideChild) { 110 $('.item-with-ul').find('ul').removeClass('flexnav-show').hide(); 111 } else { 112 $('.item-with-ul').children('ul').removeClass('flexnav-show').hide(); 113 } 114 resetMenu(); 115 if (settings.hoverIntent === true) { 116 return $('.item-with-ul').hoverIntent({ 117 over: showMenu, 118 out: resetMenu, 119 timeout: settings.hoverIntentTimeout 120 }); 121 } else if (settings.hoverIntent === false) { 122 if (!settings.oneChild) { 123 return $('.item-with-ul').on('mouseenter', showMenu).on('mouseleave', resetMenu); 124 } else { 125 return $nav.children("li.item-with-ul").on('mouseenter', showMenu).on('mouseleave', resetMenu); 126 } 127 } 128 } 129 }; 130 $(settings['buttonSelector']).data('navEl', $nav); 131 touch_selector = '.item-with-ul, ' + settings['buttonSelector']; 132 $(touch_selector).append('<span class="touch-button"><i class="navicon">▼</i></span>'); 133 toggle_selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'; 134 $(toggle_selector).on('click', function(e) { 135 var $btnParent, $thisNav, bs; 136 $(toggle_selector).toggleClass('active'); 137 e.preventDefault(); 138 e.stopPropagation(); 139 bs = settings['buttonSelector']; 140 $btnParent = $(this).is(bs) ? $(this) : $(this).parent(bs); 141 $thisNav = $btnParent.data('navEl'); 142 return $thisNav.toggleClass('flexnav-show'); 143 }); 144 $('.touch-button').on('click', function(e) { 145 var $sub, $touchButton; 146 $sub = $(this).parent('.item-with-ul').find('>ul'); 147 $touchButton = $(this).parent('.item-with-ul').find('>span.touch-button'); 148 if ($nav.hasClass('lg-screen') === true) { 149 $(this).parent('.item-with-ul').siblings().find('ul.flexnav-show').removeClass('flexnav-show').hide(); 150 } 151 if ($sub.hasClass('flexnav-show') === true) {
152 $sub.removeClass('flexnav-show').slideUp(settings.animationSpeed); 153 return $touchButton.removeClass('active'); 154 } else if ($sub.hasClass('flexnav-show') === false) { 155 $sub.addClass('flexnav-show').slideDown(settings.animationSpeed); 156 return $touchButton.addClass('active'); 157 } 158 }); 159 if (settings.click === true) { 160 $nav.find('.item-with-ul *').focus(function() { 161 $(this).parent('.item-with-ul').parent().find(".open").not(this).removeClass("open").hide(); 162 return $(this).parent('.item-with-ul').find('>ul').addClass("open").show(); 163 }); 164 } 165 resizer(); 166 return $(window).on('resize', resizer); 167 }; 168 169}).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.