1/** 2 * jquery.slimmenu.js 3 * http://adnantopal.github.io/slimmenu/ 4 * Author: @adnantopal 5 * Copyright 2013, Adnan Topal (atopal.com) 6 * Licensed under the MIT license. 7 */ 8;(function ( $, window, document, undefined ) 9{ 10 var pluginName = "slimmenu", 11 defaults = 12 { 13 resizeWidth: '768', 14 collapserTitle: 'Main Menu', 15 animSpeed: 'medium', 16 easingEffect: null, 17 indentChildren: false, 18 childrenIndenter: ' ' 19 }; 20 21 function Plugin( element, options ) 22 { 23 this.element = element; 24 this.$elem = $(this.element); 25 this.options = $.extend( {}, defaults, options ); 26 this.init(); 27 } 28 29 Plugin.prototype = { 30 31 init: function() 32 { 33 var $options = this.options, 34 $menu = this.$elem, 35 $collapser = '<div class="slimmenu-menu-collapser">'+$options.collapserTitle+'<div class="slimmenu-collapse-button"><span class="slimmenu-icon-bar"></span><span class="slimmenu-icon-bar"></span><span class="slimmenu-icon-bar"></span></div></div>', 36 $menu_collapser; 37 38 $menu.before($collapser); 39 $menu_collapser = $menu.prev('.slimmenu-menu-collapser'); 40 41 $menu.on('click', '.slimmenu-sub-collapser', function(e) 42 { 43 e.preventDefault(); 44 e.stopPropagation(); 45 46 var $parent_li = $(this).closest('li'); 47 48 if ($(this).hasClass('expanded')) 49 { 50 $(this).removeClass('expanded'); 51 $(this).find('i').addClass('fa fa-angle-down'); 52 $parent_li.find('>ul').slideUp($options.animSpeed, $options.easingEffect); 53 } 54 else 55 { 56 $(this).addClass('expanded'); 57 $(this).find('i').removeClass('fa-angle-down').addClass('fa fa-angle-up'); 58 $parent_li.find('>ul').slideDown($options.animSpeed, $options.easingEffect); 59 } 60 }); 61 62 $menu_collapser.on('click', '.slimmenu-collapse-button', function(e) 63 { 64 e.preventDefault(); 65 $menu.slideToggle($options.animSpeed, $options.easingEffect); 66 }); 67 68 this.resizeMenu({ data: { el: this.element, options: this.options } }); 69 $(window).on('resize', { el: this.element, options: this.options }, this.resizeMenu); 70 }, 71 72 resizeMenu: function(event) 73 { 74 var $window = $(window), 75 $options = event.data.options, 76 $menu = $(event.data.el), 77 $menu_collapser = $('body').find('.slimmenu-menu-collapser'); 78 79 $menu.find('li').each(function() 80 { 81 if ($(this).has('ul').length) 82 { 83 $(this).addClass('slimmenu-sub-menu'); 84 if ($(this).has('.slimmenu-sub-collapser').length) 85 { 86 $(this).children('.slimmenu-sub-collapser i').addClass('fa fa-angle-down'); 87 } 88 else 89 { 90 $(this).append('<span class="slimmenu-sub-collapser"><i class="fa fa-angle-down"></i></span>'); 91 } 92 } 93 94 $(this).children('ul').hide(); 95 $(this).find('.slimmenu-sub-collapser').removeClass('expanded').children('i').addClass('fa fa-angle-down'); 96 }); 97 98 if ($options.resizeWidth >= $window.width() || $('body').hasClass('touch')) 99 { 100 if ($options.indentChildren) 101 { 102 $menu.find('ul').each(function() 103 { 104 var $depth = $(this).parents('ul').length; 105 if (!$(this).children('li').children('a').has('i').length) 106 { 107 $(this).children('li').children('a').prepend(Plugin.prototype.indent($depth, $options)); 108 } 109 }); 110 } 111 112 $menu.find('li').has('ul').off('mouseenter mouseleave'); 113 $menu.addClass('slimmenu-collapsed').hide(); 114 $menu_collapser.show(); 115 } 116 else 117 { 118 $menu.find('li').has('ul').on('mouseenter', function() 119 { 120 $(this).find('>
120ul').stop().slideDown($options.animSpeed, $options.easingEffect); 121 }) 122 .on('mouseleave', function() 123 { 124 $(this).find('>ul').stop().slideUp($options.animSpeed, $options.easingEffect); 125 }); 126 127 $menu.find('li > a > i').remove(); 128 $menu.removeClass('slimmenu-collapsed').show(); 129 $menu_collapser.hide(); 130 } 131 }, 132 133 indent: function(num, options) 134 { 135 var $indent = ''; 136 for (var i=0; i < num; i++) 137 { 138 $indent += options.childrenIndenter; 139 } 140 return '<i>'+$indent+'</i>'; 141 } 142 }; 143 144 $.fn[pluginName] = function ( options ) 145 { 146 return this.each(function () 147 { 148 if (!$.data(this, "plugin_" + pluginName)) 149 { 150 $.data(this, "plugin_" + pluginName, 151 new Plugin( this, options )); 152 } 153 }); 154 }; 155 156})( jQuery, window, document );
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.