-
Notifications
You must be signed in to change notification settings - Fork 5
/
jquery.treemenu.min.js
1 lines (1 loc) · 1.21 KB
/
jquery.treemenu.min.js
1
!function(a){a.fn.treemenu=function(l){if((l=l||{}).delay=l.delay||0,l.openActive=l.openActive||!1,l.closeOther=l.closeOther||!1,l.activeSelector=l.activeSelector||"active",this.addClass("treemenu"),l.nonroot||this.addClass("treemenu-root"),l.nonroot=!0,this.find("> li").each(function(){e=a(this);var t,s=e.find("> ul");0==(t=e.find(".toggler").eq(0)).length&&((t=a("<span>")).addClass("toggler"),e.prepend(t));0<s.length?(s.hide(),e.addClass("tree-closed"),e.find(t).click(function(){var e=a(this).parent("li");if(l.closeOther&&e.hasClass("tree-closed")){var t=e.parent("ul").find("li:not(.tree-empty)");t.removeClass("tree-opened"),t.addClass("tree-closed"),t.removeClass(l.activeSelector),t.find("> ul").slideUp(l.delay)}e.find("> ul").slideToggle(l.delay),e.toggleClass("tree-opened"),e.toggleClass("tree-closed"),e.toggleClass(l.activeSelector)}),a(this).find("> ul").treemenu(l)):a(this).addClass("tree-empty")}),l.openActive){var t=this.attr("class");this.find("."+l.activeSelector).each(function(){for(var e=a(this).parent();e.attr("class")!==t;)e.find("> ul").show(),"UL"===e.prop("tagName")?e.show():"LI"===e.prop("tagName")&&(e.removeClass("tree-closed"),e.addClass("tree-opened"),e.show()),e=e.parent()})}return this}}(jQuery);