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