mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
6.6 KiB
3 lines
6.6 KiB
/*! UIkit 3.0.0-rc.17 | http://www.getuikit.com | (c) 2014 - 2018 YOOtheme | MIT License */
|
|
|
|
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("uikit-util")):"function"==typeof define&&define.amd?define("uikittooltip",["uikit-util"],i):t.UIkitTooltip=i(t.UIkit.util)}(this,function(g){"use strict";var t,i={props:{container:Boolean},data:{container:!0},computed:{container:function(t){var i=t.container;return!0===i&&this.$container||i&&g.$(i)}}},n={props:{cls:Boolean,animation:"list",duration:Number,origin:String,transition:String,queued:Boolean},data:{cls:!1,animation:[!1],duration:200,origin:!1,transition:"linear",queued:!1,initProps:{overflow:"",height:"",paddingTop:"",paddingBottom:"",marginTop:"",marginBottom:""},hideProps:{overflow:"hidden",height:0,paddingTop:0,paddingBottom:0,marginTop:0,marginBottom:0}},computed:{hasAnimation:function(t){return!!t.animation[0]},hasTransition:function(t){var i=t.animation;return this.hasAnimation&&!0===i[0]}},methods:{toggleElement:function(l,u,d){var c=this;return new g.Promise(function(t){l=g.toNodes(l);var i,n=function(t){return g.Promise.all(t.map(function(t){return c._toggleElement(t,u,d)}))},o=l.filter(function(t){return c.isToggled(t)}),e=l.filter(function(t){return!g.includes(o,t)});if(c.queued&&g.isUndefined(d)&&g.isUndefined(u)&&c.hasAnimation&&!(l.length<2)){var s=document.body,r=s.scrollTop,a=o[0],h=g.Animation.inProgress(a)&&g.hasClass(a,"uk-animation-leave")||g.Transition.inProgress(a)&&"0px"===a.style.height;i=n(o),h||(i=i.then(function(){var t=n(e);return s.scrollTop=r,t}))}else i=n(e.concat(o));i.then(t,g.noop)})},toggleNow:function(i,n){var o=this;return new g.Promise(function(t){return g.Promise.all(g.toNodes(i).map(function(t){return o._toggleElement(t,n,!1)})).then(t,g.noop)})},isToggled:function(t){var i=g.toNodes(t||this.$el);return this.cls?g.hasClass(i,this.cls.split(" ")[0]):!g.hasAttr(i,"hidden")},updateAria:function(t){!1===this.cls&&g.attr(t,"aria-hidden",!this.isToggled(t))},_toggleElement:function(t,i,n){var o=this;if(i=g.isBoolean(i)?i:g.Animation.inProgress(t)?g.hasClass(t,"uk-animation-leave"):g.Transition.inProgress(t)?"0px"===t.style.height:!this.isToggled(t),!g.trigger(t,"before"+(i?"show":"hide"),[this]))return g.Promise.reject();var e=(!1!==n&&this.hasAnimation?this.hasTransition?this._toggleHeight:this._toggleAnimation:this._toggleImmediate)(t,i);return g.trigger(t,i?"show":"hide",[this]),e.then(function(){g.trigger(t,i?"shown":"hidden",[o]),o.$update(t)})},_toggle:function(t,i){var n;t&&(this.cls?(n=g.includes(this.cls," ")||Boolean(i)!==g.hasClass(t,this.cls))&&g.toggleClass(t,this.cls,g.includes(this.cls," ")?void 0:i):(n=Boolean(i)===g.hasAttr(t,"hidden"))&&g.attr(t,"hidden",i?null:""),g.$$("[autofocus]",t).some(function(t){return g.isVisible(t)&&(t.focus()||!0)}),this.updateAria(t),n&&this.$update(t))},_toggleImmediate:function(t,i){return this._toggle(t,i),g.Promise.resolve()},_toggleHeight:function(t,i){var n=this,o=g.Transition.inProgress(t),e=t.hasChildNodes?g.toFloat(g.css(t.firstElementChild,"marginTop"))+g.toFloat(g.css(t.lastElementChild,"marginBottom")):0,s=g.isVisible(t)?g.height(t)+(o?0:e):0;g.Transition.cancel(t),this.isToggled(t)||this._toggle(t,!0),g.height(t,""),g.fastdom.flush();var r=g.height(t)+(o?0:e);return g.height(t,s),(i?g.Transition.start(t,g.assign({},this.initProps,{overflow:"hidden",height:r}),Math.round(this.duration*(1-s/r)),this.transition):g.Transition.start(t,this.hideProps,Math.round(this.duration*(s/r)),this.transition).then(function(){return n._toggle(t,!1)})).then(function(){return g.css(t,n.initProps)})},_toggleAnimation:function(t,i){var n=this;return g.Animation.cancel(t),i?(this._toggle(t,!0),g.Animation.in(t,this.animation[0],this.duration,this.origin)):g.Animation.out(t,this.animation[1]||this.animation[0],this.duration,this.origin).then(function(){return n._toggle(t,!1)})}}},o={props:{pos:String,offset:null,flip:Boolean,clsPos:String},data:{pos:"bottom-"+(g.isRtl?"right":"left"),flip:!0,offset:!1,clsPos:""},computed:{pos:function(t){var i=t.pos;return(i+(g.includes(i,"-")?"":"-center")).split("-")},dir:function(){return this.pos[0]},align:function(){return this.pos[1]}},methods:{positionAt:function(t,i,n){var o;g.removeClasses(t,this.clsPos+"-(top|bottom|left|right)(-[a-z]+)?"),g.css(t,{top:"",left:""});var e=this.offset;e=g.isNumeric(e)?e:(o=g.$(e))?g.offset(o)["x"===s?"left":"top"]-g.offset(i)["x"===s?"right":"bottom"]:0;var s=this.getAxis(),r=g.positionAt(t,i,"x"===s?g.flipPosition(this.dir)+" "+this.align:this.align+" "+g.flipPosition(this.dir),"x"===s?this.dir+" "+this.align:this.align+" "+this.dir,"x"===s?""+("left"===this.dir?-e:e):" "+("top"===this.dir?-e:e),null,this.flip,n).target,a=r.x,h=r.y;this.dir="x"===s?a:h,this.align="x"===s?h:a,g.toggleClass(t,this.clsPos+"-"+this.dir+"-"+this.align,!1===this.offset)},getAxis:function(){return"top"===this.dir||"bottom"===this.dir?"y":"x"}}},e=[],s={mixins:[i,n,o],args:"title",props:{delay:Number,title:String},data:{pos:"top",title:"",delay:0,animation:["uk-animation-scale-up"],duration:100,cls:"uk-active",clsPos:"uk-tooltip"},beforeConnect:function(){this._hasTitle=g.hasAttr(this.$el,"title"),g.attr(this.$el,{title:"","aria-expanded":!1})},disconnected:function(){this.hide(),g.attr(this.$el,{title:this._hasTitle?this.title:null,"aria-expanded":null})},methods:{show:function(){var i=this;g.includes(e,this)||(e.forEach(function(t){return t.hide()}),e.push(this),this._unbind=g.on(document,"click",function(t){return!g.within(t.target,i.$el)&&i.hide()}),clearTimeout(this.showTimer),this.showTimer=setTimeout(function(){i._show(),i.hideTimer=setInterval(function(){g.isVisible(i.$el)||i.hide()},150)},this.delay))},hide:function(){var t=e.indexOf(this);!~t||g.matches(this.$el,"input")&&this.$el===document.activeElement||(e.splice(t,1),clearTimeout(this.showTimer),clearInterval(this.hideTimer),g.attr(this.$el,"aria-expanded",!1),this.toggleElement(this.tooltip,!1),this.tooltip&&g.remove(this.tooltip),this.tooltip=!1,this._unbind())},_show:function(){this.tooltip=g.append(this.container,'<div class="'+this.clsPos+'" aria-expanded="true" aria-hidden> <div class="'+this.clsPos+'-inner">'+this.title+"</div> </div>"),this.positionAt(this.tooltip,this.$el),this.origin="y"===this.getAxis()?g.flipPosition(this.dir)+"-"+this.align:this.align+"-"+g.flipPosition(this.dir),this.toggleElement(this.tooltip,!0)}},events:(t={},t["focus "+g.pointerEnter+" "+g.pointerDown]=function(t){t.type===g.pointerDown&&g.isTouch(t)||this.show()},t.blur="hide",t[g.pointerLeave]=function(t){g.isTouch(t)||this.hide()},t)};return"undefined"!=typeof window&&window.UIkit&&window.UIkit.component("tooltip",s),s});
|