From 7dbf99a3251cddd9398da13a421ab94042fc4534 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 09:21:11 +1100 Subject: [PATCH 01/13] Passthrough of class for image using imgAttributes --- src/components/img-loader.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index 4203b3e..b9f2721 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -58,6 +58,12 @@ export class ImgLoader implements OnInit { private _useImg: boolean = this._config.useImg; + + /** + * Attributes to pass through to img tag if _useImg == true + */ + @Input('imgAttributes') imgAttributes: string = ""; + /** * Convenience attribute to disable caching * @param val @@ -197,6 +203,11 @@ export class ImgLoader implements OnInit { // set it's src this._renderer.setElementAttribute(this.element, 'src', imageUrl); + // if imgAttributes are defined, add them here + if (this.imgAttributes != '') { + this._renderer.setElementAttribute(this.element, 'class', this.imgAttributes); + } + if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', () => this._renderer.setElementAttribute(this.element, 'src', this.fallbackUrl)); From e0664d3622b87af2f9d8f747b6a3527a99f63e82 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 09:54:01 +1100 Subject: [PATCH 02/13] Passthrough of class attribute for _useImg --- .gitignore | 1 - ionic-image-loader/ionic-image-loader.component.js | 12 ++++++++++++ ionic-image-loader/ionic-image-loader.html | 1 + ionic-image-loader/ionic-image-loader.scss | 2 ++ package.json | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 ionic-image-loader/ionic-image-loader.component.js create mode 100644 ionic-image-loader/ionic-image-loader.html create mode 100644 ionic-image-loader/ionic-image-loader.scss diff --git a/.gitignore b/.gitignore index 31c9f78..b41bc25 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ node_modules aot -dist .idea diff --git a/ionic-image-loader/ionic-image-loader.component.js b/ionic-image-loader/ionic-image-loader.component.js new file mode 100644 index 0000000..1045e49 --- /dev/null +++ b/ionic-image-loader/ionic-image-loader.component.js @@ -0,0 +1,12 @@ +class IonicImageLoaderController { + constructor() { + } +} + +export default { + controller: IonicImageLoaderController, + template: require('./ionic-image-loader.html'), + bindings: { + + } +}; \ No newline at end of file diff --git a/ionic-image-loader/ionic-image-loader.html b/ionic-image-loader/ionic-image-loader.html new file mode 100644 index 0000000..281c686 --- /dev/null +++ b/ionic-image-loader/ionic-image-loader.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/ionic-image-loader/ionic-image-loader.scss b/ionic-image-loader/ionic-image-loader.scss new file mode 100644 index 0000000..d9151ff --- /dev/null +++ b/ionic-image-loader/ionic-image-loader.scss @@ -0,0 +1,2 @@ +ionic-image-loader { +} \ No newline at end of file diff --git a/package.json b/package.json index 44f5f5a..1dae71a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-image-loader", - "version": "4.2.1", + "version": "4.2.2", "description": "Ionic Component and Service to load images in a background thread and cache them for later use", "main": "dist/index.js", "typings": "dist/index.d.ts", From b2fcf3d1bf8e6d3c865563afa1849fe5398eb625 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 09:56:02 +1100 Subject: [PATCH 03/13] Build for deployment --- dist/components/img-loader.d.ts | 97 ++++ dist/components/img-loader.js | 229 ++++++++ dist/components/img-loader.js.map | 1 + dist/components/img-loader.metadata.json | 1 + dist/image-loader.module.d.ts | 4 + dist/image-loader.module.js | 40 ++ dist/image-loader.module.js.map | 1 + dist/image-loader.module.metadata.json | 1 + dist/index.d.ts | 4 + dist/index.js | 5 + dist/index.js.map | 1 + dist/index.metadata.json | 1 + dist/providers/image-loader-config.d.ts | 114 ++++ dist/providers/image-loader-config.js | 167 ++++++ dist/providers/image-loader-config.js.map | 1 + .../image-loader-config.metadata.json | 1 + dist/providers/image-loader.d.ts | 144 +++++ dist/providers/image-loader.js | 541 ++++++++++++++++++ dist/providers/image-loader.js.map | 1 + dist/providers/image-loader.metadata.json | 1 + package-lock.json | 30 +- 21 files changed, 1370 insertions(+), 15 deletions(-) create mode 100644 dist/components/img-loader.d.ts create mode 100644 dist/components/img-loader.js create mode 100644 dist/components/img-loader.js.map create mode 100644 dist/components/img-loader.metadata.json create mode 100644 dist/image-loader.module.d.ts create mode 100644 dist/image-loader.module.js create mode 100644 dist/image-loader.module.js.map create mode 100644 dist/image-loader.module.metadata.json create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/index.metadata.json create mode 100644 dist/providers/image-loader-config.d.ts create mode 100644 dist/providers/image-loader-config.js create mode 100644 dist/providers/image-loader-config.js.map create mode 100644 dist/providers/image-loader-config.metadata.json create mode 100644 dist/providers/image-loader.d.ts create mode 100644 dist/providers/image-loader.js create mode 100644 dist/providers/image-loader.js.map create mode 100644 dist/providers/image-loader.metadata.json diff --git a/dist/components/img-loader.d.ts b/dist/components/img-loader.d.ts new file mode 100644 index 0000000..113457f --- /dev/null +++ b/dist/components/img-loader.d.ts @@ -0,0 +1,97 @@ +import { ElementRef, Renderer, OnInit, EventEmitter } from '@angular/core'; +import { ImageLoader } from '../providers/image-loader'; +import { ImageLoaderConfig } from '../providers/image-loader-config'; +export declare class ImgLoader implements OnInit { + private _element; + private _renderer; + private _imageLoader; + private _config; + /** + * The URL of the image to load. + */ + src: string; + private _src; + /** + * Fallback URL to load when the image url fails to load or does not exist. + */ + fallbackUrl: string; + /** + * Whether to show a spinner while the image loads + */ + spinner: boolean; + /** + * Whether to show the fallback image instead of a spinner while the image loads + */ + fallbackAsPlaceholder: boolean; + /** + * Use tag + */ + useImg: boolean; + private _useImg; + /** + * Attributes to pass through to img tag if _useImg == true + */ + imgAttributes: string; + /** + * Convenience attribute to disable caching + * @param val + */ + noCache: boolean; + /** + * Enable/Disable caching + * @type {boolean} + */ + cache: boolean; + /** + * Width of the image. This will be ignored if using useImg. + */ + width: string; + /** + * Height of the image. This will be ignored if using useImg. + */ + height: string; + /** + * Display type of the image. This will be ignored if using useImg. + */ + display: string; + /** + * Background size. This will be ignored if using useImg. + */ + backgroundSize: string; + /** + * Background repeat. This will be ignored if using useImg. + */ + backgroundRepeat: string; + /** + * Name of the spinner + */ + spinnerName: string; + /** + * Color of the spinner + */ + spinnerColor: string; + /** + * Notify on image load.. + */ + load: EventEmitter; + /** + * Indicates if the image is still loading + * @type {boolean} + */ + isLoading: boolean; + element: HTMLElement; + constructor(_element: ElementRef, _renderer: Renderer, _imageLoader: ImageLoader, _config: ImageLoaderConfig); + ngOnInit(): void; + private updateImage(imageUrl); + /** + * Gets the image URL to be loaded and disables caching if necessary + * @returns {string} + */ + private processImageUrl(imageUrl); + /** + * Set the image to be displayed + * @param imageUrl {string} image src + * @param stopLoading {boolean} set to true to mark the image as loaded + */ + private setImage(imageUrl, stopLoading?); +} diff --git a/dist/components/img-loader.js b/dist/components/img-loader.js new file mode 100644 index 0000000..4e717e8 --- /dev/null +++ b/dist/components/img-loader.js @@ -0,0 +1,229 @@ +import { Component, Input, Output, ElementRef, Renderer, EventEmitter } from '@angular/core'; +import { ImageLoader } from '../providers/image-loader'; +import { ImageLoaderConfig } from '../providers/image-loader-config'; +var propMap = { + display: 'display', + height: 'height', + width: 'width', + backgroundSize: 'background-size', + backgroundRepeat: 'background-repeat' +}; +var ImgLoader = (function () { + function ImgLoader(_element, _renderer, _imageLoader, _config) { + this._element = _element; + this._renderer = _renderer; + this._imageLoader = _imageLoader; + this._config = _config; + /** + * Fallback URL to load when the image url fails to load or does not exist. + */ + this.fallbackUrl = this._config.fallbackUrl; + /** + * Whether to show a spinner while the image loads + */ + this.spinner = this._config.spinnerEnabled; + /** + * Whether to show the fallback image instead of a spinner while the image loads + */ + this.fallbackAsPlaceholder = this._config.fallbackAsPlaceholder; + this._useImg = this._config.useImg; + /** + * Attributes to pass through to img tag if _useImg == true + */ + this.imgAttributes = ""; + /** + * Enable/Disable caching + * @type {boolean} + */ + this.cache = true; + /** + * Width of the image. This will be ignored if using useImg. + */ + this.width = this._config.width; + /** + * Height of the image. This will be ignored if using useImg. + */ + this.height = this._config.height; + /** + * Display type of the image. This will be ignored if using useImg. + */ + this.display = this._config.display; + /** + * Background size. This will be ignored if using useImg. + */ + this.backgroundSize = this._config.backgroundSize; + /** + * Background repeat. This will be ignored if using useImg. + */ + this.backgroundRepeat = this._config.backgroundRepeat; + /** + * Name of the spinner + */ + this.spinnerName = this._config.spinnerName; + /** + * Color of the spinner + */ + this.spinnerColor = this._config.spinnerColor; + /** + * Notify on image load.. + */ + this.load = new EventEmitter(); + /** + * Indicates if the image is still loading + * @type {boolean} + */ + this.isLoading = true; + } + Object.defineProperty(ImgLoader.prototype, "src", { + get: function () { + return this._src; + }, + /** + * The URL of the image to load. + */ + set: function (imageUrl) { + this._src = this.processImageUrl(imageUrl); + this.updateImage(this._src); + }, + enumerable: true, + configurable: true + }); + ; + Object.defineProperty(ImgLoader.prototype, "useImg", { + /** + * Use tag + */ + set: function (val) { + this._useImg = val !== false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ImgLoader.prototype, "noCache", { + /** + * Convenience attribute to disable caching + * @param val + */ + set: function (val) { + this.cache = val !== false; + }, + enumerable: true, + configurable: true + }); + ImgLoader.prototype.ngOnInit = function () { + if (this.fallbackAsPlaceholder && this.fallbackUrl) { + this.setImage(this.fallbackUrl, false); + } + if (!this.src) { + // image url was not passed + // this can happen when [src] is set to a variable that turned out to be undefined + // one example could be a list of users with their profile pictures + // in this case, it would be useful to use the fallback image instead + // if fallbackUrl was used as placeholder we do not need to set it again + if (!this.fallbackAsPlaceholder && this.fallbackUrl) { + // we're not going to cache the fallback image since it should be locally saved + this.setImage(this.fallbackUrl); + } + else { + this.isLoading = false; + } + } + }; + ImgLoader.prototype.updateImage = function (imageUrl) { + var _this = this; + this._imageLoader.getImagePath(imageUrl) + .then(function (imageUrl) { return _this.setImage(imageUrl); }) + .catch(function (error) { return _this.setImage(_this.fallbackUrl || imageUrl); }); + }; + /** + * Gets the image URL to be loaded and disables caching if necessary + * @returns {string} + */ + ImgLoader.prototype.processImageUrl = function (imageUrl) { + if (this.cache === false) { + // need to disable caching + if (imageUrl.indexOf('?') === -1) { + imageUrl += '?'; + } + if (['&', '?'].indexOf(imageUrl.charAt(imageUrl.length)) === -1) { + imageUrl += '&'; + } + // append timestamp at the end to make URL unique + imageUrl += 'cache_buster=' + Date.now(); + } + return imageUrl; + }; + /** + * Set the image to be displayed + * @param imageUrl {string} image src + * @param stopLoading {boolean} set to true to mark the image as loaded + */ + ImgLoader.prototype.setImage = function (imageUrl, stopLoading) { + var _this = this; + if (stopLoading === void 0) { stopLoading = true; } + this.isLoading = !stopLoading; + if (this._useImg) { + // Using tag + if (!this.element) { + // create img element if we dont have one + this.element = this._renderer.createElement(this._element.nativeElement, 'img'); + } + // set it's src + this._renderer.setElementAttribute(this.element, 'src', imageUrl); + // if imgAttributes are defined, add them here + if (this.imgAttributes != '') { + this._renderer.setElementAttribute(this.element, 'class', this.imgAttributes); + } + if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { + this._renderer.listen(this.element, 'error', function () { return _this._renderer.setElementAttribute(_this.element, 'src', _this.fallbackUrl); }); + } + } + else { + // Not using tag + this.element = this._element.nativeElement; + for (var prop in propMap) { + if (this[prop]) { + this._renderer.setElementStyle(this.element, propMap[prop], this[prop]); + } + } + this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + (imageUrl || this.fallbackUrl) + '\')'); + } + this.load.emit(this); + }; + return ImgLoader; +}()); +export { ImgLoader }; +ImgLoader.decorators = [ + { type: Component, args: [{ + selector: 'img-loader', + template: '' + + '', + styles: ['ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }'] + },] }, +]; +/** @nocollapse */ +ImgLoader.ctorParameters = function () { return [ + { type: ElementRef, }, + { type: Renderer, }, + { type: ImageLoader, }, + { type: ImageLoaderConfig, }, +]; }; +ImgLoader.propDecorators = { + 'src': [{ type: Input },], + 'fallbackUrl': [{ type: Input, args: ['fallback',] },], + 'spinner': [{ type: Input },], + 'fallbackAsPlaceholder': [{ type: Input },], + 'useImg': [{ type: Input },], + 'imgAttributes': [{ type: Input, args: ['imgAttributes',] },], + 'noCache': [{ type: Input },], + 'cache': [{ type: Input },], + 'width': [{ type: Input },], + 'height': [{ type: Input },], + 'display': [{ type: Input },], + 'backgroundSize': [{ type: Input },], + 'backgroundRepeat': [{ type: Input },], + 'spinnerName': [{ type: Input },], + 'spinnerColor': [{ type: Input },], + 'load': [{ type: Output },], +}; +//# sourceMappingURL=img-loader.js.map \ No newline at end of file diff --git a/dist/components/img-loader.js.map b/dist/components/img-loader.js.map new file mode 100644 index 0000000..3521491 --- /dev/null +++ b/dist/components/img-loader.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/components/img-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAkB,YAAA,EAAa,MAAO,eAAA,CAAgB;AACrG,OAAO,EAAE,WAAA,EAAY,MAAO,2BAAA,CAA4B;AACxD,OAAO,EAAE,iBAAA,EAAkB,MAAO,kCAAA,CAAmC;AAErE,IAAM,OAAA,GAAe;IACnB,OAAO,EAAE,SAAA;IACT,MAAM,EAAE,QAAA;IACR,KAAK,EAAE,OAAA;IACP,cAAc,EAAE,iBAAA;IAChB,gBAAgB,EAAE,mBAAA;CACnB,CAAC;AAGF;IAgHE,mBACU,QAAoB,EACpB,SAAmB,EACnB,YAAyB,EACzB,OAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,iBAAY,GAAZ,YAAY,CAAa;QACzB,YAAO,GAAP,OAAO,CAAmB;QAnGpC;;WAEG;QACF,gBAAW,GAAW,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAEhD;;WAEG;QACF,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAEhD;;WAEG;QACF,0BAAqB,G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EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/components/img-loader.metadata.json b/dist/components/img-loader.metadata.json new file mode 100644 index 0000000..3c493e0 --- /dev/null +++ b/dist/components/img-loader.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"ImgLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"img-loader","template":"","styles":["ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }"]}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackUrl":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["fallback"]}]}],"spinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackAsPlaceholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"useImg":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"imgAttributes":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["imgAttributes"]}]}],"noCache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"cache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"width":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"display":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundSize":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundRepeat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerColor":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"load":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"../providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"../providers/image-loader-config","name":"ImageLoaderConfig"}]}],"ngOnInit":[{"__symbolic":"method"}],"updateImage":[{"__symbolic":"method"}],"processImageUrl":[{"__symbolic":"method"}],"setImage":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImgLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"img-loader","template":"","styles":["ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }"]}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackUrl":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["fallback"]}]}],"spinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackAsPlaceholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"useImg":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"imgAttributes":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["imgAttributes"]}]}],"noCache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"cache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"width":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"display":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundSize":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundRepeat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerColor":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"load":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"../providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"../providers/image-loader-config","name":"ImageLoaderConfig"}]}],"ngOnInit":[{"__symbolic":"method"}],"updateImage":[{"__symbolic":"method"}],"processImageUrl":[{"__symbolic":"method"}],"setImage":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/dist/image-loader.module.d.ts b/dist/image-loader.module.d.ts new file mode 100644 index 0000000..5c64f81 --- /dev/null +++ b/dist/image-loader.module.d.ts @@ -0,0 +1,4 @@ +import { ModuleWithProviders } from '@angular/core'; +export declare class IonicImageLoader { + static forRoot(): ModuleWithProviders; +} diff --git a/dist/image-loader.module.js b/dist/image-loader.module.js new file mode 100644 index 0000000..bcd36f6 --- /dev/null +++ b/dist/image-loader.module.js @@ -0,0 +1,40 @@ +import { NgModule } from '@angular/core'; +import { ImgLoader } from './components/img-loader'; +import { ImageLoader } from './providers/image-loader'; +import { ImageLoaderConfig } from './providers/image-loader-config'; +import { IonicModule } from 'ionic-angular'; +import { File } from '@ionic-native/file'; +import { FileTransfer } from '@ionic-native/file-transfer'; +var IonicImageLoader = (function () { + function IonicImageLoader() { + } + IonicImageLoader.forRoot = function () { + return { + ngModule: IonicImageLoader, + providers: [ + ImageLoaderConfig, + ImageLoader, + File, + FileTransfer + ] + }; + }; + return IonicImageLoader; +}()); +export { IonicImageLoader }; +IonicImageLoader.decorators = [ + { type: NgModule, args: [{ + declarations: [ + ImgLoader + ], + imports: [ + IonicModule + ], + exports: [ + ImgLoader + ] + },] }, +]; +/** @nocollapse */ +IonicImageLoader.ctorParameters = function () { return []; }; +//# sourceMappingURL=image-loader.module.js.map \ No newline at end of file diff --git a/dist/image-loader.module.js.map b/dist/image-loader.module.js.map new file mode 100644 index 0000000..a5f441a --- /dev/null +++ b/dist/image-loader.module.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/image-loader.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAA,EAA8B,MAAO,eAAA,CAAgB;AAC9D,OAAO,EAAE,SAAA,EAAU,MAAO,yBAAA,CAA0B;AACpD,OAAO,EAAE,WAAA,EAAY,MAAO,0BAAA,CAA2B;AACvD,OAAO,EAAE,iBAAA,EAAkB,MAAO,iCAAA,CAAkC;AACpE,OAAO,EAAE,WAAA,EAAY,MAAO,eAAA,CAAgB;AAC5C,OAAO,EAAE,IAAA,EAAK,MAAO,oBAAA,CAAqB;AAC1C,OAAO,EAAE,YAAA,EAAa,MAAO,6BAAA,CAA8B;AAG3D;IAAA;IA4BA,CAAC;IA3BQ,wBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE;gBACT,iBAAiB;gBACjB,WAAW;gBACX,IAAI;gBACJ,YAAY;aACb;SACF,CAAC;IACJ,CAAC;IAiBH,uBAAC;AAAD,CA5BA,AA4BC;;AAhBM,2BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvB,YAAY,EAAE;oBACZ,SAAS;iBACV;gBACD,OAAO,EAAE;oBACP,WAAW;iBACZ;gBACD,OAAO,EAAE;oBACP,SAAS;iBACV;aACF,EAAG,EAAE;CACL,CAAC;AACF,kBAAkB;AACX,+BAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader.module.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/image-loader.module.metadata.json b/dist/image-loader.module.metadata.json new file mode 100644 index 0000000..cde94e3 --- /dev/null +++ b/dist/image-loader.module.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"IonicImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}],"imports":[{"__symbolic":"reference","module":"ionic-angular","name":"IonicModule"}],"exports":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"IonicImageLoader"},"providers":[{"__symbolic":"reference","module":"./providers/image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"./providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"}]}}}}}},{"__symbolic":"module","version":1,"metadata":{"IonicImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}],"imports":[{"__symbolic":"reference","module":"ionic-angular","name":"IonicModule"}],"exports":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"IonicImageLoader"},"providers":[{"__symbolic":"reference","module":"./providers/image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"./providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"}]}}}}}}] \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..251e5dd --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,4 @@ +export * from './image-loader.module'; +export * from './components/img-loader'; +export * from './providers/image-loader-config'; +export * from './providers/image-loader'; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..e0eb36e --- /dev/null +++ b/dist/index.js @@ -0,0 +1,5 @@ +export * from './image-loader.module'; +export * from './components/img-loader'; +export * from './providers/image-loader-config'; +export * from './providers/image-loader'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..c09b3fc --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC","file":"index.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/index.metadata.json b/dist/index.metadata.json new file mode 100644 index 0000000..b590e34 --- /dev/null +++ b/dist/index.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./providers/image-loader"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./providers/image-loader"}]}] \ No newline at end of file diff --git a/dist/providers/image-loader-config.d.ts b/dist/providers/image-loader-config.d.ts new file mode 100644 index 0000000..2c8557c --- /dev/null +++ b/dist/providers/image-loader-config.d.ts @@ -0,0 +1,114 @@ +export declare class ImageLoaderConfig { + debugMode: boolean; + spinnerEnabled: boolean; + fallbackAsPlaceholder: boolean; + backgroundSize: string; + backgroundRepeat: string; + display: string; + width: string; + height: string; + useImg: boolean; + fallbackUrl: string; + concurrency: number; + maxCacheSize: number; + maxCacheAge: number; + imageReturnType: 'base64' | 'uri'; + spinnerName: string; + spinnerColor: string; + fileTransferOptions: any; + private _cacheDirectoryName; + cacheDirectoryName: string; + /** + * Enables debug mode to receive console logs, errors, warnings + */ + enableDebugMode(): void; + /** + * Enable/Disable the spinner by default. Defaults to true. + * @param enable {boolean} set to true to enable + */ + enableSpinner(enable: boolean): void; + /** + * Enable/Disable the fallback image as placeholder instead of the spinner. Defaults to false. + * @param enable {boolean} set to true to enable + */ + enableFallbackAsPlaceholder(enable: boolean): void; + /** + * Sets the cache directory name. Defaults to 'image-loader-cache' + * @param name {string} name of directory + */ + setCacheDirectoryName(name: string): void; + /** + * Set default height for images that are not using tag + * @param height {string} height + */ + setHeight(height: string): void; + /** + * Set default width for images that are not using tag + * @param width {string} Width + */ + setWidth(width: string): void; + /** + * Enable display mode for images that are not using tag + * @param display {string} Display mode + */ + setDisplay(display: string): void; + /** + * Use tag by default + * @param use {boolean} set to true to use tag by default + */ + useImageTag(use: boolean): void; + /** + * Set default background size for images that are not using tag + * @param backgroundSize {string} Background size + */ + setBackgroundSize(backgroundSize: string): void; + /** + * Set background repeat for images that are not using tag + * @param backgroundRepeat {string} Background repeat + */ + setBackgroundRepeat(backgroundRepeat: string): void; + /** + * Set fallback URL to use when image src is undefined or did not resolve. + * This image will not be cached. This should ideally be a locally saved image. + * @param fallbackUrl {string} The remote or local URL of the image + */ + setFallbackUrl(fallbackUrl: string): void; + /** + * Set the maximum number of allowed connections at the same time. + * @param concurrency + */ + setConcurrency(concurrency: number): void; + /** + * Sets the maximum allowed cache size + * @param cacheSize {number} Cache size in bytes + */ + setMaximumCacheSize(cacheSize: number): void; + /** + * Sets the maximum allowed cache age + * @param cacheAge {number} Maximum cache age in milliseconds + */ + setMaximumCacheAge(cacheAge: number): void; + /** + * Set the return type of cached images + * @param imageReturnType {string} The return type; either 'base64' or 'uri' + */ + setImageReturnType(imageReturnType: 'base64' | 'uri'): void; + /** + * Set the default spinnern ame + * @param name + */ + setSpinnerName(name: string): void; + /** + * Set the default spinner color + * @param color + */ + setSpinnerColor(color: string): void; + /** + * Set options for the FileTransfer plugin + * @param options + */ + setFileTransferOptions(options: { + trustAllHosts: boolean; + [key: string]: any; + }): void; +} diff --git a/dist/providers/image-loader-config.js b/dist/providers/image-loader-config.js new file mode 100644 index 0000000..b145097 --- /dev/null +++ b/dist/providers/image-loader-config.js @@ -0,0 +1,167 @@ +import { Injectable } from '@angular/core'; +var ImageLoaderConfig = (function () { + function ImageLoaderConfig() { + this.debugMode = false; + this.spinnerEnabled = true; + this.fallbackAsPlaceholder = false; + this.backgroundSize = 'contain'; + this.backgroundRepeat = 'no-repeat'; + this.display = 'block'; + this.width = '100%'; + this.height = '100%'; + this.useImg = false; + this.concurrency = 5; + this.maxCacheSize = -1; + this.maxCacheAge = -1; + this.imageReturnType = 'uri'; + this.fileTransferOptions = { + trustAllHosts: false + }; + this._cacheDirectoryName = 'image-loader-cache'; + } + Object.defineProperty(ImageLoaderConfig.prototype, "cacheDirectoryName", { + get: function () { + return this._cacheDirectoryName; + }, + set: function (name) { + name.replace(/\W/g, ''); + this._cacheDirectoryName = name; + }, + enumerable: true, + configurable: true + }); + /** + * Enables debug mode to receive console logs, errors, warnings + */ + ImageLoaderConfig.prototype.enableDebugMode = function () { + this.debugMode = true; + }; + /** + * Enable/Disable the spinner by default. Defaults to true. + * @param enable {boolean} set to true to enable + */ + ImageLoaderConfig.prototype.enableSpinner = function (enable) { + this.spinnerEnabled = enable; + }; + /** + * Enable/Disable the fallback image as placeholder instead of the spinner. Defaults to false. + * @param enable {boolean} set to true to enable + */ + ImageLoaderConfig.prototype.enableFallbackAsPlaceholder = function (enable) { + this.fallbackAsPlaceholder = enable; + }; + /** + * Sets the cache directory name. Defaults to 'image-loader-cache' + * @param name {string} name of directory + */ + ImageLoaderConfig.prototype.setCacheDirectoryName = function (name) { + this.cacheDirectoryName = name; + }; + /** + * Set default height for images that are not using tag + * @param height {string} height + */ + ImageLoaderConfig.prototype.setHeight = function (height) { + this.height = height; + }; + /** + * Set default width for images that are not using tag + * @param width {string} Width + */ + ImageLoaderConfig.prototype.setWidth = function (width) { + this.width = width; + }; + /** + * Enable display mode for images that are not using tag + * @param display {string} Display mode + */ + ImageLoaderConfig.prototype.setDisplay = function (display) { + this.display = display; + }; + /** + * Use tag by default + * @param use {boolean} set to true to use tag by default + */ + ImageLoaderConfig.prototype.useImageTag = function (use) { + this.useImg = use; + }; + /** + * Set default background size for images that are not using tag + * @param backgroundSize {string} Background size + */ + ImageLoaderConfig.prototype.setBackgroundSize = function (backgroundSize) { + this.backgroundSize = backgroundSize; + }; + /** + * Set background repeat for images that are not using tag + * @param backgroundRepeat {string} Background repeat + */ + ImageLoaderConfig.prototype.setBackgroundRepeat = function (backgroundRepeat) { + this.backgroundRepeat = backgroundRepeat; + }; + /** + * Set fallback URL to use when image src is undefined or did not resolve. + * This image will not be cached. This should ideally be a locally saved image. + * @param fallbackUrl {string} The remote or local URL of the image + */ + ImageLoaderConfig.prototype.setFallbackUrl = function (fallbackUrl) { + this.fallbackUrl = fallbackUrl; + }; + /** + * Set the maximum number of allowed connections at the same time. + * @param concurrency + */ + ImageLoaderConfig.prototype.setConcurrency = function (concurrency) { + this.concurrency = concurrency; + }; + /** + * Sets the maximum allowed cache size + * @param cacheSize {number} Cache size in bytes + */ + ImageLoaderConfig.prototype.setMaximumCacheSize = function (cacheSize) { + this.maxCacheSize = cacheSize; + }; + /** + * Sets the maximum allowed cache age + * @param cacheAge {number} Maximum cache age in milliseconds + */ + ImageLoaderConfig.prototype.setMaximumCacheAge = function (cacheAge) { + this.maxCacheAge = cacheAge; + }; + /** + * Set the return type of cached images + * @param imageReturnType {string} The return type; either 'base64' or 'uri' + */ + ImageLoaderConfig.prototype.setImageReturnType = function (imageReturnType) { + this.imageReturnType = imageReturnType; + }; + /** + * Set the default spinnern ame + * @param name + */ + ImageLoaderConfig.prototype.setSpinnerName = function (name) { + this.spinnerName = name; + }; + /** + * Set the default spinner color + * @param color + */ + ImageLoaderConfig.prototype.setSpinnerColor = function (color) { + this.spinnerColor = color; + }; + /** + * Set options for the FileTransfer plugin + * @param options + */ + ImageLoaderConfig.prototype.setFileTransferOptions = function (options) { + this.fileTransferOptions = options; + }; + return ImageLoaderConfig; +}()); +export { ImageLoaderConfig }; +ImageLoaderConfig.decorators = [ + { type: Injectable }, +]; +/** @nocollapse */ +ImageLoaderConfig.ctorParameters = function () { return []; }; +//# sourceMappingURL=image-loader-config.js.map \ No newline at end of file diff --git a/dist/providers/image-loader-config.js.map b/dist/providers/image-loader-config.js.map new file mode 100644 index 0000000..99e49ce --- /dev/null +++ b/dist/providers/image-loader-config.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/providers/image-loader-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAA,EAAW,MAAO,eAAA,CAAgB;AAG3C;IAAA;QAEE,cAAS,GAAY,KAAK,CAAC;QAE3B,mBAAc,GAAY,IAAI,CAAC;QAE/B,0BAAqB,GAAY,KAAK,CAAC;QAEvC,mBAAc,GAAW,SAAS,CAAC;QAEnC,qBAAgB,GAAW,WAAW,CAAC;QAEvC,YAAO,GAAW,OAAO,CAAC;QAE1B,UAAK,GAAW,MAAM,CAAC;QAEvB,WAAM,GAAW,MAAM,CAAC;QAExB,WAAM,GAAY,KAAK,CAAC;QAIxB,gBAAW,GAAW,CAAC,CAAC;QAExB,iBAAY,GAAW,CAAC,CAAC,CAAC;QAE1B,gBAAW,GAAW,CAAC,CAAC,CAAC;QAEzB,oBAAe,GAAqB,KAAK,CAAC;QAM1C,wBAAmB,GAAQ;YACzB,aAAa,EAAE,KAAK;SACrB,CAAC;QAEM,wBAAmB,GAAW,oBAAoB,CAAC;IAiK7D,CAAC;IA/JC,sBAAI,iDAAkB;aAKtB;YACE,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC;QAClC,CAAC;aAPD,UAAuB,IAAY;YACjC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAClC,CAAC;;;OAAA;IAMD;;OAEG;IACH,2CAAe,GAAf;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,yCAAa,GAAb,UAAc,MAAe;QAC3B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,uDAA2B,GAA3B,UAA4B,MAAe;QACzC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC;IACtC,CAAC;IAED;;;OA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Ad,UAAe,IAAY;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,2CAAe,GAAf,UAAgB,KAAa;QAC3B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,kDAAsB,GAAtB,UAAuB,OAAwD;QAC7E,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC;IACrC,CAAC;IAQH,wBAAC;AAAD,CAvMA,AAuMC;;AANM,4BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,UAAU,EAAE;CACnB,CAAC;AACF,kBAAkB;AACX,gCAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader-config.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/providers/image-loader-config.metadata.json b/dist/providers/image-loader-config.metadata.json new file mode 100644 index 0000000..7bdd35d --- /dev/null +++ b/dist/providers/image-loader-config.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"ImageLoaderConfig":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"enableDebugMode":[{"__symbolic":"method"}],"enableSpinner":[{"__symbolic":"method"}],"enableFallbackAsPlaceholder":[{"__symbolic":"method"}],"setCacheDirectoryName":[{"__symbolic":"method"}],"setHeight":[{"__symbolic":"method"}],"setWidth":[{"__symbolic":"method"}],"setDisplay":[{"__symbolic":"method"}],"useImageTag":[{"__symbolic":"method"}],"setBackgroundSize":[{"__symbolic":"method"}],"setBackgroundRepeat":[{"__symbolic":"method"}],"setFallbackUrl":[{"__symbolic":"method"}],"setConcurrency":[{"__symbolic":"method"}],"setMaximumCacheSize":[{"__symbolic":"method"}],"setMaximumCacheAge":[{"__symbolic":"method"}],"setImageReturnType":[{"__symbolic":"method"}],"setSpinnerName":[{"__symbolic":"method"}],"setSpinnerColor":[{"__symbolic":"method"}],"setFileTransferOptions":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImageLoaderConfig":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"enableDebugMode":[{"__symbolic":"method"}],"enableSpinner":[{"__symbolic":"method"}],"enableFallbackAsPlaceholder":[{"__symbolic":"method"}],"setCacheDirectoryName":[{"__symbolic":"method"}],"setHeight":[{"__symbolic":"method"}],"setWidth":[{"__symbolic":"method"}],"setDisplay":[{"__symbolic":"method"}],"useImageTag":[{"__symbolic":"method"}],"setBackgroundSize":[{"__symbolic":"method"}],"setBackgroundRepeat":[{"__symbolic":"method"}],"setFallbackUrl":[{"__symbolic":"method"}],"setConcurrency":[{"__symbolic":"method"}],"setMaximumCacheSize":[{"__symbolic":"method"}],"setMaximumCacheAge":[{"__symbolic":"method"}],"setImageReturnType":[{"__symbolic":"method"}],"setSpinnerName":[{"__symbolic":"method"}],"setSpinnerColor":[{"__symbolic":"method"}],"setFileTransferOptions":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/dist/providers/image-loader.d.ts b/dist/providers/image-loader.d.ts new file mode 100644 index 0000000..32875a8 --- /dev/null +++ b/dist/providers/image-loader.d.ts @@ -0,0 +1,144 @@ +import { File } from '@ionic-native/file'; +import { FileTransfer } from '@ionic-native/file-transfer'; +import { ImageLoaderConfig } from "./image-loader-config"; +import { Platform } from 'ionic-angular'; +import 'rxjs/add/operator/first'; +export declare class ImageLoader { + private config; + private file; + private fileTransfer; + private platform; + readonly nativeAvailable: boolean; + /** + * Indicates if the cache service is ready. + * When the cache service isn't ready, images are loaded via browser instead. + * @type {boolean} + */ + private isCacheReady; + /** + * Indicates if this service is initialized. + * This service is initialized once all the setup is done. + * @type {boolean} + */ + private isInit; + /** + * Number of concurrent requests allowed + * @type {number} + */ + private concurrency; + /** + * Queue items + * @type {Array} + */ + private queue; + private transferInstances; + private processing; + private cacheIndex; + private currentCacheSize; + private indexed; + private readonly shouldIndex; + private readonly isWKWebView; + private readonly isIonicWKWebView; + constructor(config: ImageLoaderConfig, file: File, fileTransfer: FileTransfer, platform: Platform); + /** + * Preload an image + * @param imageUrl {string} Image URL + * @returns {Promise} returns a promise that resolves with the cached image URL + */ + preload(imageUrl: string): Promise; + /** + * Clears the cache + */ + clearCache(): void; + /** + * Gets the filesystem path of an image. + * This will return the remote path if anything goes wrong or if the cache service isn't ready yet. + * @param imageUrl {string} The remote URL of the image + * @returns {Promise} Returns a promise that will always resolve with an image URL + */ + getImagePath(imageUrl: string): Promise; + /** + * Add an item to the queue + * @param imageUrl + * @param resolve + * @param reject + */ + private addItemToQueue(imageUrl, resolve, reject); + /** + * Check if we can process more items in the queue + * @returns {boolean} + */ + private readonly canProcess; + /** + * Processes one item from the queue + */ + private processQueue(); + /** + * Initialize the cache service + * @param replace {boolean} Whether to replace the cache directory if it already exists + */ + private initCache(replace?); + /** + * Adds a file to index. + * Also deletes any files if they are older than the set maximum cache age. + * @param file {FileEntry} File to index + * @returns {Promise} + */ + private addFileToIndex(file); + /** + * Indexes the cache if necessary + * @returns {any} + */ + private indexCache(); + /** + * This method runs every time a new file is added. + * It checks the cache size and ensures that it doesn't exceed the maximum cache size set in the config. + * If the limit is reached, it will delete old images to create free space. + */ + private maintainCacheSize(); + /** + * Remove a file + * @param file {string} The name of the file to remove + */ + private removeFile(file); + /** + * Get the local path of a previously cached image if exists + * @param url {string} The remote URL of the image + * @returns {Promise} Returns a promise that resolves with the local path if exists, or rejects if doesn't exist + */ + private getCachedImagePath(url); + /** + * Throws a console error if debug mode is enabled + * @param args {any[]} Error message + */ + private throwError(...args); + /** + * Throws a console warning if debug mode is enabled + * @param args {any[]} Error message + */ + private throwWarning(...args); + /** + * Check if the cache directory exists + * @param directory {string} The directory to check. Either this.file.tempDirectory or this.file.cacheDirectory + * @returns {Promise} Returns a promise that resolves if exists, and rejects if it doesn't + */ + private cacheDirectoryExists(directory); + /** + * Create the cache directories + * @param replace {boolean} override directory if exists + * @returns {Promise} Returns a promise that resolves if the directories were created, and rejects on error + */ + private createCacheDirectory(replace?); + /** + * Creates a unique file name out of the URL + * @param url {string} URL of the file + * @returns {string} Unique file name + */ + private createFileName(url); + /** + * Converts a string to a unique 32-bit int + * @param string {string} string to hash + * @returns {number} 32-bit int + */ + private hashString(string); +} diff --git a/dist/providers/image-loader.js b/dist/providers/image-loader.js new file mode 100644 index 0000000..18f7090 --- /dev/null +++ b/dist/providers/image-loader.js @@ -0,0 +1,541 @@ +import { Injectable } from '@angular/core'; +import { File } from '@ionic-native/file'; +import { FileTransfer } from '@ionic-native/file-transfer'; +import { ImageLoaderConfig } from "./image-loader-config"; +import { Platform } from 'ionic-angular'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/first'; +var ImageLoader = (function () { + function ImageLoader(config, file, fileTransfer, platform) { + var _this = this; + this.config = config; + this.file = file; + this.fileTransfer = fileTransfer; + this.platform = platform; + /** + * Indicates if the cache service is ready. + * When the cache service isn't ready, images are loaded via browser instead. + * @type {boolean} + */ + this.isCacheReady = false; + /** + * Indicates if this service is initialized. + * This service is initialized once all the setup is done. + * @type {boolean} + */ + this.isInit = false; + /** + * Number of concurrent requests allowed + * @type {number} + */ + this.concurrency = 5; + /** + * Queue items + * @type {Array} + */ + this.queue = []; + this.transferInstances = []; + this.processing = 0; + this.cacheIndex = []; + this.currentCacheSize = 0; + this.indexed = false; + if (!platform.is('cordova')) { + // we are running on a browser, or using livereload + // plugin will not function in this case + this.isInit = true; + this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); + } + else { + Observable.fromEvent(document, 'deviceready').first().subscribe(function (res) { + if (_this.nativeAvailable) { + _this.initCache(); + } + else { + // we are running on a browser, or using livereload + // plugin will not function in this case + _this.isInit = true; + _this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); + } + }); + } + } + Object.defineProperty(ImageLoader.prototype, "nativeAvailable", { + get: function () { + return File.installed() && FileTransfer.installed(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ImageLoader.prototype, "shouldIndex", { + get: function () { + return (this.config.maxCacheAge > -1) || (this.config.maxCacheSize > -1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ImageLoader.prototype, "isWKWebView", { + get: function () { + return this.platform.is('ios') && window.webkit && window.webkit.messageHandlers; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ImageLoader.prototype, "isIonicWKWebView", { + get: function () { + return this.isWKWebView && (location.host === 'localhost:8080' || window.LiveReload); + }, + enumerable: true, + configurable: true + }); + /** + * Preload an image + * @param imageUrl {string} Image URL + * @returns {Promise} returns a promise that resolves with the cached image URL + */ + ImageLoader.prototype.preload = function (imageUrl) { + return this.getImagePath(imageUrl); + }; + /** + * Clears the cache + */ + ImageLoader.prototype.clearCache = function () { + var _this = this; + if (!this.platform.is('cordova')) + return; + var clear = function () { + if (!_this.isInit) { + // do not run this method until our service is initialized + setTimeout(clear.bind(_this), 500); + return; + } + // pause any operations + _this.isInit = false; + _this.file.removeRecursively(_this.file.cacheDirectory, _this.config.cacheDirectoryName) + .then(function () { + if (_this.isWKWebView && !_this.isIonicWKWebView) { + // also clear the temp files + _this.file.removeRecursively(_this.file.tempDirectory, _this.config.cacheDirectoryName) + .catch(function (error) { + // Noop catch. Removing the tempDirectory might fail, + // as it is not persistent. + }) + .then(function () { + _this.initCache(true); + }); + } + else { + _this.initCache(true); + } + }) + .catch(_this.throwError.bind(_this)); + }; + clear(); + }; + /** + * Gets the filesystem path of an image. + * This will return the remote path if anything goes wrong or if the cache service isn't ready yet. + * @param imageUrl {string} The remote URL of the image + * @returns {Promise} Returns a promise that will always resolve with an image URL + */ + ImageLoader.prototype.getImagePath = function (imageUrl) { + var _this = this; + if (typeof imageUrl !== 'string' || imageUrl.length <= 0) { + return Promise.reject('The image url provided was empty or invalid.'); + } + return new Promise(function (resolve, reject) { + var getImage = function () { + _this.getCachedImagePath(imageUrl) + .then(resolve) + .catch(function () { + // image doesn't exist in cache, lets fetch it and save it + _this.addItemToQueue(imageUrl, resolve, reject); + }); + }; + var check = function () { + if (_this.isInit) { + if (_this.isCacheReady) { + getImage(); + } + else { + _this.throwWarning('The cache system is not running. Images will be loaded by your browser instead.'); + resolve(imageUrl); + } + } + else { + setTimeout(function () { return check(); }, 250); + } + }; + check(); + }); + }; + /** + * Add an item to the queue + * @param imageUrl + * @param resolve + * @param reject + */ + ImageLoader.prototype.addItemToQueue = function (imageUrl, resolve, reject) { + this.queue.push({ + imageUrl: imageUrl, + resolve: resolve, + reject: reject + }); + this.processQueue(); + }; + Object.defineProperty(ImageLoader.prototype, "canProcess", { + /** + * Check if we can process more items in the queue + * @returns {boolean} + */ + get: function () { + return (this.queue.length > 0 + && this.processing < this.concurrency); + }, + enumerable: true, + configurable: true + }); + /** + * Processes one item from the queue + */ + ImageLoader.prototype.processQueue = function () { + var _this = this; + // make sure we can process items first + if (!this.canProcess) + return; + // increase the processing number + this.processing++; + // take the first item from queue + var currentItem = this.queue.splice(0, 1)[0]; + // create FileTransferObject instance if needed + // we would only reach here if current jobs < concurrency limit + // so, there's no need to check anything other than the length of + // the FileTransferObject instances we have in memory + if (this.transferInstances.length === 0) { + this.transferInstances.push(this.fileTransfer.create()); + } + var transfer = this.transferInstances.splice(0, 1)[0]; + // process more items concurrently if we can + if (this.canProcess) + this.processQueue(); + // function to call when done processing this item + // this will reduce the processing number + // then will execute this function again to process any remaining items + var done = function () { + _this.processing--; + _this.transferInstances.push(transfer); + _this.processQueue(); + }; + var localPath = this.file.cacheDirectory + this.config.cacheDirectoryName + '/' + this.createFileName(currentItem.imageUrl); + transfer.download(currentItem.imageUrl, localPath, Boolean(this.config.fileTransferOptions.trustAllHosts), this.config.fileTransferOptions) + .then(function (file) { + if (_this.shouldIndex) { + _this.addFileToIndex(file).then(_this.maintainCacheSize.bind(_this)); + } + return _this.getCachedImagePath(currentItem.imageUrl); + }) + .then(function (localUrl) { + currentItem.resolve(localUrl); + done(); + }) + .catch(function (e) { + currentItem.reject(); + _this.throwError(e); + done(); + }); + }; + /** + * Initialize the cache service + * @param replace {boolean} Whether to replace the cache directory if it already exists + */ + ImageLoader.prototype.initCache = function (replace) { + var _this = this; + this.concurrency = this.config.concurrency; + // create cache directories if they do not exist + this.createCacheDirectory(replace) + .catch(function (e) { + _this.throwError(e); + _this.isInit = true; + }) + .then(function () { return _this.indexCache(); }) + .then(function () { + _this.isCacheReady = true; + _this.isInit = true; + }); + }; + /** + * Adds a file to index. + * Also deletes any files if they are older than the set maximum cache age. + * @param file {FileEntry} File to index + * @returns {Promise} + */ + ImageLoader.prototype.addFileToIndex = function (file) { + var _this = this; + return new Promise(function (resolve, reject) { return file.getMetadata(resolve, reject); }) + .then(function (metadata) { + if (_this.config.maxCacheAge > -1 + && (Date.now() - metadata.modificationTime.getTime()) > _this.config.maxCacheAge) { + // file age exceeds maximum cache age + return _this.removeFile(file.name); + } + else { + // file age doesn't exceed maximum cache age, or maximum cache age isn't set + _this.currentCacheSize += metadata.size; + // add item to index + _this.cacheIndex.push({ + name: file.name, + modificationTime: metadata.modificationTime, + size: metadata.size + }); + return Promise.resolve(); + } + }); + }; + /** + * Indexes the cache if necessary + * @returns {any} + */ + ImageLoader.prototype.indexCache = function () { + var _this = this; + // only index if needed, to save resources + if (!this.shouldIndex) + return Promise.resolve(); + this.cacheIndex = []; + return this.file.listDir(this.file.cacheDirectory, this.config.cacheDirectoryName) + .then(function (files) { return Promise.all(files.map(_this.addFileToIndex.bind(_this))); }) + .then(function () { + // Sort items by date. Most recent to oldest. + _this.cacheIndex = _this.cacheIndex.sort(function (a, b) { return a > b ? -1 : a < b ? 1 : 0; }); + _this.indexed = true; + return Promise.resolve(); + }) + .catch(function (e) { + _this.throwError(e); + return Promise.resolve(); + }); + }; + /** + * This method runs every time a new file is added. + * It checks the cache size and ensures that it doesn't exceed the maximum cache size set in the config. + * If the limit is reached, it will delete old images to create free space. + */ + ImageLoader.prototype.maintainCacheSize = function () { + var _this = this; + if (this.config.maxCacheSize > -1 && this.indexed) { + var maintain_1 = function () { + if (_this.currentCacheSize > _this.config.maxCacheSize) { + // called when item is done processing + var next_1 = function () { + _this.currentCacheSize -= file_1.size; + maintain_1(); + }; + // grab the first item in index since it's the oldest one + var file_1 = _this.cacheIndex.splice(0, 1)[0]; + if (typeof file_1 == 'undefined') + return maintain_1(); + // delete the file then process next file if necessary + _this.removeFile(file_1.name) + .then(function () { return next_1(); }) + .catch(function () { return next_1(); }); // ignore errors, nothing we can do about it + } + }; + maintain_1(); + } + }; + /** + * Remove a file + * @param file {string} The name of the file to remove + */ + ImageLoader.prototype.removeFile = function (file) { + var _this = this; + return this.file + .removeFile(this.file.cacheDirectory + this.config.cacheDirectoryName, file) + .then(function () { + if (_this.isWKWebView && !_this.isIonicWKWebView) { + return _this.file + .removeFile(_this.file.tempDirectory + _this.config.cacheDirectoryName, file) + .catch(function () { + // Noop catch. Removing the files from tempDirectory might fail, as it is not persistent. + }); + } + }); + }; + /** + * Get the local path of a previously cached image if exists + * @param url {string} The remote URL of the image + * @returns {Promise} Returns a promise that resolves with the local path if exists, or rejects if doesn't exist + */ + ImageLoader.prototype.getCachedImagePath = function (url) { + var _this = this; + return new Promise(function (resolve, reject) { + // make sure cache is ready + if (!_this.isCacheReady) { + return reject(); + } + // get file name + var fileName = _this.createFileName(url); + // get full path + var dirPath = _this.file.cacheDirectory + _this.config.cacheDirectoryName, tempDirPath = _this.file.tempDirectory + _this.config.cacheDirectoryName; + // check if exists + _this.file.resolveLocalFilesystemUrl(dirPath + '/' + fileName) + .then(function (fileEntry) { + // file exists in cache + if (_this.config.imageReturnType === 'base64') { + // read the file as data url and return the base64 string. + // should always be successful as the existence of the file + // is alreay ensured + _this.file + .readAsDataURL(dirPath, fileName) + .then(function (base64) { + base64 = base64.replace('data:null', 'data:*/*'); + resolve(base64); + }) + .catch(reject); + } + else if (_this.config.imageReturnType === 'uri') { + // now check if iOS device & using WKWebView Engine. + // in this case only the tempDirectory is accessible, + // therefore the file needs to be copied into that directory first! + if (_this.isIonicWKWebView) { + // Ionic WKWebView can access all files, but we just need to replace file:/// with http://localhost:8080/ + resolve(fileEntry.nativeURL.replace('file:///', 'http://localhost:8080/')); + } + else if (_this.isWKWebView) { + // check if file already exists in temp directory + _this.file.resolveLocalFilesystemUrl(tempDirPath + '/' + fileName) + .then(function (tempFileEntry) { + // file exists in temp directory + // return native path + resolve(tempFileEntry.nativeURL); + }) + .catch(function () { + // file does not yet exist in the temp directory. + // copy it! + _this.file.copyFile(dirPath, fileName, tempDirPath, fileName) + .then(function (tempFileEntry) { + // now the file exists in the temp directory + // return native path + resolve(tempFileEntry.nativeURL); + }) + .catch(reject); + }); + } + else { + // return native path + resolve(fileEntry.nativeURL); + } + } + }) + .catch(reject); // file doesn't exist + }); + }; + /** + * Throws a console error if debug mode is enabled + * @param args {any[]} Error message + */ + ImageLoader.prototype.throwError = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (this.config.debugMode) { + args.unshift('ImageLoader Error: '); + console.error.apply(console, args); + } + }; + /** + * Throws a console warning if debug mode is enabled + * @param args {any[]} Error message + */ + ImageLoader.prototype.throwWarning = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (this.config.debugMode) { + args.unshift('ImageLoader Warning: '); + console.warn.apply(console, args); + } + }; + /** + * Check if the cache directory exists + * @param directory {string} The directory to check. Either this.file.tempDirectory or this.file.cacheDirectory + * @returns {Promise} Returns a promise that resolves if exists, and rejects if it doesn't + */ + ImageLoader.prototype.cacheDirectoryExists = function (directory) { + return this.file.checkDir(directory, this.config.cacheDirectoryName); + }; + /** + * Create the cache directories + * @param replace {boolean} override directory if exists + * @returns {Promise} Returns a promise that resolves if the directories were created, and rejects on error + */ + ImageLoader.prototype.createCacheDirectory = function (replace) { + var _this = this; + if (replace === void 0) { replace = false; } + var cacheDirectoryPromise, tempDirectoryPromise; + if (replace) { + // create or replace the cache directory + cacheDirectoryPromise = this.file.createDir(this.file.cacheDirectory, this.config.cacheDirectoryName, replace); + } + else { + // check if the cache directory exists. + // if it does not exist create it! + cacheDirectoryPromise = this.cacheDirectoryExists(this.file.cacheDirectory) + .catch(function () { return _this.file.createDir(_this.file.cacheDirectory, _this.config.cacheDirectoryName, false); }); + } + if (this.isWKWebView && !this.isIonicWKWebView) { + if (replace) { + // create or replace the temp directory + tempDirectoryPromise = this.file.createDir(this.file.tempDirectory, this.config.cacheDirectoryName, replace); + } + else { + // check if the temp directory exists. + // if it does not exist create it! + tempDirectoryPromise = this.cacheDirectoryExists(this.file.tempDirectory) + .catch(function () { return _this.file.createDir(_this.file.tempDirectory, _this.config.cacheDirectoryName, false); }); + } + } + else { + tempDirectoryPromise = Promise.resolve(); + } + return Promise.all([cacheDirectoryPromise, tempDirectoryPromise]); + }; + /** + * Creates a unique file name out of the URL + * @param url {string} URL of the file + * @returns {string} Unique file name + */ + ImageLoader.prototype.createFileName = function (url) { + // hash the url to get a unique file name + return this.hashString(url).toString(); + }; + /** + * Converts a string to a unique 32-bit int + * @param string {string} string to hash + * @returns {number} 32-bit int + */ + ImageLoader.prototype.hashString = function (string) { + var hash = 0, char; + if (string.length === 0) + return hash; + for (var i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; + } + return hash; + }; + return ImageLoader; +}()); +export { ImageLoader }; +ImageLoader.decorators = [ + { type: Injectable }, +]; +/** @nocollapse */ +ImageLoader.ctorParameters = function () { return [ + { type: ImageLoaderConfig, }, + { type: File, }, + { type: FileTransfer, }, + { type: Platform, }, +]; }; +//# sourceMappingURL=image-loader.js.map \ No newline at end of file diff --git a/dist/providers/image-loader.js.map b/dist/providers/image-loader.js.map new file mode 100644 index 0000000..8d4eb41 --- /dev/null +++ b/dist/providers/image-loader.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/providers/image-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,U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C,IAAI,CAAC;QACrC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAYH,kBAAC;AAAD,CA1kBA,AA0kBC;;AAVM,sBAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,UAAU,EAAE;CACnB,CAAC;AACF,kBAAkB;AACX,0BAAc,GAAmE,cAAM,OAAA;IAC9F,EAAC,IAAI,EAAE,iBAAiB,GAAG;IAC3B,EAAC,IAAI,EAAE,IAAI,GAAG;IACd,EAAC,IAAI,EAAE,YAAY,GAAG;IACtB,EAAC,IAAI,EAAE,QAAQ,GAAG;CACjB,EAL6F,CAK7F,CAAC","file":"image-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/providers/image-loader.metadata.json b/dist/providers/image-loader.metadata.json new file mode 100644 index 0000000..32fc3e9 --- /dev/null +++ b/dist/providers/image-loader.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"ImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"},{"__symbolic":"reference","module":"ionic-angular","name":"Platform"}]}],"preload":[{"__symbolic":"method"}],"clearCache":[{"__symbolic":"method"}],"getImagePath":[{"__symbolic":"method"}],"addItemToQueue":[{"__symbolic":"method"}],"processQueue":[{"__symbolic":"method"}],"initCache":[{"__symbolic":"method"}],"addFileToIndex":[{"__symbolic":"method"}],"indexCache":[{"__symbolic":"method"}],"maintainCacheSize":[{"__symbolic":"method"}],"removeFile":[{"__symbolic":"method"}],"getCachedImagePath":[{"__symbolic":"method"}],"throwError":[{"__symbolic":"method"}],"throwWarning":[{"__symbolic":"method"}],"cacheDirectoryExists":[{"__symbolic":"method"}],"createCacheDirectory":[{"__symbolic":"method"}],"createFileName":[{"__symbolic":"method"}],"hashString":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"},{"__symbolic":"reference","module":"ionic-angular","name":"Platform"}]}],"preload":[{"__symbolic":"method"}],"clearCache":[{"__symbolic":"method"}],"getImagePath":[{"__symbolic":"method"}],"addItemToQueue":[{"__symbolic":"method"}],"processQueue":[{"__symbolic":"method"}],"initCache":[{"__symbolic":"method"}],"addFileToIndex":[{"__symbolic":"method"}],"indexCache":[{"__symbolic":"method"}],"maintainCacheSize":[{"__symbolic":"method"}],"removeFile":[{"__symbolic":"method"}],"getCachedImagePath":[{"__symbolic":"method"}],"throwError":[{"__symbolic":"method"}],"throwWarning":[{"__symbolic":"method"}],"cacheDirectoryExists":[{"__symbolic":"method"}],"createCacheDirectory":[{"__symbolic":"method"}],"createFileName":[{"__symbolic":"method"}],"hashString":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 274ec48..c63c220 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ionic-image-loader", - "version": "4.2.1", + "version": "4.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -84,6 +84,16 @@ "integrity": "sha512-YzIYd5QSWbW4RROaCOElVjzcXynep+yc5l/q0f28oa6vvu1kwqMDYrkNFkapTKGowhlhDge7En5qqw/8elacwQ==", "dev": true }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "add-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", @@ -435,8 +445,8 @@ "integrity": "sha1-4ye1MZThp61dxjR57pCZpSsCSGU=", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.1.1", @@ -635,9 +645,9 @@ "dev": true }, "ionic-angular": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/ionic-angular/-/ionic-angular-3.6.0.tgz", - "integrity": "sha512-V6NNax+X8CihwCerb+IlSTKe+GOfLyp/AYtD7zYkGqu1euL++LxepCCUo5Cn1UWn4aif+rUr0/JC2TQ0iwduOw==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/ionic-angular/-/ionic-angular-3.6.1.tgz", + "integrity": "sha512-lsUX9VEj5fXMoDXW9SBgKl33hlOYf/JmD+SJKYreXT63XN1C8N+jP01H5VoHYQFR18nzNZAxX5sv+/U1UdPtTA==", "dev": true }, "is-arrayish": { @@ -715,16 +725,6 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", From 8e4d2800db404678adac5e3d88bfc563019b8a6b Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 10:17:02 +1100 Subject: [PATCH 04/13] Pass through attribute dictionary for _useImg --- dist/components/img-loader.d.ts | 2 +- dist/components/img-loader.js | 7 +++++-- dist/components/img-loader.js.map | 2 +- src/components/img-loader.ts | 13 +++++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dist/components/img-loader.d.ts b/dist/components/img-loader.d.ts index 113457f..64c2716 100644 --- a/dist/components/img-loader.d.ts +++ b/dist/components/img-loader.d.ts @@ -31,7 +31,7 @@ export declare class ImgLoader implements OnInit { /** * Attributes to pass through to img tag if _useImg == true */ - imgAttributes: string; + imgAttributes: {}; /** * Convenience attribute to disable caching * @param val diff --git a/dist/components/img-loader.js b/dist/components/img-loader.js index 4e717e8..029a913 100644 --- a/dist/components/img-loader.js +++ b/dist/components/img-loader.js @@ -30,7 +30,7 @@ var ImgLoader = (function () { /** * Attributes to pass through to img tag if _useImg == true */ - this.imgAttributes = ""; + this.imgAttributes = {}; /** * Enable/Disable caching * @type {boolean} @@ -172,7 +172,10 @@ var ImgLoader = (function () { this._renderer.setElementAttribute(this.element, 'src', imageUrl); // if imgAttributes are defined, add them here if (this.imgAttributes != '') { - this._renderer.setElementAttribute(this.element, 'class', this.imgAttributes); + for (var key in this.imgAttributes) { + var value = this.imgAttributes[key]; + this._renderer.setElementAttribute(this.element, key, value); + } } if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', function () { return _this._renderer.setElementAttribute(_this.element, 'src', _this.fallbackUrl); }); diff --git a/dist/components/img-loader.js.map b/dist/components/img-loader.js.map index 3521491..31845e1 100644 --- a/dist/components/img-loader.js.map +++ b/dist/components/img-loader.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AAG,EAAE,EAAE;IAC9D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5B,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACpC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index b9f2721..d6901a1 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -62,7 +62,7 @@ export class ImgLoader implements OnInit { /** * Attributes to pass through to img tag if _useImg == true */ - @Input('imgAttributes') imgAttributes: string = ""; + @Input('imgAttributes') imgAttributes: {} = {}; /** * Convenience attribute to disable caching @@ -133,7 +133,7 @@ export class ImgLoader implements OnInit { private _renderer: Renderer, private _imageLoader: ImageLoader, private _config: ImageLoaderConfig - ) {} + ) { } ngOnInit(): void { if (this.fallbackAsPlaceholder && this.fallbackUrl) { @@ -205,10 +205,15 @@ export class ImgLoader implements OnInit { // if imgAttributes are defined, add them here if (this.imgAttributes != '') { - this._renderer.setElementAttribute(this.element, 'class', this.imgAttributes); + + for (var key in this.imgAttributes) { + var value = this.imgAttributes[key]; + this._renderer.setElementAttribute(this.element, key, value); + } } + if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', () => this._renderer.setElementAttribute(this.element, 'src', this.fallbackUrl)); } @@ -225,7 +230,7 @@ export class ImgLoader implements OnInit { } } - this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + ( imageUrl || this.fallbackUrl ) + '\')'); + this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + (imageUrl || this.fallbackUrl) + '\')'); } this.load.emit(this); From 7e75de8d0c64bb5e78c419809f0def508fa917f0 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 11:05:39 +1100 Subject: [PATCH 05/13] Attribute object definition --- dist/components/image-attribute.d.ts | 5 +++++ dist/components/image-attribute.js | 10 ++++++++++ dist/components/image-attribute.js.map | 1 + dist/components/image-attribute.metadata.json | 1 + dist/components/img-loader.d.ts | 3 ++- dist/components/img-loader.js | 16 ++++++++++------ dist/components/img-loader.js.map | 2 +- src/components/image-attribute.ts | 5 +++++ src/components/img-loader.ts | 19 +++++++++++++------ 9 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 dist/components/image-attribute.d.ts create mode 100644 dist/components/image-attribute.js create mode 100644 dist/components/image-attribute.js.map create mode 100644 dist/components/image-attribute.metadata.json create mode 100644 src/components/image-attribute.ts diff --git a/dist/components/image-attribute.d.ts b/dist/components/image-attribute.d.ts new file mode 100644 index 0000000..9ad7fdc --- /dev/null +++ b/dist/components/image-attribute.d.ts @@ -0,0 +1,5 @@ +export declare class ImageAttribute { + element: string; + value: string; + encapsulateWithBrackets: boolean; +} diff --git a/dist/components/image-attribute.js b/dist/components/image-attribute.js new file mode 100644 index 0000000..74918fc --- /dev/null +++ b/dist/components/image-attribute.js @@ -0,0 +1,10 @@ +var ImageAttribute = (function () { + function ImageAttribute() { + this.element = ""; + this.value = ""; + this.encapsulateWithBrackets = false; + } + return ImageAttribute; +}()); +export { ImageAttribute }; +//# sourceMappingURL=image-attribute.js.map \ No newline at end of file diff --git a/dist/components/image-attribute.js.map b/dist/components/image-attribute.js.map new file mode 100644 index 0000000..db36abd --- /dev/null +++ b/dist/components/image-attribute.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/components/image-attribute.ts"],"names":[],"mappings":"AAAA;IAAA;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,UAAK,GAAW,EAAE,CAAC;QACnB,4BAAuB,GAAY,KAAK,CAAC;IAC7C,CAAC;IAAD,qBAAC;AAAD,CAJA,AAIC,IAAA","file":"image-attribute.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/components/image-attribute.metadata.json b/dist/components/image-attribute.metadata.json new file mode 100644 index 0000000..f96dfaf --- /dev/null +++ b/dist/components/image-attribute.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"ImageAttribute":{"__symbolic":"class"}}},{"__symbolic":"module","version":1,"metadata":{"ImageAttribute":{"__symbolic":"class"}}}] \ No newline at end of file diff --git a/dist/components/img-loader.d.ts b/dist/components/img-loader.d.ts index 64c2716..3cf5d8d 100644 --- a/dist/components/img-loader.d.ts +++ b/dist/components/img-loader.d.ts @@ -1,6 +1,7 @@ import { ElementRef, Renderer, OnInit, EventEmitter } from '@angular/core'; import { ImageLoader } from '../providers/image-loader'; import { ImageLoaderConfig } from '../providers/image-loader-config'; +import { ImageAttribute } from './image-attribute'; export declare class ImgLoader implements OnInit { private _element; private _renderer; @@ -31,7 +32,7 @@ export declare class ImgLoader implements OnInit { /** * Attributes to pass through to img tag if _useImg == true */ - imgAttributes: {}; + imgAttributes: ImageAttribute[]; /** * Convenience attribute to disable caching * @param val diff --git a/dist/components/img-loader.js b/dist/components/img-loader.js index 029a913..c484961 100644 --- a/dist/components/img-loader.js +++ b/dist/components/img-loader.js @@ -30,7 +30,7 @@ var ImgLoader = (function () { /** * Attributes to pass through to img tag if _useImg == true */ - this.imgAttributes = {}; + this.imgAttributes = []; /** * Enable/Disable caching * @type {boolean} @@ -171,11 +171,15 @@ var ImgLoader = (function () { // set it's src this._renderer.setElementAttribute(this.element, 'src', imageUrl); // if imgAttributes are defined, add them here - if (this.imgAttributes != '') { - for (var key in this.imgAttributes) { - var value = this.imgAttributes[key]; - this._renderer.setElementAttribute(this.element, key, value); - } + if (this.imgAttributes.length > 0) { + this.imgAttributes.forEach(function (attribute) { + var value = attribute.value; + var element = attribute.element; + if (attribute.encapsulateWithBrackets == true) { + element = '(' + element + ')'; + } + _this._renderer.setElementAttribute(_this.element, element, value); + }); } if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', function () { return _this._renderer.setElementAttribute(_this.element, 'src', _this.fallbackUrl); }); diff --git a/dist/components/img-loader.js.map b/dist/components/img-loader.js.map index 31845e1..e8402a7 100644 --- a/dist/components/img-loader.js.map +++ b/dist/components/img-loader.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/components/img-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAkB,YAAA,EAAa,MAAO,eAAA,CAAgB;AACrG,OAAO,EAAE,WAAA,EAAY,MAAO,2BAAA,CAA4B;AACxD,OAAO,EAAE,iBAAA,EAAkB,MAAO,kCAAA,CAAmC;AAErE,IAAM,OAAA,GAAe;IACnB,OAAO,EAAE,SAAA;IACT,MAAM,EAAE,QAAA;IACR,KAAK,EAAE,OAAA;IACP,cAAc,EAAE,iBAAA;IAChB,gBAAgB,EAAE,mBAAA;CACnB,CAAC;AAGF;IAgHE,mBACU,QAAoB,EACpB,SAAmB,EACnB,YAAyB,EACzB,OAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,iBAAY,GAAZ,YAAY,CAAa;QACzB,YAAO,GAAP,OAAO,CAAmB;QAnGpC;;WAEG;QACF,gBAAW,GAAW,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAEhD;;WAEG;QACF,YAAO,G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E,KAAK,EAAE,EAAE;IACpC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../src/components/img-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAkB,YAAA,EAAa,MAAO,eAAA,CAAgB;AACrG,OAAO,EAAE,WAAA,EAAY,MAAO,2BAAA,CAA4B;AACxD,OAAO,EAAE,iBAAA,EAAkB,MAAO,kCAAA,CAAmC;AAGrE,IAAM,OAAA,GAAe;IACnB,OAAO,EAAE,SAAA;IACT,MAAM,EAAE,QAAA;IACR,KAAK,EAAE,OAAA;IACP,cAAc,EAAE,iBAAA;IAChB,gBAAgB,EAAE,mBAAA;CACnB,CAAC;AAGF;IAgHE,mBACU,QAAoB,EACpB,SAAmB,EACnB,YAAyB,EACzB,OAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,iBAAY,GAAZ,YAAY,CAAa;QACzB,YAAO,GAAP,OAAO,CAAmB;QAnGpC;;WAEG;QACF,gBAAW,GAAW,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAEhD;;WAEG;QACF,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAEhD;;WAEG;QACF,0BAAqB,GAAY,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QAU7D,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAG/C;;WAEG;QACF,kBAAa,GAAqB,EAAE,CAA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AAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/src/components/image-attribute.ts b/src/components/image-attribute.ts new file mode 100644 index 0000000..13dcd55 --- /dev/null +++ b/src/components/image-attribute.ts @@ -0,0 +1,5 @@ +export class ImageAttribute { + element: string = ""; + value: string = ""; + encapsulateWithBrackets: boolean = false; +} \ No newline at end of file diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index d6901a1..e485c85 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -1,6 +1,7 @@ import { Component, Input, Output, ElementRef, Renderer, OnInit, EventEmitter } from '@angular/core'; import { ImageLoader } from '../providers/image-loader'; import { ImageLoaderConfig } from '../providers/image-loader-config'; +import { ImageAttribute } from './image-attribute'; const propMap: any = { display: 'display', @@ -62,7 +63,7 @@ export class ImgLoader implements OnInit { /** * Attributes to pass through to img tag if _useImg == true */ - @Input('imgAttributes') imgAttributes: {} = {}; + @Input('imgAttributes') imgAttributes: ImageAttribute[] = []; /** * Convenience attribute to disable caching @@ -204,12 +205,18 @@ export class ImgLoader implements OnInit { this._renderer.setElementAttribute(this.element, 'src', imageUrl); // if imgAttributes are defined, add them here - if (this.imgAttributes != '') { + if (this.imgAttributes.length > 0) { + + this.imgAttributes.forEach((attribute) => { + var value = attribute.value; + var element = attribute.element; + if (attribute.encapsulateWithBrackets == true) { + element = '(' + element + ')'; + } + this._renderer.setElementAttribute(this.element, element, value); + + }); - for (var key in this.imgAttributes) { - var value = this.imgAttributes[key]; - this._renderer.setElementAttribute(this.element, key, value); - } } From 231a22aa151432ce17e85f5af0524523d7773070 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 13:22:25 +1100 Subject: [PATCH 06/13] Updated include statement in index.ts, Readme documentation. --- README.md | 31 +++++++++++++++++++++++++++++++ src/components/image-attribute.ts | 1 - src/components/img-loader.ts | 20 ++++---------------- src/index.ts | 1 + 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 92f5a61..5b96721 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ The `` component takes many attributes that allows you to customize | backgroundSize | string | Sets the `background-size` CSS property of the `` element. This is ignored if `useImg` is set to `true`. | contain | | backgroundRepeat | string | Sets the `background-repeat` CSS property of the `` element. This is ignored if `useImg` is set to `true`. | no-repeat | | fallbackAsPlaceholder | boolean | Use fallback as a placeholder until the image loads. | false | +| imgAttributes | ImageAttribute[] | An array of ImageAttribute objects (element, value). If `useImg == true`, this array will be iterated and each object added as an attribute to the generated `` HTML element. | []] | **Note:** The default values can be changed using the [global configuration](https://github.com/zyramedia/ionic-image-loader#global-configuration) feature. @@ -311,6 +312,36 @@ class MyComponent { ``` +# Passing HTML / CSS Attributes to a generated image + +When using ImageLoader to generate an `` element it may be desirable for the generated element to include additional attributes to provide styling or interaction qualities. The optional `imgAttributes` value can be used to provide such additional attributes which will be included in the generated `` element in the DOM. + +Usage: + +1. Include the ImageAttribute model in your .ts +```typescript +import { ImageAttribute } from 'ionic-image-loader' +``` + +2. Generate an array of ImageAttribute objects +```typescript +var imageAttributes: ImageAttribute[] = []; +imageAttributes.push({ + element: 'class', + value: 'circle-photo' +}) +``` + +3. Include the `imgAttributes` element in the `img-loader` element of your HTML +```html + +``` + +4. The generated `` tag will be rendered with the specified attributes +```html + +``` +

## Contribution - **Having an issue**? or looking for support? [Open an issue](https://github.com/zyra/ionic-image-loader/issues/new) and we will get you the help you need. diff --git a/src/components/image-attribute.ts b/src/components/image-attribute.ts index 13dcd55..0255ee0 100644 --- a/src/components/image-attribute.ts +++ b/src/components/image-attribute.ts @@ -1,5 +1,4 @@ export class ImageAttribute { element: string = ""; value: string = ""; - encapsulateWithBrackets: boolean = false; } \ No newline at end of file diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index e485c85..e56b236 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -204,22 +204,10 @@ export class ImgLoader implements OnInit { // set it's src this._renderer.setElementAttribute(this.element, 'src', imageUrl); - // if imgAttributes are defined, add them here - if (this.imgAttributes.length > 0) { - - this.imgAttributes.forEach((attribute) => { - var value = attribute.value; - var element = attribute.element; - if (attribute.encapsulateWithBrackets == true) { - element = '(' + element + ')'; - } - this._renderer.setElementAttribute(this.element, element, value); - - }); - - } - - + // if imgAttributes are defined, add them to our img element + this.imgAttributes.forEach((attribute, index, attributeArray) => { + this._renderer.setElementAttribute(this.element, attribute.element, attribute.value); + }); if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', () => this._renderer.setElementAttribute(this.element, 'src', this.fallbackUrl)); diff --git a/src/index.ts b/src/index.ts index 251e5dd..913c8f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export * from './image-loader.module'; export * from './components/img-loader'; export * from './providers/image-loader-config'; +export * from './components/image-attribute'; export * from './providers/image-loader'; From 7b21b9e3b880fb788caaf1458f88d5ad2a80d28d Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 13:33:40 +1100 Subject: [PATCH 07/13] Updated include statements --- dist/components/image-attribute.d.ts | 1 - dist/components/image-attribute.js | 1 - dist/components/image-attribute.js.map | 2 +- dist/components/img-loader.js | 15 ++++----------- dist/components/img-loader.js.map | 2 +- dist/image-loader.module.js.map | 2 +- dist/index.d.ts | 1 + dist/index.js | 1 + dist/index.js.map | 2 +- dist/index.metadata.json | 2 +- src/image-loader.module.ts | 1 + 11 files changed, 12 insertions(+), 18 deletions(-) diff --git a/dist/components/image-attribute.d.ts b/dist/components/image-attribute.d.ts index 9ad7fdc..7af2235 100644 --- a/dist/components/image-attribute.d.ts +++ b/dist/components/image-attribute.d.ts @@ -1,5 +1,4 @@ export declare class ImageAttribute { element: string; value: string; - encapsulateWithBrackets: boolean; } diff --git a/dist/components/image-attribute.js b/dist/components/image-attribute.js index 74918fc..a89602a 100644 --- a/dist/components/image-attribute.js +++ b/dist/components/image-attribute.js @@ -2,7 +2,6 @@ var ImageAttribute = (function () { function ImageAttribute() { this.element = ""; this.value = ""; - this.encapsulateWithBrackets = false; } return ImageAttribute; }()); diff --git a/dist/components/image-attribute.js.map b/dist/components/image-attribute.js.map index db36abd..8325d8d 100644 --- a/dist/components/image-attribute.js.map +++ b/dist/components/image-attribute.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/components/image-attribute.ts"],"names":[],"mappings":"AAAA;IAAA;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,UAAK,GAAW,EAAE,CAAC;QACnB,4BAAuB,GAAY,KAAK,CAAC;IAC7C,CAAC;IAAD,qBAAC;AAAD,CAJA,AAIC,IAAA","file":"image-attribute.js","sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../src/components/image-attribute.ts"],"names":[],"mappings":"AAAA;IAAA;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,UAAK,GAAW,EAAE,CAAC;IACvB,CAAC;IAAD,qBAAC;AAAD,CAHA,AAGC,IAAA","file":"image-attribute.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/components/img-loader.js b/dist/components/img-loader.js index c484961..14a834b 100644 --- a/dist/components/img-loader.js +++ b/dist/components/img-loader.js @@ -170,17 +170,10 @@ var ImgLoader = (function () { } // set it's src this._renderer.setElementAttribute(this.element, 'src', imageUrl); - // if imgAttributes are defined, add them here - if (this.imgAttributes.length > 0) { - this.imgAttributes.forEach(function (attribute) { - var value = attribute.value; - var element = attribute.element; - if (attribute.encapsulateWithBrackets == true) { - element = '(' + element + ')'; - } - _this._renderer.setElementAttribute(_this.element, element, value); - }); - } + // if imgAttributes are defined, add them to our img element + this.imgAttributes.forEach(function (attribute, index, attributeArray) { + _this._renderer.setElementAttribute(_this.element, attribute.element, attribute.value); + }); if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { this._renderer.listen(this.element, 'error', function () { return _this._renderer.setElementAttribute(_this.element, 'src', _this.fallbackUrl); }); } diff --git a/dist/components/img-loader.js.map b/dist/components/img-loader.js.map index e8402a7..14d1eea 100644 --- a/dist/components/img-loader.js.map +++ b/dist/components/img-loader.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/components/img-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAkB,YAAA,EAAa,MAAO,eAAA,CAAgB;AACrG,OAAO,EAAE,WAAA,EAAY,MAAO,2BAAA,CAA4B;AACxD,OAAO,EAAE,iBAAA,EAAkB,MAAO,kCAAA,CAAmC;AAGrE,IAAM,OAAA,GAAe;IACnB,OAAO,EAAE,SAAA;IACT,MAAM,EAAE,QAAA;IACR,KAAK,EAAE,OAAA;IACP,cAAc,EAAE,iBAAA;IAChB,gBAAgB,EAAE,mBAAA;CACnB,CAAC;AAGF;IAgHE,mBACU,QAAoB,EACpB,SAAmB,EACnB,YAAyB,EACzB,OAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,iBAAY,GAAZ,YAAY,CAAa;QACzB,YAAO,GAAP,OAAO,CAAmB;QAnGpC;;WAEG;QACF,gBAAW,GAAW,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAEhD;;WAEG;QACF,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAEhD;;WAEG;QACF,0BAAqB,GAAY,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QAU7D,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAG/C;;WAEG;QACF,kBAAa,GAAqB,EAAE,CAAC;QAWtC;;;WAGG;QACF,UA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AE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../../src/components/img-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAA,EAAW,KAAA,EAAO,MAAA,EAAQ,UAAA,EAAY,QAAA,EAAkB,YAAA,EAAa,MAAO,eAAA,CAAgB;AACrG,OAAO,EAAE,WAAA,EAAY,MAAO,2BAAA,CAA4B;AACxD,OAAO,EAAE,iBAAA,EAAkB,MAAO,kCAAA,CAAmC;AAGrE,IAAM,OAAA,GAAe;IACnB,OAAO,EAAE,SAAA;IACT,MAAM,EAAE,QAAA;IACR,KAAK,EAAE,OAAA;IACP,cAAc,EAAE,iBAAA;IAChB,gBAAgB,EAAE,mBAAA;CACnB,CAAC;AAGF;IAgHE,mBACU,QAAoB,EACpB,SAAmB,EACnB,YAAyB,EACzB,OAA0B;QAH1B,aAAQ,GAAR,QAAQ,CAAY;QACpB,cAAS,GAAT,SAAS,CAAU;QACnB,iBAAY,GAAZ,YAAY,CAAa;QACzB,YAAO,GAAP,OAAO,CAAmB;QAnGpC;;WAEG;QACF,gBAAW,GAAW,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAEhD;;WAEG;QACF,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAEhD;;WAEG;QACF,0BAAqB,GAAY,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QAU7D,YAAO,GAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QAG/C;;WAEG;QACF,kBAAa,GAAqB,EAAE,CAAC;QAWtC;;;WAGG;QACF,UAAK,GAAY,IAAI,CAAC;QAEvB;;WAEG;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AAG;CAC1B,EAL6F,CAK7F,CAAC;AACK,wBAAc,GAA2C;IAChE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACzB,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,UAAU,EAAG,EAAE,EAAE;IACvD,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,uBAAuB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3C,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5B,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,eAAe,EAAG,EAAE,EAAE;IAC9D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5B,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACpC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/image-loader.module.js.map b/dist/image-loader.module.js.map index a5f441a..a993f45 100644 --- a/dist/image-loader.module.js.map +++ b/dist/image-loader.module.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/image-loader.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAA,EAA8B,MAAO,eAAA,CAAgB;AAC9D,OAAO,EAAE,SAAA,EAAU,MAAO,yBAAA,CAA0B;AACpD,OAAO,EAAE,WAAA,EAAY,MAAO,0BAAA,CAA2B;AACvD,OAAO,EAAE,iBAAA,EAAkB,MAAO,iCAAA,CAAkC;AACpE,OAAO,EAAE,WAAA,EAAY,MAAO,eAAA,CAAgB;AAC5C,OAAO,EAAE,IAAA,EAAK,MAAO,oBAAA,CAAqB;AAC1C,OAAO,EAAE,YAAA,EAAa,MAAO,6BAAA,CAA8B;AAG3D;IAAA;IA4BA,CAAC;IA3BQ,wBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE;gBACT,iBAAiB;gBACjB,WAAW;gBACX,IAAI;gBACJ,YAAY;aACb;SACF,CAAC;IACJ,CAAC;IAiBH,uBAAC;AAAD,CA5BA,AA4BC;;AAhBM,2BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvB,YAAY,EAAE;oBACZ,SAAS;iBACV;gBACD,OAAO,EAAE;oBACP,WAAW;iBACZ;gBACD,OAAO,EAAE;oBACP,SAAS;iBACV;aACF,EAAG,EAAE;CACL,CAAC;AACF,kBAAkB;AACX,+BAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader.module.js","sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../src/image-loader.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAA,EAA8B,MAAO,eAAA,CAAgB;AAC9D,OAAO,EAAE,SAAA,EAAU,MAAO,yBAAA,CAA0B;AACpD,OAAO,EAAE,WAAA,EAAY,MAAO,0BAAA,CAA2B;AAEvD,OAAO,EAAE,iBAAA,EAAkB,MAAO,iCAAA,CAAkC;AACpE,OAAO,EAAE,WAAA,EAAY,MAAO,eAAA,CAAgB;AAC5C,OAAO,EAAE,IAAA,EAAK,MAAO,oBAAA,CAAqB;AAC1C,OAAO,EAAE,YAAA,EAAa,MAAO,6BAAA,CAA8B;AAG3D;IAAA;IA4BA,CAAC;IA3BQ,wBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE;gBACT,iBAAiB;gBACjB,WAAW;gBACX,IAAI;gBACJ,YAAY;aACb;SACF,CAAC;IACJ,CAAC;IAiBH,uBAAC;AAAD,CA5BA,AA4BC;;AAhBM,2BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvB,YAAY,EAAE;oBACZ,SAAS;iBACV;gBACD,OAAO,EAAE;oBACP,WAAW;iBACZ;gBACD,OAAO,EAAE;oBACP,SAAS;iBACV;aACF,EAAG,EAAE;CACL,CAAC;AACF,kBAAkB;AACX,+BAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader.module.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 251e5dd..913c8f0 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,4 +1,5 @@ export * from './image-loader.module'; export * from './components/img-loader'; export * from './providers/image-loader-config'; +export * from './components/image-attribute'; export * from './providers/image-loader'; diff --git a/dist/index.js b/dist/index.js index e0eb36e..bd1e7c8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,6 @@ export * from './image-loader.module'; export * from './components/img-loader'; export * from './providers/image-loader-config'; +export * from './components/image-attribute'; export * from './providers/image-loader'; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index c09b3fc..076713d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC","file":"index.js","sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC","file":"index.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/index.metadata.json b/dist/index.metadata.json index b590e34..f92b08d 100644 --- a/dist/index.metadata.json +++ b/dist/index.metadata.json @@ -1 +1 @@ -[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./providers/image-loader"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./providers/image-loader"}]}] \ No newline at end of file +[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./components/image-attribute"},{"from":"./providers/image-loader"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./components/image-attribute"},{"from":"./providers/image-loader"}]}] \ No newline at end of file diff --git a/src/image-loader.module.ts b/src/image-loader.module.ts index 6573125..8daf6cb 100644 --- a/src/image-loader.module.ts +++ b/src/image-loader.module.ts @@ -1,6 +1,7 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { ImgLoader } from './components/img-loader'; import { ImageLoader } from './providers/image-loader'; +import { ImageAttribute } from './components/image-attribute'; import { ImageLoaderConfig } from './providers/image-loader-config'; import { IonicModule } from 'ionic-angular'; import { File } from '@ionic-native/file'; From 71c04710ce480dc3c9cb4bd8eb0b5e47bc7ffc99 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 15:32:33 +1100 Subject: [PATCH 08/13] Reverted .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b41bc25..31c9f78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules aot +dist .idea From bf40584a9a64b8d59b15acd61fdbc0055dae422a Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 15:35:00 +1100 Subject: [PATCH 09/13] Remove dist files from git repo --- dist/components/image-attribute.d.ts | 4 - dist/components/image-attribute.js | 9 - dist/components/image-attribute.js.map | 1 - dist/components/image-attribute.metadata.json | 1 - dist/components/img-loader.d.ts | 98 ---- dist/components/img-loader.js | 229 -------- dist/components/img-loader.js.map | 1 - dist/components/img-loader.metadata.json | 1 - dist/image-loader.module.d.ts | 4 - dist/image-loader.module.js | 40 -- dist/image-loader.module.js.map | 1 - dist/image-loader.module.metadata.json | 1 - dist/index.d.ts | 5 - dist/index.js | 6 - dist/index.js.map | 1 - dist/index.metadata.json | 1 - dist/providers/image-loader-config.d.ts | 114 ---- dist/providers/image-loader-config.js | 167 ------ dist/providers/image-loader-config.js.map | 1 - .../image-loader-config.metadata.json | 1 - dist/providers/image-loader.d.ts | 144 ----- dist/providers/image-loader.js | 541 ------------------ dist/providers/image-loader.js.map | 1 - dist/providers/image-loader.metadata.json | 1 - 24 files changed, 1373 deletions(-) delete mode 100644 dist/components/image-attribute.d.ts delete mode 100644 dist/components/image-attribute.js delete mode 100644 dist/components/image-attribute.js.map delete mode 100644 dist/components/image-attribute.metadata.json delete mode 100644 dist/components/img-loader.d.ts delete mode 100644 dist/components/img-loader.js delete mode 100644 dist/components/img-loader.js.map delete mode 100644 dist/components/img-loader.metadata.json delete mode 100644 dist/image-loader.module.d.ts delete mode 100644 dist/image-loader.module.js delete mode 100644 dist/image-loader.module.js.map delete mode 100644 dist/image-loader.module.metadata.json delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 dist/index.metadata.json delete mode 100644 dist/providers/image-loader-config.d.ts delete mode 100644 dist/providers/image-loader-config.js delete mode 100644 dist/providers/image-loader-config.js.map delete mode 100644 dist/providers/image-loader-config.metadata.json delete mode 100644 dist/providers/image-loader.d.ts delete mode 100644 dist/providers/image-loader.js delete mode 100644 dist/providers/image-loader.js.map delete mode 100644 dist/providers/image-loader.metadata.json diff --git a/dist/components/image-attribute.d.ts b/dist/components/image-attribute.d.ts deleted file mode 100644 index 7af2235..0000000 --- a/dist/components/image-attribute.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare class ImageAttribute { - element: string; - value: string; -} diff --git a/dist/components/image-attribute.js b/dist/components/image-attribute.js deleted file mode 100644 index a89602a..0000000 --- a/dist/components/image-attribute.js +++ /dev/null @@ -1,9 +0,0 @@ -var ImageAttribute = (function () { - function ImageAttribute() { - this.element = ""; - this.value = ""; - } - return ImageAttribute; -}()); -export { ImageAttribute }; -//# sourceMappingURL=image-attribute.js.map \ No newline at end of file diff --git a/dist/components/image-attribute.js.map b/dist/components/image-attribute.js.map deleted file mode 100644 index 8325d8d..0000000 --- a/dist/components/image-attribute.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/components/image-attribute.ts"],"names":[],"mappings":"AAAA;IAAA;QACI,YAAO,GAAW,EAAE,CAAC;QACrB,UAAK,GAAW,EAAE,CAAC;IACvB,CAAC;IAAD,qBAAC;AAAD,CAHA,AAGC,IAAA","file":"image-attribute.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/components/image-attribute.metadata.json b/dist/components/image-attribute.metadata.json deleted file mode 100644 index f96dfaf..0000000 --- a/dist/components/image-attribute.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{"ImageAttribute":{"__symbolic":"class"}}},{"__symbolic":"module","version":1,"metadata":{"ImageAttribute":{"__symbolic":"class"}}}] \ No newline at end of file diff --git a/dist/components/img-loader.d.ts b/dist/components/img-loader.d.ts deleted file mode 100644 index 3cf5d8d..0000000 --- a/dist/components/img-loader.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { ElementRef, Renderer, OnInit, EventEmitter } from '@angular/core'; -import { ImageLoader } from '../providers/image-loader'; -import { ImageLoaderConfig } from '../providers/image-loader-config'; -import { ImageAttribute } from './image-attribute'; -export declare class ImgLoader implements OnInit { - private _element; - private _renderer; - private _imageLoader; - private _config; - /** - * The URL of the image to load. - */ - src: string; - private _src; - /** - * Fallback URL to load when the image url fails to load or does not exist. - */ - fallbackUrl: string; - /** - * Whether to show a spinner while the image loads - */ - spinner: boolean; - /** - * Whether to show the fallback image instead of a spinner while the image loads - */ - fallbackAsPlaceholder: boolean; - /** - * Use tag - */ - useImg: boolean; - private _useImg; - /** - * Attributes to pass through to img tag if _useImg == true - */ - imgAttributes: ImageAttribute[]; - /** - * Convenience attribute to disable caching - * @param val - */ - noCache: boolean; - /** - * Enable/Disable caching - * @type {boolean} - */ - cache: boolean; - /** - * Width of the image. This will be ignored if using useImg. - */ - width: string; - /** - * Height of the image. This will be ignored if using useImg. - */ - height: string; - /** - * Display type of the image. This will be ignored if using useImg. - */ - display: string; - /** - * Background size. This will be ignored if using useImg. - */ - backgroundSize: string; - /** - * Background repeat. This will be ignored if using useImg. - */ - backgroundRepeat: string; - /** - * Name of the spinner - */ - spinnerName: string; - /** - * Color of the spinner - */ - spinnerColor: string; - /** - * Notify on image load.. - */ - load: EventEmitter; - /** - * Indicates if the image is still loading - * @type {boolean} - */ - isLoading: boolean; - element: HTMLElement; - constructor(_element: ElementRef, _renderer: Renderer, _imageLoader: ImageLoader, _config: ImageLoaderConfig); - ngOnInit(): void; - private updateImage(imageUrl); - /** - * Gets the image URL to be loaded and disables caching if necessary - * @returns {string} - */ - private processImageUrl(imageUrl); - /** - * Set the image to be displayed - * @param imageUrl {string} image src - * @param stopLoading {boolean} set to true to mark the image as loaded - */ - private setImage(imageUrl, stopLoading?); -} diff --git a/dist/components/img-loader.js b/dist/components/img-loader.js deleted file mode 100644 index 14a834b..0000000 --- a/dist/components/img-loader.js +++ /dev/null @@ -1,229 +0,0 @@ -import { Component, Input, Output, ElementRef, Renderer, EventEmitter } from '@angular/core'; -import { ImageLoader } from '../providers/image-loader'; -import { ImageLoaderConfig } from '../providers/image-loader-config'; -var propMap = { - display: 'display', - height: 'height', - width: 'width', - backgroundSize: 'background-size', - backgroundRepeat: 'background-repeat' -}; -var ImgLoader = (function () { - function ImgLoader(_element, _renderer, _imageLoader, _config) { - this._element = _element; - this._renderer = _renderer; - this._imageLoader = _imageLoader; - this._config = _config; - /** - * Fallback URL to load when the image url fails to load or does not exist. - */ - this.fallbackUrl = this._config.fallbackUrl; - /** - * Whether to show a spinner while the image loads - */ - this.spinner = this._config.spinnerEnabled; - /** - * Whether to show the fallback image instead of a spinner while the image loads - */ - this.fallbackAsPlaceholder = this._config.fallbackAsPlaceholder; - this._useImg = this._config.useImg; - /** - * Attributes to pass through to img tag if _useImg == true - */ - this.imgAttributes = []; - /** - * Enable/Disable caching - * @type {boolean} - */ - this.cache = true; - /** - * Width of the image. This will be ignored if using useImg. - */ - this.width = this._config.width; - /** - * Height of the image. This will be ignored if using useImg. - */ - this.height = this._config.height; - /** - * Display type of the image. This will be ignored if using useImg. - */ - this.display = this._config.display; - /** - * Background size. This will be ignored if using useImg. - */ - this.backgroundSize = this._config.backgroundSize; - /** - * Background repeat. This will be ignored if using useImg. - */ - this.backgroundRepeat = this._config.backgroundRepeat; - /** - * Name of the spinner - */ - this.spinnerName = this._config.spinnerName; - /** - * Color of the spinner - */ - this.spinnerColor = this._config.spinnerColor; - /** - * Notify on image load.. - */ - this.load = new EventEmitter(); - /** - * Indicates if the image is still loading - * @type {boolean} - */ - this.isLoading = true; - } - Object.defineProperty(ImgLoader.prototype, "src", { - get: function () { - return this._src; - }, - /** - * The URL of the image to load. - */ - set: function (imageUrl) { - this._src = this.processImageUrl(imageUrl); - this.updateImage(this._src); - }, - enumerable: true, - configurable: true - }); - ; - Object.defineProperty(ImgLoader.prototype, "useImg", { - /** - * Use tag - */ - set: function (val) { - this._useImg = val !== false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ImgLoader.prototype, "noCache", { - /** - * Convenience attribute to disable caching - * @param val - */ - set: function (val) { - this.cache = val !== false; - }, - enumerable: true, - configurable: true - }); - ImgLoader.prototype.ngOnInit = function () { - if (this.fallbackAsPlaceholder && this.fallbackUrl) { - this.setImage(this.fallbackUrl, false); - } - if (!this.src) { - // image url was not passed - // this can happen when [src] is set to a variable that turned out to be undefined - // one example could be a list of users with their profile pictures - // in this case, it would be useful to use the fallback image instead - // if fallbackUrl was used as placeholder we do not need to set it again - if (!this.fallbackAsPlaceholder && this.fallbackUrl) { - // we're not going to cache the fallback image since it should be locally saved - this.setImage(this.fallbackUrl); - } - else { - this.isLoading = false; - } - } - }; - ImgLoader.prototype.updateImage = function (imageUrl) { - var _this = this; - this._imageLoader.getImagePath(imageUrl) - .then(function (imageUrl) { return _this.setImage(imageUrl); }) - .catch(function (error) { return _this.setImage(_this.fallbackUrl || imageUrl); }); - }; - /** - * Gets the image URL to be loaded and disables caching if necessary - * @returns {string} - */ - ImgLoader.prototype.processImageUrl = function (imageUrl) { - if (this.cache === false) { - // need to disable caching - if (imageUrl.indexOf('?') === -1) { - imageUrl += '?'; - } - if (['&', '?'].indexOf(imageUrl.charAt(imageUrl.length)) === -1) { - imageUrl += '&'; - } - // append timestamp at the end to make URL unique - imageUrl += 'cache_buster=' + Date.now(); - } - return imageUrl; - }; - /** - * Set the image to be displayed - * @param imageUrl {string} image src - * @param stopLoading {boolean} set to true to mark the image as loaded - */ - ImgLoader.prototype.setImage = function (imageUrl, stopLoading) { - var _this = this; - if (stopLoading === void 0) { stopLoading = true; } - this.isLoading = !stopLoading; - if (this._useImg) { - // Using tag - if (!this.element) { - // create img element if we dont have one - this.element = this._renderer.createElement(this._element.nativeElement, 'img'); - } - // set it's src - this._renderer.setElementAttribute(this.element, 'src', imageUrl); - // if imgAttributes are defined, add them to our img element - this.imgAttributes.forEach(function (attribute, index, attributeArray) { - _this._renderer.setElementAttribute(_this.element, attribute.element, attribute.value); - }); - if (this.fallbackUrl && !this._imageLoader.nativeAvailable) { - this._renderer.listen(this.element, 'error', function () { return _this._renderer.setElementAttribute(_this.element, 'src', _this.fallbackUrl); }); - } - } - else { - // Not using tag - this.element = this._element.nativeElement; - for (var prop in propMap) { - if (this[prop]) { - this._renderer.setElementStyle(this.element, propMap[prop], this[prop]); - } - } - this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + (imageUrl || this.fallbackUrl) + '\')'); - } - this.load.emit(this); - }; - return ImgLoader; -}()); -export { ImgLoader }; -ImgLoader.decorators = [ - { type: Component, args: [{ - selector: 'img-loader', - template: '' + - '', - styles: ['ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }'] - },] }, -]; -/** @nocollapse */ -ImgLoader.ctorParameters = function () { return [ - { type: ElementRef, }, - { type: Renderer, }, - { type: ImageLoader, }, - { type: ImageLoaderConfig, }, -]; }; -ImgLoader.propDecorators = { - 'src': [{ type: Input },], - 'fallbackUrl': [{ type: Input, args: ['fallback',] },], - 'spinner': [{ type: Input },], - 'fallbackAsPlaceholder': [{ type: Input },], - 'useImg': [{ type: Input },], - 'imgAttributes': [{ type: Input, args: ['imgAttributes',] },], - 'noCache': [{ type: Input },], - 'cache': [{ type: Input },], - 'width': [{ type: Input },], - 'height': [{ type: Input },], - 'display': [{ type: Input },], - 'backgroundSize': [{ type: Input },], - 'backgroundRepeat': [{ type: Input },], - 'spinnerName': [{ type: Input },], - 'spinnerColor': [{ type: Input },], - 'load': [{ type: Output },], -}; -//# sourceMappingURL=img-loader.js.map \ No newline at end of file diff --git a/dist/components/img-loader.js.map b/dist/components/img-loader.js.map deleted file mode 100644 index 14d1eea..0000000 --- a/dist/components/img-loader.js.map +++ /dev/null @@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AE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,uBAAuB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3C,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5B,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,eAAe,EAAG,EAAE,EAAE;IAC9D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC3B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC5B,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACpC,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACtC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IACjC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CAC1B,CAAC","file":"img-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/components/img-loader.metadata.json b/dist/components/img-loader.metadata.json deleted file mode 100644 index 3c493e0..0000000 --- a/dist/components/img-loader.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{"ImgLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"img-loader","template":"","styles":["ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }"]}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackUrl":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["fallback"]}]}],"spinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackAsPlaceholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"useImg":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"imgAttributes":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["imgAttributes"]}]}],"noCache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"cache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"width":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"display":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundSize":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundRepeat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerColor":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"load":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"../providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"../providers/image-loader-config","name":"ImageLoaderConfig"}]}],"ngOnInit":[{"__symbolic":"method"}],"updateImage":[{"__symbolic":"method"}],"processImageUrl":[{"__symbolic":"method"}],"setImage":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImgLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"img-loader","template":"","styles":["ion-spinner { float: none; margin-left: auto; margin-right: auto; display: block; }"]}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackUrl":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["fallback"]}]}],"spinner":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"fallbackAsPlaceholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"useImg":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"imgAttributes":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["imgAttributes"]}]}],"noCache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"cache":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"width":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"height":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"display":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundSize":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"backgroundRepeat":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"spinnerColor":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"load":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"../providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"../providers/image-loader-config","name":"ImageLoaderConfig"}]}],"ngOnInit":[{"__symbolic":"method"}],"updateImage":[{"__symbolic":"method"}],"processImageUrl":[{"__symbolic":"method"}],"setImage":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/dist/image-loader.module.d.ts b/dist/image-loader.module.d.ts deleted file mode 100644 index 5c64f81..0000000 --- a/dist/image-loader.module.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ModuleWithProviders } from '@angular/core'; -export declare class IonicImageLoader { - static forRoot(): ModuleWithProviders; -} diff --git a/dist/image-loader.module.js b/dist/image-loader.module.js deleted file mode 100644 index bcd36f6..0000000 --- a/dist/image-loader.module.js +++ /dev/null @@ -1,40 +0,0 @@ -import { NgModule } from '@angular/core'; -import { ImgLoader } from './components/img-loader'; -import { ImageLoader } from './providers/image-loader'; -import { ImageLoaderConfig } from './providers/image-loader-config'; -import { IonicModule } from 'ionic-angular'; -import { File } from '@ionic-native/file'; -import { FileTransfer } from '@ionic-native/file-transfer'; -var IonicImageLoader = (function () { - function IonicImageLoader() { - } - IonicImageLoader.forRoot = function () { - return { - ngModule: IonicImageLoader, - providers: [ - ImageLoaderConfig, - ImageLoader, - File, - FileTransfer - ] - }; - }; - return IonicImageLoader; -}()); -export { IonicImageLoader }; -IonicImageLoader.decorators = [ - { type: NgModule, args: [{ - declarations: [ - ImgLoader - ], - imports: [ - IonicModule - ], - exports: [ - ImgLoader - ] - },] }, -]; -/** @nocollapse */ -IonicImageLoader.ctorParameters = function () { return []; }; -//# sourceMappingURL=image-loader.module.js.map \ No newline at end of file diff --git a/dist/image-loader.module.js.map b/dist/image-loader.module.js.map deleted file mode 100644 index a993f45..0000000 --- a/dist/image-loader.module.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/image-loader.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAA,EAA8B,MAAO,eAAA,CAAgB;AAC9D,OAAO,EAAE,SAAA,EAAU,MAAO,yBAAA,CAA0B;AACpD,OAAO,EAAE,WAAA,EAAY,MAAO,0BAAA,CAA2B;AAEvD,OAAO,EAAE,iBAAA,EAAkB,MAAO,iCAAA,CAAkC;AACpE,OAAO,EAAE,WAAA,EAAY,MAAO,eAAA,CAAgB;AAC5C,OAAO,EAAE,IAAA,EAAK,MAAO,oBAAA,CAAqB;AAC1C,OAAO,EAAE,YAAA,EAAa,MAAO,6BAAA,CAA8B;AAG3D;IAAA;IA4BA,CAAC;IA3BQ,wBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,gBAAgB;YAC1B,SAAS,EAAE;gBACT,iBAAiB;gBACjB,WAAW;gBACX,IAAI;gBACJ,YAAY;aACb;SACF,CAAC;IACJ,CAAC;IAiBH,uBAAC;AAAD,CA5BA,AA4BC;;AAhBM,2BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvB,YAAY,EAAE;oBACZ,SAAS;iBACV;gBACD,OAAO,EAAE;oBACP,WAAW;iBACZ;gBACD,OAAO,EAAE;oBACP,SAAS;iBACV;aACF,EAAG,EAAE;CACL,CAAC;AACF,kBAAkB;AACX,+BAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader.module.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/image-loader.module.metadata.json b/dist/image-loader.module.metadata.json deleted file mode 100644 index cde94e3..0000000 --- a/dist/image-loader.module.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{"IonicImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}],"imports":[{"__symbolic":"reference","module":"ionic-angular","name":"IonicModule"}],"exports":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"IonicImageLoader"},"providers":[{"__symbolic":"reference","module":"./providers/image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"./providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"}]}}}}}},{"__symbolic":"module","version":1,"metadata":{"IonicImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}],"imports":[{"__symbolic":"reference","module":"ionic-angular","name":"IonicModule"}],"exports":[{"__symbolic":"reference","module":"./components/img-loader","name":"ImgLoader"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"IonicImageLoader"},"providers":[{"__symbolic":"reference","module":"./providers/image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"./providers/image-loader","name":"ImageLoader"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"}]}}}}}}] \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 913c8f0..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './image-loader.module'; -export * from './components/img-loader'; -export * from './providers/image-loader-config'; -export * from './components/image-attribute'; -export * from './providers/image-loader'; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bd1e7c8..0000000 --- a/dist/index.js +++ /dev/null @@ -1,6 +0,0 @@ -export * from './image-loader.module'; -export * from './components/img-loader'; -export * from './providers/image-loader-config'; -export * from './components/image-attribute'; -export * from './providers/image-loader'; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 076713d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC","file":"index.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/index.metadata.json b/dist/index.metadata.json deleted file mode 100644 index f92b08d..0000000 --- a/dist/index.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./components/image-attribute"},{"from":"./providers/image-loader"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./image-loader.module"},{"from":"./components/img-loader"},{"from":"./providers/image-loader-config"},{"from":"./components/image-attribute"},{"from":"./providers/image-loader"}]}] \ No newline at end of file diff --git a/dist/providers/image-loader-config.d.ts b/dist/providers/image-loader-config.d.ts deleted file mode 100644 index 2c8557c..0000000 --- a/dist/providers/image-loader-config.d.ts +++ /dev/null @@ -1,114 +0,0 @@ -export declare class ImageLoaderConfig { - debugMode: boolean; - spinnerEnabled: boolean; - fallbackAsPlaceholder: boolean; - backgroundSize: string; - backgroundRepeat: string; - display: string; - width: string; - height: string; - useImg: boolean; - fallbackUrl: string; - concurrency: number; - maxCacheSize: number; - maxCacheAge: number; - imageReturnType: 'base64' | 'uri'; - spinnerName: string; - spinnerColor: string; - fileTransferOptions: any; - private _cacheDirectoryName; - cacheDirectoryName: string; - /** - * Enables debug mode to receive console logs, errors, warnings - */ - enableDebugMode(): void; - /** - * Enable/Disable the spinner by default. Defaults to true. - * @param enable {boolean} set to true to enable - */ - enableSpinner(enable: boolean): void; - /** - * Enable/Disable the fallback image as placeholder instead of the spinner. Defaults to false. - * @param enable {boolean} set to true to enable - */ - enableFallbackAsPlaceholder(enable: boolean): void; - /** - * Sets the cache directory name. Defaults to 'image-loader-cache' - * @param name {string} name of directory - */ - setCacheDirectoryName(name: string): void; - /** - * Set default height for images that are not using tag - * @param height {string} height - */ - setHeight(height: string): void; - /** - * Set default width for images that are not using tag - * @param width {string} Width - */ - setWidth(width: string): void; - /** - * Enable display mode for images that are not using tag - * @param display {string} Display mode - */ - setDisplay(display: string): void; - /** - * Use tag by default - * @param use {boolean} set to true to use tag by default - */ - useImageTag(use: boolean): void; - /** - * Set default background size for images that are not using tag - * @param backgroundSize {string} Background size - */ - setBackgroundSize(backgroundSize: string): void; - /** - * Set background repeat for images that are not using tag - * @param backgroundRepeat {string} Background repeat - */ - setBackgroundRepeat(backgroundRepeat: string): void; - /** - * Set fallback URL to use when image src is undefined or did not resolve. - * This image will not be cached. This should ideally be a locally saved image. - * @param fallbackUrl {string} The remote or local URL of the image - */ - setFallbackUrl(fallbackUrl: string): void; - /** - * Set the maximum number of allowed connections at the same time. - * @param concurrency - */ - setConcurrency(concurrency: number): void; - /** - * Sets the maximum allowed cache size - * @param cacheSize {number} Cache size in bytes - */ - setMaximumCacheSize(cacheSize: number): void; - /** - * Sets the maximum allowed cache age - * @param cacheAge {number} Maximum cache age in milliseconds - */ - setMaximumCacheAge(cacheAge: number): void; - /** - * Set the return type of cached images - * @param imageReturnType {string} The return type; either 'base64' or 'uri' - */ - setImageReturnType(imageReturnType: 'base64' | 'uri'): void; - /** - * Set the default spinnern ame - * @param name - */ - setSpinnerName(name: string): void; - /** - * Set the default spinner color - * @param color - */ - setSpinnerColor(color: string): void; - /** - * Set options for the FileTransfer plugin - * @param options - */ - setFileTransferOptions(options: { - trustAllHosts: boolean; - [key: string]: any; - }): void; -} diff --git a/dist/providers/image-loader-config.js b/dist/providers/image-loader-config.js deleted file mode 100644 index b145097..0000000 --- a/dist/providers/image-loader-config.js +++ /dev/null @@ -1,167 +0,0 @@ -import { Injectable } from '@angular/core'; -var ImageLoaderConfig = (function () { - function ImageLoaderConfig() { - this.debugMode = false; - this.spinnerEnabled = true; - this.fallbackAsPlaceholder = false; - this.backgroundSize = 'contain'; - this.backgroundRepeat = 'no-repeat'; - this.display = 'block'; - this.width = '100%'; - this.height = '100%'; - this.useImg = false; - this.concurrency = 5; - this.maxCacheSize = -1; - this.maxCacheAge = -1; - this.imageReturnType = 'uri'; - this.fileTransferOptions = { - trustAllHosts: false - }; - this._cacheDirectoryName = 'image-loader-cache'; - } - Object.defineProperty(ImageLoaderConfig.prototype, "cacheDirectoryName", { - get: function () { - return this._cacheDirectoryName; - }, - set: function (name) { - name.replace(/\W/g, ''); - this._cacheDirectoryName = name; - }, - enumerable: true, - configurable: true - }); - /** - * Enables debug mode to receive console logs, errors, warnings - */ - ImageLoaderConfig.prototype.enableDebugMode = function () { - this.debugMode = true; - }; - /** - * Enable/Disable the spinner by default. Defaults to true. - * @param enable {boolean} set to true to enable - */ - ImageLoaderConfig.prototype.enableSpinner = function (enable) { - this.spinnerEnabled = enable; - }; - /** - * Enable/Disable the fallback image as placeholder instead of the spinner. Defaults to false. - * @param enable {boolean} set to true to enable - */ - ImageLoaderConfig.prototype.enableFallbackAsPlaceholder = function (enable) { - this.fallbackAsPlaceholder = enable; - }; - /** - * Sets the cache directory name. Defaults to 'image-loader-cache' - * @param name {string} name of directory - */ - ImageLoaderConfig.prototype.setCacheDirectoryName = function (name) { - this.cacheDirectoryName = name; - }; - /** - * Set default height for images that are not using tag - * @param height {string} height - */ - ImageLoaderConfig.prototype.setHeight = function (height) { - this.height = height; - }; - /** - * Set default width for images that are not using tag - * @param width {string} Width - */ - ImageLoaderConfig.prototype.setWidth = function (width) { - this.width = width; - }; - /** - * Enable display mode for images that are not using tag - * @param display {string} Display mode - */ - ImageLoaderConfig.prototype.setDisplay = function (display) { - this.display = display; - }; - /** - * Use tag by default - * @param use {boolean} set to true to use tag by default - */ - ImageLoaderConfig.prototype.useImageTag = function (use) { - this.useImg = use; - }; - /** - * Set default background size for images that are not using tag - * @param backgroundSize {string} Background size - */ - ImageLoaderConfig.prototype.setBackgroundSize = function (backgroundSize) { - this.backgroundSize = backgroundSize; - }; - /** - * Set background repeat for images that are not using tag - * @param backgroundRepeat {string} Background repeat - */ - ImageLoaderConfig.prototype.setBackgroundRepeat = function (backgroundRepeat) { - this.backgroundRepeat = backgroundRepeat; - }; - /** - * Set fallback URL to use when image src is undefined or did not resolve. - * This image will not be cached. This should ideally be a locally saved image. - * @param fallbackUrl {string} The remote or local URL of the image - */ - ImageLoaderConfig.prototype.setFallbackUrl = function (fallbackUrl) { - this.fallbackUrl = fallbackUrl; - }; - /** - * Set the maximum number of allowed connections at the same time. - * @param concurrency - */ - ImageLoaderConfig.prototype.setConcurrency = function (concurrency) { - this.concurrency = concurrency; - }; - /** - * Sets the maximum allowed cache size - * @param cacheSize {number} Cache size in bytes - */ - ImageLoaderConfig.prototype.setMaximumCacheSize = function (cacheSize) { - this.maxCacheSize = cacheSize; - }; - /** - * Sets the maximum allowed cache age - * @param cacheAge {number} Maximum cache age in milliseconds - */ - ImageLoaderConfig.prototype.setMaximumCacheAge = function (cacheAge) { - this.maxCacheAge = cacheAge; - }; - /** - * Set the return type of cached images - * @param imageReturnType {string} The return type; either 'base64' or 'uri' - */ - ImageLoaderConfig.prototype.setImageReturnType = function (imageReturnType) { - this.imageReturnType = imageReturnType; - }; - /** - * Set the default spinnern ame - * @param name - */ - ImageLoaderConfig.prototype.setSpinnerName = function (name) { - this.spinnerName = name; - }; - /** - * Set the default spinner color - * @param color - */ - ImageLoaderConfig.prototype.setSpinnerColor = function (color) { - this.spinnerColor = color; - }; - /** - * Set options for the FileTransfer plugin - * @param options - */ - ImageLoaderConfig.prototype.setFileTransferOptions = function (options) { - this.fileTransferOptions = options; - }; - return ImageLoaderConfig; -}()); -export { ImageLoaderConfig }; -ImageLoaderConfig.decorators = [ - { type: Injectable }, -]; -/** @nocollapse */ -ImageLoaderConfig.ctorParameters = function () { return []; }; -//# sourceMappingURL=image-loader-config.js.map \ No newline at end of file diff --git a/dist/providers/image-loader-config.js.map b/dist/providers/image-loader-config.js.map deleted file mode 100644 index 99e49ce..0000000 --- a/dist/providers/image-loader-config.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/providers/image-loader-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAA,EAAW,MAAO,eAAA,CAAgB;AAG3C;IAAA;QAEE,cAAS,GAAY,KAAK,CAAC;QAE3B,mBAAc,GAAY,IAAI,CAAC;QAE/B,0BAAqB,GAAY,KAAK,CAAC;QAEvC,mBAAc,GAA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,wBAAC;AAAD,CAvMA,AAuMC;;AANM,4BAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,UAAU,EAAE;CACnB,CAAC;AACF,kBAAkB;AACX,gCAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC","file":"image-loader-config.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/providers/image-loader-config.metadata.json b/dist/providers/image-loader-config.metadata.json deleted file mode 100644 index 7bdd35d..0000000 --- a/dist/providers/image-loader-config.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{"ImageLoaderConfig":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"enableDebugMode":[{"__symbolic":"method"}],"enableSpinner":[{"__symbolic":"method"}],"enableFallbackAsPlaceholder":[{"__symbolic":"method"}],"setCacheDirectoryName":[{"__symbolic":"method"}],"setHeight":[{"__symbolic":"method"}],"setWidth":[{"__symbolic":"method"}],"setDisplay":[{"__symbolic":"method"}],"useImageTag":[{"__symbolic":"method"}],"setBackgroundSize":[{"__symbolic":"method"}],"setBackgroundRepeat":[{"__symbolic":"method"}],"setFallbackUrl":[{"__symbolic":"method"}],"setConcurrency":[{"__symbolic":"method"}],"setMaximumCacheSize":[{"__symbolic":"method"}],"setMaximumCacheAge":[{"__symbolic":"method"}],"setImageReturnType":[{"__symbolic":"method"}],"setSpinnerName":[{"__symbolic":"method"}],"setSpinnerColor":[{"__symbolic":"method"}],"setFileTransferOptions":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImageLoaderConfig":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"enableDebugMode":[{"__symbolic":"method"}],"enableSpinner":[{"__symbolic":"method"}],"enableFallbackAsPlaceholder":[{"__symbolic":"method"}],"setCacheDirectoryName":[{"__symbolic":"method"}],"setHeight":[{"__symbolic":"method"}],"setWidth":[{"__symbolic":"method"}],"setDisplay":[{"__symbolic":"method"}],"useImageTag":[{"__symbolic":"method"}],"setBackgroundSize":[{"__symbolic":"method"}],"setBackgroundRepeat":[{"__symbolic":"method"}],"setFallbackUrl":[{"__symbolic":"method"}],"setConcurrency":[{"__symbolic":"method"}],"setMaximumCacheSize":[{"__symbolic":"method"}],"setMaximumCacheAge":[{"__symbolic":"method"}],"setImageReturnType":[{"__symbolic":"method"}],"setSpinnerName":[{"__symbolic":"method"}],"setSpinnerColor":[{"__symbolic":"method"}],"setFileTransferOptions":[{"__symbolic":"method"}]}}}}] \ No newline at end of file diff --git a/dist/providers/image-loader.d.ts b/dist/providers/image-loader.d.ts deleted file mode 100644 index 32875a8..0000000 --- a/dist/providers/image-loader.d.ts +++ /dev/null @@ -1,144 +0,0 @@ -import { File } from '@ionic-native/file'; -import { FileTransfer } from '@ionic-native/file-transfer'; -import { ImageLoaderConfig } from "./image-loader-config"; -import { Platform } from 'ionic-angular'; -import 'rxjs/add/operator/first'; -export declare class ImageLoader { - private config; - private file; - private fileTransfer; - private platform; - readonly nativeAvailable: boolean; - /** - * Indicates if the cache service is ready. - * When the cache service isn't ready, images are loaded via browser instead. - * @type {boolean} - */ - private isCacheReady; - /** - * Indicates if this service is initialized. - * This service is initialized once all the setup is done. - * @type {boolean} - */ - private isInit; - /** - * Number of concurrent requests allowed - * @type {number} - */ - private concurrency; - /** - * Queue items - * @type {Array} - */ - private queue; - private transferInstances; - private processing; - private cacheIndex; - private currentCacheSize; - private indexed; - private readonly shouldIndex; - private readonly isWKWebView; - private readonly isIonicWKWebView; - constructor(config: ImageLoaderConfig, file: File, fileTransfer: FileTransfer, platform: Platform); - /** - * Preload an image - * @param imageUrl {string} Image URL - * @returns {Promise} returns a promise that resolves with the cached image URL - */ - preload(imageUrl: string): Promise; - /** - * Clears the cache - */ - clearCache(): void; - /** - * Gets the filesystem path of an image. - * This will return the remote path if anything goes wrong or if the cache service isn't ready yet. - * @param imageUrl {string} The remote URL of the image - * @returns {Promise} Returns a promise that will always resolve with an image URL - */ - getImagePath(imageUrl: string): Promise; - /** - * Add an item to the queue - * @param imageUrl - * @param resolve - * @param reject - */ - private addItemToQueue(imageUrl, resolve, reject); - /** - * Check if we can process more items in the queue - * @returns {boolean} - */ - private readonly canProcess; - /** - * Processes one item from the queue - */ - private processQueue(); - /** - * Initialize the cache service - * @param replace {boolean} Whether to replace the cache directory if it already exists - */ - private initCache(replace?); - /** - * Adds a file to index. - * Also deletes any files if they are older than the set maximum cache age. - * @param file {FileEntry} File to index - * @returns {Promise} - */ - private addFileToIndex(file); - /** - * Indexes the cache if necessary - * @returns {any} - */ - private indexCache(); - /** - * This method runs every time a new file is added. - * It checks the cache size and ensures that it doesn't exceed the maximum cache size set in the config. - * If the limit is reached, it will delete old images to create free space. - */ - private maintainCacheSize(); - /** - * Remove a file - * @param file {string} The name of the file to remove - */ - private removeFile(file); - /** - * Get the local path of a previously cached image if exists - * @param url {string} The remote URL of the image - * @returns {Promise} Returns a promise that resolves with the local path if exists, or rejects if doesn't exist - */ - private getCachedImagePath(url); - /** - * Throws a console error if debug mode is enabled - * @param args {any[]} Error message - */ - private throwError(...args); - /** - * Throws a console warning if debug mode is enabled - * @param args {any[]} Error message - */ - private throwWarning(...args); - /** - * Check if the cache directory exists - * @param directory {string} The directory to check. Either this.file.tempDirectory or this.file.cacheDirectory - * @returns {Promise} Returns a promise that resolves if exists, and rejects if it doesn't - */ - private cacheDirectoryExists(directory); - /** - * Create the cache directories - * @param replace {boolean} override directory if exists - * @returns {Promise} Returns a promise that resolves if the directories were created, and rejects on error - */ - private createCacheDirectory(replace?); - /** - * Creates a unique file name out of the URL - * @param url {string} URL of the file - * @returns {string} Unique file name - */ - private createFileName(url); - /** - * Converts a string to a unique 32-bit int - * @param string {string} string to hash - * @returns {number} 32-bit int - */ - private hashString(string); -} diff --git a/dist/providers/image-loader.js b/dist/providers/image-loader.js deleted file mode 100644 index 18f7090..0000000 --- a/dist/providers/image-loader.js +++ /dev/null @@ -1,541 +0,0 @@ -import { Injectable } from '@angular/core'; -import { File } from '@ionic-native/file'; -import { FileTransfer } from '@ionic-native/file-transfer'; -import { ImageLoaderConfig } from "./image-loader-config"; -import { Platform } from 'ionic-angular'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/first'; -var ImageLoader = (function () { - function ImageLoader(config, file, fileTransfer, platform) { - var _this = this; - this.config = config; - this.file = file; - this.fileTransfer = fileTransfer; - this.platform = platform; - /** - * Indicates if the cache service is ready. - * When the cache service isn't ready, images are loaded via browser instead. - * @type {boolean} - */ - this.isCacheReady = false; - /** - * Indicates if this service is initialized. - * This service is initialized once all the setup is done. - * @type {boolean} - */ - this.isInit = false; - /** - * Number of concurrent requests allowed - * @type {number} - */ - this.concurrency = 5; - /** - * Queue items - * @type {Array} - */ - this.queue = []; - this.transferInstances = []; - this.processing = 0; - this.cacheIndex = []; - this.currentCacheSize = 0; - this.indexed = false; - if (!platform.is('cordova')) { - // we are running on a browser, or using livereload - // plugin will not function in this case - this.isInit = true; - this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); - } - else { - Observable.fromEvent(document, 'deviceready').first().subscribe(function (res) { - if (_this.nativeAvailable) { - _this.initCache(); - } - else { - // we are running on a browser, or using livereload - // plugin will not function in this case - _this.isInit = true; - _this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.'); - } - }); - } - } - Object.defineProperty(ImageLoader.prototype, "nativeAvailable", { - get: function () { - return File.installed() && FileTransfer.installed(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ImageLoader.prototype, "shouldIndex", { - get: function () { - return (this.config.maxCacheAge > -1) || (this.config.maxCacheSize > -1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ImageLoader.prototype, "isWKWebView", { - get: function () { - return this.platform.is('ios') && window.webkit && window.webkit.messageHandlers; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ImageLoader.prototype, "isIonicWKWebView", { - get: function () { - return this.isWKWebView && (location.host === 'localhost:8080' || window.LiveReload); - }, - enumerable: true, - configurable: true - }); - /** - * Preload an image - * @param imageUrl {string} Image URL - * @returns {Promise} returns a promise that resolves with the cached image URL - */ - ImageLoader.prototype.preload = function (imageUrl) { - return this.getImagePath(imageUrl); - }; - /** - * Clears the cache - */ - ImageLoader.prototype.clearCache = function () { - var _this = this; - if (!this.platform.is('cordova')) - return; - var clear = function () { - if (!_this.isInit) { - // do not run this method until our service is initialized - setTimeout(clear.bind(_this), 500); - return; - } - // pause any operations - _this.isInit = false; - _this.file.removeRecursively(_this.file.cacheDirectory, _this.config.cacheDirectoryName) - .then(function () { - if (_this.isWKWebView && !_this.isIonicWKWebView) { - // also clear the temp files - _this.file.removeRecursively(_this.file.tempDirectory, _this.config.cacheDirectoryName) - .catch(function (error) { - // Noop catch. Removing the tempDirectory might fail, - // as it is not persistent. - }) - .then(function () { - _this.initCache(true); - }); - } - else { - _this.initCache(true); - } - }) - .catch(_this.throwError.bind(_this)); - }; - clear(); - }; - /** - * Gets the filesystem path of an image. - * This will return the remote path if anything goes wrong or if the cache service isn't ready yet. - * @param imageUrl {string} The remote URL of the image - * @returns {Promise} Returns a promise that will always resolve with an image URL - */ - ImageLoader.prototype.getImagePath = function (imageUrl) { - var _this = this; - if (typeof imageUrl !== 'string' || imageUrl.length <= 0) { - return Promise.reject('The image url provided was empty or invalid.'); - } - return new Promise(function (resolve, reject) { - var getImage = function () { - _this.getCachedImagePath(imageUrl) - .then(resolve) - .catch(function () { - // image doesn't exist in cache, lets fetch it and save it - _this.addItemToQueue(imageUrl, resolve, reject); - }); - }; - var check = function () { - if (_this.isInit) { - if (_this.isCacheReady) { - getImage(); - } - else { - _this.throwWarning('The cache system is not running. Images will be loaded by your browser instead.'); - resolve(imageUrl); - } - } - else { - setTimeout(function () { return check(); }, 250); - } - }; - check(); - }); - }; - /** - * Add an item to the queue - * @param imageUrl - * @param resolve - * @param reject - */ - ImageLoader.prototype.addItemToQueue = function (imageUrl, resolve, reject) { - this.queue.push({ - imageUrl: imageUrl, - resolve: resolve, - reject: reject - }); - this.processQueue(); - }; - Object.defineProperty(ImageLoader.prototype, "canProcess", { - /** - * Check if we can process more items in the queue - * @returns {boolean} - */ - get: function () { - return (this.queue.length > 0 - && this.processing < this.concurrency); - }, - enumerable: true, - configurable: true - }); - /** - * Processes one item from the queue - */ - ImageLoader.prototype.processQueue = function () { - var _this = this; - // make sure we can process items first - if (!this.canProcess) - return; - // increase the processing number - this.processing++; - // take the first item from queue - var currentItem = this.queue.splice(0, 1)[0]; - // create FileTransferObject instance if needed - // we would only reach here if current jobs < concurrency limit - // so, there's no need to check anything other than the length of - // the FileTransferObject instances we have in memory - if (this.transferInstances.length === 0) { - this.transferInstances.push(this.fileTransfer.create()); - } - var transfer = this.transferInstances.splice(0, 1)[0]; - // process more items concurrently if we can - if (this.canProcess) - this.processQueue(); - // function to call when done processing this item - // this will reduce the processing number - // then will execute this function again to process any remaining items - var done = function () { - _this.processing--; - _this.transferInstances.push(transfer); - _this.processQueue(); - }; - var localPath = this.file.cacheDirectory + this.config.cacheDirectoryName + '/' + this.createFileName(currentItem.imageUrl); - transfer.download(currentItem.imageUrl, localPath, Boolean(this.config.fileTransferOptions.trustAllHosts), this.config.fileTransferOptions) - .then(function (file) { - if (_this.shouldIndex) { - _this.addFileToIndex(file).then(_this.maintainCacheSize.bind(_this)); - } - return _this.getCachedImagePath(currentItem.imageUrl); - }) - .then(function (localUrl) { - currentItem.resolve(localUrl); - done(); - }) - .catch(function (e) { - currentItem.reject(); - _this.throwError(e); - done(); - }); - }; - /** - * Initialize the cache service - * @param replace {boolean} Whether to replace the cache directory if it already exists - */ - ImageLoader.prototype.initCache = function (replace) { - var _this = this; - this.concurrency = this.config.concurrency; - // create cache directories if they do not exist - this.createCacheDirectory(replace) - .catch(function (e) { - _this.throwError(e); - _this.isInit = true; - }) - .then(function () { return _this.indexCache(); }) - .then(function () { - _this.isCacheReady = true; - _this.isInit = true; - }); - }; - /** - * Adds a file to index. - * Also deletes any files if they are older than the set maximum cache age. - * @param file {FileEntry} File to index - * @returns {Promise} - */ - ImageLoader.prototype.addFileToIndex = function (file) { - var _this = this; - return new Promise(function (resolve, reject) { return file.getMetadata(resolve, reject); }) - .then(function (metadata) { - if (_this.config.maxCacheAge > -1 - && (Date.now() - metadata.modificationTime.getTime()) > _this.config.maxCacheAge) { - // file age exceeds maximum cache age - return _this.removeFile(file.name); - } - else { - // file age doesn't exceed maximum cache age, or maximum cache age isn't set - _this.currentCacheSize += metadata.size; - // add item to index - _this.cacheIndex.push({ - name: file.name, - modificationTime: metadata.modificationTime, - size: metadata.size - }); - return Promise.resolve(); - } - }); - }; - /** - * Indexes the cache if necessary - * @returns {any} - */ - ImageLoader.prototype.indexCache = function () { - var _this = this; - // only index if needed, to save resources - if (!this.shouldIndex) - return Promise.resolve(); - this.cacheIndex = []; - return this.file.listDir(this.file.cacheDirectory, this.config.cacheDirectoryName) - .then(function (files) { return Promise.all(files.map(_this.addFileToIndex.bind(_this))); }) - .then(function () { - // Sort items by date. Most recent to oldest. - _this.cacheIndex = _this.cacheIndex.sort(function (a, b) { return a > b ? -1 : a < b ? 1 : 0; }); - _this.indexed = true; - return Promise.resolve(); - }) - .catch(function (e) { - _this.throwError(e); - return Promise.resolve(); - }); - }; - /** - * This method runs every time a new file is added. - * It checks the cache size and ensures that it doesn't exceed the maximum cache size set in the config. - * If the limit is reached, it will delete old images to create free space. - */ - ImageLoader.prototype.maintainCacheSize = function () { - var _this = this; - if (this.config.maxCacheSize > -1 && this.indexed) { - var maintain_1 = function () { - if (_this.currentCacheSize > _this.config.maxCacheSize) { - // called when item is done processing - var next_1 = function () { - _this.currentCacheSize -= file_1.size; - maintain_1(); - }; - // grab the first item in index since it's the oldest one - var file_1 = _this.cacheIndex.splice(0, 1)[0]; - if (typeof file_1 == 'undefined') - return maintain_1(); - // delete the file then process next file if necessary - _this.removeFile(file_1.name) - .then(function () { return next_1(); }) - .catch(function () { return next_1(); }); // ignore errors, nothing we can do about it - } - }; - maintain_1(); - } - }; - /** - * Remove a file - * @param file {string} The name of the file to remove - */ - ImageLoader.prototype.removeFile = function (file) { - var _this = this; - return this.file - .removeFile(this.file.cacheDirectory + this.config.cacheDirectoryName, file) - .then(function () { - if (_this.isWKWebView && !_this.isIonicWKWebView) { - return _this.file - .removeFile(_this.file.tempDirectory + _this.config.cacheDirectoryName, file) - .catch(function () { - // Noop catch. Removing the files from tempDirectory might fail, as it is not persistent. - }); - } - }); - }; - /** - * Get the local path of a previously cached image if exists - * @param url {string} The remote URL of the image - * @returns {Promise} Returns a promise that resolves with the local path if exists, or rejects if doesn't exist - */ - ImageLoader.prototype.getCachedImagePath = function (url) { - var _this = this; - return new Promise(function (resolve, reject) { - // make sure cache is ready - if (!_this.isCacheReady) { - return reject(); - } - // get file name - var fileName = _this.createFileName(url); - // get full path - var dirPath = _this.file.cacheDirectory + _this.config.cacheDirectoryName, tempDirPath = _this.file.tempDirectory + _this.config.cacheDirectoryName; - // check if exists - _this.file.resolveLocalFilesystemUrl(dirPath + '/' + fileName) - .then(function (fileEntry) { - // file exists in cache - if (_this.config.imageReturnType === 'base64') { - // read the file as data url and return the base64 string. - // should always be successful as the existence of the file - // is alreay ensured - _this.file - .readAsDataURL(dirPath, fileName) - .then(function (base64) { - base64 = base64.replace('data:null', 'data:*/*'); - resolve(base64); - }) - .catch(reject); - } - else if (_this.config.imageReturnType === 'uri') { - // now check if iOS device & using WKWebView Engine. - // in this case only the tempDirectory is accessible, - // therefore the file needs to be copied into that directory first! - if (_this.isIonicWKWebView) { - // Ionic WKWebView can access all files, but we just need to replace file:/// with http://localhost:8080/ - resolve(fileEntry.nativeURL.replace('file:///', 'http://localhost:8080/')); - } - else if (_this.isWKWebView) { - // check if file already exists in temp directory - _this.file.resolveLocalFilesystemUrl(tempDirPath + '/' + fileName) - .then(function (tempFileEntry) { - // file exists in temp directory - // return native path - resolve(tempFileEntry.nativeURL); - }) - .catch(function () { - // file does not yet exist in the temp directory. - // copy it! - _this.file.copyFile(dirPath, fileName, tempDirPath, fileName) - .then(function (tempFileEntry) { - // now the file exists in the temp directory - // return native path - resolve(tempFileEntry.nativeURL); - }) - .catch(reject); - }); - } - else { - // return native path - resolve(fileEntry.nativeURL); - } - } - }) - .catch(reject); // file doesn't exist - }); - }; - /** - * Throws a console error if debug mode is enabled - * @param args {any[]} Error message - */ - ImageLoader.prototype.throwError = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (this.config.debugMode) { - args.unshift('ImageLoader Error: '); - console.error.apply(console, args); - } - }; - /** - * Throws a console warning if debug mode is enabled - * @param args {any[]} Error message - */ - ImageLoader.prototype.throwWarning = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (this.config.debugMode) { - args.unshift('ImageLoader Warning: '); - console.warn.apply(console, args); - } - }; - /** - * Check if the cache directory exists - * @param directory {string} The directory to check. Either this.file.tempDirectory or this.file.cacheDirectory - * @returns {Promise} Returns a promise that resolves if exists, and rejects if it doesn't - */ - ImageLoader.prototype.cacheDirectoryExists = function (directory) { - return this.file.checkDir(directory, this.config.cacheDirectoryName); - }; - /** - * Create the cache directories - * @param replace {boolean} override directory if exists - * @returns {Promise} Returns a promise that resolves if the directories were created, and rejects on error - */ - ImageLoader.prototype.createCacheDirectory = function (replace) { - var _this = this; - if (replace === void 0) { replace = false; } - var cacheDirectoryPromise, tempDirectoryPromise; - if (replace) { - // create or replace the cache directory - cacheDirectoryPromise = this.file.createDir(this.file.cacheDirectory, this.config.cacheDirectoryName, replace); - } - else { - // check if the cache directory exists. - // if it does not exist create it! - cacheDirectoryPromise = this.cacheDirectoryExists(this.file.cacheDirectory) - .catch(function () { return _this.file.createDir(_this.file.cacheDirectory, _this.config.cacheDirectoryName, false); }); - } - if (this.isWKWebView && !this.isIonicWKWebView) { - if (replace) { - // create or replace the temp directory - tempDirectoryPromise = this.file.createDir(this.file.tempDirectory, this.config.cacheDirectoryName, replace); - } - else { - // check if the temp directory exists. - // if it does not exist create it! - tempDirectoryPromise = this.cacheDirectoryExists(this.file.tempDirectory) - .catch(function () { return _this.file.createDir(_this.file.tempDirectory, _this.config.cacheDirectoryName, false); }); - } - } - else { - tempDirectoryPromise = Promise.resolve(); - } - return Promise.all([cacheDirectoryPromise, tempDirectoryPromise]); - }; - /** - * Creates a unique file name out of the URL - * @param url {string} URL of the file - * @returns {string} Unique file name - */ - ImageLoader.prototype.createFileName = function (url) { - // hash the url to get a unique file name - return this.hashString(url).toString(); - }; - /** - * Converts a string to a unique 32-bit int - * @param string {string} string to hash - * @returns {number} 32-bit int - */ - ImageLoader.prototype.hashString = function (string) { - var hash = 0, char; - if (string.length === 0) - return hash; - for (var i = 0; i < string.length; i++) { - char = string.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; - } - return hash; - }; - return ImageLoader; -}()); -export { ImageLoader }; -ImageLoader.decorators = [ - { type: Injectable }, -]; -/** @nocollapse */ -ImageLoader.ctorParameters = function () { return [ - { type: ImageLoaderConfig, }, - { type: File, }, - { type: FileTransfer, }, - { type: Platform, }, -]; }; -//# sourceMappingURL=image-loader.js.map \ No newline at end of file diff --git a/dist/providers/image-loader.js.map b/dist/providers/image-loader.js.map deleted file mode 100644 index 8d4eb41..0000000 --- a/dist/providers/image-loader.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/providers/image-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAA,EAAW,MAAO,eAAA,CAAgB;AAC3C,OAAO,EAAE,IAAA,EAA2C,MAAO,oBAAA,CAAqB;AAChF,OAAO,EAAE,YAAA,EAAiC,MAAO,6BAAA,CAA8B;AAC/E,OAAO,EAAE,iBAAA,EAAkB,MAAO,uBAAA,CAAwB;AAC1D,OAAO,EAAE,QAAA,EAAS,MAAO,eAAA,CAAgB;AACzC,OAAO,EAAE,UAAA,EAAW,MA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I,CAAC;YACnC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAYH,kBAAC;AAAD,CA1kBA,AA0kBC;;AAVM,sBAAU,GAA0B;IAC3C,EAAE,IAAI,EAAE,UAAU,EAAE;CACnB,CAAC;AACF,kBAAkB;AACX,0BAAc,GAAmE,cAAM,OAAA;IAC9F,EAAC,IAAI,EAAE,iBAAiB,GAAG;IAC3B,EAAC,IAAI,EAAE,IAAI,GAAG;IACd,EAAC,IAAI,EAAE,YAAY,GAAG;IACtB,EAAC,IAAI,EAAE,QAAQ,GAAG;CACjB,EAL6F,CAK7F,CAAC","file":"image-loader.js","sourceRoot":""} \ No newline at end of file diff --git a/dist/providers/image-loader.metadata.json b/dist/providers/image-loader.metadata.json deleted file mode 100644 index 32fc3e9..0000000 --- a/dist/providers/image-loader.metadata.json +++ /dev/null @@ -1 +0,0 @@ -[{"__symbolic":"module","version":3,"metadata":{"ImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"},{"__symbolic":"reference","module":"ionic-angular","name":"Platform"}]}],"preload":[{"__symbolic":"method"}],"clearCache":[{"__symbolic":"method"}],"getImagePath":[{"__symbolic":"method"}],"addItemToQueue":[{"__symbolic":"method"}],"processQueue":[{"__symbolic":"method"}],"initCache":[{"__symbolic":"method"}],"addFileToIndex":[{"__symbolic":"method"}],"indexCache":[{"__symbolic":"method"}],"maintainCacheSize":[{"__symbolic":"method"}],"removeFile":[{"__symbolic":"method"}],"getCachedImagePath":[{"__symbolic":"method"}],"throwError":[{"__symbolic":"method"}],"throwWarning":[{"__symbolic":"method"}],"cacheDirectoryExists":[{"__symbolic":"method"}],"createCacheDirectory":[{"__symbolic":"method"}],"createFileName":[{"__symbolic":"method"}],"hashString":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"ImageLoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./image-loader-config","name":"ImageLoaderConfig"},{"__symbolic":"reference","module":"@ionic-native/file","name":"File"},{"__symbolic":"reference","module":"@ionic-native/file-transfer","name":"FileTransfer"},{"__symbolic":"reference","module":"ionic-angular","name":"Platform"}]}],"preload":[{"__symbolic":"method"}],"clearCache":[{"__symbolic":"method"}],"getImagePath":[{"__symbolic":"method"}],"addItemToQueue":[{"__symbolic":"method"}],"processQueue":[{"__symbolic":"method"}],"initCache":[{"__symbolic":"method"}],"addFileToIndex":[{"__symbolic":"method"}],"indexCache":[{"__symbolic":"method"}],"maintainCacheSize":[{"__symbolic":"method"}],"removeFile":[{"__symbolic":"method"}],"getCachedImagePath":[{"__symbolic":"method"}],"throwError":[{"__symbolic":"method"}],"throwWarning":[{"__symbolic":"method"}],"cacheDirectoryExists":[{"__symbolic":"method"}],"createCacheDirectory":[{"__symbolic":"method"}],"createFileName":[{"__symbolic":"method"}],"hashString":[{"__symbolic":"method"}]}}}}] \ No newline at end of file From f0f083fdbb9e8362f7e0bb1a21be310e19c1552e Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 15:36:47 +1100 Subject: [PATCH 10/13] Return newline characters to html and css files --- ionic-image-loader/ionic-image-loader.html | 2 +- ionic-image-loader/ionic-image-loader.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ionic-image-loader/ionic-image-loader.html b/ionic-image-loader/ionic-image-loader.html index 281c686..7c89b54 100644 --- a/ionic-image-loader/ionic-image-loader.html +++ b/ionic-image-loader/ionic-image-loader.html @@ -1 +1 @@ -
\ No newline at end of file +
diff --git a/ionic-image-loader/ionic-image-loader.scss b/ionic-image-loader/ionic-image-loader.scss index d9151ff..a6fc08b 100644 --- a/ionic-image-loader/ionic-image-loader.scss +++ b/ionic-image-loader/ionic-image-loader.scss @@ -1,2 +1,2 @@ ionic-image-loader { -} \ No newline at end of file +} From 8ccdbc17698d736baaa8eaefc196653aad2a1695 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 15:38:36 +1100 Subject: [PATCH 11/13] Reverting changes to html and css files --- ionic-image-loader/ionic-image-loader.html | 1 - ionic-image-loader/ionic-image-loader.scss | 2 -- 2 files changed, 3 deletions(-) diff --git a/ionic-image-loader/ionic-image-loader.html b/ionic-image-loader/ionic-image-loader.html index 7c89b54..e69de29 100644 --- a/ionic-image-loader/ionic-image-loader.html +++ b/ionic-image-loader/ionic-image-loader.html @@ -1 +0,0 @@ -
diff --git a/ionic-image-loader/ionic-image-loader.scss b/ionic-image-loader/ionic-image-loader.scss index a6fc08b..e69de29 100644 --- a/ionic-image-loader/ionic-image-loader.scss +++ b/ionic-image-loader/ionic-image-loader.scss @@ -1,2 +0,0 @@ -ionic-image-loader { -} From c302cc08c1b165395e6b1e5862287d8a519ef8a6 Mon Sep 17 00:00:00 2001 From: James Hodge Date: Tue, 24 Oct 2017 15:40:27 +1100 Subject: [PATCH 12/13] Revert tslint changes --- src/components/img-loader.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index e56b236..f639a79 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -134,7 +134,7 @@ export class ImgLoader implements OnInit { private _renderer: Renderer, private _imageLoader: ImageLoader, private _config: ImageLoaderConfig - ) { } + ) {} ngOnInit(): void { if (this.fallbackAsPlaceholder && this.fallbackUrl) { @@ -225,7 +225,7 @@ export class ImgLoader implements OnInit { } } - this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + (imageUrl || this.fallbackUrl) + '\')'); + this._renderer.setElementStyle(this.element, 'background-image', 'url(\'' + ( imageUrl || this.fallbackUrl ) + '\')'); } this.load.emit(this); From 658b9ea87ee36c7e72ecfadc84f05461ae8e3f8c Mon Sep 17 00:00:00 2001 From: Mohammad Baker Date: Fri, 14 Sep 2018 16:25:45 -0400 Subject: [PATCH 13/13] @ihadeed requested changes --- README.md | 2 +- .../ionic-image-loader.component.js | 12 ----- ionic-image-loader/ionic-image-loader.html | 0 ionic-image-loader/ionic-image-loader.scss | 0 src/components/image-attribute.ts | 8 +-- src/components/img-loader.ts | 51 ++++++------------- 6 files changed, 20 insertions(+), 53 deletions(-) delete mode 100644 ionic-image-loader/ionic-image-loader.component.js delete mode 100644 ionic-image-loader/ionic-image-loader.html delete mode 100644 ionic-image-loader/ionic-image-loader.scss diff --git a/README.md b/README.md index 9ee26f0..649ce8a 100644 --- a/README.md +++ b/README.md @@ -351,7 +351,7 @@ import { ImageAttribute } from 'ionic-image-loader' 2. Generate an array of ImageAttribute objects ```typescript -var imageAttributes: ImageAttribute[] = []; +const imageAttributes: ImageAttribute[] = []; imageAttributes.push({ element: 'class', value: 'circle-photo' diff --git a/ionic-image-loader/ionic-image-loader.component.js b/ionic-image-loader/ionic-image-loader.component.js deleted file mode 100644 index 1045e49..0000000 --- a/ionic-image-loader/ionic-image-loader.component.js +++ /dev/null @@ -1,12 +0,0 @@ -class IonicImageLoaderController { - constructor() { - } -} - -export default { - controller: IonicImageLoaderController, - template: require('./ionic-image-loader.html'), - bindings: { - - } -}; \ No newline at end of file diff --git a/ionic-image-loader/ionic-image-loader.html b/ionic-image-loader/ionic-image-loader.html deleted file mode 100644 index e69de29..0000000 diff --git a/ionic-image-loader/ionic-image-loader.scss b/ionic-image-loader/ionic-image-loader.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/image-attribute.ts b/src/components/image-attribute.ts index 0255ee0..05249f4 100644 --- a/src/components/image-attribute.ts +++ b/src/components/image-attribute.ts @@ -1,4 +1,4 @@ -export class ImageAttribute { - element: string = ""; - value: string = ""; -} \ No newline at end of file +export interface ImageAttribute { + element: string; + value: string; +} diff --git a/src/components/img-loader.ts b/src/components/img-loader.ts index 6da70eb..1a2e0a5 100644 --- a/src/components/img-loader.ts +++ b/src/components/img-loader.ts @@ -56,12 +56,25 @@ export class ImgLoader implements OnInit { set noCache(val: boolean) { this.cache = val !== false; } - /** * Enable/Disable caching * @type {boolean} */ @Input() cache: boolean = true; + /** + * The URL of the image to load. + */ + @Input() + set src(imageUrl: string) { + this._src = this.processImageUrl(imageUrl); + this.updateImage(this._src); + }; + + get src(): string { + return this._src; + } + + private _src: string; /** * Width of the image. This will be ignored if using useImg. */ @@ -110,40 +123,6 @@ export class ImgLoader implements OnInit { ) { } - private _src: string; - - get src(): string { - return this._src; - } - - /** - * The URL of the image to load. - */ - @Input() - set src(imageUrl: string) { - this._src = this.processImageUrl(imageUrl); - this.updateImage(this._src); - }; - - private _useImg: boolean = this._config.useImg; - - /** - * Use tag - */ - @Input() - set useImg(val: boolean) { - this._useImg = val !== false; - } - - /** - * Convenience attribute to disable caching - * @param val - */ - @Input() - set noCache(val: boolean) { - this.cache = val !== false; - } - ngOnInit(): void { if (this.fallbackAsPlaceholder && this.fallbackUrl) { this.setImage(this.fallbackUrl, false); @@ -213,7 +192,7 @@ export class ImgLoader implements OnInit { this._renderer.setElementAttribute(this.element, 'src', imageUrl); // if imgAttributes are defined, add them to our img element - this.imgAttributes.forEach((attribute, index, attributeArray) => { + this.imgAttributes.forEach((attribute) => { this._renderer.setElementAttribute(this.element, attribute.element, attribute.value); });