/*! * imagesloaded packaged v4.1.0 * javascript is all like "you images are done yet or what?" * mit license */ !function (t, e) { "function" == typeof define && define.amd ? define("ev-emitter/ev-emitter", e) : "object" == typeof module && module.exports ? module.exports = e() : t.evemitter = e() }(this, function () { function t() { } var e = t.prototype; return e.on = function (t, e) { if (t && e) { var i = this._events = this._events || {}, n = i[t] = i[t] || []; return -1 == n.indexof(e) && n.push(e), this } }, e.once = function (t, e) { if (t && e) { this.on(t, e); var i = this._onceevents = this._onceevents || {}, n = i[t] = i[t] || []; return n[e] = !0, this } }, e.off = function (t, e) { var i = this._events && this._events[t]; if (i && i.length) { var n = i.indexof(e); return -1 != n && i.splice(n, 1), this } }, e.emitevent = function (t, e) { var i = this._events && this._events[t]; if (i && i.length) { var n = 0, o = i[n]; e = e || []; for (var r = this._onceevents && this._onceevents[t]; o;) { var s = r && r[o]; s && (this.off(t, o), delete r[o]), o.apply(this, e), n += s ? 0 : 1, o = i[n] } return this } }, t }), function (t, e) { "use strict"; "function" == typeof define && define.amd ? define(["ev-emitter/ev-emitter"], function (i) { return e(t, i) }) : "object" == typeof module && module.exports ? module.exports = e(t, require("ev-emitter")) : t.imagesloaded = e(t, t.evemitter) }(window, function (t, e) { function i(t, e) { for (var i in e) t[i] = e[i]; return t } function n(t) { var e = []; if (array.isarray(t)) e = t; else if ("number" == typeof t.length) for (var i = 0; i < t.length; i++) e.push(t[i]); else e.push(t); return e } function o(t, e, r) { return this instanceof o ? ("string" == typeof t && (t = document.queryselectorall(t)), this.elements = n(t), this.options = i({}, this.options), "function" == typeof e ? r = e : i(this.options, e), r && this.on("always", r), this.getimages(), h && (this.jqdeferred = new h.deferred), void settimeout(function () { this.check() }.bind(this))) : new o(t, e, r) } function r(t) { this.img = t } function s(t, e) { this.url = t, this.element = e, this.img = new image } var h = t.jquery, a = t.console; o.prototype = object.create(e.prototype), o.prototype.options = {}, o.prototype.getimages = function () { this.images = [], this.elements.foreach(this.addelementimages, this) }, o.prototype.addelementimages = function (t) { "img" == t.nodename && this.addimage(t), this.options.background === !0 && this.addelementbackgroundimages(t); var e = t.nodetype; if (e && d[e]) { for (var i = t.queryselectorall("img"), n = 0; n < i.length; n++) { var o = i[n]; this.addimage(o) } if ("string" == typeof this.options.background) { var r = t.queryselectorall(this.options.background); for (n = 0; n < r.length; n++) { var s = r[n]; this.addelementbackgroundimages(s) } } } }; var d = { 1: !0, 9: !0, 11: !0 }; return o.prototype.addelementbackgroundimages = function (t) { var e = getcomputedstyle(t); if (e) for (var i = /url\((['"])?(.*?)\1\)/gi, n = i.exec(e.backgroundimage) ; null !== n;) { var o = n && n[2]; o && this.addbackground(o, t), n = i.exec(e.backgroundimage) } }, o.prototype.addimage = function (t) { var e = new r(t); this.images.push(e) }, o.prototype.addbackground = function (t, e) { var i = new s(t, e); this.images.push(i) }, o.prototype.check = function () { function t(t, i, n) { settimeout(function () { e.progress(t, i, n) }) } var e = this; return this.progressedcount = 0, this.hasanybroken = !1, this.images.length ? void this.images.foreach(function (e) { e.once("progress", t), e.check() }) : void this.complete() }, o.prototype.progress = function (t, e, i) { this.progressedcount++, this.hasanybroken = this.hasanybroken || !t.isloaded, this.emitevent("progress", [this, t, e]), this.jqdeferred && this.jqdeferred.notify && this.jqdeferred.notify(this, t), this.progressedcount == this.images.length && this.complete(), this.options.debug && a && a.log("progress: " + i, t, e) }, o.prototype.complete = function () { var t = this.hasanybroken ? "fail" : "done"; if (this.iscomplete = !0, this.emitevent(t, [this]), this.emitevent("always", [this]), this.jqdeferred) { var e = this.hasanybroken ? "reject" : "resolve"; this.jqdeferred[e](this) } }, r.prototype = object.create(e.prototype), r.prototype.check = function () { var t = this.getisimagecomplete(); return t ? void this.confirm(0 !== this.img.naturalwidth, "naturalwidth") : (this.proxyimage = new image, this.proxyimage.addeventlistener("load", this), this.proxyimage.addeventlistener("error", this), this.img.addeventlistener("load", this), this.img.addeventlistener("error", this), void (this.proxyimage.src = this.img.src)) }, r.prototype.getisimagecomplete = function () { return this.img.complete && void 0 !== this.img.naturalwidth }, r.prototype.confirm = function (t, e) { this.isloaded = t, this.emitevent("progress", [this, this.img, e]) }, r.prototype.handleevent = function (t) { var e = "on" + t.type; this[e] && this[e](t) }, r.prototype.onload = function () { this.confirm(!0, "onload"), this.unbindevents() }, r.prototype.onerror = function () { this.confirm(!1, "onerror"), this.unbindevents() }, r.prototype.unbindevents = function () { this.proxyimage.removeeventlistener("load", this), this.proxyimage.removeeventlistener("error", this), this.img.removeeventlistener("load", this), this.img.removeeventlistener("error", this) }, s.prototype = object.create(r.prototype), s.prototype.check = function () { this.img.addeventlistener("load", this), this.img.addeventlistener("error", this), this.img.src = this.url; var t = this.getisimagecomplete(); t && (this.confirm(0 !== this.img.naturalwidth, "naturalwidth"), this.unbindevents()) }, s.prototype.unbindevents = function () { this.img.removeeventlistener("load", this), this.img.removeeventlistener("error", this) }, s.prototype.confirm = function (t, e) { this.isloaded = t, this.emitevent("progress", [this, this.element, e]) }, o.makejqueryplugin = function (e) { e = e || t.jquery, e && (h = e, h.fn.imagesloaded = function (t, e) { var i = new o(this, t, e); return i.jqdeferred.promise(h(this)) }) }, o.makejqueryplugin(), o });