forked from BorisMoore/jsviews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.views.min.js
6 lines (6 loc) · 24.5 KB
/
jquery.views.min.js
1
2
3
4
5
6
/*! JsViews v1.0.0-alpha: http://github.com/BorisMoore/jsviews and http://jsviews.com/jsviews
informal pre V1.0 commit counter: 61 (Beta Candidate) */
(function(n,t,i){"use strict";function nt(n,r,u){var k,it,v,o,d,y,h,g,l,p,rt,nt,tt,s,e,w,a,b=n.target,ut=b._jsvBnd,ft=/&(\d+)\+?/g;if(ut)while(p=ft.exec(ut))if((p=c[p[1]])&&(e=p.to)){if(o=p.linkCtx,l=o.view,s=o.tag,g=t(b),nt=l.hlp(ii),tt=l.hlp(ri),v=vt(b),k=ei[v],u===i&&(u=et(v)?v(b):k?g[k]():g.attr(v)),y=e[1],e=e[0],e=e+""===e?[o.data,e]:e,y&&(d=et(y)?y:l.getRsc("converters",y)),d&&(u=d.call(s,u)),rt=l.linkCtx,l.linkCtx=o,w={change:"change",oldValue:o._val,value:u},(!nt||!(it=nt.call(o,n,w)===!1))&&(!s||!s.onBeforeChange||!(it=s.onBeforeChange(n,w)===!1))&&u!==i&&(h=e[0],u!==i&&h)){if(h._jsv)for(a=h,h=o.data;a&&a.sb;)h=o._ctxCb(a,h),a=a.sb;if(s&&(s._.chging=!0),f(h).setProperty(e[2]||e[1],u),tt&&tt.call(o,n,w),s){if(s.onAfterChange)s.onAfterChange(n,w);delete s._.chging}o._val=u}l.linkCtx=rt}}function wu(n,t,r){var h,o,d,b,a,v,e=this,f=e.tag,l=e.data,p=e.elem,c=e.convert,nt=p.parentNode,s=e.view,g=s.linkCtx,w=s.hlp(ii);if(s.linkCtx=e,nt&&(!w||!(t&&w.call(e,n,t)===!1))&&!(t&&n.data.prop!=="*"&&n.data.prop!==t.path)){if(t&&(e.eventArgs=t),t||e._initVal){if(delete e._initVal,r._er)try{o=r(l,s)}catch(tt){a=r._er;v=k(tt,s,new Function("data,view","return "+a+";")(l,s));o=[{props:{},args:[v]}]}else o=r(l,s,u);if(h=bu(o,e,f=e.tag,e.attr||vt(p,!0,c!==i)),f){if(b=a||f._er,o=o[0]?o:[o],d=!b&&t&&f.onUpdate&&f.onUpdate(n,t,o)===!1,gr(f,o,b),d||h===ct){h===y&&f.onBeforeLink&&f.onBeforeLink();bt(f,f.tagCtx);vi(e,l,p);s.linkCtx=g;return}if(f._.chging)return;o=f.tagName===":"?u._cnvt(f.cvt,s,o[0]):u._tag(f,s,s.tmpl,o,!0,v)}else r._tag&&(c=c===""?at:c,o=c?u._cnvt(c,s,o[0]||o):u._tag(r._tag,s,s.tmpl,o,!0,v),f=e.tag,h=e.attr||h);ar(o,e,h,f)&&t&&(w=s.hlp(ri))&&w.call(e,n,t);f&&(f._er=a,bt(f,f.tagCtx))}vi(e,l,p);s.linkCtx=g}}function bu(n,r,u,f){var e,h,c,o,s=u&&u.parentElem||r.elem;if(n!==i){if(o=t(s),f=u&&u.attr||f,et(n)&&k(r.expr+": missing parens"),c=/^css-/.test(f)&&f.slice(4))e=t.style(s,c),+n===n&&(e=parseInt(e));else if(f!=="link"){if(f==="value")s.type===ui&&(e=o.prop(f=g));else if(f===ht)if(s.value===""+n)e=o.prop(g);else return f;e===i&&(h=ei[f],e=h?o[h]():o.attr(f))}r._val=e}return f}function p(n,t){n._df=t;n[(t?"set":"remove")+"Attribute"](ur,"")}function ar(r,u,f,o){var ot,h,c,tt,st,d,a,nt,v,b,k,it,rt,ut=r!==i,lt=u.data,s=o&&o.parentElem||u.elem,ft=t(s),w=u.view,et=u._val,at=w.linkCtx,l=o||f===y;if(o&&(o.parentElem=o.parentElem||u.expr||o._elCnt?s:s.parentNode,h=o._prv,c=o._nxt),!ut){f===y&&o&&o.onBeforeLink&&o.onBeforeLink();return}if(f==="visible"&&(f="css-display"),/^css-/.test(f))u.attr==="visible"&&(rt=(s.currentStyle||lr.call(n,s,"")).display,r?(r=s._jsvd||rt,r!==ct||(r=or[it=s.nodeName])||(k=e.createElement(it),e.body.appendChild(k),r=or[it]=(k.currentStyle||lr.call(n,k,"")).display,e.body.removeChild(k))):(s._jsvd=rt,r=ct)),(l=l||et!==r)&&t.style(s,f.slice(4),r);else if(f!=="link"){if(f===g)d=!0,r=r&&r!=="false";else if(f===ht)if(s.value===""+r)r=d=!0,f=g;else{vi(u,lt,s);return}else(f==="selected"||f==="disabled"||f==="multiple"||f==="readonly")&&(r=r&&r!=="false"?f:null);(ot=ei[f])?f===y?(w.linkCtx=u,o&&o._.inline?(st=o.nodes(!0),o._elCnt&&(h&&h!==c?bi(h,c,s,o._tgId,"^",!0):(a=s._df)&&(nt=o._tgId+"^",v=a.indexOf("#"+nt)+1,b=a.indexOf("/"+nt),v&&b>0&&(v+=nt.length,b>v&&(p(s,a.slice(0,v)+a.slice(b)),tu(a.slice(v,b))))),h=h?h.previousSibling:c?c.previousSibling:s.lastChild),t(st).remove(),o&&o.onBeforeLink&&o.onBeforeLink(),tt=w.link(w.data,s,h,c,r,o&&{tag:o._tgId,lazyLink:o.tagCtx.props.lazyLink})):(ut&&ft.empty(),o&&o.onBeforeLink&&o.onBeforeLink(),ut&&(tt=w.link(lt,s,h,c,r,o&&{tag:o._tgId}))),w.linkCtx=at):(l=l||et!==r)&&(f==="text"&&s.children&&!s.children[0]?s.textContent!==i?s.textContent=r:s.innerText=r===null?"":r:ft[ot](r)):(l=l||et!==r)&&ft[d?"prop":"attr"](f,r===i&&!d?null:r);u._val=r}return tt||l}function vr(n,t){var i=this,r=i.hlp(ii),u=i.hlp(ri);if(!r||r.call(this,n,t)!==!1){if(t){var o=t.change,f=t.index,e=t.items;switch(o){case"insert":i.addViews(f,e);break;case"remove":i.removeViews(f,e.length);break;case"move":i.refresh();break;case"refresh":i.refresh()}}u&&u.call(this,n,t)}}function ai(n){var u,f,o=n.type,e=n.data,r=n._.bnd;if(!n._.useKey&&r)if((f=n._.bndArr)&&(t([f[1]]).off(ti,f[0]),n._.bndArr=i),r!==!!r&&r._.inline)o?r._.arrVws[n._.id]=n:delete r._.arrVws[n._.id];else if(o&&e){u=function(t){t.data&&t.data.off||vr.apply(n,arguments)};t([e]).on(ti,u);n._.bndArr=[u,e]}}function vt(n,t,i){var u=n.nodeName.toLowerCase(),r=a.merge[u]||n.contentEditable===at&&{to:y,from:y};return r?t?u==="input"&&n.type===ht?ht:r.to:r.from:t?i?"text":y:""}function yr(n,r,u,f,e,o,s){var p,c,v,w,b,l=n.parentElem,h=n._prv,a=n._nxt,y=n._elCnt;if(h&&h.parentNode!==l&&k("Missing parentNode"),s){w=n.nodes();y&&h&&h!==a&&bi(h,a,l,n._.id,"_",!0);n.removeViews(i,i,!0);c=a;y&&(h=h?h.previousSibling:a?a.previousSibling:l.lastChild);t(w).remove();for(b in n._.bnds)dt(b)}else{if(r){if(v=f[r-1],!v)return!1;h=v._nxt}y?(c=h,h=c?c.previousSibling:l.lastChild):c=h.nextSibling}p=u.render(e,o,n._.useKey&&s,n,s||r,!0);n.link(e,l,h,c,p,v)}function yt(n,t,r){var u,f,e;return r?(e="^`",f=t._.tag,u=f._tgId,u||(c[u=sr++]=f,f._tgId=""+u)):(e="_`",b[u=t._.id]=t),"#"+u+e+(n!=i?n:"")+"/"+u+e}function vi(n,t,r){var h,s,e,y,p,u=n.tag,w=n.convertBack,l=[],a=n._bndId||""+sr++,b=n._hdl;if(delete n._bndId,u&&(l=u.depends||l,l=et(l)?u.depends(u):l,e=u.linkedElem),!n._depends||""+n._depends!=""+l){for(n._depends&&f._apply(!1,[t],n._depends,b,!0),y=n.fn.deps.slice(),s=y.length;s--;)p=y[s],p._jsv&&(y[s]=v({},p));if(h=f._apply(!1,[t],y,l,b,n._ctxCb),h.elem=r,h.linkCtx=n,h._tgId=a,r._jsvBnd=r._jsvBnd||"",r._jsvBnd+="&"+a,n._depends=l,n.view._.bnds[a]=a,c[a]=h,e&&(h.to=[[],w]),(e||w!==i)&&dr(h,u&&u.convertBack||w),u){if(u.onAfterBind)u.onAfterBind(h);u.flow||u._.inline||(r.setAttribute(o,(r.getAttribute(o)||"")+"#"+a+"^/"+a+"^"),u._tgId=""+a)}}if(e&&e[0])for(u._.radio&&(e=e.children("input[type=radio]")),s=e.length;s--;)e[s]._jsvBnd=e[s]._jsvBnd||r._jsvBnd+"+",e[s]._jsvLkEl=u}function pr(n,t,i,r,u,f,e){return yi(this,n,t,i,r,u,f,e)}function yi(n,r,u,f,o,h,c,a){if(typeof f!="object"&&(f=i),n&&r){if(r=r.jquery?r:t(r),!tt){tt=e.body;t(tt).on(tr,nt).on("blur","[contenteditable]",nt)}for(var w,g,rt,d,y,k,v,ut,ft=yt,ot=f&&f.target==="replace",et=r.length;et--;)if(v=r[et],""+n===n)pt(n,v,it(v),i,!0,u,f);else{if(h=h||it(v),n.markup!==i)h.link===!1&&(f=f||{},f.link=ft=!1),ot&&(k=v.parentNode),rt=n.render(u,f,o,h,i,ft),k?(c=v.previousSibling,a=v.nextSibling,t.cleanData([v],!0),k.removeChild(v),v=k):(c=a=i,t(v).empty());else if(n===!0&&h===l)ut={lnk:1};else break;if(v._df&&!a){for(d=s(v._df,!0,hr),w=0,g=d.length;w<g;w++)y=d[w],(y=b[y.id])&&y.data!==i&&y.parent.removeViews(y._.key,i,!0);p(v)}h.link(u,v,c,a,rt,ut,f)}}return r}function ku(n,r,u,f,l,v,y,d){function pu(n,t,r,u,f,e,s,h,c,a,v,y,p){var w,b="";return p?(ui=0,n):(nt=h||c||"",u=u||a,r=r||y,oi&&!r&&(u||nt||e)&&(oi=i,ut=dt.shift()),u=u||r,u&&(ui=0,oi=i,wr&&(r||y?li[ut]||/;svg;|;math;/.test(";"+dt.join(";")+";")||(w="'<"+ut+".../"):li[u]?w="'<\/"+u:dt.length&&u===ut||(w="Mismatch: '<\/"+u),w&&si(w+">' in:\n"+l)),sr=ft,ut=dt.shift(),ft=ci[ut],a=a?"<\/"+a+">":"",sr&&(ht+=lt,lt="",ft?ht+="-":(b=a+rr+"@"+ht+ir+(v||""),ht=lu.shift()))),ft?(e?lt+=e:t=a||y||"",nt&&(t+=nt,lt&&(t+=" "+o+'="'+lt+'"',lt=""))):t=e?t+b+f+rr+e+ir+s+nt:b||n,ui&&e&&si(" No {^{ tags within elem markup ("+ui+' ). Use data-link="..."'),nt&&(ui=nt,dt.unshift(ut),ut=nt.slice(1),dt[0]&&dt[0]===cu[ut]&&k("Parent of <tr> must be <tbody>"),oi=li[ut],(ft=ci[ut])&&!sr&&(lu.unshift(ht),ht=""),sr=ft,ht&&ft&&(ht+="+")),t)}function wi(n,t){var o,l,u,e,f,a,s,h=[];if(n){for(n._tkns.charAt(0)==="@"&&(t=g.previousSibling,g.parentNode.removeChild(g),g=i),vt=n.length;vt--;){if(rt=n[vt],u=rt.ch,o=rt.path)for(et=o.length-1;l=o.charAt(et--);)l==="+"?o.charAt(et)==="-"?(et--,t=t.previousSibling):t=t.parentNode:t=t.lastChild;u==="^"?(nt=c[f=rt.id])&&(s=t&&(!g||g.parentNode!==t),(!g||s)&&(nt.parentElem=t),rt.elCnt&&s&&p(t,(rt.open?"#":"/")+f+u+(t._df||"")),h.push([s?null:g,rt])):(tt=b[f=rt.id])&&(tt.parentElem||(tt.parentElem=t||g&&g.parentNode||r,tt._.onRender=yt,tt._.onArrayChange=vr,ai(tt)),e=tt.parentElem,rt.open?(tt._elCnt=rt.elCnt,t&&!g?p(t,"#"+f+u+(t._df||"")):(tt._prv||p(e,wt(e._df,"#"+f+u)),tt._prv=g)):(t&&(!g||g.parentNode!==t)?(p(t,"/"+f+u+(t._df||"")),tt._nxt=i):g&&(tt._nxt||p(e,wt(e._df,"/"+f+u)),tt._nxt=g),fi=tt.linkCtx,(a=tt.ctx&&tt.ctx.onAfterCreate||wu)&&a.call(fi,tt)))}for(vt=h.length;vt--;)pi.push(h[vt])}return!n||n.elCnt}function tu(n){var t,i;if(n)for(vt=n.length,et=0;et<vt;et++)if(rt=n[et],i=nt=c[rt.id].linkCtx.tag,!nt.flow){if(!ar){for(t=1;i=i.parent;)t++;fr=fr||t}(ar||t===fr)&&(!yr||nt.tagName===yr)&&ru.push(nt)}}function iu(){var h,a,e="",p={},v=gi+(st?",["+ur+"]":"");for(bi=hi?r.querySelectorAll(v):t(v,r).get(),gt=bi.length,u&&u.innerHTML&&(ki=hi?u.querySelectorAll(v):t(v,u).get(),u=ki.length?ki[ki.length-1]:u),fr=0,ct=0;ct<gt;ct++)if(g=bi[ct],u&&!ou)ou=g===u;else if(f&&g===f){st&&(e+=ot(g));break}else if(g.parentNode)if(st){if(e+=ot(g),g._df){for(h=ct+1;h<gt&&g.contains(bi[h]);)h++;p[h-1]=g._df}p[ct]&&(e+=p[ct]||"")}else gr&&(rt=s(g,i,cr))&&(rt=rt[0])&&(yi=yi?rt.id!==yi&&yi:rt.open&&rt.id),!yi&&vu(s(g))&&g.getAttribute(w)&&pi.push([g]);if(st&&(e+=r._df||"",(a=e.indexOf("#"+st.id)+1)&&(e=e.slice(a+st.id.length)),a=e.indexOf("/"+st.id),a+1&&(e=e.slice(0,a)),tu(s(e,i,yu))),l===i&&r.getAttribute(w)&&pi.push([r]),br(u,ft),br(f,ft),st){kt&&kt.resolve();return}for(ft&&ht+lt&&(g=f,ht&&(f?wi(s(ht+"+",!0),f):wi(s(ht,!0),r)),wi(s(lt,!0),r),f&&(e=f.getAttribute(o),(gt=e.indexOf(hr)+1)&&(e=e.slice(gt+hr.length-1)),f.setAttribute(o,lt+e))),gt=pi.length,ct=0;ct<gt;ct++)g=pi[ct],ni=g[1],g=g[0],ni?(nt=c[ni.id])&&((fi=nt.linkCtx)&&(nt=fi.tag,nt.linkCtx=fi),ni.open?(g&&(nt.parentElem=g.parentNode,nt._prv=g),nt._elCnt=ni.elCnt,!nt||nt.onBeforeLink&&nt.onBeforeLink()===!1||nt._.bound||(nt._.bound=!0,tt=nt.tagCtx.view,pt(i,nt._prv,tt,ni.id)),nt._.linking=!0):(nt._nxt=g,nt._.linking&&(pr=nt.tagCtx,tt=pr.view,delete nt._.linking,nt._.bound||(nt._.bound=!0,pt(i,nt._prv,tt,ni.id)),bt(nt,pr)))):pt(g.getAttribute(w),g,it(g),i,gr,n,y);kt&&kt.resolve()}var ui,fi,nt,ct,gt,et,vt,bi,g,tt,rt,ni,ki,nr,lr,tr,ii,ru,ar,yr,pr,wr,fr,uu,dr,eu,ei,ut,oi,vi,or,ti,ft,sr,ri,lt,hr,ou,yi,kt,gr,st,nu=this,hu=nu._.id+"_",ht="",pi=[],dt=[],lu=[],wu=nu.hlp(fu),vu=wi;if(v&&(kt=v.lazyLink&&t.Deferred(),v.tmpl?lr="/"+v._.id+"_":(gr=v.lnk,v.tag&&(hu=v.tag+"^",v=!0),(st=v.get)&&(vu=tu,ru=st.tags,ar=st.deep,yr=st.name)),v=v===!0),r=r?""+r===r?t(r)[0]:r.jquery?r[0]:r:nu.parentElem||e.body,wr=!a.noValidate&&r.contentEditable!==at,ut=r.tagName.toLowerCase(),ft=!!ci[ut],u=u&&kr(u,ft),f=f&&kr(f,ft)||null,l!=i){if(or=e.createElement("div"),vi=or,hr=lt="",ri=r.namespaceURI==="http://www.w3.org/2000/svg"?"svg_ns":(ei=su.exec(l))&&ei[1]||"",di&&ei&&ei[2]&&k("Unsupported: "+ei[2]),ft){for(ii=f;ii&&!(tr=s(ii));)ii=ii.nextSibling;(ti=tr?tr._tkns:r._df)&&(nr=lr||"",(v||!lr)&&(nr+="#"+hu),et=ti.indexOf(nr),et+1&&(et+=nr.length,hr=lt=ti.slice(0,et),ti=ti.slice(et),tr?ii.setAttribute(o,ti):p(r,ti)))}if(oi=i,l=(""+l).replace(au,pu),wr&&dt.length&&si("Mismatched '<"+ut+"...>' in:\n"+l),d)return;for(er.appendChild(or),ri=h[ri]||h.div,uu=ri[0],vi.innerHTML=ri[1]+l+ri[2];uu--;)vi=vi.lastChild;for(er.removeChild(or),dr=e.createDocumentFragment();eu=vi.firstChild;)dr.appendChild(eu);r.insertBefore(dr,f)}return kt?setTimeout(iu,0):iu(),kt&&kt.promise()}function pt(n,t,u,f,e,o,s){var k,v,w,h,d,g,p,b,a,l,nt;if(f)l=c[f],l=l.linkCtx?l.linkCtx.tag:l,a=l.linkCtx||{data:u.data,elem:l._elCnt?l.parentElem:t,view:u,ctx:u.ctx,attr:y,fn:l._.bnd,tag:l,_bndId:f},wr(a,a.fn);else if(n&&t)for(o=e?o:u.data,k=u.tmpl,n=du(n,vt(t)),rt.lastIndex=0;v=rt.exec(n);)nt=rt.lastIndex,w=v[1],p=v[3],d=v[10],h=i,a={data:o,elem:t,view:u,ctx:s,attr:w,isLk:e,_initVal:!v[2]},v[6]&&(!w&&(h=/:([\w$]*)$/.exec(d))&&(h=h[1],h!==i&&(g=-h.length-1,p=p.slice(0,g-1)+ut)),h===null&&(h=i),a.convert=v[5]||""),a.expr=w+p,b=k.links[p],b||(k.links[p]=b=r.tmplFn(p,k,!0,h)),a.fn=b,w||h===i||(a.convertBack=h),wr(a,b),rt.lastIndex=nt}function wr(n,t){function u(i,r){wu.call(n,i,r,t)}u.noArray=!0;n.isLk&&(n.view=new r.View(n.ctx,"link",l,n.data,l.tmpl,i,i,yt));n._ctxCb=nf(n.view);n._hdl=u;u(!0)}function wt(n,t){var i;return n?(i=n.indexOf(t),i+1?n.slice(0,i)+n.slice(i+t.length):n):""}function ot(n){return n&&(""+n===n?n:n.tagName===lt?n.type.slice(3):n.nodeType===1&&n.getAttribute(o)||"")}function s(n,t,i){function e(n,t,i,u,e,o){f.push({elCnt:r,id:u,ch:e,open:t,close:i,path:o,token:n})}var r,u,f=[];if(u=t?n:ot(n))return r=f.elCnt=n.tagName!==lt,r=u.charAt(0)==="@"||r,f._tkns=u,u.replace(i||pu,e),f}function br(n,t){n&&(n.type==="jsv"?n.parentNode.removeChild(n):t&&n.getAttribute(w)===""&&n.removeAttribute(w))}function kr(n,t){for(var i=n;t&&i&&i.nodeType!==1;)i=i.previousSibling;return i&&(i.nodeType!==1?(i=e.createElement(lt),i.type="jsv",n.parentNode.insertBefore(i,n)):ot(i)||i.getAttribute(w)||i.setAttribute(w,"")),i}function du(n,i){return n=t.trim(n).replace(hu,"\\$&"),n.slice(-1)!==ut?n=ni+":"+n+(i?":":"")+ut:n}function bt(n,u){var e,f,l,o,s,y,p,a,w,v,b=u.view,h=n.linkCtx=n.linkCtx||{tag:n,data:b.data,view:b,ctx:b.ctx};if(n.onAfterLink)n.onAfterLink(u,h);if(e=n.targetTag?n.targetTag.linkedElem:n.linkedElem,(f=e&&e[0])&&((l=n._.radio)&&(e=e.children("input[type=radio]")),l||!n._.chging)){if(o=r.cvt(n,n.convert)[0],l||f!==h.elem){for(p=e.length;p--;){if(f=e[p],a=f._jsvLkEl,n._.inline&&(!a||a!==n&&a.targetTag!==n))for(f._jsvLkEl=n,s=h.elem?h.elem._jsvBnd:n._prv._jsvBnd,f._jsvBnd=s+"+",s=s.slice(1).split("&"),y=s.length;y--;)dr(c[s[y]],n.convertBack);l&&(f[g]=o===f.value)}h._val=o}o!==i&&(l||f.value===i?f.contentEditable===at&&(f.innerHTML=o):f.type===ui?f[g]=o&&o!=="false":e.val(o))}(f=f||n.tagName===":"&&h.elem)&&(w=f._jsvTr,v=u.props.trigger,w!==v&&(f._jsvTr=v,e=e||t(f),pi(e,w,"off"),pi(e,v,"on")))}function gu(n){setTimeout(function(){nt(n)},0)}function pi(n,t,i){t&&n[i](t===!0?"keydown":t,t===!0?gu:nt)}function dr(n,t){var s,e,r,i,o,f=n.linkCtx,h=f.data,u=f.fn.paths;if(n&&u)if(u=(s=u._jsvto)||u[0],e=u&&u.length,e&&(!f.tag||f.tag.tagCtx.args.length)){if(i=u[e-1],i._jsv){for(o=i;i.sb&&i.sb._jsv;)r=i=i.sb;r=i.sb||r&&r.path;i=r?r.slice(1):o.path}n.to=r?[[o,i],t]:[f._ctxCb(r=i.split("^").join("."))||[h,r],t]}else n.to=[[],t]}function gr(n,t,i){var o,s,h=n.tagCtx.view,e=n.tagCtxs||[n.tagCtx],c=e.length,l=!t;if(t=t||n._.bnd.call(h.tmpl,(n.linkCtx||h).data,h,u),i)e=n.tagCtxs=t,n.tagCtx=e[0];else while(c--)o=e[c],s=t[c],f(o.props).setProperty(s.props),v(o.ctx,s.ctx),o.args=s.args,l&&(o.tmpl=s.tmpl);return r._ths(n,e[0]),e}function kt(n){for(var u,t,i,f=[],e=n.length,r=e;r--;)f.push(n[r]);for(r=e;r--;)if(t=f[r],t.parentNode){if(i=t._jsvBnd)for(i=i.slice(1).split("&"),t._jsvBnd="",u=i.length;u--;)dt(i[u],t._jsvLkEl,t);tu(ot(t)+(t._df||""))}}function dt(n,u,f){var y,h,e,l,a,p,w,b,v,s,k,o=c[n];if(u)f===u.linkedElem[0]&&(delete f._jsvLkEl,delete u.linkedElem);else if(o){delete c[n];for(y in o.bnd)l=o.bnd[y],a=o.cbId,t.isArray(l)?t([l]).off(ti+a).off(nr+a):t(l).off(nr+a),delete o.bnd[y];if(h=o.linkCtx){if(e=h.tag){if(p=e.tagCtxs)for(w=p.length;w--;)(b=p[w].map)&&b.unmap();v=e.linkedElem;s=v&&v[0]||h.elem;(k=s&&s._jsvTr)&&(pi(v||t(s),k,"off"),s._jsvTr=i);e.onDispose&&e.onDispose();e._elCnt||(e._prv&&e._prv.parentNode.removeChild(e._prv),e._nxt&&e._nxt.parentNode.removeChild(e._nxt))}delete h.view._.bnds[n]}delete r._cbBnds[o.cbId]}}function wi(n,r){return n===i?(tt&&(t(tt).off(tr,nt).off("blur","[contenteditable]",nt),tt=i),n=!0,l.removeViews(),kt(e.body.getElementsByTagName("*"))):r&&n===!0&&(r=r.jquery?r:t(r),r.each(function(){for(var n;(n=it(this,!0))&&n.parent;)n.parent.removeViews(n._.key,i,!0);kt(this.getElementsByTagName("*"));kt([this])})),r}function nu(n,t){return wi(this,n,t)}function nf(n){return function(t,i){var f,r,e=[i];if(n&&t){if(t._jsv)return t._jsv.call(n.tmpl,i,n,u);if(t.charAt(0)==="~")return t.slice(0,4)==="~tag"&&(r=n.ctx,t.charAt(4)==="."&&(f=t.slice(5).split("."),r=r.tag),f)?r?[r,f.join("."),i]:[]:(t=t.slice(1).split("."),(i=n.hlp(t.shift()))&&(t.length&&e.unshift(t.join(".")),e.unshift(i)),i?e:[]);if(t.charAt(0)==="#")return t==="#data"?[]:[n,t.replace(lu,""),i]}}}function tf(n){return n.type===ui?n[g]:n.value}function bi(n,t,i,r,u,f){var v,l,y,h,k,a,e,w=0,d=n===t;if(n){for(y=s(n)||[],v=0,l=y.length;v<l;v++){if(h=y[v],a=h.id,a===r&&h.ch===u)if(f)l=0;else break;d||(k=h.ch==="_"?b[a]:c[a].linkCtx.tag,h.open?k._prv=t:h.close&&(k._nxt=t));w+=a.length+2}w&&n.setAttribute(o,n.getAttribute(o).slice(w));e=t?t.getAttribute(o):i._df;(l=e.indexOf("/"+r+u)+1)&&(e=y._tkns.slice(0,w)+e.slice(l+(f?-1:r.length+1)));e&&(t?t.setAttribute(o,e):p(i,e))}else p(i,wt(i._df,"#"+r+u)),f||t||p(i,wt(i._df,"/"+r+u))}function tu(n){var r,f,t,u;if(u=s(n,!0,vu))for(r=0,f=u.length;r<f;r++)t=u[r],t.ch==="_"?(t=b[t.id])&&t.type&&t.parent.removeViews(t._.key,i,!0):dt(t.id)}function rf(n,t,i){if(i.change==="set"){for(var r=n.tgt,u=r.length;u--;)if(r[u].key===i.path)break;u===-1?i.path&&f(r).insert({key:i.path,prop:i.value}):i.remove?f(r).remove(u):f(r[u]).setProperty("prop",i.value)}}function uf(n,t,i){var r,u=n.src,e=i.change;e==="set"?i.path==="prop"?f(u).setProperty(t.target.key,i.value):(f(u).setProperty(i.oldValue,null),delete u[i.oldValue],f(u).setProperty(i.value,t.target.prop)):e==="remove"?(r=i.items[0],f(u).removeProperty(r.key),delete u[r.key]):e==="insert"&&(r=i.items[0],r.key&&f(u).setProperty(r.key,r.prop))}function ff(n){return n.indexOf(".")<0}var gt="JsViews requires ",tt,it,rt,iu,ni,ut,ru,ki,di,k,w,ft,gi,h,l,b,e=n.document,u=t.views,r=u.sub,a=u.settings,v=r.extend,et=t.isFunction,uu=u.converters,d=u.tags,f=t.observable,st=f.observe,o="data-jsv",nr=r.propChng=r.propChng||"propertyChange",ti=r.arrChng=r.arrChng||"arrayChange",tr="change.jsv",ii="onBeforeChange",ri="onAfterChange",fu="onAfterCreate",g="checked",ui="checkbox",ht="radio",ct="none",lt="SCRIPT",at="true",ir='"><\/script>',rr='<script type="jsv',ur=o+"-df",fi="script,["+o+"]",y="html",ei={value:"val",input:"val",html:y,text:"text"},fr={from:"value",to:"value"},oi=0,eu=t.cleanData,ou=a.delimiters,si=r.syntaxErr,su=/<(?!script)(\w+)(?:[^>]*(on\w+)\s*=)?[^>]*>/,hu=/['"\\]/g,er=e.createDocumentFragment(),hi=e.querySelector,ci={ol:1,ul:1,table:1,tbody:1,thead:1,tfoot:1,tr:1,colgroup:1,dl:1,select:1,optgroup:1,svg:1,svg_ns:1},cu={tr:"table"},li={br:1,img:1,input:1,hr:1,area:1,base:1,col:1,link:1,meta:1,command:1,embed:1,keygen:1,param:1,source:1,track:1,wbr:1},or={},c={},sr=1,lu=/^#(view\.?)?/,au=/(^|(\/>)|<\/(\w+)>|)(\s*)([#\/]\d+[_^])`(\s*)(<\w+(?=[\s\/>]))?|\s*(?:(<\w+(?=[\s\/>]))|<\/(\w+)>(\s*)|(\/>)\s*|(>))/g,hr=/(#)()(\d+)(_)/g,vu=/(#)()(\d+)([_^])/g,cr=/(?:(#)|(\/))(\d+)(_)/g,yu=/(#)()(\d+)(\^)/g,pu=/(?:(#)|(\/))(\d+)([_^])([-+@\d]+)?/g,lr=n.getComputedStyle;if(!t)throw gt+"jQuery";if(!u)throw gt+"JsRender";if(!f)throw gt+"jquery.observable";t.link||(ft={contents:function(n,r){n!==!!n&&(r=n,n=i);var f,u=t(this.nodes());return u[0]&&(f=r?u.filter(r):u,u=n&&r?f.add(u.find(r)):f),u},nodes:function(n,t,i){var r,u=this,f=u._elCnt,o=!t&&f,e=[];for(t=t||u._prv,i=i||u._nxt,r=o?t===u._nxt?u.parentElem.lastSibling:t:u._.inline===!1?t||u.linkCtx.elem.firstChild:t&&t.nextSibling;r&&(!i||r!==i);)(n||f||r.tagName!==lt)&&e.push(r),r=r.nextSibling;return e},childTags:function(n,t){n!==!!n&&(t=n,n=i);var r=this,e=r.link?r:r.tagCtx.view,u=r._prv,o=r._elCnt,f=[];return e.link(i,r.parentElem,o?u&&u.previousSibling:u,r._nxt,i,{get:{tags:f,deep:n,name:t,id:r.link?r._.id+"_":r._tgId+"^"}}),f},refresh:function(n){var r,f,t=this,e=t.linkCtx,o=t.tagCtx.view;return t.disposed&&k("Removed tag"),n===i&&(n=u._tag(t,o,o.tmpl,gr(t),!0)),n+""===n&&(f=t._.inline?y:e.attr||vt(t.parentElem,!0),r=ar(n,e,f,t)),bt(t,t.tagCtx),r||t},update:function(n){var t=this.linkedElem;t&&nt({target:t[0]},i,n)}},r.onStore.template=function(n,i){i.link=pr;i.unlink=nu;n&&(t.link[n]=function(){return pr.apply(i,arguments)},t.unlink[n]=function(){return nu.apply(i,arguments)})},r.onStore.tag=function(n,t){r._lnk(t)},r._lnk=function(n){return v(n,ft)},r.viewInfos=s,(a.delimiters=function(){var n=ou.apply(u,arguments);return iu=n[0],ni=n[1],ut=n[2],ru=n[3],ki=n[4],rt=new RegExp("(?:^|\\s*)([\\w-]*)(\\"+ki+")?(\\"+ni+r.rTag+"\\"+ut+")","g"),this})(),v(r._lnk(r.View.prototype),{addViews:function(n,t,i){var u,s,r=this,e=t.length,o=r.views;if(!r._.useKey&&e&&(i=r.tmpl)&&(s=o.length+e,yr(r,n,i,o,t,r.ctx)!==!1))for(u=n+e;u<s;u++)f(o[u]).setProperty("index",u);return r},removeViews:function(n,r,u){function s(n){var s,h,c,f,o,l,r=e[n];if(r&&r.link){if(s=r._.id,u||(l=r.nodes()),r.removeViews(i,i,!0),r.type=i,f=r._prv,o=r._nxt,c=r.parentElem,u||(r._elCnt&&bi(f,o,c,s,"_"),t(l).remove()),!r._elCnt)try{f.parentNode.removeChild(f);o.parentNode.removeChild(o)}catch(a){}ai(r);for(h in r._.bnds)dt(h);delete b[s]}}var o,a,h,c=this,l=!c._.useKey,e=c.views;if(l&&(h=e.length),n===i)if(l){for(o=h;o--;)s(o);c.views=[]}else{for(a in e)s(a);c.views={}}else if(r===i&&(l?r=1:(s(n),delete e[n])),l&&r){for(o=n+r;o-->n;)s(o);if(e.splice(n,r),h=e.length)while(n<h)f(e[n]).setProperty("index",n++)}return this},refresh:function(n){var t=this,i=t.parent;return i&&(yr(t,t.index,t.tmpl,i.views,t.data,n,!0),ai(t)),t},link:ku}),b={0:l=new r.View},uu.merge=function(n){var t,i=this.linkCtx._val||"",r=this.tagCtx.props.toggle;return r&&(t=r.replace(/[\\^$.|?*+()[{]/g,"\\$&"),t="(\\s(?="+t+"$)|(\\s)|^)("+t+"(\\s|$))",i=i.replace(new RegExp(t),"$2"),n=i+(n?(i&&" ")+r:"")),n},d("on",{attr:ct,onAfterLink:function(n,u){for(var l,o,s=this,h=0,f=n.args,v=f.length,a=n.props.data,c=n.view,e=n.props.context;h<v&&!(o=et(l=f[h++])););if(o){o=f.slice(h);f=f.slice(0,h-1);e||(e=/^(.*)[\.^][\w$]+$/.exec(n.params.args.slice(-o.length-1)[0]),e=e&&r.tmplFn("{:"+e[1]+"}",c.tmpl,!0)(u.data,c));s._evs&&s.onDispose();t(u.elem).on(s._evs=f[0]||"click",s._sel=f[1],a==i?null:a,s._hlr=function(n){return l.apply(e||u.data,[].concat(o,n,{change:n.type,view:c,linkCtx:u}))})}},onDispose:function(){t(this.parentElem).off(this._evs,this._sel,this._hlr)},flow:!0}),v(d["for"],{onArrayChange:function(n,t){var i,r=this,u=t.change;if(r.tagCtxs[1]&&(u==="insert"&&n.target.length===t.items.length||u==="remove"&&!n.target.length||u==="refresh"&&!t.oldItems.length!=!n.target.length))r.refresh();else for(i in r._.arrVws)i=r._.arrVws[i],i.data===n.target&&i._.onArrayChange.apply(i,arguments);n.done=!0},onAfterLink:function(){for(var u,o,i,f,e=this,r=e._ars||{},s=e.tagCtxs,c=s.length,h=e.selected||0,n=0;n<=h;n++)u=s[n],f=u.map?u.map.tgt:u.args.length?u.args[0]:u.view.data,(i=r[n])&&f!==i[0]&&(st(i[0],i[1],!0),delete r[n]),!r[n]&&t.isArray(f)&&(st(f,o=function(n,t){e.onArrayChange(n,t)}),r[n]=[f,o]);for(n=h+1;n<c;n++)(i=r[n])&&(st(i[0],i[1],!0),delete r[n]);e._ars=r},onDispose:function(){var n,t=this;for(n in t._ars)st(t._ars[n][0],t._ars[n][1],!0)}}),v(d["for"],ft),v(d["if"],ft),v(d.include,ft),d("props",{baseTag:"for",dataMap:u.map({getTgt:d.props.dataMap.getTgt,obsSrc:rf,obsTgt:uf,tgtFlt:ff})}),v(t,{view:u.view=it=function(n,r,u){function p(n,t){if(n)for(o=s(n,t,hr),a=0,w=o.length;a<w;a++)if((f=b[o[a].id])&&(f=f&&u?f.get(!0,u):f))break}r!==!!r&&(u=r,r=i);var f,o,c,a,w,h,v,y=0,k=e.body;if(n&&n!==k&&l._.useKey>1&&(n=""+n===n?t(n)[0]:n.jquery?n[0]:n,n)){if(r){if(p(n._df,!0),!f)for(v=hi?n.querySelectorAll(fi):t(fi,n).get(),h=v.length,c=0;!f&&c<h;c++)p(v[c]);return f}while(n){if(o=s(n,i,cr))for(h=o.length;h--;)if(f=o[h],f.open){if(y<1)return f=b[f.id],f&&u?f.get(u):f||l;y--}else y++;n=n.previousSibling||n.parentNode}}return l},link:u.link=yi,unlink:u.unlink=wi,cleanData:function(n){n.length&&oi&&kt(n);eu.apply(t,arguments)}}),u.utility={validate:function(n){try{l.link(i,e.createElement("div"),i,i,n,i,i,1)}catch(t){return t.message}}},v(t.fn,{link:function(n,t,i,r,u,f,e){return yi(n,this,t,i,r,u,f,e)},unlink:function(n){return wi(n,this)},view:function(n){return it(this[0],n)}}),t.each([y,"replaceWith","empty","remove"],function(n,i){var r=t.fn[i];t.fn[i]=function(){var n;oi=1;try{n=r.apply(this,arguments)}finally{oi=0}return n}}),v(l,{tmpl:{links:{},tags:{}}}),l._.onRender=yt,a({wrapMap:h={option:[1,"<select multiple='multiple'>","<\/select>"],legend:[1,"<fieldset>","<\/fieldset>"],area:[1,"<map>","<\/map>"],param:[1,"<object>","<\/object>"],thead:[1,"<table>","<\/table>"],tr:[2,"<table><tbody>","<\/tbody><\/table>"],td:[3,"<table><tbody><tr>","<\/tr><\/tbody><\/table>"],col:[2,"<table><tbody><\/tbody><colgroup>","<\/colgroup><\/table>"],svg_ns:[1,"<svg>","<\/svg>"],div:jQuery.support.htmlSerialize?[0,"",""]:[1,"X<div>","<\/div>"]},linkAttr:w="data-link",merge:{input:{from:tf,to:"value"},textarea:fr,select:fr,optgroup:{to:"label"}},jsrDbgMode:a.debugMode,debugMode:function(t){a.jsrDbgMode(t);t?n._jsv={views:b,bindings:c}:delete n._jsv},jsv:function(){a.debugMode(a._dbgMode);w=a.linkAttr;k=u._err;gi=fi+",["+w+"]";di=a.noDomLevel0;h.optgroup=h.option;h.tbody=h.tfoot=h.colgroup=h.caption=h.thead;h.th=h.td}}))})(this,this.jQuery);
/*
//# sourceMappingURL=jquery.views.min.js.map
*/