UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

123 lines (122 loc) 4.44 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { Base, String_$type, markType } from "./type"; import { List$1 } from "./List$1"; import { Dictionary$2 } from "./Dictionary$2"; import { ImageLoadResult } from "./ImageLoadResult"; import { Uri } from "./Uri"; import { ImageLoadEventArgs } from "./ImageLoadEventArgs"; import { stringIsNullOrEmpty } from "./string"; /** * @hidden */ export let ImageLoader = /*@__PURE__*/ (() => { class ImageLoader extends Base { constructor() { super(); this.e = "https://dl.infragistics.com/x/img/flags/png/S/3/USA.png"; this.c = ((() => { let $ret = new List$1(String_$type, 0); $ret.add("https://dl.infragistics.com/x/img/flags/USA.png"); $ret.add("https://dl.infragistics.com/x/img/flags/CHN.png"); $ret.add("https://dl.infragistics.com/x/img/flags/MEX.png"); $ret.add("https://dl.infragistics.com/x/img/flags/FRA.png"); $ret.add("https://dl.infragistics.com/x/img/flags/BROKEN.png"); return $ret; })()); this.b = new Dictionary$2(String_$type, ImageLoadResult.$, 0); this.loadCompleted = null; } l() { let a = this.e; this.request(a); } request(a) { if (this.b.containsKey(a)) { let b = this.b.item(a); if (b.status == 3) { this.j(a, b); return; } else if (b.status == 2) { this.j(a, b); return; } else if (b.status == 4 || b.status == 0) { this.b.removeItem(a); } else { return; } } if (!this.b.containsKey(a)) { let c = new ImageLoadResult(); c.path = a; c.status = 1; this.b.addItem(a, c); this.h(a); } } cancel(a) { if (!this.b.containsKey(a)) { let b = new ImageLoadResult(); b.path = a; this.b.addItem(a, b); } this.b.item(a).status = 4; } clear() { this.b.clear(); } h(a) { let b = new Uri(1, a, 0); if (ImageLoader.d != null) { let c = ImageLoader.d.createElement("img"); c.listen("load", (d) => this.i(d, a)); c.setAttribute("src", a); this.b.item(a).data = c.getNativeElement(); } } i(a, b) { if (stringIsNullOrEmpty(b)) { return; } if (!this.b.containsKey(b)) { return; } let c = this.b.item(b); if (c.status == 4) { c.data = null; return; } let e_ = a.originalEvent; let img_ = (e_.target); let d = (img_.complete || (img_.readyState == 'complete' && e_.type == 'readystatechange')); if (d) { c.status = 2; c.path = b; c.data = img_; } else { c.status = 3; c.data = null; c.error = "Failed to load " + b; } this.b.item(b, c); this.j(b, c); } j(a, b) { if (this.loadCompleted != null) { let c = new ImageLoadEventArgs(b); this.loadCompleted(this, c); } } } ImageLoader.$t = markType(ImageLoader, 'ImageLoader'); ImageLoader.d = null; return ImageLoader; })();