1+ ( function webpackUniversalModuleDefinition ( root , factory ) {
2+ if ( typeof exports === 'object' && typeof module === 'object' )
3+ module . exports = factory ( ) ;
4+ else if ( typeof define === 'function' && define . amd )
5+ define ( [ ] , factory ) ;
6+ else if ( typeof exports === 'object' )
7+ exports [ "VueImageLoader" ] = factory ( ) ;
8+ else
9+ root [ "VueImageLoader" ] = factory ( ) ;
10+ } ) ( this , function ( ) {
11+ return /******/ ( function ( modules ) { // webpackBootstrap
12+ /******/ // The module cache
13+ /******/ var installedModules = { } ;
14+
15+ /******/ // The require function
16+ /******/ function __webpack_require__ ( moduleId ) {
17+
18+ /******/ // Check if module is in cache
19+ /******/ if ( installedModules [ moduleId ] )
20+ /******/ return installedModules [ moduleId ] . exports ;
21+
22+ /******/ // Create a new module (and put it into the cache)
23+ /******/ var module = installedModules [ moduleId ] = {
24+ /******/ exports : { } ,
25+ /******/ id : moduleId ,
26+ /******/ loaded : false
27+ /******/ } ;
28+
29+ /******/ // Execute the module function
30+ /******/ modules [ moduleId ] . call ( module . exports , module , module . exports , __webpack_require__ ) ;
31+
32+ /******/ // Flag the module as loaded
33+ /******/ module . loaded = true ;
34+
35+ /******/ // Return the exports of the module
36+ /******/ return module . exports ;
37+ /******/ }
38+
39+
40+ /******/ // expose the modules object (__webpack_modules__)
41+ /******/ __webpack_require__ . m = modules ;
42+
43+ /******/ // expose the module cache
44+ /******/ __webpack_require__ . c = installedModules ;
45+
46+ /******/ // __webpack_public_path__
47+ /******/ __webpack_require__ . p = "" ;
48+
49+ /******/ // Load entry module and return exports
50+ /******/ return __webpack_require__ ( 0 ) ;
51+ /******/ } )
52+ /************************************************************************/
53+ /******/ ( [
54+ /* 0 */
55+ /***/ function ( module , exports , __webpack_require__ ) {
56+
57+ 'use strict' ;
58+
59+ Object . defineProperty ( exports , "__esModule" , {
60+ value : true
61+ } ) ;
62+ exports . install = install ;
63+
64+ var _VueImageLoader = __webpack_require__ ( 1 ) ;
65+
66+ var _VueImageLoader2 = _interopRequireDefault ( _VueImageLoader ) ;
67+
68+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
69+
70+ function install ( Vue , options ) {
71+
72+ _VueImageLoader2 . default . mixins = _VueImageLoader2 . default . mixins || [ ] ;
73+
74+ _VueImageLoader2 . default . mixins . push ( {
75+ props : {
76+ timeout : {
77+ type : Number ,
78+ default : options . timeout || null
79+ }
80+ } ,
81+ data : function data ( ) {
82+ return {
83+ loadInfo : options . loadInfo || null ,
84+ loadError : options . loadError || null
85+ } ;
86+ }
87+ } ) ;
88+
89+ Vue . component ( 'image-loader' , _VueImageLoader2 . default ) ;
90+ }
91+
92+ /***/ } ,
93+ /* 1 */
94+ /***/ function ( module , exports , __webpack_require__ ) {
95+
96+ var __vue_script__ , __vue_template__
97+ __vue_script__ = __webpack_require__ ( 2 )
98+ if ( __vue_script__ &&
99+ __vue_script__ . __esModule &&
100+ Object . keys ( __vue_script__ ) . length > 1 ) {
101+ console . warn ( "[vue-loader] src/VueImageLoader.vue: named exports in *.vue files are ignored." ) }
102+ __vue_template__ = __webpack_require__ ( 3 )
103+ module . exports = __vue_script__ || { }
104+ if ( module . exports . __esModule ) module . exports = module . exports . default
105+ if ( __vue_template__ ) {
106+ ( typeof module . exports === "function" ? ( module . exports . options || ( module . exports . options = { } ) ) : module . exports ) . template = __vue_template__
107+ }
108+ if ( false ) { ( function ( ) { module . hot . accept ( )
109+ var hotAPI = require ( "vue-hot-reload-api" )
110+ hotAPI . install ( require ( "vue" ) , true )
111+ if ( ! hotAPI . compatible ) return
112+ var id = "/Users/eduardostuart/Code/Projects/vue-image-loader/src/VueImageLoader.vue"
113+ if ( ! module . hot . data ) {
114+ hotAPI . createRecord ( id , module . exports )
115+ } else {
116+ hotAPI . update ( id , module . exports , __vue_template__ )
117+ }
118+ } ) ( ) }
119+
120+ /***/ } ,
121+ /* 2 */
122+ /***/ function ( module , exports ) {
123+
124+ 'use strict' ;
125+
126+ Object . defineProperty ( exports , "__esModule" , {
127+ value : true
128+ } ) ;
129+ exports . default = {
130+ props : {
131+ src : {
132+ type : String ,
133+ required : true
134+ } ,
135+ alt : {
136+ type : String ,
137+ default : ''
138+ }
139+ } ,
140+ data : function data ( ) {
141+ return {
142+ isLoading : false ,
143+ success : false
144+ } ;
145+ } ,
146+ ready : function ready ( ) {
147+ var image = this . $els . image ;
148+
149+ this . isLoading = true ;
150+
151+ if ( this . timeout !== null ) {
152+ this . defineTimeout ( ) ;
153+ }
154+
155+ image . onload = this . onLoad . bind ( this ) ;
156+ image . onerror = image . onabort = this . onFail . bind ( this ) ;
157+ } ,
158+
159+ methods : {
160+ defineTimeout : function defineTimeout ( ) {
161+
162+ if ( typeof this . timer !== 'undefined' ) {
163+ clearTimeout ( this . timer ) ;
164+ }
165+
166+ this . timer = setTimeout ( this . checkTimeout . bind ( this ) , this . timeout * 1000 ) ;
167+ } ,
168+ checkTimeout : function checkTimeout ( ) {
169+ if ( ! this . success ) {
170+ this . $dispatch ( 'imageloader.fail' , this . $els . image ) ;
171+ this . $els . image . setAttribute ( 'src' , '' ) ;
172+ }
173+ } ,
174+ onLoad : function onLoad ( res ) {
175+ this . $dispatch ( 'imageloader.success' , this . $els . image ) ;
176+ this . isLoading = false ;
177+ this . success = true ;
178+ } ,
179+ onFail : function onFail ( ) {
180+ this . isLoading = false ;
181+ this . success = false ;
182+ }
183+ }
184+ } ;
185+
186+ /***/ } ,
187+ /* 3 */
188+ /***/ function ( module , exports ) {
189+
190+ module . exports = "\n<div class=\"image-loader\">\n <div class=\"image-loader-info\" v-if=\"loadInfo && isLoading\">{{ loadInfo }}</div>\n <div class=\"image-loader-error\" v-if=\"loadError && !success\">{{ loadError }}</div>\n <img v-bind='{\"src\":src,\"alt\":alt}' v-el:image class=\"image\" v-show=\"!isLoading && success\">\n</div>\n" ;
191+
192+ /***/ }
193+ /******/ ] )
194+ } ) ;
195+ ;
0 commit comments