Component-Builder/media/uikit-v2/js/core/nav.min.js

2 lines
2.1 KiB
JavaScript

/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){"use strict";function i(i){var s=t.$(i),e="auto";if(s.is(":visible"))e=s.outerHeight();else{var a={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};e=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(a)}return e}t.component("nav",{defaults:{toggle:'>li.uk-parent > a[href="#"]',lists:">li.uk-parent > ul",multiple:!1},boot:function(){t.ready(function(i){t.$("[data-uk-nav]",i).each(function(){var i=t.$(this);if(!i.data("nav")){t.nav(i,t.Utils.options(i.attr("data-uk-nav")))}})})},init:function(){var i=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var e=t.$(this);i.open(e.parent()[0]==i.element[0]?e:e.parent("li"))}),this.update(),t.domObserve(this.element,function(){i.element.find(i.options.lists).not("[role]").length&&i.update()})},update:function(){var i=this;this.find(this.options.lists).each(function(){var s=t.$(this).attr("role","menu"),e=s.closest("li"),a=e.hasClass("uk-active");e.data("list-container")||(s.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>'),e.data("list-container",s.parent()[a?"removeClass":"addClass"]("uk-hidden"))),e.attr("aria-expanded",e.hasClass("uk-open")),a&&i.open(e,!0)})},open:function(s,e){var a=this,n=this.element,o=t.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var i=t.$(this);i.data("list-container")&&i.data("list-container").stop().animate({height:0},function(){t.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),e?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?i(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),a.trigger("display.uk.check")}))}})}(UIkit2);