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