UNPKG

vue-preload

Version:

Preloading data for Vue component

1 lines 6.92 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vue-preload"]=t():e["vue-preload"]=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),r=o(i);n(6),t["default"]={install:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];(0,r["default"])(e,t)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t){function n(){return navigator.userAgent.indexOf("Windows Phone")>-1||navigator.userAgent.indexOf("Android")>-1||navigator.userAgent.indexOf("iPad")>-1||navigator.userAgent.indexOf("iPhone")>-1||navigator.userAgent.indexOf("Mobile")>-1}var o=e.util;t.showProgress&&e.component("preloading",{data:function(){return{show:!1}},template:'\n <div class="vue-preload" transition="vue-preload" v-show="show">\n <div class="vue-preload-progress"></div>\n </div>\n ',methods:{toggle:function(e){this.show=e}},ready:function(){this.$on("preloading",this.toggle)}}),e.directive("preload",{bind:function(){var e=this;this.preLoading=!1,this.tmp=null,this.clickToPreload=!1,this.handleMouseOver=function(n){return e.preLoading?void(t.onPreloading&&t.onPreLoading()):(e.preLoading=!0,void e.vm[e.expression].call(null,e,n))},this.handleClick=function(t){return t.preventDefault(),e.showBar(),e.tmp||e.preLoading?void e.setState(e.tmp):(e.clickToPreload=!0,e.handleMouseOver(t))},n()?o.on(this.el,"touchstart",this.handleMouseOver):(o.on(this.el,"mouseover",this.handleMouseOver),o.on(this.el,"click",this.handleClick))},set:function(e){this.tmp=e},setState:function(e){for(var t in e)this.vm.$set(t,e[t]);this.hideBar(),this.tmp=null},end:function(){this.preLoading=!1,this.hideBar(),(this.clickToPreload||n())&&(this.setState(this.tmp),this.clickToPreload=!1)},showBar:function(){t.showProgress&&this.vm.$broadcast("preloading",!0),"function"==typeof t.onStart&&t.onStart()},hideBar:function(){t.showProgress&&!this.preLoading&&this.vm.$broadcast("preloading",!1),"function"==typeof t.onStart&&t.onEnd()},reset:function(){n()?o.off(this.el,"touchstart",this.handleMouseOver):(o.off(this.el,"mouseover",this.handleMouseOver),o.off(this.el,"click",this.handleClick))},unbind:function(){this.reset()}})}},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".vue-preload{height:3px;position:fixed;top:0;left:0;right:0;opacity:1;-webkit-transition:opacity .3s ease;transition:opacity .3s ease}.vue-preload .vue-preload-progress{background-color:#007fff;position:absolute;height:100%;-webkit-animation:loading 1.2s linear infinite;animation:loading 1.2s linear infinite}.vue-preload-enter,.vue-preload-leave{opacity:0}@-webkit-keyframes loading{0%{left:0;right:100%;opacity:1}50%{left:0}50%,to{right:0}to{left:100%;opacity:.4}}@keyframes loading{0%{left:0;right:100%;opacity:1}50%{left:0}50%,to{right:0}to{left:100%;opacity:.4}}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t];n[2]?e.push("@media "+n[2]+"{"+n[1]+"}"):e.push(n[1])}return e.join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(o[r]=!0)}for(i=0;i<t.length;i++){var s=t[i];"number"==typeof s[0]&&o[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),e.push(s))}},e}},function(e,t,n){function o(e,t){for(var n=0;n<e.length;n++){var o=e[n],i=p[o.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](o.parts[r]);for(;r<o.parts.length;r++)i.parts.push(l(o.parts[r],t))}else{for(var s=[],r=0;r<o.parts.length;r++)s.push(l(o.parts[r],t));p[o.id]={id:o.id,refs:1,parts:s}}}}function i(e){for(var t=[],n={},o=0;o<e.length;o++){var i=e[o],r=i[0],s=i[1],a=i[2],u=i[3],l={css:s,media:a,sourceMap:u};n[r]?n[r].parts.push(l):t.push(n[r]={id:r,parts:[l]})}return t}function r(e,t){var n=g(),o=b[b.length-1];if("top"===e.insertAt)o?o.nextSibling?n.insertBefore(t,o.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),b.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function s(e){e.parentNode.removeChild(e);var t=b.indexOf(e);t>=0&&b.splice(t,1)}function a(e){var t=document.createElement("style");return t.type="text/css",r(e,t),t}function u(e){var t=document.createElement("link");return t.rel="stylesheet",r(e,t),t}function l(e,t){var n,o,i;if(t.singleton){var r=y++;n=m||(m=a(t)),o=f.bind(null,n,r,!1),i=f.bind(null,n,r,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=u(t),o=c.bind(null,n),i=function(){s(n),n.href&&URL.revokeObjectURL(n.href)}):(n=a(t),o=d.bind(null,n),i=function(){s(n)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else i()}}function f(e,t,n,o){var i=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=x(t,i);else{var r=document.createTextNode(i),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(r,s[t]):e.appendChild(r)}}function d(e,t){var n=t.css,o=t.media;t.sourceMap;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function c(e,t){var n=t.css,o=(t.media,t.sourceMap);o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([n],{type:"text/css"}),r=e.href;e.href=URL.createObjectURL(i),r&&URL.revokeObjectURL(r)}var p={},h=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},v=h(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),g=h(function(){return document.head||document.getElementsByTagName("head")[0]}),m=null,y=0,b=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=v()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=i(e);return o(n,t),function(e){for(var r=[],s=0;s<n.length;s++){var a=n[s],u=p[a.id];u.refs--,r.push(u)}if(e){var l=i(e);o(l,t)}for(var s=0;s<r.length;s++){var u=r[s];if(0===u.refs){for(var f=0;f<u.parts.length;f++)u.parts[f]();delete p[u.id]}}}};var x=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t,n){var o=n(3);"string"==typeof o&&(o=[[e.id,o,""]]);n(5)(o,{});o.locals&&(e.exports=o.locals)}])});