You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
70 KiB

2 years ago
  1. /*! jsviews.js v0.9.80 (Beta) single-file version: http://jsviews.com/ */
  2. /*! includes JsRender, JsObservable and JsViews - see: http://jsviews.com/#download */
  3. !function (e, t) { var n = t.jQuery; "object" == typeof exports ? module.exports = n ? e(t, n) : function (n) { return e(t, n) } : "function" == typeof define && define.amd ? define(["jquery"], function (n) { return e(t, n) }) : e(t, !1) }(function (e, t) {
  4. "use strict"; function n(e, t) { return function () { var n, r = this, i = r.base; return r.base = e, n = t.apply(r, arguments), r.base = i, n } } function r(e, t) { return Oe(t) && (t = n(e ? e._d ? e : n(a, e) : a, t), t._d = 1), t } function i(e, t) { for (var n in t.props) vt.test(n) && (e[n] = r(e[n], t.props[n])) } function o(e) { return e } function a() { return "" } function s(e) { try { throw console.log("JsRender dbg breakpoint: " + e), "dbg breakpoint" } catch (t) { } return this.base ? this.baseApply(arguments) : e } function l(e) { this.name = (t.link ? "JsViews" : "JsRender") + " Error", this.message = e || this.name } function d(e, t) { for (var n in t) e[n] = t[n]; return e } function p(e, t, n) { return e ? qe(e) ? p.apply(Me, e) : (ze.delimiters = [e, t, et = n ? n.charAt(0) : et], Xe = e.charAt(0), Ze = e.charAt(1), Ge = t.charAt(0), Ye = t.charAt(1), e = "\\" + Xe + "(\\" + et + ")?\\" + Ze, t = "\\" + Ge + "\\" + Ye, Be = "(?:(\\w+(?=[\\/\\s\\" + Ge + "]))|(\\w+)?(:)|(>)|(\\*))\\s*((?:[^\\" + Ge + "]|\\" + Ge + "(?!\\" + Ye + "))*?)", Je.rTag = "(?:" + Be + ")", Be = new RegExp("(?:" + e + Be + "(\\/)?|\\" + Xe + "(\\" + et + ")?\\" + Ze + "(?:(?:\\/(\\w+))\\s*|!--[\\s\\S]*?--))" + t, "g"), Je.rTmpl = new RegExp("<.*>|([^\\\\]|^)[{}]|" + e + ".*" + t), We) : ze.delimiters } function c(e, t) { t || e === !0 || (t = e, e = void 0); var n, r, i, o, a = this, s = !t || "root" === t; if (e) { if (o = t && a.type === t && a, !o) if (n = a.views, a._.useKey) { for (r in n) if (o = t ? n[r].get(e, t) : n[r]) break } else for (r = 0, i = n.length; !o && i > r; r++) o = t ? n[r].get(e, t) : n[r] } else if (s) for (; a.parent;) o = a, a = a.parent; else for (; a && !o;) o = a.type === t ? a : void 0, a = a.parent; return o } function f() { var e = this.get("item"); return e ? e.index : void 0 } function u() { return this.index } function v(t, n) { var r, i, o = this, a = o.ctx; if (a && (a = a[t]), void 0 === a && (a = Ke[t]), a && a._cp) { if (n) return i = Je._ceo(a[1].deps), i.unshift(a[0].data), i._cp = !0, i; a = Me.getCtx(a) } return a && Oe(a) && !a._wrp && (r = function () { return a.apply(this && this !== e ? this : o, arguments) }, r._wrp = o, d(r, a)), r || a } function g(e) { return e && (e.fn ? e : this.getRsc("templates", e) || De(e)) } function h(e, t, n, r) { var o, a, s = "number" == typeof n && t.tmpl.bnds[n - 1], l = t.linkCtx; return void 0 !== r ? n = r = { props: {}, args: [r] } : s && (n = s(t.data, t, Je)), a = n.args[0], (e || s) && (o = l && l.tag, o || (o = d(new Je._tg, { _: { inline: !l, bnd: s, unlinked: !0 }, tagName: ":", cvt: e, flow: !0, tagCtx: n }), l && (l.tag = o, o.linkCtx = l), n.ctx = U(n.ctx, (l ? l.view : t).ctx)), o._er = r && a, i(o, n), n.view = t, o.ctx = n.ctx || o.ctx || {}, n.ctx = void 0, a = o.cvtArgs("true" !== e && e)[0], a = s && t._.onRender ? t._.onRender(a, t, o) : a), void 0 != a ? a : "" } function _(e) { var t = this, n = t.tagCtx, r = n.view, i = n.args; return e = e || t.convert, e = e && ("" + e === e ? r.getRsc("converters", e) || F("Unknown converter: '" + e + "'") : e), i = i.length || n.index ? e ? i.slice() : i : [r.data], e && (e.depends && (t.depends = Je.getDeps(t.depends, t, e.depends, e)), i[0] = e.apply(t, i)), i } function m(e, t) { for (var n, r, i = this; void 0 === n && i;) r = i.tmpl && i.tmpl[e], n = r && r[t], i = i.parent; return n || Me[e][t] } function b(e, t, n, r, o, a) { t = t || Fe; var s, l, d, p, c, f, u, v, g, h, _, m, b, x, y, w, k, C, j, A = "", I = t.linkCtx || 0, E = t.ctx, T = n || t.tmpl, S = "number" == typeof r && t.tmpl.bnds[r - 1]; for ("tag" === e._is ? (s = e, e = s.tagName, r = s.tagCtxs, d = s.template) : (l = t.getRsc("tags", e) || F("Unknown tag: {{" + e + "}} "), d = l.template), void 0 !== a ? (A += a, r = a = [{ props: {}, args: [] }]) : S && (r = S(t.data, t, Je)), v = r.length, u = 0; v > u; u++) h = r[u], (!I || !I.tag || u && !I.tag._.inline || s._er) && ((m = T.tmpls && h.tmpl) && (m = h.content = T.tmpls[m - 1]), h.index = u, h.tmpl = m, h.render = N, h.view = t, h.ctx = U(h.ctx, E)), (n = h
  5. var r, i, o = e.tagCtx.view, a = e.tagCtxs || [e.tagCtx], s = a.length, l = !t; if (t = t || e._.bnd.call(o.tmpl, (e.linkCtx || o).data, o, Je), n) a = e.tagCtxs = t, e.tagCtx = a[0]; else for (; s--;) r = a[s], i = t[s], $e(r.props).setProperty(i.props), d(r.ctx, i.ctx),
  6. r.args = i.args, l && (r.tmpl = i.tmpl); return Je._ths(e, a[0]), a
  7. } function ye(e) { for (var t, n, r, i = [], o = e.length, a = o; a--;) i.push(e[a]); for (a = o; a--;) if (n = i[a], n.parentNode) { if (r = n._jsvBnd) for (r = r.slice(1).split("&"), n._jsvBnd = "", t = r.length; t--;) we(r[t], n._jsvLkEl, n); Ie(ce(n) + (n._df || "")) } } function we(e, n, r) { var i, o, a, s, l, d, p, c, f, u, v, g, h = $n[e]; if (n) r === n.linkedElem[0] && (r._jsvLkEl = void 0, n.linkedElem = void 0); else if (h) { delete $n[e]; for (i in h.bnd) s = h.bnd[i], l = h.cbId, qe(s) ? t([s]).off(Bt + l).off(Lt + l) : t(s).off(Lt + l), delete h.bnd[i]; if (o = h.linkCtx) { if (a = o.tag) { if (d = a.tagCtxs) for (p = d.length; p--;) (c = d[p].map) && c.unmap(); f = a.linkedElem, a.onDispose && a.onDispose(), a._elCnt || (a._prv && a._prv.parentNode.removeChild(a._prv), a._nxt && a._nxt.parentNode.removeChild(a._nxt)) } u = f && f[0] || o.elem, (v = u && u._jsvTr) && (me(f || t(u), v, "off"), u._jsvTr = void 0), g = o.view, "link" === g.type ? g.parent.removeViews(g._.key, void 0, !0) : delete g._.bnds[e] } delete Ft[h.cbId] } } function ke(e) { e ? (e = e.jquery ? e : t(e), e.each(function () { for (var e; (e = on(this, !0)) && e.parent;) e.parent.removeViews(e._.key, void 0, !0); ye(this.getElementsByTagName("*")) }), ye(e)) : (nn && (t(nn).off(fn, Q).off("blur", "[contenteditable]", Q), nn = void 0), Fe.removeViews(), ye(document.body.getElementsByTagName("*"))) } function Ce(e) { return function (t, n, r) { var i, o, a, s, l, d, p; if (e && t) { if (t._jsv) return t._jsv.call(e.tmpl, n, e, Je); if ("~" === t.charAt(0)) return "~tag" === t.slice(0, 4) && (o = e.ctx, "." === t.charAt(4) && (i = t.slice(5).split("."), o = o.tag), i) ? o ? [o, i.join("."), n] : [] : (t = t.slice(1).split("."), (s = e.hlp(l = t.shift(), !0)) && (s._cp ? (t.length && (d = "." + t.join("."), l = s[p = s.length - 1], l._jsv ? (l.sb = d, l.bnd = !!r) : (s[p] = (l + d).replace("#data.", ""), "#view" === l.slice(0, 5) && (s[p] = s[p].slice(6), s.splice(p, 0, e)))), s.push(n), a = s) : (t.length || Oe(s)) && (a = [s, t.join("."), n])), a || []); if ("#" === t.charAt(0)) return "#data" === t ? [] : [e, t.replace(On, ""), n] } } } function je(e) { return e.type === _n ? e[hn] : e.value } function Ae(e, t, n, r, i, o) { var a, s, l, d, p, c, f, u = 0, v = e === t; if (e) { for (l = fe(e) || [], a = 0, s = l.length; s > a; a++) { if (d = l[a], c = d.id, c === r && d.ch === i) { if (!o) break; s = 0 } v || (p = "_" === d.ch ? dn[c] : $n[c].linkCtx.tag, d.open ? p._prv = t : d.close && (p._nxt = t)), u += c.length + 2 } u && e.setAttribute(cn, e.getAttribute(cn).slice(u)), f = t ? t.getAttribute(cn) : n._df, (s = f.indexOf("/" + r + i) + 1) && (f = l._tkns.slice(0, u) + f.slice(s + (o ? -1 : r.length + 1))), f && (t ? t.setAttribute(cn, f) : Z(n, f)) } else Z(n, pe(n._df, "#" + r + i)), o || t || Z(n, pe(n._df, "/" + r + i)) } function Ie(e) { var t, n, r, i; if (i = fe(e, !0, Un)) for (t = 0, n = i.length; n > t; t++) r = i[t], "_" === r.ch ? (r = dn[r.id]) && r.type && r.parent.removeViews(r._.key, void 0, !0) : we(r.id) } function Ee(e, n) { e.contents = function (e, n) { e !== !!e && (n = e, e = void 0); var r, i = t(this.nodes()); return i[0] && (r = n ? i.filter(n) : i, i = e && n ? r.add(i.find(n)) : r), i }, e.nodes = function (e, t, n) { var r, i = this, o = i._elCnt, a = !t && o, s = []; for (t = t || i._prv, n = n || i._nxt, r = a ? t === i._nxt ? i.parentElem.lastSibling : t : i._.inline === !1 ? t || i.linkCtx.elem.firstChild : t && t.nextSibling; r && (!n || r !== n) ;) (e || o || r.tagName !== yn) && s.push(r), r = r.nextSibling; return s }, e.childTags = function (e, t) { e !== !!e && (t = e, e = void 0); var n = this, r = n.link ? n : n.tagCtx.view, i = n._prv, o = n._elCnt, a = []; return r.link(void 0, n.parentElem, o ? i && i.previousSibling : i, n._nxt, void 0, { get: { tags: a, deep: e, name: t, id: n.link ? n._.id + "_" : n._tgId + "^" } }), a }, e.refresh = function (e) { var t, n, r = this, i = r.linkCtx, o = r.tagCtx.view; return r.disposed && F("Removed tag"), void 0 === e && (e = Je._tag(r, o, o.tmpl, xe
  8. }, window);
  9. //# sourceMappingURL=jsviews.min.js.map