Component-Builder/admin/custom/uikit-v2/js/core/offcanvas.min.js

2 lines
2.9 KiB
JavaScript
Raw Normal View History

2019-04-22 13:31:39 +00:00
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i,e){if(i=a.$(i),i.length){e=a.$.extend({mode:"push"},e);var o=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),r="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,c=f*(r?-1:1),h=window.innerWidth-o.width();t={x:window.pageXOffset,y:window.pageYOffset},s.attr("mode",e.mode),i.addClass("uk-active"),o.css({width:window.innerWidth-h,height:window.innerHeight}).addClass("uk-offcanvas-page"),("push"==e.mode||"reveal"==e.mode)&&o.css(r?"margin-right":"margin-left",(r?-1:1)*s.outerWidth()*c),"reveal"==e.mode&&s.css("clip","rect(0, "+s.outerWidth()+"px, 100vh, 0)"),n.css("margin-top",-1*t.y).width(),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var e=a.$("body"),o=a.$(".uk-offcanvas.uk-active"),s="right"==a.langdirection,r=o.find(".uk-offcanvas-bar:first"),f=function(){e.removeClass("uk-offcanvas-page").css({width:"",height:"",marginLeft:"",marginRight:""}),o.removeClass("uk-active"),r.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),r.trigger("hide.uk.offcanvas",[o,r]),o.attr("aria-hidden","true")};o.length&&("none"==r.attr("mode")&&(i=!0),a.support.transition&&!i?(e.one(a.support.transition.end,function(){f()}).css(s?"margin-right":"margin-left",""),"reveal"==r.attr("mode")&&r.css("clip",""),setTimeout(function(){r.removeClass("uk-offcanvas-bar-show")},0)):f())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(t.type.match(/swipe/)){if(n.parents(".uk-offcanvas-bar:first").length)return}else if(!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click",'a[href*="#"]',function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(e){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1,mode:"push"},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target,t.options)})}}),a.offcanvas=i}(UIkit2);