UNPKG

vue-status

Version:

Vue component for detecting the network status - online or offline

1 lines 1.89 kB
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r=["online","offline"];var o=function(t,e,n,r,o,i,s,u){var a,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=n,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),s?(a=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},c._ssrRegister=a):o&&(a=u?function(){o.call(this,this.$root.$options.shadowRoot)}:o),a)if(c.functional){c._injectStyles=a;var f=c.render;c.render=function(t,e){return a.call(e),f(t,e)}}else{var l=c.beforeCreate;c.beforeCreate=l?[].concat(l,a):[a]}return{exports:t,options:c}}({name:"vue-status",data:function(){return{isOnline:navigator.onLine||!1}},created:function(){var t=this;r.forEach(function(e){return window.addEventListener(e,t.currentStatus)})},beforeDestroy:function(){var t=this;r.forEach(function(e){return window.removeEventListener(e,t.currentStatus)})},methods:{currentStatus:function(){this.isOnline=navigator.onLine||!1,this.$emit("current-status",this.isOnline)}}},function(){var t=this.$createElement;return(this._self._c||t)("div",[this.isOnline?this._t("online"):this._t("offline")],2)},[],!1,null,null,null).exports;e.default=o}]);