1/** 2 * A nice sliding menu jquery extension. 3 * See https://github.com/zeupin/nicemenu 4 * 5 * Copyright (c) 2017 Zeupin LLC. 6 * Author: Macc Liu (https://github.com/maccliu) 7 * Licensed under MIT. 8 */ 9; 10(function ($) { 11 $.fn.extend({ 12 "nicemenu": function (parameters) { 13 // default parameters 14 var defaults = { 15 pos: "list.bottom", 16 classes: "active", 17 } 18 19 // combines defaults and parameters 20 var options = $.extend({}, defaults, parameters); 21 22 // extension main 23 this.each(function () { 24 // get [data-pos=...] attribute 25 var pos = $(this).attr("data-pos"); 26 if (pos == undefined) { 27 pos = options.pos; 28 } 29 30 // get [data-classes=...] attribute 31 var classes = $(this).attr("data-classes"); 32 if (classes == undefined) { 33 classes = options.classes; 34 } 35 36 // get .nicemenu-list element 37 var list = $(this); 38 // each .nicemenu-item element 39 $(this).find(".nicemenu-item").each(function () { 40 41 // get .nicemenu-sub element 42 var sub = $(this).find(".nicemenu-sub"); 43 if (sub.length == 0) return true; 44 45 switch (pos) { 46 case "list.right": 47 sub.css({ 48 "top": 0, 49 "left": 0, 50 "margin-left": (list.outerWidth() - 1) + "px", 51 "height": list.outerHeight() + "px", 52 "border-left": "none" 53 }); 54 break; 55 56 case "list.left": 57 sub.css({ 58 "top": 0, 59 "right": 0, 60 "margin-right": (list.outerWidth() - 1) + "px", 61 "height": list.outerHeight() + "px", 62 "border-right": "none" 63 }); 64 break; 65 66 case "list.bottom": 67 sub.css({ 68 "left": 0, 69 "width": list.outerWidth() + "px" 70 }); 71 break; 72 73 case "list.top": 74 sub.css({ 75 "left": 0, 76 "width": list.outerWidth() + "px", 77 "bottom": 0, 78 "margin-bottom": list.outerHeight() + "px", 79 }); 80 break; 81 } 82 83 $(this).mouseenter(function () { 84 $(this).addClass("active"); 85 $("#mytab").addClass("active"); 86 // $("#mytab1").addClass("active");
87 sub.addClass(classes); 88 89 }); 90 91 $(this).mouseleave(function () { 92 $(this).removeClass("active"); 93 $("#mytab").addClass("active"); 94 // $("#mytab1").addClass("active"); 95 sub.removeClass(classes); 96 // $("#mytab1").addClass("active"); 97 98 }); 99 }); 100 }); 101 102 // for chain-style code 103 return this; 104 } 105 }); 106})(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.