UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

126 lines (125 loc) 4.48 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 { __extends } from "tslib"; 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 */ var ImageLoader = /** @class */ /*@__PURE__*/ (function (_super) { __extends(ImageLoader, _super); function ImageLoader() { var _this = _super.call(this) || this; _this.e = "https://dl.infragistics.com/x/img/flags/png/S/3/USA.png"; _this.c = ((function () { var $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; return _this; } ImageLoader.prototype.l = function () { var a = this.e; this.request(a); }; ImageLoader.prototype.request = function (a) { if (this.b.containsKey(a)) { var 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)) { var c = new ImageLoadResult(); c.path = a; c.status = 1; this.b.addItem(a, c); this.h(a); } }; ImageLoader.prototype.cancel = function (a) { if (!this.b.containsKey(a)) { var b = new ImageLoadResult(); b.path = a; this.b.addItem(a, b); } this.b.item(a).status = 4; }; ImageLoader.prototype.clear = function () { this.b.clear(); }; ImageLoader.prototype.h = function (a) { var _this = this; var b = new Uri(1, a, 0); if (ImageLoader.d != null) { var c = ImageLoader.d.createElement("img"); c.listen("load", function (d) { return _this.i(d, a); }); c.setAttribute("src", a); this.b.item(a).data = c.getNativeElement(); } }; ImageLoader.prototype.i = function (a, b) { if (stringIsNullOrEmpty(b)) { return; } if (!this.b.containsKey(b)) { return; } var c = this.b.item(b); if (c.status == 4) { c.data = null; return; } var e_ = a.originalEvent; var img_ = (e_.target); var 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); }; ImageLoader.prototype.j = function (a, b) { if (this.loadCompleted != null) { var c = new ImageLoadEventArgs(b); this.loadCompleted(this, c); } }; ImageLoader.$t = markType(ImageLoader, 'ImageLoader'); ImageLoader.d = null; return ImageLoader; }(Base)); export { ImageLoader };