UNPKG

uikit

Version:

UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.

3 lines (2 loc) 2.37 kB
/*! UIkit 3.6.19 | https://www.getuikit.com | (c) 2014 - 2021 YOOtheme | MIT License */ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("uikit-util")):"function"==typeof define&&define.amd?define("uikitnotification",["uikit-util"],i):(t="undefined"!=typeof globalThis?globalThis:t||self).UIkitNotification=i(t.UIkit.util)}(this,function(s){"use strict";var t={mixins:[{props:{container:Boolean},data:{container:!0},computed:{container:function(t){t=t.container;return!0===t&&this.$container||t&&s.$(t)}}}],functional:!0,args:["message","status"],data:{message:"",status:"",timeout:5e3,group:null,pos:"top-center",clsContainer:"uk-notification",clsClose:"uk-notification-close",clsMsg:"uk-notification-message"},install:function(o){o.notification.closeAll=function(i,e){s.apply(document.body,function(t){t=o.getComponent(t,"notification");!t||i&&i!==t.group||t.close(e)})}},computed:{marginProp:function(t){t=t.pos;return"margin"+(s.startsWith(t,"top")?"Top":"Bottom")},startProps:function(){var t={opacity:0};return t[this.marginProp]=-this.$el.offsetHeight,t}},created:function(){var t=s.$("."+this.clsContainer+"-"+this.pos,this.container)||s.append(this.container,'<div class="'+this.clsContainer+" "+this.clsContainer+"-"+this.pos+'" style="display: block"></div>');this.$mount(s.append(t,'<div class="'+this.clsMsg+(this.status?" "+this.clsMsg+"-"+this.status:"")+'"> <a href class="'+this.clsClose+'" data-uk-close></a> <div>'+this.message+"</div> </div>"))},connected:function(){var t,i=this,e=s.toFloat(s.css(this.$el,this.marginProp));s.Transition.start(s.css(this.$el,this.startProps),((t={opacity:1})[this.marginProp]=e,t)).then(function(){i.timeout&&(i.timer=setTimeout(i.close,i.timeout))})},events:((t={click:function(t){s.closest(t.target,'a[href="#"],a[href=""]')&&t.preventDefault(),this.close()}})[s.pointerEnter]=function(){this.timer&&clearTimeout(this.timer)},t[s.pointerLeave]=function(){this.timeout&&(this.timer=setTimeout(this.close,this.timeout))},t),methods:{close:function(t){function i(t){var i=s.parent(t);s.trigger(t,"close",[e]),s.remove(t),i&&!i.hasChildNodes()&&s.remove(i)}var e=this;this.timer&&clearTimeout(this.timer),t?i(this.$el):s.Transition.start(this.$el,this.startProps).then(i)}}};return"undefined"!=typeof window&&window.UIkit&&window.UIkit.component("notification",t),t});