forked from ravendb/ravendb
/
yepnope.js
4 lines (4 loc) · 4.12 KB
/
yepnope.js
1
2
3
4
/*yepnope1.0.2|WTFPL*/
if (!this.yepnope) {
(function (a, b, c) { function H() { var a = z; a.loader = { load: G, i: 0 }; return a } function G(a, b, c) { var e = b == "c" ? r : q; i = 0, b = b || "j", u(a) ? F(e, a, b, this.i++, d, c) : (h.splice(this.i++, 0, a), h.length == 1 && E()); return this } function F(a, c, d, g, j, l) { function q() { !o && A(n.readyState) && (p.r = o = 1, !i && B(), n.onload = n.onreadystatechange = null, e(function () { m.removeChild(n) }, 0)) } var n = b.createElement(a), o = 0, p = { t: d, s: c, e: l }; n.src = n.data = c, !k && (n.style.display = "none"), n.width = n.height = "0", a != "object" && (n.type = d), n.onload = n.onreadystatechange = q, a == "img" ? n.onerror = q : a == "script" && (n.onerror = function () { p.e = p.r = 1, E() }), h.splice(g, 0, p), m.insertBefore(n, k ? null : f), e(function () { o || (m.removeChild(n), p.r = p.e = o = 1, B()) }, z.errorTimeout) } function E() { var a = h.shift(); i = 1, a ? a.t ? e(function () { a.t == "c" ? D(a) : C(a) }, 0) : (a(), B()) : i = 0 } function D(a) { var c = b.createElement("link"), d; c.href = a.s, c.rel = "stylesheet", c.type = "text/css"; if (!a.e && (o || j)) { var g = function (a) { e(function () { if (!d) try { a.sheet.cssRules.length ? (d = 1, B()) : g(a) } catch (b) { b.code == 1e3 || b.message == "security" || b.message == "denied" ? (d = 1, e(function () { B() }, 0)) : g(a) } }, 0) }; g(c) } else c.onload = function () { d || (d = 1, e(function () { B() }, 0)) }, a.e && c.onload(); e(function () { d || (d = 1, B()) }, z.errorTimeout), !a.e && f.parentNode.insertBefore(c, f) } function C(a) { var c = b.createElement("script"), d; c.src = a.s, c.onreadystatechange = c.onload = function () { !d && A(c.readyState) && (d = 1, B(), c.onload = c.onreadystatechange = null) }, e(function () { d || (d = 1, B()) }, z.errorTimeout), a.e ? c.onload() : f.parentNode.insertBefore(c, f) } function B() { var a = 1, b = -1; while (h.length - ++b) if (h[b].s && !(a = h[b].r)) break; a && E() } function A(a) { return !a || a == "loaded" || a == "complete" } var d = b.documentElement, e = a.setTimeout, f = b.getElementsByTagName("script")[0], g = {}.toString, h = [], i = 0, j = "MozAppearance" in d.style, k = j && !!b.createRange().compareNode, l = j && !k, m = k ? d : f.parentNode, n = a.opera && g.call(a.opera) == "[object Opera]", o = "webkitAppearance" in d.style, p = o && "async" in b.createElement("script"), q = j ? "object" : n || p ? "img" : "script", r = o ? "img" : q, s = Array.isArray || function (a) { return g.call(a) == "[object Array]" }, t = function (a) { return Object(a) === a }, u = function (a) { return typeof a == "string" }, v = function (a) { return g.call(a) == "[object Function]" }, w = [], x = {}, y, z; z = function (a) { function h(a, b) { function i(a) { if (u(a)) g(a, f, b, 0, c); else if (t(a)) for (h in a) a.hasOwnProperty(h) && g(a[h], f, b, h, c) } var c = !!a.test, d = c ? a.yep : a.nope, e = a.load || a.both, f = a.callback, h; i(d), i(e), a.complete && b.load(a.complete) } function g(a, b, d, e, g) { var h = f(a), i = h.autoCallback; if (!h.bypass) { b && (b = v(b) ? b : b[a] || b[e] || b[a.split("/").pop().split("?")[0]]); if (h.instead) return h.instead(a, b, d, e, g); d.load(h.url, h.forceCSS || !h.forceJS && /css$/.test(h.url) ? "c" : c, h.noexec), (v(b) || v(i)) && d.load(function () { H(), b && b(h.origUrl, g, e), i && i(h.origUrl, g, e) }) } } function f(a) { var b = a.split("!"), c = w.length, d = b.pop(), e = b.length, f = { url: d, origUrl: d, prefixes: b }, g, h; for (h = 0; h < e; h++) g = x[b[h]], g && (f = g(f)); for (h = 0; h < c; h++) f = w[h](f); return f } var b, d, e = this.yepnope.loader; if (u(a)) g(a, 0, e, 0); else if (s(a)) for (b = 0; b < a.length; b++) d = a[b], u(d) ? g(d, 0, e, 0) : s(d) ? z(d) : t(d) && h(d, e); else t(a) && h(a, e) }, z.addPrefix = function (a, b) { x[a] = b }, z.addFilter = function (a) { w.push(a) }, z.errorTimeout = 1e4, b.readyState == null && b.addEventListener && (b.readyState = "loading", b.addEventListener("DOMContentLoaded", y = function () { b.removeEventListener("DOMContentLoaded", y, 0), b.readyState = "complete" }, 0)), a.yepnope = H() })(this, this.document)
}