Comparing version 0.2.0 to 0.2.1
@@ -1,2 +0,2 @@ | ||
(function(){"use strict";Date.now||(Date.now=function(){return+new Date}),document.createElementNS||(document.createElementNS=function(t,e){if(null!==t&&"http://www.w3.org/1999/xhtml"!==t)throw"This browser does not support namespaces other than http://www.w3.org/1999/xhtml";return document.createElement(e)}),Element.prototype.contains||(Element.prototype.contains=function(t){for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),window.addEventListener||function(t,e,i,n,r,s,o){t[n]=e[n]=i[n]=function(t,e){var i=this;o.unshift([i,t,e,function(t){t.currentTarget=i,t.preventDefault=function(){t.returnValue=!1},t.stopPropagation=function(){t.cancelBubble=!0},t.target=t.srcElement||i,e.call(i,t)}]),this.attachEvent("on"+t,o[0][3])},t[r]=e[r]=i[r]=function(t,e){for(var i,n=0;i=o[n];++n)if(i[0]===this&&i[1]===t&&i[2]===e)return this.detachEvent("on"+t,o.splice(n,1)[0][3])},t[s]=e[s]=i[s]=function(t){return this.fireEvent("on"+t.type,t)}}(Window.prototype,HTMLDocument.prototype,Element.prototype,"addEventListener","removeEventListener","dispatchEvent",[]),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var i;for(void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0),i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var i,n;for(i=0,n=this.length;n>i;i+=1)i in this&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)i in this&&(r[i]=t.call(e,this[i],i,this));return r}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)i in this&&t.call(e,this[i],i,this)&&(r[r.length]=this[i]);return r})})(),function(t){"use strict";var e;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this.observers={},this.pendingResolution=[],this.deferredAttributes=[],this.data&&this.set(this.data),this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,callback:this.callback,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this.deferredAttributes.length;)this.deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h,l;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o,e),a=this.pendingResolution.length;a--;)l=this.pendingResolution.splice(a,1)[0],h=this.resolveRef(l.view.model.ref,l.view.contextStack),h?l.callback(h.keypath,h.value):this.registerUnresolvedKeypath(l)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(t in this._cache)return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(n in this._cache)return this._cache[n];if(e.length>1?(r=e.pop(),a=this.get(e)):(r=e.pop(),a=this.data),s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a)return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(){throw Error("not implemented yet!")},link:function(t){var e=this;return function(i){e.set(t,i)}},registerView:function(t){var e,n,r,s,o=this;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(s=t.parentFragment.indexRefs[t.model.ref],r=t.model.fmtrs?this._format(s,t.model.fmtrs):s,t.update(r),void 0):(n=function(e){t.keypath=t.model.fmtrs?e+"."+i.stringifyFormatters(t.model.fmtrs):e,t.observerRefs=o.observe(t.model.p||0,t),t.update(o.get(t.keypath))},e=this.resolveRef(t.model.ref,t.contextStack),e?n(e.keypath,e.value):(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this.registerUnresolvedKeypath({view:t,callback:n})),void 0)},resolveRef:function(t,e){var i,n,r;if("."===t)return n=e[e.length-1],r=this.get(n),{keypath:n,value:r};for(e=e.concat();e.length;)if(i=e.pop(),n=i+"."+t,r=this.get(n),void 0!==r)return{keypath:n,value:r};return r=this.get(t),void 0!==r?{keypath:t,value:r}:void 0},registerUnresolvedKeypath:function(t){this.pendingResolution[this.pendingResolution.length]=t},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this.observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t,e){var n,r,s=this,o=e.keypath,a=[];if(!o)return void 0;for(n=function(i){var n;n=s.observers[i]=s.observers[i]||[],n=n[t]=n[t]||[],n[n.length]=e,a[a.length]={keypath:i,priority:t,view:e}},r=i.splitKeypath(e.keypath);r.length>1;)n(r.join(".")),r.pop();return n(r[0]),a},unobserve:function(t){var e,i,n,r,s;if(e=this.observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.view){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this.observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})();var i;(function(){var t={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var e,i,n,r,s,o,a,h,l,u;if(!(e=/\\\./.test(t))&&!(i=/⭆.+⭅/.test(t)))return t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".");for(h=[],l=t,i&&(n=[],l=l.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),a=0;l.length;){if(o=l.indexOf(".",a),-1===o)u=l,l="";else{if("\\"===l.charAt(o-1)&&"\\"!==l.charAt(o-2)){a=o+1;continue}u=l.substr(0,o),a=0}/\[/.test(u)?h=h.concat(u.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):h[h.length]=u,l=l.substring(o+1)}if(i)for(s=function(){return"⭆"+n.pop()+"⭅"},r=h.length;r--;)"⭆x⭅"===h[r]&&(h[r]="⭆"+n.pop()+"⭅");return h},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}})(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t._Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerView(this),!this.keypath&&this.model.inv&&this.update(!1)},t._Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t._sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0;return this.postUpdate&&this.postUpdate(),void 0}if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0);this.postUpdate&&this.postUpdate()}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype);var e=e||{},i=i||{};(function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m;t.compile=function(i,r){var s,o,a;return r=r||{},r.sanitize===!0&&(r.sanitize={elements:["applet","base","basefont","body","frame","frameset","head","html","isindex","link","meta","noframes","noscript","object","param","script","style","title"],eventAttributes:!0}),t.delimiters=r.delimiters||["{{","}}"],t.tripleDelimiters=r.tripleDelimiters||["{{{","}}}"],s=e.tokenize(i),o=n(s,0,r,r.preserveWhitespace),a=o.toJson(),"string"==typeof a?[a]:a},p=e.types,c=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],d=["a","abbr","acronym","address","applet","area","b","base","basefont","bdo","big","blockquote","body","br","button","caption","center","cite","code","col","colgroup","dd","del","dfn","dir","div","dl","dt","em","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","i","iframe","img","input","ins","isindex","kbd","label","legend","li","link","map","menu","meta","noframes","noscript","object","ol","optgroup","option","p","param","pre","q","s","samp","script","select","small","span","strike","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","u","ul","var","article","aside","audio","bdi","canvas","command","data","datagrid","datalist","details","embed","eventsource","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","ruby","rp","rt","section","source","summary","time","track","video","wbr"],f=["li","dd","rt","rp","optgroup","option","tbody","tfoot","tr","td","th"],m={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:["address","article","aside","blockquote","dir","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","menu","nav","ol","p","pre","section","table","ul"],rt:["rt","rp"],rp:["rp","rt"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tr:["tr"],td:["td","th"],th:["td","th"]},u=function(t){var e,i,n,r;if(r=t.indexOf("["),-1!==r){e=t.substr(0,r),i=t.substring(r,t.length);try{n=JSON.parse(i)}catch(s){throw"Could not parse arguments ("+i+") using JSON.parse"}return{name:e,args:n}}return{name:t}},l={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},h=function(t){var e;return e=t.replace(/&([a-zA-Z]+);/,function(t,e){return l[e]?String.fromCharCode(l[e]):t}),e=e.replace(/&#x([0-9]+);/,function(t,e){return String.fromCharCode(parseInt(e,16))}),e=e.replace(/&#([0-9]+);/,function(t,e){return String.fromCharCode(e)})},r=function(t){this.type=p.TEXT,this.text=t.value},r.prototype={toJson:function(){return this.decoded||(this.decoded=h(this.text))},toString:function(){return this.text},decodeCharacterReferences:function(){}},s=function(t,e){var r,s,o,a,h,l;if(this.type=p.ELEMENT,this.tag=t.tag,this.parentFragment=e,this.parentElement=e.parentElement,r=t.attributes.items,o=r.length){for(s=[],a=0;o>a;a+=1)e.options.sanitize&&e.options.sanitize.eventAttributes&&"on"===r[a].name.value.toLowerCase().substr(0,2)||(h={name:r[a].name.value},r[a].value.isNull||(h.value=n(r[a].value.tokens,this.parentFragment.priority+1)),s[a]=h);this.attributes=s}t.isSelfClosingTag||-1!==c.indexOf(t.tag.toLowerCase())||(l=e.preserveWhitespace||"pre"===this.tag.toLowerCase(),this.fragment=new i(this,e.priority+1,e.options,l))},s.prototype={read:function(t){return this.fragment&&this.fragment.read(t)},toJson:function(t){var e,i,n,r,s;if(e={type:p.ELEMENT,tag:this.tag},this.attributes)for(e.attrs={},s=0;this.attributes.length>s;s+=1)i=this.attributes[s].name,void 0===this.attributes[s].value?n=null:(r=""+this.attributes[s].value,n=r!==!1?r:this.attributes[s].value.toJson()),e.attrs[i]=n;return this.fragment&&this.fragment.items.length&&(e.frag=this.fragment.toJson(t)),e},toString:function(){var t,e,i,n,r,s,o;if(-1===d.indexOf(this.tag.toLowerCase()))return!1;if(s=this.fragment?""+this.fragment:"",s===!1)return!1;if(o=-1!==c.indexOf(this.tag.toLowerCase()),t="<"+this.tag,this.attributes)for(e=0,i=this.attributes.length;i>e;e+=1){if(-1!==this.attributes[e].name.indexOf(":"))return!1;if(n=" "+this.attributes[e].name,void 0!==this.attributes[e].value){if(r=""+this.attributes[e].value,r===!1)return!1;""!==r&&(n+="=",n+=/[\s"'=<>`]/.test(r)?'"'+r.replace(/"/g,""")+'"':r)}t+=n}return this.isSelfClosing&&!o?t+="/>":(t+=">",o?t:(t+=s,t+="</"+this.tag+">"))}},o=function(t,e){this.type=p.SECTION,this.parentFragment=e,this.ref=t.ref,this.inverted=t.type===p.INVERTED,this.formatters=t.formatters,this.i=t.i,this.fragment=new i(this,e.priority+1,e.options,e.preserveWhitespace)},o.prototype={read:function(t){return this.fragment.read(t)},toJson:function(t){var e;return e={type:p.SECTION,ref:this.ref},this.fragment&&(e.frag=this.fragment.toJson(t)),this.formatters&&this.formatters.length&&(e.fmtrs=this.formatters.map(u)),this.inverted&&(e.inv=!0),this.priority&&(e.p=this.parentFragment.priority),this.i&&(e.i=this.i),e},toString:function(){return!1}},a=function(t,e){this.type=t.type,this.priority=e,this.ref=t.ref,this.formatters=t.formatters},a.prototype={toJson:function(){var t={type:this.type,ref:this.ref};return this.formatters&&(t.fmtrs=this.formatters.map(u)),this.priority&&(t.p=this.priority),t},toString:function(){return!1}},i=function(t,e,i,n){this.owner=t,this.items=[],this.options=i,this.preserveWhitespace=n,t&&(this.parentElement=t.type===p.ELEMENT?t:t.parentElement),this.priority=e},i.prototype={read:function(t){if(this.sealed)return!1;if(this.isImplicitlyClosedBy(t))return this.seal(),!1;if(this.currentChild){if(this.currentChild.read(t))return!0;this.currentChild=null}return this.isExplicitlyClosedBy(t)?(this.seal(),!0):t.type===p.CLOSING||t.type===p.DELIMCHANGE||t.type===p.COMMENT?!1:t.type===p.SECTION||t.type===p.INVERTED?(this.currentChild=new o(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===p.TAG?(this.currentChild=new s(t,this),this.options.sanitize&&this.options.sanitize.elements&&-1!==this.options.sanitize.elements.indexOf(t.tag.toLowerCase())?!0:(this.items[this.items.length]=this.currentChild,!0)):t.type===p.TEXT||t.type===p.ATTR_VALUE_TOKEN?(this.items[this.items.length]=new r(t),!0):(this.items[this.items.length]=new a(t,this.priority),!0)},isClosedBy:function(t){return this.isImplicitlyClosedBy(t)||this.isExplicitlyClosedBy(t)},isImplicitlyClosedBy:function(t){var e,i,n,r,s;return t.tag&&this.owner&&this.owner.type===p.ELEMENT?(r=this.owner.tag.toLowerCase(),s=t.tag.toLowerCase(),i=this.owner,n=i.parentElement||null,e=m[r],e&&!t.isClosingTag&&-1!==e.indexOf(s)?!0:-1!==f.indexOf(r)&&n&&n.fragment.isClosedBy(t)?!0:"p"===r&&n&&"a"===n.tag.toLowerCase()&&n.fragment.isClosedBy(t)?!0:void 0):!1},isExplicitlyClosedBy:function(t){return this.owner?this.owner.type===p.SECTION&&t.type===p.CLOSING&&t.ref===this.owner.ref?!0:this.owner.type===p.ELEMENT&&this.owner&&t.isClosingTag&&t.tag.toLowerCase()===this.owner.tag.toLowerCase()?!0:void 0:!1},toJson:function(t){var e,i,n,r=[];if(!t&&(n=""+this,n!==!1))return n;for(e=0,i=this.items.length;i>e;e+=1)r[e]=this.items[e].toJson(t);return r},toString:function(){var t,e,i,n="";for(t=0,e=this.items.length;e>t;t+=1){if(i=""+this.items[t],i===!1)return!1;n+=i}return n},seal:function(){var t,e,i,n;if(this.sealed=!0,!this.preserveWhitespace)for(this.owner.type===p.ELEMENT&&(t=this.items[0],t&&t.type===p.TEXT&&(t.text=t.text.replace(/^\s*/,""),""===t.text&&this.items.shift()),e=this.items[this.items.length-1],e&&e.type===p.TEXT&&(e.text=e.text.replace(/\s*$/,""),""===e.text&&this.items.pop())),i=this.items.length;i--;)n=this.items[i],n.type===p.TEXT&&(n.text=n.text.replace(/\s{2,}/g," "));this.items.length||delete this.owner.fragment}},n=function(t,e,n,r){for(var s,o=new i(null,e,n,r);t.length;)s=t.shift(),o.read(s);return o}})(e,i),function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m,g,v,y,w,b,N,x;e.tokenize=function(t){var e=a.fromString(r(t));return o(s(e.tokens))},a=function(){this.tokens=[],this.buffer=new h},a.prototype={read:function(t){var e,n;if(this.currentToken&&this.currentToken.type!==i.TEXT&&this.currentToken.read(t))return!0;if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(n=this.buffer.release(),this.currentToken){for(;n.length;){for(;n.length&&this.currentToken.read(n.charAt(0));)n=n.substring(1);n.length&&("<"===n.charAt(0)?(this.currentToken=new c,this.currentToken.read("<")):(this.currentToken=new l,this.currentToken.read(n.charAt(0))),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1))}return!0}return this.currentToken="<"===t?new c:new l,this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,!0},end:function(){this.buffer.isEmpty()||(this.tokens[this.tokens.length]=this.buffer.convert())}},a.fromString=function(t){var e,i,n;for(e=new a,i=0,n=t.length;n>i;)e.read(t.charAt(i)),i+=1;return e.end(),e},h=function(){this.value=""},h.prototype={read:function(e){var i;return this.value+=e,i=this.isPartialMatchOf(t.delimiters[0])||this.isPartialMatchOf(t.tripleDelimiters[0])},convert:function(){var e,i,n,r,s,o;if(i=t.delimiters[0],n=t.tripleDelimiters[0],e=this.value,s=function(){return 0===e.indexOf(n)?new p:void 0},o=function(){return 0===e.indexOf(i)?new u:void 0},r=n.length>i.length?s()||o():o()||s()){for(;this.value.length;)r.read(this.value.charAt(0)),this.value=this.value.substring(1);return r}return!1},release:function(){var t=this.value;return this.value="",t},isEmpty:function(){return!this.value.length},isPartialMatchOf:function(t){return 0===t.indexOf(this.value)}},l=function(){this.type=i.TEXT,this.value=""},l.prototype={read:function(t){return this.sealed?!1:"<"===t?!1:(this.value+=t,!0)},seal:function(){this.sealed=!0}},u=function(){this.value="",this.openingDelimiter=t.delimiters[0],this.closingDelimiter=t.delimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length},p=function(){this.value="",this.openingDelimiter=t.tripleDelimiters[0],this.closingDelimiter=t.tripleDelimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length,this.type=i.TRIPLE},u.prototype=p.prototype={read:function(t){return this.sealed?!1:(this.value+=t,this.value.length>=this.minLength&&this.value.substr(-this.closingDelimiter.length)===this.closingDelimiter&&this.seal(),!0)},seal:function(){var t,e,n,r,s;this.sealed||(t=this.value.replace(this.openingDelimiter,"").replace(this.closingDelimiter,"").trim(),"="===t.charAt(0)&&(this.changeDelimiters(t),this.type=i.DELIMCHANGE),this.type||(e=t.charAt(0),f[e]?(this.type=f[e],t=t.substring(1).trim()):this.type=i.INTERPOLATOR),this.type===i.SECTION&&(r=/:\s*([a-zA-Z_$][a-zA-Z0-9_$]*)$/,s=r.exec(t),s&&(this.i=s[1],t=t.substr(0,t.length-s[0].length))),n=t.split("|"),this.ref=n.shift().trim(),n.length&&(this.formatters=n.map(function(t){return t.trim()})),this.sealed=!0)},changeDelimiters:function(e){var n,r;r=/\=\s*([^\s=]+)\s+([^\s=]+)\s*=/.exec(e),n=this.type===i.TRIPLE?t.tripleDelimiters:t.delimiters,n[0]=r[1],n[1]=r[2]}},c=function(){this.type=i.TAG,this.openingBracket=new m,this.closingTagSolidus=new y,this.tagName=new g,this.attributes=new v,this.selfClosingSolidus=new y,this.closingBracket=new w},c.prototype={read:function(t){var e;return this.sealed?!1:(e=this.openingBracket.read(t)||this.closingTagSolidus.read(t)||this.tagName.read(t)||this.attributes.read(t)||this.selfClosingSolidus.read(t)||this.closingBracket.read(t))?(this.closingBracket.sealed&&this.seal(),!0):(this.seal(),!1)},seal:function(){this.tag=this.tagName.value,this.closingTagSolidus.value&&(this.isClosingTag=!0),this.selfClosingSolidus.value&&(this.isSelfClosingTag=!0),this.sealed=!0}},m=function(){},m.prototype={read:function(t){if(this.sealed)return!1;if("<"===t)return this.value="<",this.seal(),!0;throw'Expected "<", saw "'+t+'"'},seal:function(){this.sealed=!0}},g=function(){},g.prototype={read:function(t){return this.sealed?!1:!this.value&&/[a-zA-Z]/.test(t)?(this.value=t,!0):/[a-zA-Z0-9\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},v=function(){this.items=[]},v.prototype={read:function(t){return this.sealed?!1:this.nextItem&&this.nextItem.read(t)?!0:n.test(t)?!0:(this.nextItem=new b,this.nextItem.read(t)?(this.items[this.items.length]=this.nextItem,!0):(this.seal(),!1))},seal:function(){this.sealed=!0}},b=function(){this.name=new N,this.value=new x},b.prototype={read:function(t){return this.sealed?!1:this.name.read(t)?!0:this.name.value?this.value.read(t)?!0:(this.seal(),!1):(this.seal(),!1)},seal:function(){this.sealed=!0}},N=function(){},N.prototype={read:function(t){return this.sealed?!1:this.value?/[_:a-zA-Z0-9\.\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1):/[a-zA-Z_:]/.test(t)?(this.value=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},x=function(){this.tokens=[],this.buffer=new h,this.isNull=!0},x.prototype={read:function(t){var e,i;if(this.sealed)return!1;if(this.isNull)return n.test(t)?!0:"="===t?(this.isNull=!1,!0):!1;if(!this.tokens.length&&!this.quoteMark){if(n.test(t))return!0;if('"'===t||"'"===t)return this.quoteMark=t,!0}if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(i=this.buffer.release(),this.currentToken){for(;i.length;){for(;i.length&&i.charAt(0)!==this.quoteMark&&this.currentToken.read(i.charAt(0));)i=i.substring(1);if(i.length){if(">"===i.charAt(0))return this.seal(),!1;if(i.charAt(0)===this.quoteMark)return this.currentToken.seal(),this.seal(),!0;this.currentToken=new d(this.quoteMark),this.currentToken.read(i.charAt(0)),this.tokens[this.tokens.length]=this.currentToken,i=i.substring(1)}}return!0}return this.currentToken=new d(this.quoteMark),this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,this.currentToken.sealed&&this.seal(),!0},seal:function(){this.sealed=!0}},d=function(t){this.type=i.ATTR_VALUE_TOKEN,this.quoteMark=t||"",this.value=""},d.prototype={read:function(t){return this.sealed?!1:t===this.quoteMark?(this.seal(),!0):this.quoteMark?(this.value+=t,!0):/[\s"'=<>`]/.test(t)?(this.seal(),!1):(this.value+=t,!0)},seal:function(){this.sealed=!0}},y=function(){},y.prototype={read:function(t){return this.sealed?!1:"/"===t?(this.value="/",this.seal(),!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},w=function(){},w.prototype={read:function(t){if(this.sealed)return!1;if(">"===t)return this.value=">",this.seal(),!0;throw'Expected ">", received "'+t+'"'},seal:function(){this.sealed=!0}},r=function(t){var e,i,n;for(n="";t.length;){if(e=t.indexOf("<!--"),i=t.indexOf("-->"),-1===e&&-1===i){n+=t;break}if(-1!==e&&-1===i)throw"Illegal HTML - expected closing comment sequence ('-->')";if(-1!==i&&-1===e||e>i)throw"Illegal HTML - unexpected closing comment sequence ('-->')";n+=t.substr(0,e),t=t.substring(i+3)}return n},s=function(t){var e,n,r,s,o,a;for(o=/^\s*\r?\n/,a=/\r?\n\s*$/,e=2;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e-2],n.type===i.TEXT&&r.type!==i.TAG&&s.type===i.TEXT&&a.test(s.value)&&o.test(n.value)&&(r.type!==i.INTERPOLATOR&&r.type!==i.TRIPLE&&(s.value=s.value.replace(a,"\n")),n.value=n.value.replace(o,""),""===n.value&&t.splice(e--,1));return t},o=function(t){var e,n,r,s;for(e=0;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e+1],n.type===i.COMMENT&&(t.splice(e,1),r&&s&&r.type===i.TEXT&&s.type===i.TEXT&&(r.value+=s.value,t.splice(e,1)),e-=1);return t},i=e.types,n=/\s/,f={"#":i.SECTION,"^":i.INVERTED,"/":i.CLOSING,">":i.PARTIAL,"!":i.COMMENT,"&":i.INTERPOLATOR}}(e,i),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t,e){var i,n,r,s,o,a,h,l,u,p,c;i=e.types,s={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},r="undefined"!=typeof window?window.document:null,n=function(t,e){var i,n=[];for(i=r.createElement("div"),i.innerHTML=t;i.firstChild;)n[n.length]=i.firstChild,e.appendChild(i.firstChild);return n},e.DomFragment=function(t){return this.docFrag=r.createDocumentFragment(),"string"==typeof t.model?(this.nodes=n(t.model,this.docFrag),void 0):(e._Fragment.call(this,t),void 0)},e.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new o(t,this.docFrag);switch(t.model.type){case i.INTERPOLATOR:return new u(t,this.docFrag);case i.SECTION:return new c(t,this.docFrag);case i.TRIPLE:return new p(t,this.docFrag);case i.ELEMENT:return new a(t,this.docFrag);case i.PARTIAL:return new h(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},h=function(t,i){this.fragment=new e.DomFragment({model:t.root.partials[t.model.ref]||[],root:t.root,parentNode:t.parentNode,contextStack:t.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},h.prototype={teardown:function(){this.fragment.teardown()}},o=function(t,e){this.node=r.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},o.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},a=function(t,i){var n,s,o,a,h,u,p;if(n=this.model=t.model,this.root=t.root,this.parentFragment=t.parentFragment,this.parentNode=t.parentNode,this.index=t.index,n.attrs&&n.attrs.xmlns){if(s=n.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=r.createElementNS(s,n.tag),n.frag&&("string"==typeof n.frag?this.node.innerHTML=n.frag:(this.children=new e.DomFragment({model:n.frag,root:t.root,parentNode:this.node,contextStack:t.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[]; | ||
for(a in n.attrs)n.attrs.hasOwnProperty(a)&&(h=n.attrs[a],o=new l({parent:this,name:a,value:void 0===h?null:h,root:t.root,parentNode:this.node,contextStack:t.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?p=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),i.appendChild(this.node)},a.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},l=function(t){var i,n,r,o,a,h,l,u;if(i=t.name,n=t.value,this.parent=t.parent,r=i.indexOf(":"),-1!==r&&(o=i.substr(0,r),"xmlns"!==o&&(i=i.substring(r+1),this.namespace=e.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?t.parentNode.setAttributeNS(this.namespace,i,n):t.parentNode.setAttribute(i,n),void 0):(this.root=t.root,this.parentNode=t.parentNode,this.name=i,this.children=[],this.namespace||t.parentNode.namespaceURI!==e.namespaces.html||(l=this.name.toLowerCase(),u=s[l]?s[l]:l,void 0!==t.parentNode[u]&&(this.propertyName=u),("boolean"==typeof t.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new e.TextFragment({model:n,root:this.root,parent:this,contextStack:t.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},l.prototype={bind:function(t){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==e.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),t||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root.deferredAttributes[this.root.deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(r.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},u=function(t,i){this.node=r.createTextNode(""),i.appendChild(this.node),e._Mustache.call(this,t)},u.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},p=function(t,i){this.nodes=[],this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},p.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=n(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},c=function(t,i){this.fragments=[],this.length=0,this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(t){e._sectionUpdate.call(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var i=new e.DomFragment(t);return this.docFrag.appendChild(i.docFrag),i}}}(e,i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t._Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t._Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t._Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t._sectionUpdate.call(this,e)},createFragment:function(e){return new t.TextFragment(e)},postUpdate:function(){this.value=this.fragments.join(""),this.parent.bubble()},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e){var i;for(i=0;t.length>i&&!r.requestAnimationFrame;++i)r.requestAnimationFrame=r[t[i]+"RequestAnimationFrame"],r.cancelAnimationFrame=r[t[i]+"CancelAnimationFrame"]||r[t[i]+"CancelRequestAnimationFrame"];r.requestAnimationFrame||(r.requestAnimationFrame=function(t){var i,n,s;return i=Date.now(),n=Math.max(0,16-(i-e)),s=r.setTimeout(function(){t(i+n)},n),e=i+n,s}),r.cancelAnimationFrame||(r.cancelAnimationFrame=function(t){r.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,p;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,p=e.splitKeypath(r),l=new i({keys:p,from:this.get(p),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e}(this); | ||
(function(t){"use strict";Date.now||(Date.now=function(){return+new Date}),t.createElementNS||(t.createElementNS=function(e,i){if(null!==e&&"http://www.w3.org/1999/xhtml"!==e)throw"This browser does not support namespaces other than http://www.w3.org/1999/xhtml";return t.createElement(i)}),Element.prototype.contains||(Element.prototype.contains=function(t){for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),window.addEventListener||function(t,e,i,n,r,s,o){t[n]=e[n]=i[n]=function(t,e){var i=this;o.unshift([i,t,e,function(t){t.currentTarget=i,t.preventDefault=function(){t.returnValue=!1},t.stopPropagation=function(){t.cancelBubble=!0},t.target=t.srcElement||i,e.call(i,t)}]),this.attachEvent("on"+t,o[0][3])},t[r]=e[r]=i[r]=function(t,e){var i,n;for(i=0,n;n=o[i];++i)if(n[0]===this&&n[1]===t&&n[2]===e)return this.detachEvent("on"+t,o.splice(i,1)[0][3])},t[s]=e[s]=i[s]=function(t){return this.fireEvent("on"+t.type,t)}}(Window.prototype,HTMLDocument.prototype,Element.prototype,"addEventListener","removeEventListener","dispatchEvent",[]),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var i;for(void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0),i=this.length;i>e;e++)if(this.hasOwnProperty(e)&&this[e]===t)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var i,n;for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&(r[i]=t.call(e,this[i],i,this));return r}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)&&(r[r.length]=this[i]);return r})})(document),function(t){"use strict";var e,i;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this._observers={},this._pendingResolution=[],this._deferredAttributes=[],this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this._deferredAttributes.length;)this._deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o),a=this._pendingResolution.length;a--;)h=this._pendingResolution.splice(a,1)[0],this.resolveRef(h)||(this._pendingResolution[this._pendingResolution.length]=h)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(this._cache.hasOwnProperty(t))return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(this._cache.hasOwnProperty(n))return this._cache[n];if(r=e.pop(),a=e.length?this.get(e):this.data,s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a||!a.hasOwnProperty(r))return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(t){return this._clearCache(t),this._notifyObservers(t),this.fire("update:"+t),this.fire("update",t),this},link:function(t){var e=this;return function(i){e.set(t,i)}},registerMustache:function(t){var e,i,n;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(n=t.parentFragment.indexRefs[t.model.ref],i=t.model.fmtrs?this._format(n,t.model.fmtrs):n,t.update(i),void 0):(e=this.resolveRef(t),e||(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this._pendingResolution[this._pendingResolution.length]=t),void 0)},resolveRef:function(t){var e,n,r,s,o,a,h,l;if(e=t.model.ref,n=t.contextStack,"."===e)l=n[n.length-1];else{for(r=i.splitKeypath(e),s=r.pop(),n=n.concat();n.length;)if(o=n.pop(),a=i.splitKeypath(o),h=this.get(a.concat(r)),"object"==typeof h&&h.hasOwnProperty(s)){l=o+"."+e;break}l||void 0===this.get(e)||(l=e)}return l?(t.keypath=t.model.fmtrs?l+"."+i.stringifyFormatters(t.model.fmtrs):l,t.observerRefs=this.observe(t),t.update(this.get(t.keypath)),!0):!1},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this._observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t){var e,n,r=this,s=[],o=t.model.p||0;for(e=function(e){var i;i=r._observers[e]=r._observers[e]||[],i=i[o]=i[o]||[],i[i.length]=t,s[s.length]={keypath:e,priority:o,mustache:t}},n=i.splitKeypath(t.keypath);n.length>1;)e(n.join(".")),n.pop();return e(n[0]),s},unobserve:function(t){var e,i,n,r,s;if(e=this._observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.mustache){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this._observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})(),function(){var t={},e={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var i,n,r,s,o,a,h,l;if(e[t])return e[t].concat();if(i=/⭆.+⭅/.test(t),!/\\\./.test(t)&&!i)return e[t]=t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split("."),e[t].concat();for(a=[],h=t,i&&(n=[],h=h.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),o=0;h.length;){if(s=h.indexOf(".",o),-1===s)l=h,h="";else{if("\\"===h.charAt(s-1)&&"\\"!==h.charAt(s-2)){o=s+1;continue}l=h.substr(0,s),o=0}/\[/.test(l)?a=a.concat(l.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):a[a.length]=l,h=h.substring(s+1)}if(i)for(r=a.length;r--;)"⭆x⭅"===a[r]&&(a[r]="⭆"+n.pop()+"⭅");return e[t]=a,a.concat()},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}}(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t.Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerMustache(this),!this.keypath&&this.model.inv&&this.update(this.model.fmtrs?this.root._format(!1,this.model.fmtrs):!1)},t.Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t.sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0}else if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0)}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype);var e=e||{},i=i||{};(function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m;t.compile=function(i,r){var s,o,a;return r=r||{},r.sanitize===!0&&(r.sanitize={elements:["applet","base","basefont","body","frame","frameset","head","html","isindex","link","meta","noframes","noscript","object","param","script","style","title"],eventAttributes:!0}),t.delimiters=r.delimiters||["{{","}}"],t.tripleDelimiters=r.tripleDelimiters||["{{{","}}}"],s=e.tokenize(i),o=n(s,0,r,r.preserveWhitespace),a=o.toJson(),"string"==typeof a?[a]:a},p=e.types,c=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],d=["a","abbr","acronym","address","applet","area","b","base","basefont","bdo","big","blockquote","body","br","button","caption","center","cite","code","col","colgroup","dd","del","dfn","dir","div","dl","dt","em","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","i","iframe","img","input","ins","isindex","kbd","label","legend","li","link","map","menu","meta","noframes","noscript","object","ol","optgroup","option","p","param","pre","q","s","samp","script","select","small","span","strike","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","u","ul","var","article","aside","audio","bdi","canvas","command","data","datagrid","datalist","details","embed","eventsource","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","ruby","rp","rt","section","source","summary","time","track","video","wbr"],f=["li","dd","rt","rp","optgroup","option","tbody","tfoot","tr","td","th"],m={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:["address","article","aside","blockquote","dir","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","menu","nav","ol","p","pre","section","table","ul"],rt:["rt","rp"],rp:["rp","rt"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tr:["tr"],td:["td","th"],th:["td","th"]},u=function(t){var e,i,n,r;if(r=t.indexOf("["),-1!==r){e=t.substr(0,r),i=t.substring(r,t.length);try{n=JSON.parse(i)}catch(s){throw"Could not parse arguments ("+i+") using JSON.parse"}return{name:e,args:n}}return{name:t}},l={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},h=function(t){var e;return e=t.replace(/&([a-zA-Z]+);/,function(t,e){return l[e]?String.fromCharCode(l[e]):t}),e=e.replace(/&#x([0-9]+);/,function(t,e){return String.fromCharCode(parseInt(e,16))}),e=e.replace(/&#([0-9]+);/,function(t,e){return String.fromCharCode(e)})},r=function(t){this.type=p.TEXT,this.text=t.value},r.prototype={toJson:function(){return this.decoded||(this.decoded=h(this.text))},toString:function(){return this.text},decodeCharacterReferences:function(){}},s=function(t,e){var r,s,o,a,h,l;if(this.type=p.ELEMENT,this.tag=t.tag,this.parentFragment=e,this.parentElement=e.parentElement,r=t.attributes.items,o=r.length){for(s=[],a=0;o>a;a+=1)e.options.sanitize&&e.options.sanitize.eventAttributes&&"on"===r[a].name.value.toLowerCase().substr(0,2)||(h={name:r[a].name.value},r[a].value.isNull||(h.value=n(r[a].value.tokens,this.parentFragment.priority+1)),s[a]=h);this.attributes=s}t.isSelfClosingTag||-1!==c.indexOf(t.tag.toLowerCase())||(l=e.preserveWhitespace||"pre"===this.tag.toLowerCase(),this.fragment=new i(this,e.priority+1,e.options,l))},s.prototype={read:function(t){return this.fragment&&this.fragment.read(t)},toJson:function(t){var e,i,n,r,s;if(e={type:p.ELEMENT,tag:this.tag},this.attributes)for(e.attrs={},s=0;this.attributes.length>s;s+=1)i=this.attributes[s].name,void 0===this.attributes[s].value?n=null:(r=""+this.attributes[s].value,n=r!==!1?r:this.attributes[s].value.toJson()),e.attrs[i]=n;return this.fragment&&this.fragment.items.length&&(e.frag=this.fragment.toJson(t)),e},toString:function(){var t,e,i,n,r,s,o;if(-1===d.indexOf(this.tag.toLowerCase()))return!1;if(s=this.fragment?""+this.fragment:"",s===!1)return!1;if(o=-1!==c.indexOf(this.tag.toLowerCase()),t="<"+this.tag,this.attributes)for(e=0,i=this.attributes.length;i>e;e+=1){if(-1!==this.attributes[e].name.indexOf(":"))return!1;if(n=" "+this.attributes[e].name,void 0!==this.attributes[e].value){if(r=""+this.attributes[e].value,r===!1)return!1;""!==r&&(n+="=",n+=/[\s"'=<>`]/.test(r)?'"'+r.replace(/"/g,""")+'"':r)}t+=n}return this.isSelfClosing&&!o?t+="/>":(t+=">",o?t:(t+=s,t+="</"+this.tag+">"))}},o=function(t,e){this.type=p.SECTION,this.parentFragment=e,this.ref=t.ref,this.inverted=t.type===p.INVERTED,this.formatters=t.formatters,this.i=t.i,this.fragment=new i(this,e.priority+1,e.options,e.preserveWhitespace)},o.prototype={read:function(t){return this.fragment.read(t)},toJson:function(t){var e;return e={type:p.SECTION,ref:this.ref},this.fragment&&(e.frag=this.fragment.toJson(t)),this.formatters&&this.formatters.length&&(e.fmtrs=this.formatters.map(u)),this.inverted&&(e.inv=!0),this.priority&&(e.p=this.parentFragment.priority),this.i&&(e.i=this.i),e},toString:function(){return!1}},a=function(t,e){this.type=t.type,this.priority=e,this.ref=t.ref,this.formatters=t.formatters},a.prototype={toJson:function(){var t={type:this.type,ref:this.ref};return this.formatters&&(t.fmtrs=this.formatters.map(u)),this.priority&&(t.p=this.priority),t},toString:function(){return!1}},i=function(t,e,i,n){this.owner=t,this.items=[],this.options=i,this.preserveWhitespace=n,t&&(this.parentElement=t.type===p.ELEMENT?t:t.parentElement),this.priority=e},i.prototype={read:function(t){if(this.sealed)return!1;if(this.isImplicitlyClosedBy(t))return this.seal(),!1;if(this.currentChild){if(this.currentChild.read(t))return!0;this.currentChild=null}return this.isExplicitlyClosedBy(t)?(this.seal(),!0):t.type===p.CLOSING||t.type===p.DELIMCHANGE||t.type===p.COMMENT?!1:t.type===p.SECTION||t.type===p.INVERTED?(this.currentChild=new o(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===p.TAG?(this.currentChild=new s(t,this),this.options.sanitize&&this.options.sanitize.elements&&-1!==this.options.sanitize.elements.indexOf(t.tag.toLowerCase())?!0:(this.items[this.items.length]=this.currentChild,!0)):t.type===p.TEXT||t.type===p.ATTR_VALUE_TOKEN?(this.items[this.items.length]=new r(t),!0):(this.items[this.items.length]=new a(t,this.priority),!0)},isClosedBy:function(t){return this.isImplicitlyClosedBy(t)||this.isExplicitlyClosedBy(t)},isImplicitlyClosedBy:function(t){var e,i,n,r,s;return t.tag&&this.owner&&this.owner.type===p.ELEMENT?(r=this.owner.tag.toLowerCase(),s=t.tag.toLowerCase(),i=this.owner,n=i.parentElement||null,e=m[r],e&&!t.isClosingTag&&-1!==e.indexOf(s)?!0:-1!==f.indexOf(r)&&n&&n.fragment.isClosedBy(t)?!0:"p"===r&&n&&"a"===n.tag.toLowerCase()&&n.fragment.isClosedBy(t)?!0:void 0):!1},isExplicitlyClosedBy:function(t){return this.owner?this.owner.type===p.SECTION&&t.type===p.CLOSING&&t.ref===this.owner.ref?!0:this.owner.type===p.ELEMENT&&this.owner&&t.isClosingTag&&t.tag.toLowerCase()===this.owner.tag.toLowerCase()?!0:void 0:!1},toJson:function(t){var e,i,n,r=[];if(!t&&(n=""+this,n!==!1))return n;for(e=0,i=this.items.length;i>e;e+=1)r[e]=this.items[e].toJson(t);return r},toString:function(){var t,e,i,n="";for(t=0,e=this.items.length;e>t;t+=1){if(i=""+this.items[t],i===!1)return!1;n+=i}return n},seal:function(){var t,e,i,n;if(this.sealed=!0,!this.preserveWhitespace)for(this.owner.type===p.ELEMENT&&(t=this.items[0],t&&t.type===p.TEXT&&(t.text=t.text.replace(/^\s*/,""),""===t.text&&this.items.shift()),e=this.items[this.items.length-1],e&&e.type===p.TEXT&&(e.text=e.text.replace(/\s*$/,""),""===e.text&&this.items.pop())),i=this.items.length;i--;)n=this.items[i],n.type===p.TEXT&&(n.text=n.text.replace(/\s{2,}/g," "));this.items.length||delete this.owner.fragment}},n=function(t,e,n,r){for(var s,o=new i(null,e,n,r);t.length;)s=t.shift(),o.read(s);return o}})(e,i),function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m,g,y,v,w,b,N,x;e.tokenize=function(t){var e=a.fromString(r(t));return o(s(e.tokens))},a=function(){this.tokens=[],this.buffer=new h},a.prototype={read:function(t){var e,n;if(this.currentToken&&this.currentToken.type!==i.TEXT&&this.currentToken.read(t))return!0;if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(n=this.buffer.release(),this.currentToken){for(;n.length;){for(;n.length&&this.currentToken.read(n.charAt(0));)n=n.substring(1);n.length&&("<"===n.charAt(0)?(this.currentToken=new c,this.currentToken.read("<")):(this.currentToken=new l,this.currentToken.read(n.charAt(0))),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1))}return!0}return this.currentToken="<"===t?new c:new l,this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,!0},end:function(){this.buffer.isEmpty()||(this.tokens[this.tokens.length]=this.buffer.convert())}},a.fromString=function(t){var e,i,n;for(e=new a,i=0,n=t.length;n>i;)e.read(t.charAt(i)),i+=1;return e.end(),e},h=function(){this.value=""},h.prototype={read:function(e){var i;return this.value+=e,i=this.isPartialMatchOf(t.delimiters[0])||this.isPartialMatchOf(t.tripleDelimiters[0])},convert:function(){var e,i,n,r,s,o;if(i=t.delimiters[0],n=t.tripleDelimiters[0],e=this.value,s=function(){return 0===e.indexOf(n)?new p:void 0},o=function(){return 0===e.indexOf(i)?new u:void 0},r=n.length>i.length?s()||o():o()||s()){for(;this.value.length;)r.read(this.value.charAt(0)),this.value=this.value.substring(1);return r}return!1},release:function(){var t=this.value;return this.value="",t},isEmpty:function(){return!this.value.length},isPartialMatchOf:function(t){return 0===t.indexOf(this.value)}},l=function(){this.type=i.TEXT,this.value=""},l.prototype={read:function(t){return this.sealed?!1:"<"===t?!1:(this.value+=t,!0)},seal:function(){this.sealed=!0}},u=function(){this.value="",this.openingDelimiter=t.delimiters[0],this.closingDelimiter=t.delimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length},p=function(){this.value="",this.openingDelimiter=t.tripleDelimiters[0],this.closingDelimiter=t.tripleDelimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length,this.type=i.TRIPLE},u.prototype=p.prototype={read:function(t){return this.sealed?!1:(this.value+=t,this.value.length>=this.minLength&&this.value.substr(-this.closingDelimiter.length)===this.closingDelimiter&&this.seal(),!0)},seal:function(){var t,e,n,r,s;this.sealed||(t=this.value.replace(this.openingDelimiter,"").replace(this.closingDelimiter,"").trim(),"="===t.charAt(0)&&(this.changeDelimiters(t),this.type=i.DELIMCHANGE),this.type||(e=t.charAt(0),f[e]?(this.type=f[e],t=t.substring(1).trim()):this.type=i.INTERPOLATOR),this.type===i.SECTION&&(r=/:\s*([a-zA-Z_$][a-zA-Z0-9_$]*)$/,s=r.exec(t),s&&(this.i=s[1],t=t.substr(0,t.length-s[0].length))),n=t.split("|"),this.ref=n.shift().trim(),n.length&&(this.formatters=n.map(function(t){return t.trim()})),this.sealed=!0)},changeDelimiters:function(e){var n,r;r=/\=\s*([^\s=]+)\s+([^\s=]+)\s*=/.exec(e),n=this.type===i.TRIPLE?t.tripleDelimiters:t.delimiters,n[0]=r[1],n[1]=r[2]}},c=function(){this.type=i.TAG,this.openingBracket=new m,this.closingTagSolidus=new v,this.tagName=new g,this.attributes=new y,this.selfClosingSolidus=new v,this.closingBracket=new w},c.prototype={read:function(t){var e;return this.sealed?!1:(e=this.openingBracket.read(t)||this.closingTagSolidus.read(t)||this.tagName.read(t)||this.attributes.read(t)||this.selfClosingSolidus.read(t)||this.closingBracket.read(t))?(this.closingBracket.sealed&&this.seal(),!0):(this.seal(),!1)},seal:function(){this.tag=this.tagName.value,this.closingTagSolidus.value&&(this.isClosingTag=!0),this.selfClosingSolidus.value&&(this.isSelfClosingTag=!0),this.sealed=!0}},m=function(){},m.prototype={read:function(t){if(this.sealed)return!1;if("<"===t)return this.value="<",this.seal(),!0;throw'Expected "<", saw "'+t+'"'},seal:function(){this.sealed=!0}},g=function(){},g.prototype={read:function(t){return this.sealed?!1:!this.value&&/[a-zA-Z]/.test(t)?(this.value=t,!0):/[a-zA-Z0-9\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},y=function(){this.items=[]},y.prototype={read:function(t){return this.sealed?!1:this.nextItem&&this.nextItem.read(t)?!0:n.test(t)?!0:(this.nextItem=new b,this.nextItem.read(t)?(this.items[this.items.length]=this.nextItem,!0):(this.seal(),!1))},seal:function(){this.sealed=!0}},b=function(){this.name=new N,this.value=new x},b.prototype={read:function(t){return this.sealed?!1:this.name.read(t)?!0:this.name.value?this.value.read(t)?!0:(this.seal(),!1):(this.seal(),!1)},seal:function(){this.sealed=!0}},N=function(){},N.prototype={read:function(t){return this.sealed?!1:this.value?/[_:a-zA-Z0-9\.\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1):/[a-zA-Z_:]/.test(t)?(this.value=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},x=function(){this.tokens=[],this.buffer=new h,this.isNull=!0},x.prototype={read:function(t){var e,i;if(this.sealed)return!1;if(this.isNull)return n.test(t)?!0:"="===t?(this.isNull=!1,!0):!1;if(!this.tokens.length&&!this.quoteMark){if(n.test(t))return!0;if('"'===t||"'"===t)return this.quoteMark=t,!0}if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(i=this.buffer.release(),this.currentToken){for(;i.length;){for(;i.length&&i.charAt(0)!==this.quoteMark&&this.currentToken.read(i.charAt(0));)i=i.substring(1);if(i.length){if(">"===i.charAt(0))return this.seal(),!1;if(i.charAt(0)===this.quoteMark)return this.currentToken.seal(),this.seal(),!0;this.currentToken=new d(this.quoteMark),this.currentToken.read(i.charAt(0)),this.tokens[this.tokens.length]=this.currentToken,i=i.substring(1)}}return!0}return this.currentToken=new d(this.quoteMark),this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,this.currentToken.sealed&&this.seal(),!0},seal:function(){this.sealed=!0}},d=function(t){this.type=i.ATTR_VALUE_TOKEN,this.quoteMark=t||"",this.value=""},d.prototype={read:function(t){return this.sealed?!1:t===this.quoteMark?(this.seal(),!0):this.quoteMark?(this.value+=t,!0):/[\s"'=<>`]/.test(t)?(this.seal(),!1):(this.value+=t,!0)},seal:function(){this.sealed=!0}},v=function(){},v.prototype={read:function(t){return this.sealed?!1:"/"===t?(this.value="/",this.seal(),!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},w=function(){},w.prototype={read:function(t){if(this.sealed)return!1;if(">"===t)return this.value=">",this.seal(),!0;throw'Expected ">", received "'+t+'"'},seal:function(){this.sealed=!0}},r=function(t){var e,i,n;for(n="";t.length;){if(e=t.indexOf("<!--"),i=t.indexOf("-->"),-1===e&&-1===i){n+=t;break}if(-1!==e&&-1===i)throw"Illegal HTML - expected closing comment sequence ('-->')";if(-1!==i&&-1===e||e>i)throw"Illegal HTML - unexpected closing comment sequence ('-->')";n+=t.substr(0,e),t=t.substring(i+3)}return n},s=function(t){var e,n,r,s,o,a;for(o=/^\s*\r?\n/,a=/\r?\n\s*$/,e=2;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e-2],n.type===i.TEXT&&r.type!==i.TAG&&s.type===i.TEXT&&a.test(s.value)&&o.test(n.value)&&(r.type!==i.INTERPOLATOR&&r.type!==i.TRIPLE&&(s.value=s.value.replace(a,"\n")),n.value=n.value.replace(o,""),""===n.value&&t.splice(e--,1));return t},o=function(t){var e,n,r,s;for(e=0;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e+1],n.type===i.COMMENT&&(t.splice(e,1),r&&s&&r.type===i.TEXT&&s.type===i.TEXT&&(r.value+=s.value,t.splice(e,1)),e-=1);return t},i=e.types,n=/\s/,f={"#":i.SECTION,"^":i.INVERTED,"/":i.CLOSING,">":i.PARTIAL,"!":i.COMMENT,"&":i.INTERPOLATOR}}(e,i),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t){var e,i,n,r,s,o,a,h,l,u,p;e=t.types,r={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},n="undefined"!=typeof window?window.document:null,i=function(t,e){var i,r=[];for(i=n.createElement("div"),i.innerHTML=t;i.firstChild;)r[r.length]=i.firstChild,e.appendChild(i.firstChild);return r},t.DomFragment=function(e){return this.docFrag=n.createDocumentFragment(),"string"==typeof e.model?(this.nodes=i(e.model,this.docFrag),void 0):(t.Fragment.call(this,e),void 0)},t.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new s(t,this.docFrag);switch(t.model.type){case e.INTERPOLATOR:return new l(t,this.docFrag);case e.SECTION:return new p(t,this.docFrag);case e.TRIPLE:return new u(t,this.docFrag);case e.ELEMENT:return new o(t,this.docFrag);case e.PARTIAL:return new a(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},a=function(e,i){this.fragment=new t.DomFragment({model:e.root.partials[e.model.ref]||[],root:e.root,parentNode:e.parentNode,contextStack:e.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},a.prototype={teardown:function(){this.fragment.teardown()}},s=function(t,e){this.node=n.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},s.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(e,i){var r,s,o,a,l,u,p;if(r=this.model=e.model,this.root=e.root,this.parentFragment=e.parentFragment,this.parentNode=e.parentNode,this.index=e.index,r.attrs&&r.attrs.xmlns){if(s=r.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=n.createElementNS(s,r.tag),r.frag&&("string"==typeof r.frag&&this.node.namespaceURI===t.namespaces.html?this.node.innerHTML=r.frag:(this.children=new t.DomFragment({model:r.frag,root:e.root,parentNode:this.node,contextStack:e.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[]; | ||
for(a in r.attrs)r.attrs.hasOwnProperty(a)&&(l=r.attrs[a],o=new h({parent:this,name:a,value:void 0===l?null:l,root:e.root,parentNode:this.node,contextStack:e.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?p=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),i.appendChild(this.node)},o.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},h=function(e){var i,n,s,o,a,h,l,u;if(i=e.name,n=e.value,this.parent=e.parent,s=i.indexOf(":"),-1!==s&&(o=i.substr(0,s),"xmlns"!==o&&(i=i.substring(s+1),this.namespace=t.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?e.parentNode.setAttributeNS(this.namespace,i,n):e.parentNode.setAttribute(i,n),void 0):(this.root=e.root,this.parentNode=e.parentNode,this.name=i,this.children=[],this.namespace||e.parentNode.namespaceURI!==t.namespaces.html||(l=this.name.toLowerCase(),u=r[l]||l,void 0!==e.parentNode[u]&&(this.propertyName=u),("boolean"==typeof e.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new t.TextFragment({model:n,root:this.root,parent:this,contextStack:e.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},h.prototype={bind:function(e){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==t.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),e||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root._deferredAttributes[this.root._deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(n.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},l=function(e,i){this.node=n.createTextNode(""),i.appendChild(this.node),t.Mustache.call(this,e)},l.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},u=function(e,i){this.nodes=[],this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},u.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=i(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},p=function(e,i){this.fragments=[],this.length=0,this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},p.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(e){t.sectionUpdate.call(this,e),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(e){var i=new t.DomFragment(e);return this.docFrag.appendChild(i.docFrag),i}}}(i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t.Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t.Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t.Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t.sectionUpdate.call(this,e),this.value=this.fragments.join(""),this.parent.bubble()},createFragment:function(e){return new t.TextFragment(e)},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e,i){var n;for(n=0;t.length>n&&!i.requestAnimationFrame;++n)i.requestAnimationFrame=i[t[n]+"RequestAnimationFrame"],i.cancelAnimationFrame=i[t[n]+"CancelAnimationFrame"]||i[t[n]+"CancelRequestAnimationFrame"];i.requestAnimationFrame||(i.requestAnimationFrame=function(t){var n,r,s;return n=Date.now(),r=Math.max(0,16-(n-e)),s=i.setTimeout(function(){t(n+r)},r),e=n+r,s}),i.cancelAnimationFrame||(i.cancelAnimationFrame=function(t){i.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,p;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,p=e.splitKeypath(r),l=new i({keys:p,from:this.get(p),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e}(this); |
@@ -1,2 +0,2 @@ | ||
(function () { | ||
(function ( doc ) { | ||
@@ -11,4 +11,4 @@ 'use strict'; | ||
if ( !document.createElementNS ) { | ||
document.createElementNS = function ( ns, type ) { | ||
if ( !doc.createElementNS ) { | ||
doc.createElementNS = function ( ns, type ) { | ||
if ( ns !== null && ns !== 'http://www.w3.org/1999/xhtml' ) { | ||
@@ -18,3 +18,3 @@ throw 'This browser does not support namespaces other than http://www.w3.org/1999/xhtml'; | ||
return document.createElement( type ); | ||
return doc.createElement( type ); | ||
}; | ||
@@ -62,3 +62,5 @@ } | ||
WindowPrototype[removeEventListener] = DocumentPrototype[removeEventListener] = ElementPrototype[removeEventListener] = function (type, listener) { | ||
for (var index = 0, register; register = registry[index]; ++index) { | ||
var index, register; | ||
for ( index = 0, register; register = registry[index]; ++index ) { | ||
if ( register[0] === this && register[1] === type && register[2] === listener ) { | ||
@@ -95,3 +97,3 @@ return this.detachEvent("on" + type, registry.splice(index, 1)[0][3]); | ||
for ( len = this.length; i<len; i++ ) { | ||
if ( i in this && this[i] === needle ) { | ||
if ( this.hasOwnProperty( i ) && this[i] === needle ) { | ||
return i; | ||
@@ -110,3 +112,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this ) { | ||
if ( this.hasOwnProperty( i ) ) { | ||
callback.call( context, this[i], i, this ); | ||
@@ -123,3 +125,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this ) { | ||
if ( this.hasOwnProperty( i ) ) { | ||
mapped[i] = mapper.call( context, this[i], i, this ); | ||
@@ -138,3 +140,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this && filter.call( context, this[i], i, this ) ) { | ||
if ( this.hasOwnProperty( i ) && filter.call( context, this[i], i, this ) ) { | ||
filtered[ filtered.length ] = this[i]; | ||
@@ -148,5 +150,5 @@ } | ||
}()); | ||
}( document )); | ||
/*! Ractive - v0.2.0 - 2013-04-18 | ||
/*! Ractive - v0.2.1 - 2013-04-20 | ||
* Faster, easier, better interactive web development | ||
@@ -165,3 +167,3 @@ | ||
var Ractive; | ||
var Ractive, _internal; | ||
@@ -219,13 +221,8 @@ (function () { | ||
// Set up observers | ||
this.observers = {}; | ||
this.pendingResolution = []; | ||
this._observers = {}; | ||
this._pendingResolution = []; | ||
// Create an array for deferred attributes | ||
this.deferredAttributes = []; | ||
this._deferredAttributes = []; | ||
// Initialise (or update) viewmodel with data | ||
if ( this.data ) { | ||
this.set( this.data ); | ||
} | ||
// If we were given uncompiled partials, compile them | ||
@@ -263,3 +260,3 @@ if ( this.partials ) { | ||
if ( this.el ) { | ||
this.render({ el: this.el, callback: this.callback, append: this.append }); | ||
this.render({ el: this.el, append: this.append }); | ||
} | ||
@@ -292,3 +289,3 @@ }; | ||
// Render our *root fragment* | ||
this.rendered = new _private.DomFragment({ | ||
this.rendered = new _internal.DomFragment({ | ||
model: this.template, | ||
@@ -309,3 +306,3 @@ root: this, | ||
set: function ( keypath, value ) { | ||
if ( _private.isObject( keypath ) ) { | ||
if ( _internal.isObject( keypath ) ) { | ||
this._setMultiple( keypath ); | ||
@@ -316,4 +313,7 @@ } else { | ||
while ( this.deferredAttributes.length ) { | ||
this.deferredAttributes.pop().update().updateDeferred = false; | ||
// Attributes don't reflect changes automatically if there is a possibility | ||
// that they will need to change again before the .set() cycle is complete | ||
// - they defer their updates until all values have been set | ||
while ( this._deferredAttributes.length ) { | ||
this._deferredAttributes.pop().update().updateDeferred = false; | ||
} | ||
@@ -323,8 +323,8 @@ }, | ||
_setSingle: function ( keypath, value ) { | ||
var keys, key, obj, normalised, i, resolved, unresolved; | ||
var keys, key, obj, normalised, i, unresolved; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); | ||
} else { | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
} | ||
@@ -334,3 +334,3 @@ | ||
// clear cache | ||
// Clear cache | ||
this._clearCache( normalised ); | ||
@@ -343,3 +343,3 @@ | ||
// if this branch doesn't exist yet, create a new one - if the next | ||
// If this branch doesn't exist yet, create a new one - if the next | ||
// key matches /^[0-9]+$/, assume we want an array branch rather | ||
@@ -358,3 +358,3 @@ // than an object | ||
// fire set event | ||
// Fire set event | ||
if ( !this.setting ) { | ||
@@ -367,21 +367,15 @@ this.setting = true; // short-circuit any potential infinite loops | ||
// Trigger updates of views that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised, value ); | ||
// Trigger updates of mustaches that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised ); | ||
// See if we can resolve any of the unresolved keypaths (if such there be) | ||
i = this.pendingResolution.length; | ||
i = this._pendingResolution.length; | ||
while ( i-- ) { // Work backwards, so we don't go in circles! | ||
unresolved = this.pendingResolution.splice( i, 1 )[0]; | ||
unresolved = this._pendingResolution.splice( i, 1 )[0]; | ||
resolved = this.resolveRef( unresolved.view.model.ref, unresolved.view.contextStack ); | ||
// If we were able to find a keypath, initialise the view | ||
if ( resolved ) { | ||
unresolved.callback( resolved.keypath, resolved.value ); | ||
// If we can't resolve the reference, add to the back of | ||
// the queue (this is why we're working backwards) | ||
if ( !this.resolveRef( unresolved ) ) { | ||
this._pendingResolution[ this._pendingResolution.length ] = unresolved; | ||
} | ||
// Otherwise add to the back of the queue (this is why we're working backwards) | ||
else { | ||
this.registerUnresolvedKeypath( unresolved ); | ||
} | ||
} | ||
@@ -415,5 +409,5 @@ }, | ||
get: function ( keypath ) { | ||
var keys, normalised, lastDotIndex, formula, match, parentKeypath, parentValue, propertyName, unformatted, unformattedKeypath, value, formatters; | ||
var keys, normalised, key, match, parentKeypath, parentValue, value, formatters; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); // clone | ||
@@ -425,7 +419,7 @@ normalised = keys.join( '.' ); | ||
// cache hit? great | ||
if ( keypath in this._cache ) { | ||
if ( this._cache.hasOwnProperty( keypath ) ) { | ||
return this._cache[ keypath ]; | ||
} | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
normalised = keys.join( '.' ); | ||
@@ -435,3 +429,3 @@ } | ||
// we may have a cache hit now that it's been normalised | ||
if ( normalised in this._cache ) { | ||
if ( this._cache.hasOwnProperty( normalised ) ) { | ||
return this._cache[ normalised ]; | ||
@@ -441,13 +435,8 @@ } | ||
// otherwise it looks like we need to do some work | ||
if ( keys.length > 1 ) { | ||
formula = keys.pop(); | ||
parentValue = this.get( keys ); | ||
} else { | ||
formula = keys.pop(); | ||
parentValue = this.data; | ||
} | ||
key = keys.pop(); | ||
parentValue = ( keys.length ? this.get( keys ) : this.data ); | ||
// is this a set of formatters? | ||
if ( match = /^⭆(.+)⭅$/.exec( formula ) ) { | ||
formatters = _private.getFormattersFromString( match[1] ); | ||
if ( match = /^⭆(.+)⭅$/.exec( key ) ) { | ||
formatters = _internal.getFormattersFromString( match[1] ); | ||
value = this._format( parentValue, formatters ); | ||
@@ -457,7 +446,7 @@ } | ||
else { | ||
if ( typeof parentValue !== 'object' ) { | ||
if ( typeof parentValue !== 'object' || !parentValue.hasOwnProperty( key ) ) { | ||
return; | ||
} | ||
value = parentValue[ formula ]; | ||
value = parentValue[ key ]; | ||
} | ||
@@ -475,4 +464,3 @@ | ||
// allow functions as values | ||
// TODO allow arguments, same as formatters? | ||
// Allow functions as values | ||
if ( typeof value === 'function' ) { | ||
@@ -482,3 +470,3 @@ value = value(); | ||
// update cache | ||
// Update cache | ||
this._cache[ normalised ] = value; | ||
@@ -489,5 +477,9 @@ | ||
update: function () { | ||
// TODO | ||
throw new Error( 'not implemented yet!' ); | ||
update: function ( keypath ) { | ||
this._clearCache( keypath ); | ||
this._notifyObservers( keypath ); | ||
this.fire( 'update:' + keypath ); | ||
this.fire( 'update', keypath ); | ||
return this; | ||
@@ -504,44 +496,28 @@ }, | ||
registerView: function ( view ) { | ||
var self = this, resolved, initialUpdate, value, index; | ||
registerMustache: function ( mustache ) { | ||
var resolved, value, index; | ||
if ( view.parentFragment && ( view.parentFragment.indexRefs.hasOwnProperty( view.model.ref ) ) ) { | ||
// this isn't a real keypath, it's an index reference | ||
index = view.parentFragment.indexRefs[ view.model.ref ]; | ||
if ( mustache.parentFragment && ( mustache.parentFragment.indexRefs.hasOwnProperty( mustache.model.ref ) ) ) { | ||
// This isn't a real keypath, it's an index reference | ||
index = mustache.parentFragment.indexRefs[ mustache.model.ref ]; | ||
value = ( view.model.fmtrs ? this._format( index, view.model.fmtrs ) : index ); | ||
view.update( value ); | ||
value = ( mustache.model.fmtrs ? this._format( index, mustache.model.fmtrs ) : index ); | ||
mustache.update( value ); | ||
return; // this value will never change, and doesn't have a keypath | ||
return; // This value will never change, and doesn't have a keypath | ||
} | ||
initialUpdate = function ( keypath, value ) { | ||
if ( view.model.fmtrs ) { | ||
view.keypath = keypath + '.' + _private.stringifyFormatters( view.model.fmtrs ); | ||
} else { | ||
view.keypath = keypath; | ||
} | ||
// See if we can resolve a keypath from this mustache's reference (e.g. | ||
// does 'bar' in {{#foo}}{{bar}}{{/foo}} mean 'bar' or 'foo.bar'?) | ||
resolved = this.resolveRef( mustache ); | ||
// create observers | ||
view.observerRefs = self.observe( view.model.p || 0, view ); | ||
view.update( self.get( view.keypath ) ); | ||
}; | ||
resolved = this.resolveRef( view.model.ref, view.contextStack ); | ||
if ( !resolved ) { | ||
// we may still need to do an update, if the view has formatters | ||
// that e.g. offer an alternative to undefined | ||
if ( view.model.fmtrs ) { | ||
view.update( this._format( undefined, view.model.fmtrs ) ); | ||
// We may still need to do an update, event with unresolved | ||
// references, if the mustache has formatters that (for example) | ||
// provide a fallback value from undefined | ||
if ( mustache.model.fmtrs ) { | ||
mustache.update( this._format( undefined, mustache.model.fmtrs ) ); | ||
} | ||
this.registerUnresolvedKeypath({ | ||
view: view, | ||
callback: initialUpdate | ||
}); | ||
} else { | ||
initialUpdate( resolved.keypath, resolved.value ); | ||
this._pendingResolution[ this._pendingResolution.length ] = mustache; | ||
} | ||
@@ -552,38 +528,51 @@ }, | ||
// `'bar.baz'` within the context stack `['foo']` might resolve to `'foo.bar.baz'` | ||
resolveRef: function ( ref, contextStack ) { | ||
resolveRef: function ( mustache ) { | ||
var innerMost, keypath, value; | ||
var ref, contextStack, keys, lastKey, innerMostContext, contextKeys, parentValue, keypath; | ||
ref = mustache.model.ref; | ||
contextStack = mustache.contextStack; | ||
// Implicit iterators - i.e. {{.}} - are a special case | ||
if ( ref === '.' ) { | ||
keypath = contextStack[ contextStack.length - 1 ]; | ||
value = this.get( keypath ); | ||
return { keypath: keypath, value: value }; | ||
} | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
else { | ||
keys = _internal.splitKeypath( ref ); | ||
lastKey = keys.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
innerMost = contextStack.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
keypath = innerMost + '.' + ref; | ||
value = this.get( keypath ); | ||
innerMostContext = contextStack.pop(); | ||
contextKeys = _internal.splitKeypath( innerMostContext ); | ||
if ( value !== undefined ) { | ||
return { keypath: keypath, value: value }; | ||
parentValue = this.get( contextKeys.concat( keys ) ); | ||
if ( typeof parentValue === 'object' && parentValue.hasOwnProperty( lastKey ) ) { | ||
keypath = innerMostContext + '.' + ref; | ||
break; | ||
} | ||
} | ||
if ( !keypath && this.get( ref ) !== undefined ) { | ||
keypath = ref; | ||
} | ||
} | ||
value = this.get( ref ); | ||
if ( value !== undefined ) { | ||
return { keypath: ref, value: value }; | ||
// If we have any formatters, we need to append them to the keypath | ||
if ( keypath ) { | ||
mustache.keypath = ( mustache.model.fmtrs ? keypath + '.' + _internal.stringifyFormatters( mustache.model.fmtrs ) : keypath ); | ||
mustache.observerRefs = this.observe( mustache ); | ||
mustache.update( this.get( mustache.keypath ) ); | ||
return true; // indicate success | ||
} | ||
}, | ||
registerUnresolvedKeypath: function ( unresolved ) { | ||
this.pendingResolution[ this.pendingResolution.length ] = unresolved; | ||
return false; // failure | ||
}, | ||
@@ -622,4 +611,4 @@ | ||
_notifyObservers: function ( keypath, value ) { | ||
var self = this, observersGroupedByPriority = this.observers[ keypath ] || [], i, j, priorityGroup, observer, actualValue; | ||
_notifyObservers: function ( keypath ) { | ||
var self = this, observersGroupedByPriority = this._observers[ keypath ] || [], i, j, priorityGroup, observer; | ||
@@ -638,29 +627,26 @@ for ( i=0; i<observersGroupedByPriority.length; i+=1 ) { | ||
observe: function ( priority, view ) { | ||
observe: function ( mustache ) { | ||
var self = this, keypath, originalKeypath = view.keypath, observerRefs = [], observe, keys; | ||
var self = this, observerRefs = [], observe, keys, priority = mustache.model.p || 0; | ||
if ( !originalKeypath ) { | ||
return undefined; | ||
} | ||
observe = function ( keypath ) { | ||
var observers, observer; | ||
var observers; | ||
observers = self.observers[ keypath ] = self.observers[ keypath ] || []; | ||
observers = self._observers[ keypath ] = self._observers[ keypath ] || []; | ||
observers = observers[ priority ] = observers[ priority ] || []; | ||
observers[ observers.length ] = view; | ||
observers[ observers.length ] = mustache; | ||
observerRefs[ observerRefs.length ] = { | ||
keypath: keypath, | ||
priority: priority, | ||
view: view | ||
mustache: mustache | ||
}; | ||
}; | ||
keys = _private.splitKeypath( view.keypath ); | ||
keys = _internal.splitKeypath( mustache.keypath ); | ||
while ( keys.length > 1 ) { | ||
observe( keys.join( '.' ) ); | ||
// remove the last item in the keypath, so that data.set( 'parent', { child: 'newValue' } ) affects views dependent on parent.child | ||
// remove the last item in the keypath, so that `data.set( 'parent', { child: 'newValue' } )` | ||
// affects mustaches dependent on `parent.child` | ||
keys.pop(); | ||
@@ -675,6 +661,6 @@ } | ||
unobserve: function ( observerRef ) { | ||
var priorities, observers, index, i, len; | ||
var priorityGroups, observers, index, i, len; | ||
priorities = this.observers[ observerRef.keypath ]; | ||
if ( !priorities ) { | ||
priorityGroups = this._observers[ observerRef.keypath ]; | ||
if ( !priorityGroups ) { | ||
// nothing to unobserve | ||
@@ -684,3 +670,3 @@ return; | ||
observers = priorities[ observerRef.priority ]; | ||
observers = priorityGroups[ observerRef.priority ]; | ||
if ( !observers ) { | ||
@@ -696,3 +682,3 @@ // nothing to unobserve | ||
for ( i=0, len=observers.length; i<len; i+=1 ) { | ||
if ( observers[i] === observerRef.view ) { | ||
if ( observers[i] === observerRef.mustache ) { | ||
index = i; | ||
@@ -715,7 +701,7 @@ break; | ||
if ( observers.length === 0 ) { | ||
delete priorities[ observerRef.priority ]; | ||
delete priorityGroups[ observerRef.priority ]; | ||
} | ||
if ( priorities.length === 0 ) { | ||
delete this.observers[ observerRef.keypath ]; | ||
if ( priorityGroups.length === 0 ) { | ||
delete this._observers[ observerRef.keypath ]; | ||
} | ||
@@ -778,4 +764,2 @@ }, | ||
}()); | ||
var _private; | ||
(function () { | ||
@@ -785,5 +769,5 @@ | ||
var formattersCache = {}; | ||
var formattersCache = {}, keypathCache = {}; | ||
_private = { | ||
_internal = { | ||
// thanks, http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ | ||
@@ -794,3 +778,2 @@ isArray: function ( obj ) { | ||
// TODO what about non-POJOs? | ||
isObject: function ( obj ) { | ||
@@ -805,10 +788,16 @@ return ( Object.prototype.toString.call( obj ) === '[object Object]' ) && ( typeof obj !== 'function' ); | ||
// TODO this is a bit regex-heavy... could be optimised maybe? | ||
splitKeypath: function ( keypath ) { | ||
var result, hasEscapedDots, hasFormatters, formatters, split, i, replacer, index, startIndex, key, keys, remaining, blanked, part; | ||
var hasFormatters, formatters, i, index, startIndex, keys, remaining, part; | ||
// if this string contains no escaped dots or formatters, | ||
// We should only have to do all the heavy regex stuff once... caching FTW | ||
if ( keypathCache[ keypath ] ) { | ||
return keypathCache[ keypath ].concat(); | ||
} | ||
// If this string contains no escaped dots or formatters, | ||
// we can just split on dots, after converting from array notation | ||
if ( !( hasEscapedDots = /\\\./.test( keypath ) ) && !( hasFormatters = /⭆.+⭅/.test( keypath ) ) ) { | ||
return keypath.replace( /\[\s*([0-9]+)\s*\]/g, '.$1' ).split( '.' ); | ||
hasFormatters = /⭆.+⭅/.test( keypath ); | ||
if ( !( /\\\./.test( keypath ) ) && !hasFormatters ) { | ||
keypathCache[ keypath ] = keypath.replace( /\[\s*([0-9]+)\s*\]/g, '.$1' ).split( '.' ); | ||
return keypathCache[ keypath ].concat(); | ||
} | ||
@@ -824,4 +813,2 @@ | ||
remaining = remaining.replace( /⭆(.+)⭅/g, function ( match, $1 ) { | ||
var blanked, i; | ||
formatters[ formatters.length ] = $1; | ||
@@ -835,10 +822,9 @@ return '⭆x⭅'; | ||
// split into keys | ||
// Split into keys | ||
while ( remaining.length ) { | ||
// find next dot | ||
// Find next dot | ||
index = remaining.indexOf( '.', startIndex ); | ||
// final part? | ||
// Final part? | ||
if ( index === -1 ) { | ||
// TODO tidy up! | ||
part = remaining; | ||
@@ -849,3 +835,3 @@ remaining = ''; | ||
else { | ||
// if this dot is preceded by a backslash, which isn't | ||
// If this dot is preceded by a backslash, which isn't | ||
// itself preceded by a backslash, we consider it escaped | ||
@@ -859,3 +845,3 @@ if ( remaining.charAt( index - 1) === '\\' && remaining.charAt( index - 2 ) !== '\\' ) { | ||
// otherwise, we have our next part | ||
// Otherwise, we have our next part | ||
part = remaining.substr( 0, index ); | ||
@@ -875,8 +861,4 @@ startIndex = 0; | ||
// then, reinstate formatters | ||
// Then, reinstate formatters | ||
if ( hasFormatters ) { | ||
replacer = function ( match ) { | ||
return '⭆' + formatters.pop() + '⭅'; | ||
}; | ||
i = keys.length; | ||
@@ -890,7 +872,8 @@ while ( i-- ) { | ||
return keys; | ||
keypathCache[ keypath ] = keys; | ||
return keys.concat(); | ||
}, | ||
getFormattersFromString: function ( str ) { | ||
var formatters, raw, remaining; | ||
var formatters, raw; | ||
@@ -939,3 +922,3 @@ if ( formattersCache[ str ] ) { | ||
}()); | ||
_private.types = { | ||
_internal.types = { | ||
TEXT: 1, | ||
@@ -955,7 +938,7 @@ INTERPOLATOR: 2, | ||
}; | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
'use strict'; | ||
_private._Mustache = function ( options ) { | ||
_internal.Mustache = function ( options ) { | ||
@@ -977,3 +960,3 @@ this.root = options.root; | ||
this.root.registerView( this ); | ||
this.root.registerMustache( this ); | ||
@@ -983,3 +966,3 @@ // if we have a failed keypath lookup, and this is an inverted section, | ||
if ( !this.keypath && this.model.inv ) { // test both section-hood and inverticity in one go | ||
this.update( false ); | ||
this.update( this.model.fmtrs ? this.root._format( false, this.model.fmtrs ) : false ); | ||
} | ||
@@ -990,3 +973,3 @@ | ||
_private._Fragment = function ( options ) { | ||
_internal.Fragment = function ( options ) { | ||
@@ -1033,3 +1016,3 @@ var numItems, i, itemOptions, parentRefs, ref; | ||
_private._sectionUpdate = function ( value ) { | ||
_internal.sectionUpdate = function ( value ) { | ||
var fragmentOptions, valueIsArray, emptyArray, i, itemsToRemove; | ||
@@ -1049,7 +1032,7 @@ | ||
valueIsArray = _private.isArray( value ); | ||
valueIsArray = _internal.isArray( value ); | ||
// modify the array to allow updates via push, pop etc | ||
if ( valueIsArray && this.root.modifyArrays ) { | ||
_private.modifyArray( value, this.keypath, this.root ); | ||
_internal.modifyArray( value, this.keypath, this.root ); | ||
} | ||
@@ -1085,6 +1068,2 @@ | ||
if ( this.postUpdate ) { | ||
this.postUpdate(); | ||
} | ||
return; | ||
@@ -1132,3 +1111,3 @@ } | ||
// if value is a hash... | ||
else if ( _private.isObject( value ) ) { | ||
else if ( _internal.isObject( value ) ) { | ||
// ...then if it isn't rendered, render it, adding this.keypath to the context stack | ||
@@ -1169,15 +1148,6 @@ // (if it is already rendered, then any children dependent on the context stack | ||
} | ||
if ( this.postUpdate ) { | ||
this.postUpdate(); | ||
} | ||
}; | ||
}( _private )); | ||
}( _internal )); | ||
(function ( proto ) { | ||
@@ -1269,3 +1239,3 @@ | ||
}( Ractive )); | ||
(function ( R, _private ) { | ||
(function ( _internal ) { | ||
@@ -1277,3 +1247,3 @@ 'use strict'; | ||
types = _private.types; | ||
types = _internal.types; | ||
@@ -1320,3 +1290,3 @@ // the property name equivalents for element attributes, where they differ | ||
_private.DomFragment = function ( options ) { | ||
_internal.DomFragment = function ( options ) { | ||
this.docFrag = doc.createDocumentFragment(); | ||
@@ -1331,6 +1301,6 @@ | ||
// otherwise we need to make a proper fragment | ||
_private._Fragment.call( this, options ); | ||
_internal.Fragment.call( this, options ); | ||
}; | ||
_private.DomFragment.prototype = { | ||
_internal.DomFragment.prototype = { | ||
createItem: function ( options ) { | ||
@@ -1393,3 +1363,3 @@ if ( typeof options.model === 'string' ) { | ||
Partial = function ( options, docFrag ) { | ||
this.fragment = new _private.DomFragment({ | ||
this.fragment = new _internal.DomFragment({ | ||
model: options.root.partials[ options.model.ref ] || [], | ||
@@ -1437,4 +1407,3 @@ root: options.root, | ||
var binding, | ||
model, | ||
var model, | ||
namespace, | ||
@@ -1445,4 +1414,3 @@ attr, | ||
bindable, | ||
twowayNameAttr, | ||
i; | ||
twowayNameAttr; | ||
@@ -1477,3 +1445,3 @@ // stuff we'll need later | ||
if ( model.frag ) { | ||
if ( typeof model.frag === 'string' ) { | ||
if ( typeof model.frag === 'string' && this.node.namespaceURI === _internal.namespaces.html ) { | ||
// great! we can use innerHTML | ||
@@ -1484,3 +1452,3 @@ this.node.innerHTML = model.frag; | ||
else { | ||
this.children = new _private.DomFragment({ | ||
this.children = new _internal.DomFragment({ | ||
model: model.frag, | ||
@@ -1565,3 +1533,3 @@ root: options.root, | ||
var name, value, colonIndex, namespacePrefix, namespace, ancestor, tagName, bindingCandidate, lowerCaseName, propertyName; | ||
var name, value, colonIndex, namespacePrefix, tagName, bindingCandidate, lowerCaseName, propertyName; | ||
@@ -1583,3 +1551,3 @@ name = options.name; | ||
name = name.substring( colonIndex + 1 ); | ||
this.namespace = _private.namespaces[ namespacePrefix ]; | ||
this.namespace = _internal.namespaces[ namespacePrefix ]; | ||
@@ -1613,5 +1581,5 @@ if ( !this.namespace ) { | ||
// can we establish this attribute's property name equivalent? | ||
if ( !this.namespace && options.parentNode.namespaceURI === _private.namespaces.html ) { | ||
if ( !this.namespace && options.parentNode.namespaceURI === _internal.namespaces.html ) { | ||
lowerCaseName = this.name.toLowerCase(); | ||
propertyName = ( propertyNames[ lowerCaseName ] ? propertyNames[ lowerCaseName ] : lowerCaseName ); | ||
propertyName = propertyNames[ lowerCaseName ] || lowerCaseName; | ||
@@ -1632,3 +1600,3 @@ if ( options.parentNode[ propertyName ] !== undefined ) { | ||
this.fragment = new _private.TextFragment({ | ||
this.fragment = new _internal.TextFragment({ | ||
model: value, | ||
@@ -1675,3 +1643,3 @@ root: this.root, | ||
// two-way binding logic should go here | ||
var self = this, node = this.parentNode, setValue, keypath, index; | ||
var self = this, node = this.parentNode, keypath, index; | ||
@@ -1686,3 +1654,3 @@ if ( !this.fragment ) { | ||
this.fragment.items.length !== 1 || | ||
this.fragment.items[0].type !== _private.types.INTERPOLATOR | ||
this.fragment.items[0].type !== _internal.types.INTERPOLATOR | ||
) { | ||
@@ -1832,3 +1800,3 @@ throw 'Not a valid two-way data binding candidate - must be a single interpolator'; | ||
else if ( !this.updateDeferred ) { | ||
this.root.deferredAttributes[ this.root.deferredAttributes.length ] = this; | ||
this.root._deferredAttributes[ this.root._deferredAttributes.length ] = this; | ||
this.updateDeferred = true; | ||
@@ -1906,3 +1874,3 @@ } | ||
// extend Mustache | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -1942,3 +1910,3 @@ | ||
this.initialising = true; | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
docFrag.appendChild( this.docFrag ); | ||
@@ -2005,3 +1973,3 @@ this.initialising = false; | ||
this.initialising = true; | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
docFrag.appendChild( this.docFrag ); | ||
@@ -2046,3 +2014,3 @@ this.initialising = false; | ||
_private._sectionUpdate.call( this, value ); | ||
_internal.sectionUpdate.call( this, value ); | ||
@@ -2057,3 +2025,3 @@ if ( !this.initialising ) { | ||
createFragment: function ( options ) { | ||
var fragment = new _private.DomFragment( options ); | ||
var fragment = new _internal.DomFragment( options ); | ||
@@ -2065,5 +2033,5 @@ this.docFrag.appendChild( fragment.docFrag ); | ||
}( Ractive, _private )); | ||
}( _internal )); | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
@@ -2075,9 +2043,9 @@ 'use strict'; | ||
types = _private.types; | ||
types = _internal.types; | ||
_private.TextFragment = function ( options ) { | ||
_private._Fragment.call( this, options ); | ||
_internal.TextFragment = function ( options ) { | ||
_internal.Fragment.call( this, options ); | ||
}; | ||
_private.TextFragment.prototype = { | ||
_internal.TextFragment.prototype = { | ||
createItem: function ( options ) { | ||
@@ -2152,3 +2120,3 @@ if ( typeof options.model === 'string' ) { | ||
Interpolator = function ( options ) { | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -2184,3 +2152,3 @@ | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -2212,14 +2180,12 @@ | ||
update: function ( value ) { | ||
_private._sectionUpdate.call( this, value ); | ||
_internal.sectionUpdate.call( this, value ); | ||
this.value = this.fragments.join( '' ); | ||
this.parent.bubble(); | ||
}, | ||
createFragment: function ( options ) { | ||
return new _private.TextFragment( options ); | ||
return new _internal.TextFragment( options ); | ||
}, | ||
postUpdate: function () { | ||
this.value = this.fragments.join( '' ); | ||
this.parent.bubble(); | ||
}, | ||
toString: function () { | ||
@@ -2231,3 +2197,3 @@ return this.fragments.join( '' ); | ||
}( _private )); | ||
}( _internal )); | ||
(function ( R ) { | ||
@@ -2275,3 +2241,3 @@ | ||
}( Ractive )); | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
@@ -2282,3 +2248,3 @@ 'use strict'; | ||
_private.modifyArray = function ( array, keypath, root ) { | ||
_internal.modifyArray = function ( array, keypath, root ) { | ||
@@ -2346,3 +2312,3 @@ var roots, keypathsByIndex, rootIndex, keypaths; | ||
}( _private )); | ||
}( _internal )); | ||
(function ( R ) { | ||
@@ -2395,7 +2361,7 @@ | ||
}( Ractive )); | ||
(function ( R, _p ) { | ||
(function ( R, _i ) { | ||
'use strict'; | ||
var Animation, animationCollection, global, interpolators; | ||
var Animation, animationCollection, global; | ||
@@ -2405,3 +2371,3 @@ global = ( typeof window !== 'undefined' ? window : {} ); | ||
// https://gist.github.com/paulirish/1579671 | ||
(function( vendors, lastTime, window ) { | ||
(function( vendors, lastTime, global ) { | ||
@@ -2533,3 +2499,3 @@ var x; | ||
R.prototype.animate = function ( keypath, to, options ) { | ||
var easing, from, duration, animation, i, keys; | ||
var easing, duration, animation, i, keys; | ||
@@ -2570,3 +2536,3 @@ options = options || {}; | ||
keys = _p.splitKeypath( keypath ); | ||
keys = _i.splitKeypath( keypath ); | ||
@@ -2588,3 +2554,3 @@ animation = new Animation({ | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); | ||
(function ( R, _p ) { | ||
@@ -2695,4 +2661,4 @@ | ||
}( Ractive, _private )); | ||
_private.namespaces = { | ||
}( Ractive, _internal )); | ||
_internal.namespaces = { | ||
html: 'http://www.w3.org/1999/xhtml', | ||
@@ -2699,0 +2665,0 @@ mathml: 'http://www.w3.org/1998/Math/MathML', |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";Date.now||(Date.now=function(){return+new Date}),document.createElementNS||(document.createElementNS=function(t,e){if(null!==t&&"http://www.w3.org/1999/xhtml"!==t)throw"This browser does not support namespaces other than http://www.w3.org/1999/xhtml";return document.createElement(e)}),Element.prototype.contains||(Element.prototype.contains=function(t){for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),window.addEventListener||function(t,e,i,n,r,s,o){t[n]=e[n]=i[n]=function(t,e){var i=this;o.unshift([i,t,e,function(t){t.currentTarget=i,t.preventDefault=function(){t.returnValue=!1},t.stopPropagation=function(){t.cancelBubble=!0},t.target=t.srcElement||i,e.call(i,t)}]),this.attachEvent("on"+t,o[0][3])},t[r]=e[r]=i[r]=function(t,e){for(var i,n=0;i=o[n];++n)if(i[0]===this&&i[1]===t&&i[2]===e)return this.detachEvent("on"+t,o.splice(n,1)[0][3])},t[s]=e[s]=i[s]=function(t){return this.fireEvent("on"+t.type,t)}}(Window.prototype,HTMLDocument.prototype,Element.prototype,"addEventListener","removeEventListener","dispatchEvent",[]),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var i;for(void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0),i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var i,n;for(i=0,n=this.length;n>i;i+=1)i in this&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)i in this&&(r[i]=t.call(e,this[i],i,this));return r}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)i in this&&t.call(e,this[i],i,this)&&(r[r.length]=this[i]);return r})})(),function(t){"use strict";var e;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this.observers={},this.pendingResolution=[],this.deferredAttributes=[],this.data&&this.set(this.data),this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,callback:this.callback,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this.deferredAttributes.length;)this.deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h,l;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o,e),a=this.pendingResolution.length;a--;)l=this.pendingResolution.splice(a,1)[0],h=this.resolveRef(l.view.model.ref,l.view.contextStack),h?l.callback(h.keypath,h.value):this.registerUnresolvedKeypath(l)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(t in this._cache)return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(n in this._cache)return this._cache[n];if(e.length>1?(r=e.pop(),a=this.get(e)):(r=e.pop(),a=this.data),s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a)return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(){throw Error("not implemented yet!")},link:function(t){var e=this;return function(i){e.set(t,i)}},registerView:function(t){var e,n,r,s,o=this;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(s=t.parentFragment.indexRefs[t.model.ref],r=t.model.fmtrs?this._format(s,t.model.fmtrs):s,t.update(r),void 0):(n=function(e){t.keypath=t.model.fmtrs?e+"."+i.stringifyFormatters(t.model.fmtrs):e,t.observerRefs=o.observe(t.model.p||0,t),t.update(o.get(t.keypath))},e=this.resolveRef(t.model.ref,t.contextStack),e?n(e.keypath,e.value):(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this.registerUnresolvedKeypath({view:t,callback:n})),void 0)},resolveRef:function(t,e){var i,n,r;if("."===t)return n=e[e.length-1],r=this.get(n),{keypath:n,value:r};for(e=e.concat();e.length;)if(i=e.pop(),n=i+"."+t,r=this.get(n),void 0!==r)return{keypath:n,value:r};return r=this.get(t),void 0!==r?{keypath:t,value:r}:void 0},registerUnresolvedKeypath:function(t){this.pendingResolution[this.pendingResolution.length]=t},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this.observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t,e){var n,r,s=this,o=e.keypath,a=[];if(!o)return void 0;for(n=function(i){var n;n=s.observers[i]=s.observers[i]||[],n=n[t]=n[t]||[],n[n.length]=e,a[a.length]={keypath:i,priority:t,view:e}},r=i.splitKeypath(e.keypath);r.length>1;)n(r.join(".")),r.pop();return n(r[0]),a},unobserve:function(t){var e,i,n,r,s;if(e=this.observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.view){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this.observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})();var i;(function(){var t={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var e,i,n,r,s,o,a,h,l,u;if(!(e=/\\\./.test(t))&&!(i=/⭆.+⭅/.test(t)))return t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".");for(h=[],l=t,i&&(n=[],l=l.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),a=0;l.length;){if(o=l.indexOf(".",a),-1===o)u=l,l="";else{if("\\"===l.charAt(o-1)&&"\\"!==l.charAt(o-2)){a=o+1;continue}u=l.substr(0,o),a=0}/\[/.test(u)?h=h.concat(u.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):h[h.length]=u,l=l.substring(o+1)}if(i)for(s=function(){return"⭆"+n.pop()+"⭅"},r=h.length;r--;)"⭆x⭅"===h[r]&&(h[r]="⭆"+n.pop()+"⭅");return h},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}})(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t._Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerView(this),!this.keypath&&this.model.inv&&this.update(!1)},t._Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t._sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0;return this.postUpdate&&this.postUpdate(),void 0}if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0);this.postUpdate&&this.postUpdate()}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t,e){var i,n,r,s,o,a,h,l,u,p,c;i=e.types,s={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},r="undefined"!=typeof window?window.document:null,n=function(t,e){var i,n=[];for(i=r.createElement("div"),i.innerHTML=t;i.firstChild;)n[n.length]=i.firstChild,e.appendChild(i.firstChild);return n},e.DomFragment=function(t){return this.docFrag=r.createDocumentFragment(),"string"==typeof t.model?(this.nodes=n(t.model,this.docFrag),void 0):(e._Fragment.call(this,t),void 0)},e.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new o(t,this.docFrag);switch(t.model.type){case i.INTERPOLATOR:return new u(t,this.docFrag);case i.SECTION:return new c(t,this.docFrag);case i.TRIPLE:return new p(t,this.docFrag);case i.ELEMENT:return new a(t,this.docFrag);case i.PARTIAL:return new h(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},h=function(t,i){this.fragment=new e.DomFragment({model:t.root.partials[t.model.ref]||[],root:t.root,parentNode:t.parentNode,contextStack:t.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},h.prototype={teardown:function(){this.fragment.teardown()}},o=function(t,e){this.node=r.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},o.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},a=function(t,i){var n,s,o,a,h,u,p;if(n=this.model=t.model,this.root=t.root,this.parentFragment=t.parentFragment,this.parentNode=t.parentNode,this.index=t.index,n.attrs&&n.attrs.xmlns){if(s=n.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=r.createElementNS(s,n.tag),n.frag&&("string"==typeof n.frag?this.node.innerHTML=n.frag:(this.children=new e.DomFragment({model:n.frag,root:t.root,parentNode:this.node,contextStack:t.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[];for(a in n.attrs)n.attrs.hasOwnProperty(a)&&(h=n.attrs[a],o=new l({parent:this,name:a,value:void 0===h?null:h,root:t.root,parentNode:this.node,contextStack:t.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?p=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),i.appendChild(this.node)},a.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},l=function(t){var i,n,r,o,a,h,l,u;if(i=t.name,n=t.value,this.parent=t.parent,r=i.indexOf(":"),-1!==r&&(o=i.substr(0,r),"xmlns"!==o&&(i=i.substring(r+1),this.namespace=e.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?t.parentNode.setAttributeNS(this.namespace,i,n):t.parentNode.setAttribute(i,n),void 0):(this.root=t.root,this.parentNode=t.parentNode,this.name=i,this.children=[],this.namespace||t.parentNode.namespaceURI!==e.namespaces.html||(l=this.name.toLowerCase(),u=s[l]?s[l]:l,void 0!==t.parentNode[u]&&(this.propertyName=u),("boolean"==typeof t.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new e.TextFragment({model:n,root:this.root,parent:this,contextStack:t.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},l.prototype={bind:function(t){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==e.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),t||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root.deferredAttributes[this.root.deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(r.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},u=function(t,i){this.node=r.createTextNode(""),i.appendChild(this.node),e._Mustache.call(this,t)},u.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},p=function(t,i){this.nodes=[],this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},p.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=n(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},c=function(t,i){this.fragments=[],this.length=0,this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(t){e._sectionUpdate.call(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var i=new e.DomFragment(t);return this.docFrag.appendChild(i.docFrag),i}}}(e,i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t._Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t._Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t._Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t._sectionUpdate.call(this,e)},createFragment:function(e){return new t.TextFragment(e)},postUpdate:function(){this.value=this.fragments.join(""),this.parent.bubble()},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e){var i;for(i=0;t.length>i&&!r.requestAnimationFrame;++i)r.requestAnimationFrame=r[t[i]+"RequestAnimationFrame"],r.cancelAnimationFrame=r[t[i]+"CancelAnimationFrame"]||r[t[i]+"CancelRequestAnimationFrame"];r.requestAnimationFrame||(r.requestAnimationFrame=function(t){var i,n,s;return i=Date.now(),n=Math.max(0,16-(i-e)),s=r.setTimeout(function(){t(i+n)},n),e=i+n,s}),r.cancelAnimationFrame||(r.cancelAnimationFrame=function(t){r.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,p;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,p=e.splitKeypath(r),l=new i({keys:p,from:this.get(p),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e}(this); | ||
(function(t){"use strict";Date.now||(Date.now=function(){return+new Date}),t.createElementNS||(t.createElementNS=function(e,i){if(null!==e&&"http://www.w3.org/1999/xhtml"!==e)throw"This browser does not support namespaces other than http://www.w3.org/1999/xhtml";return t.createElement(i)}),Element.prototype.contains||(Element.prototype.contains=function(t){for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),window.addEventListener||function(t,e,i,n,r,s,o){t[n]=e[n]=i[n]=function(t,e){var i=this;o.unshift([i,t,e,function(t){t.currentTarget=i,t.preventDefault=function(){t.returnValue=!1},t.stopPropagation=function(){t.cancelBubble=!0},t.target=t.srcElement||i,e.call(i,t)}]),this.attachEvent("on"+t,o[0][3])},t[r]=e[r]=i[r]=function(t,e){var i,n;for(i=0,n;n=o[i];++i)if(n[0]===this&&n[1]===t&&n[2]===e)return this.detachEvent("on"+t,o.splice(i,1)[0][3])},t[s]=e[s]=i[s]=function(t){return this.fireEvent("on"+t.type,t)}}(Window.prototype,HTMLDocument.prototype,Element.prototype,"addEventListener","removeEventListener","dispatchEvent",[]),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){var i;for(void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0),i=this.length;i>e;e++)if(this.hasOwnProperty(e)&&this[e]===t)return e;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var i,n;for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&(r[i]=t.call(e,this[i],i,this));return r}),Array.prototype.map||(Array.prototype.map=function(t,e){var i,n,r=[];for(i=0,n=this.length;n>i;i+=1)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)&&(r[r.length]=this[i]);return r})})(document),function(t){"use strict";var e,i;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this._observers={},this._pendingResolution=[],this._deferredAttributes=[],this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this._deferredAttributes.length;)this._deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o),a=this._pendingResolution.length;a--;)h=this._pendingResolution.splice(a,1)[0],this.resolveRef(h)||(this._pendingResolution[this._pendingResolution.length]=h)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(this._cache.hasOwnProperty(t))return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(this._cache.hasOwnProperty(n))return this._cache[n];if(r=e.pop(),a=e.length?this.get(e):this.data,s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a||!a.hasOwnProperty(r))return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(t){return this._clearCache(t),this._notifyObservers(t),this.fire("update:"+t),this.fire("update",t),this},link:function(t){var e=this;return function(i){e.set(t,i)}},registerMustache:function(t){var e,i,n;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(n=t.parentFragment.indexRefs[t.model.ref],i=t.model.fmtrs?this._format(n,t.model.fmtrs):n,t.update(i),void 0):(e=this.resolveRef(t),e||(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this._pendingResolution[this._pendingResolution.length]=t),void 0)},resolveRef:function(t){var e,n,r,s,o,a,h,l;if(e=t.model.ref,n=t.contextStack,"."===e)l=n[n.length-1];else{for(r=i.splitKeypath(e),s=r.pop(),n=n.concat();n.length;)if(o=n.pop(),a=i.splitKeypath(o),h=this.get(a.concat(r)),"object"==typeof h&&h.hasOwnProperty(s)){l=o+"."+e;break}l||void 0===this.get(e)||(l=e)}return l?(t.keypath=t.model.fmtrs?l+"."+i.stringifyFormatters(t.model.fmtrs):l,t.observerRefs=this.observe(t),t.update(this.get(t.keypath)),!0):!1},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this._observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t){var e,n,r=this,s=[],o=t.model.p||0;for(e=function(e){var i;i=r._observers[e]=r._observers[e]||[],i=i[o]=i[o]||[],i[i.length]=t,s[s.length]={keypath:e,priority:o,mustache:t}},n=i.splitKeypath(t.keypath);n.length>1;)e(n.join(".")),n.pop();return e(n[0]),s},unobserve:function(t){var e,i,n,r,s;if(e=this._observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.mustache){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this._observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})(),function(){var t={},e={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var i,n,r,s,o,a,h,l;if(e[t])return e[t].concat();if(i=/⭆.+⭅/.test(t),!/\\\./.test(t)&&!i)return e[t]=t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split("."),e[t].concat();for(a=[],h=t,i&&(n=[],h=h.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),o=0;h.length;){if(s=h.indexOf(".",o),-1===s)l=h,h="";else{if("\\"===h.charAt(s-1)&&"\\"!==h.charAt(s-2)){o=s+1;continue}l=h.substr(0,s),o=0}/\[/.test(l)?a=a.concat(l.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):a[a.length]=l,h=h.substring(s+1)}if(i)for(r=a.length;r--;)"⭆x⭅"===a[r]&&(a[r]="⭆"+n.pop()+"⭅");return e[t]=a,a.concat()},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}}(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t.Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerMustache(this),!this.keypath&&this.model.inv&&this.update(this.model.fmtrs?this.root._format(!1,this.model.fmtrs):!1)},t.Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t.sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0}else if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0)}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t){var e,i,n,r,s,o,a,h,l,u,p;e=t.types,r={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},n="undefined"!=typeof window?window.document:null,i=function(t,e){var i,r=[];for(i=n.createElement("div"),i.innerHTML=t;i.firstChild;)r[r.length]=i.firstChild,e.appendChild(i.firstChild);return r},t.DomFragment=function(e){return this.docFrag=n.createDocumentFragment(),"string"==typeof e.model?(this.nodes=i(e.model,this.docFrag),void 0):(t.Fragment.call(this,e),void 0)},t.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new s(t,this.docFrag);switch(t.model.type){case e.INTERPOLATOR:return new l(t,this.docFrag);case e.SECTION:return new p(t,this.docFrag);case e.TRIPLE:return new u(t,this.docFrag);case e.ELEMENT:return new o(t,this.docFrag);case e.PARTIAL:return new a(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},a=function(e,i){this.fragment=new t.DomFragment({model:e.root.partials[e.model.ref]||[],root:e.root,parentNode:e.parentNode,contextStack:e.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},a.prototype={teardown:function(){this.fragment.teardown()}},s=function(t,e){this.node=n.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},s.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(e,i){var r,s,o,a,l,u,p;if(r=this.model=e.model,this.root=e.root,this.parentFragment=e.parentFragment,this.parentNode=e.parentNode,this.index=e.index,r.attrs&&r.attrs.xmlns){if(s=r.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=n.createElementNS(s,r.tag),r.frag&&("string"==typeof r.frag&&this.node.namespaceURI===t.namespaces.html?this.node.innerHTML=r.frag:(this.children=new t.DomFragment({model:r.frag,root:e.root,parentNode:this.node,contextStack:e.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[];for(a in r.attrs)r.attrs.hasOwnProperty(a)&&(l=r.attrs[a],o=new h({parent:this,name:a,value:void 0===l?null:l,root:e.root,parentNode:this.node,contextStack:e.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?p=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),i.appendChild(this.node)},o.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},h=function(e){var i,n,s,o,a,h,l,u;if(i=e.name,n=e.value,this.parent=e.parent,s=i.indexOf(":"),-1!==s&&(o=i.substr(0,s),"xmlns"!==o&&(i=i.substring(s+1),this.namespace=t.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?e.parentNode.setAttributeNS(this.namespace,i,n):e.parentNode.setAttribute(i,n),void 0):(this.root=e.root,this.parentNode=e.parentNode,this.name=i,this.children=[],this.namespace||e.parentNode.namespaceURI!==t.namespaces.html||(l=this.name.toLowerCase(),u=r[l]||l,void 0!==e.parentNode[u]&&(this.propertyName=u),("boolean"==typeof e.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new t.TextFragment({model:n,root:this.root,parent:this,contextStack:e.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},h.prototype={bind:function(e){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==t.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),e||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root._deferredAttributes[this.root._deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(n.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},l=function(e,i){this.node=n.createTextNode(""),i.appendChild(this.node),t.Mustache.call(this,e)},l.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},u=function(e,i){this.nodes=[],this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},u.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=i(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},p=function(e,i){this.fragments=[],this.length=0,this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},p.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(e){t.sectionUpdate.call(this,e),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(e){var i=new t.DomFragment(e);return this.docFrag.appendChild(i.docFrag),i}}}(i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t.Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t.Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t.Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t.sectionUpdate.call(this,e),this.value=this.fragments.join(""),this.parent.bubble()},createFragment:function(e){return new t.TextFragment(e)},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e,i){var n;for(n=0;t.length>n&&!i.requestAnimationFrame;++n)i.requestAnimationFrame=i[t[n]+"RequestAnimationFrame"],i.cancelAnimationFrame=i[t[n]+"CancelAnimationFrame"]||i[t[n]+"CancelRequestAnimationFrame"];i.requestAnimationFrame||(i.requestAnimationFrame=function(t){var n,r,s;return n=Date.now(),r=Math.max(0,16-(n-e)),s=i.setTimeout(function(){t(n+r)},r),e=n+r,s}),i.cancelAnimationFrame||(i.cancelAnimationFrame=function(t){i.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,p;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,p=e.splitKeypath(r),l=new i({keys:p,from:this.get(p),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e}(this); |
@@ -1,2 +0,2 @@ | ||
(function(t){"use strict";var e;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this.observers={},this.pendingResolution=[],this.deferredAttributes=[],this.data&&this.set(this.data),this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,callback:this.callback,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this.deferredAttributes.length;)this.deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h,l;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o,e),a=this.pendingResolution.length;a--;)l=this.pendingResolution.splice(a,1)[0],h=this.resolveRef(l.view.model.ref,l.view.contextStack),h?l.callback(h.keypath,h.value):this.registerUnresolvedKeypath(l)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(t in this._cache)return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(n in this._cache)return this._cache[n];if(e.length>1?(r=e.pop(),a=this.get(e)):(r=e.pop(),a=this.data),s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a)return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(){throw Error("not implemented yet!")},link:function(t){var e=this;return function(i){e.set(t,i)}},registerView:function(t){var e,n,r,s,o=this;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(s=t.parentFragment.indexRefs[t.model.ref],r=t.model.fmtrs?this._format(s,t.model.fmtrs):s,t.update(r),void 0):(n=function(e){t.keypath=t.model.fmtrs?e+"."+i.stringifyFormatters(t.model.fmtrs):e,t.observerRefs=o.observe(t.model.p||0,t),t.update(o.get(t.keypath))},e=this.resolveRef(t.model.ref,t.contextStack),e?n(e.keypath,e.value):(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this.registerUnresolvedKeypath({view:t,callback:n})),void 0)},resolveRef:function(t,e){var i,n,r;if("."===t)return n=e[e.length-1],r=this.get(n),{keypath:n,value:r};for(e=e.concat();e.length;)if(i=e.pop(),n=i+"."+t,r=this.get(n),void 0!==r)return{keypath:n,value:r};return r=this.get(t),void 0!==r?{keypath:t,value:r}:void 0},registerUnresolvedKeypath:function(t){this.pendingResolution[this.pendingResolution.length]=t},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this.observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t,e){var n,r,s=this,o=e.keypath,a=[];if(!o)return void 0;for(n=function(i){var n;n=s.observers[i]=s.observers[i]||[],n=n[t]=n[t]||[],n[n.length]=e,a[a.length]={keypath:i,priority:t,view:e}},r=i.splitKeypath(e.keypath);r.length>1;)n(r.join(".")),r.pop();return n(r[0]),a},unobserve:function(t){var e,i,n,r,s;if(e=this.observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.view){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this.observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})();var i;(function(){var t={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var e,i,n,r,s,o,a,h,l,u;if(!(e=/\\\./.test(t))&&!(i=/⭆.+⭅/.test(t)))return t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".");for(h=[],l=t,i&&(n=[],l=l.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),a=0;l.length;){if(o=l.indexOf(".",a),-1===o)u=l,l="";else{if("\\"===l.charAt(o-1)&&"\\"!==l.charAt(o-2)){a=o+1;continue}u=l.substr(0,o),a=0}/\[/.test(u)?h=h.concat(u.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):h[h.length]=u,l=l.substring(o+1)}if(i)for(s=function(){return"⭆"+n.pop()+"⭅"},r=h.length;r--;)"⭆x⭅"===h[r]&&(h[r]="⭆"+n.pop()+"⭅");return h},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}})(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t._Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerView(this),!this.keypath&&this.model.inv&&this.update(!1)},t._Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t._sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0;return this.postUpdate&&this.postUpdate(),void 0}if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0);this.postUpdate&&this.postUpdate()}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype);var e=e||{},i=i||{};(function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m;t.compile=function(i,r){var s,o,a;return r=r||{},r.sanitize===!0&&(r.sanitize={elements:["applet","base","basefont","body","frame","frameset","head","html","isindex","link","meta","noframes","noscript","object","param","script","style","title"],eventAttributes:!0}),t.delimiters=r.delimiters||["{{","}}"],t.tripleDelimiters=r.tripleDelimiters||["{{{","}}}"],s=e.tokenize(i),o=n(s,0,r,r.preserveWhitespace),a=o.toJson(),"string"==typeof a?[a]:a},p=e.types,c=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],d=["a","abbr","acronym","address","applet","area","b","base","basefont","bdo","big","blockquote","body","br","button","caption","center","cite","code","col","colgroup","dd","del","dfn","dir","div","dl","dt","em","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","i","iframe","img","input","ins","isindex","kbd","label","legend","li","link","map","menu","meta","noframes","noscript","object","ol","optgroup","option","p","param","pre","q","s","samp","script","select","small","span","strike","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","u","ul","var","article","aside","audio","bdi","canvas","command","data","datagrid","datalist","details","embed","eventsource","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","ruby","rp","rt","section","source","summary","time","track","video","wbr"],f=["li","dd","rt","rp","optgroup","option","tbody","tfoot","tr","td","th"],m={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:["address","article","aside","blockquote","dir","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","menu","nav","ol","p","pre","section","table","ul"],rt:["rt","rp"],rp:["rp","rt"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tr:["tr"],td:["td","th"],th:["td","th"]},u=function(t){var e,i,n,r;if(r=t.indexOf("["),-1!==r){e=t.substr(0,r),i=t.substring(r,t.length);try{n=JSON.parse(i)}catch(s){throw"Could not parse arguments ("+i+") using JSON.parse"}return{name:e,args:n}}return{name:t}},l={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},h=function(t){var e;return e=t.replace(/&([a-zA-Z]+);/,function(t,e){return l[e]?String.fromCharCode(l[e]):t}),e=e.replace(/&#x([0-9]+);/,function(t,e){return String.fromCharCode(parseInt(e,16))}),e=e.replace(/&#([0-9]+);/,function(t,e){return String.fromCharCode(e)})},r=function(t){this.type=p.TEXT,this.text=t.value},r.prototype={toJson:function(){return this.decoded||(this.decoded=h(this.text))},toString:function(){return this.text},decodeCharacterReferences:function(){}},s=function(t,e){var r,s,o,a,h,l;if(this.type=p.ELEMENT,this.tag=t.tag,this.parentFragment=e,this.parentElement=e.parentElement,r=t.attributes.items,o=r.length){for(s=[],a=0;o>a;a+=1)e.options.sanitize&&e.options.sanitize.eventAttributes&&"on"===r[a].name.value.toLowerCase().substr(0,2)||(h={name:r[a].name.value},r[a].value.isNull||(h.value=n(r[a].value.tokens,this.parentFragment.priority+1)),s[a]=h);this.attributes=s}t.isSelfClosingTag||-1!==c.indexOf(t.tag.toLowerCase())||(l=e.preserveWhitespace||"pre"===this.tag.toLowerCase(),this.fragment=new i(this,e.priority+1,e.options,l))},s.prototype={read:function(t){return this.fragment&&this.fragment.read(t)},toJson:function(t){var e,i,n,r,s;if(e={type:p.ELEMENT,tag:this.tag},this.attributes)for(e.attrs={},s=0;this.attributes.length>s;s+=1)i=this.attributes[s].name,void 0===this.attributes[s].value?n=null:(r=""+this.attributes[s].value,n=r!==!1?r:this.attributes[s].value.toJson()),e.attrs[i]=n;return this.fragment&&this.fragment.items.length&&(e.frag=this.fragment.toJson(t)),e},toString:function(){var t,e,i,n,r,s,o;if(-1===d.indexOf(this.tag.toLowerCase()))return!1;if(s=this.fragment?""+this.fragment:"",s===!1)return!1;if(o=-1!==c.indexOf(this.tag.toLowerCase()),t="<"+this.tag,this.attributes)for(e=0,i=this.attributes.length;i>e;e+=1){if(-1!==this.attributes[e].name.indexOf(":"))return!1;if(n=" "+this.attributes[e].name,void 0!==this.attributes[e].value){if(r=""+this.attributes[e].value,r===!1)return!1;""!==r&&(n+="=",n+=/[\s"'=<>`]/.test(r)?'"'+r.replace(/"/g,""")+'"':r)}t+=n}return this.isSelfClosing&&!o?t+="/>":(t+=">",o?t:(t+=s,t+="</"+this.tag+">"))}},o=function(t,e){this.type=p.SECTION,this.parentFragment=e,this.ref=t.ref,this.inverted=t.type===p.INVERTED,this.formatters=t.formatters,this.i=t.i,this.fragment=new i(this,e.priority+1,e.options,e.preserveWhitespace)},o.prototype={read:function(t){return this.fragment.read(t)},toJson:function(t){var e;return e={type:p.SECTION,ref:this.ref},this.fragment&&(e.frag=this.fragment.toJson(t)),this.formatters&&this.formatters.length&&(e.fmtrs=this.formatters.map(u)),this.inverted&&(e.inv=!0),this.priority&&(e.p=this.parentFragment.priority),this.i&&(e.i=this.i),e},toString:function(){return!1}},a=function(t,e){this.type=t.type,this.priority=e,this.ref=t.ref,this.formatters=t.formatters},a.prototype={toJson:function(){var t={type:this.type,ref:this.ref};return this.formatters&&(t.fmtrs=this.formatters.map(u)),this.priority&&(t.p=this.priority),t},toString:function(){return!1}},i=function(t,e,i,n){this.owner=t,this.items=[],this.options=i,this.preserveWhitespace=n,t&&(this.parentElement=t.type===p.ELEMENT?t:t.parentElement),this.priority=e},i.prototype={read:function(t){if(this.sealed)return!1;if(this.isImplicitlyClosedBy(t))return this.seal(),!1;if(this.currentChild){if(this.currentChild.read(t))return!0;this.currentChild=null}return this.isExplicitlyClosedBy(t)?(this.seal(),!0):t.type===p.CLOSING||t.type===p.DELIMCHANGE||t.type===p.COMMENT?!1:t.type===p.SECTION||t.type===p.INVERTED?(this.currentChild=new o(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===p.TAG?(this.currentChild=new s(t,this),this.options.sanitize&&this.options.sanitize.elements&&-1!==this.options.sanitize.elements.indexOf(t.tag.toLowerCase())?!0:(this.items[this.items.length]=this.currentChild,!0)):t.type===p.TEXT||t.type===p.ATTR_VALUE_TOKEN?(this.items[this.items.length]=new r(t),!0):(this.items[this.items.length]=new a(t,this.priority),!0)},isClosedBy:function(t){return this.isImplicitlyClosedBy(t)||this.isExplicitlyClosedBy(t)},isImplicitlyClosedBy:function(t){var e,i,n,r,s;return t.tag&&this.owner&&this.owner.type===p.ELEMENT?(r=this.owner.tag.toLowerCase(),s=t.tag.toLowerCase(),i=this.owner,n=i.parentElement||null,e=m[r],e&&!t.isClosingTag&&-1!==e.indexOf(s)?!0:-1!==f.indexOf(r)&&n&&n.fragment.isClosedBy(t)?!0:"p"===r&&n&&"a"===n.tag.toLowerCase()&&n.fragment.isClosedBy(t)?!0:void 0):!1},isExplicitlyClosedBy:function(t){return this.owner?this.owner.type===p.SECTION&&t.type===p.CLOSING&&t.ref===this.owner.ref?!0:this.owner.type===p.ELEMENT&&this.owner&&t.isClosingTag&&t.tag.toLowerCase()===this.owner.tag.toLowerCase()?!0:void 0:!1},toJson:function(t){var e,i,n,r=[];if(!t&&(n=""+this,n!==!1))return n;for(e=0,i=this.items.length;i>e;e+=1)r[e]=this.items[e].toJson(t);return r},toString:function(){var t,e,i,n="";for(t=0,e=this.items.length;e>t;t+=1){if(i=""+this.items[t],i===!1)return!1;n+=i}return n},seal:function(){var t,e,i,n;if(this.sealed=!0,!this.preserveWhitespace)for(this.owner.type===p.ELEMENT&&(t=this.items[0],t&&t.type===p.TEXT&&(t.text=t.text.replace(/^\s*/,""),""===t.text&&this.items.shift()),e=this.items[this.items.length-1],e&&e.type===p.TEXT&&(e.text=e.text.replace(/\s*$/,""),""===e.text&&this.items.pop())),i=this.items.length;i--;)n=this.items[i],n.type===p.TEXT&&(n.text=n.text.replace(/\s{2,}/g," "));this.items.length||delete this.owner.fragment}},n=function(t,e,n,r){for(var s,o=new i(null,e,n,r);t.length;)s=t.shift(),o.read(s);return o}})(e,i),function(t,e){var i,n,r,s,o,a,h,l,u,p,c,d,f,m,g,v,y,w,b,N,x;e.tokenize=function(t){var e=a.fromString(r(t));return o(s(e.tokens))},a=function(){this.tokens=[],this.buffer=new h},a.prototype={read:function(t){var e,n;if(this.currentToken&&this.currentToken.type!==i.TEXT&&this.currentToken.read(t))return!0;if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(n=this.buffer.release(),this.currentToken){for(;n.length;){for(;n.length&&this.currentToken.read(n.charAt(0));)n=n.substring(1);n.length&&("<"===n.charAt(0)?(this.currentToken=new c,this.currentToken.read("<")):(this.currentToken=new l,this.currentToken.read(n.charAt(0))),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1))}return!0}return this.currentToken="<"===t?new c:new l,this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,!0},end:function(){this.buffer.isEmpty()||(this.tokens[this.tokens.length]=this.buffer.convert())}},a.fromString=function(t){var e,i,n;for(e=new a,i=0,n=t.length;n>i;)e.read(t.charAt(i)),i+=1;return e.end(),e},h=function(){this.value=""},h.prototype={read:function(e){var i;return this.value+=e,i=this.isPartialMatchOf(t.delimiters[0])||this.isPartialMatchOf(t.tripleDelimiters[0])},convert:function(){var e,i,n,r,s,o;if(i=t.delimiters[0],n=t.tripleDelimiters[0],e=this.value,s=function(){return 0===e.indexOf(n)?new p:void 0},o=function(){return 0===e.indexOf(i)?new u:void 0},r=n.length>i.length?s()||o():o()||s()){for(;this.value.length;)r.read(this.value.charAt(0)),this.value=this.value.substring(1);return r}return!1},release:function(){var t=this.value;return this.value="",t},isEmpty:function(){return!this.value.length},isPartialMatchOf:function(t){return 0===t.indexOf(this.value)}},l=function(){this.type=i.TEXT,this.value=""},l.prototype={read:function(t){return this.sealed?!1:"<"===t?!1:(this.value+=t,!0)},seal:function(){this.sealed=!0}},u=function(){this.value="",this.openingDelimiter=t.delimiters[0],this.closingDelimiter=t.delimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length},p=function(){this.value="",this.openingDelimiter=t.tripleDelimiters[0],this.closingDelimiter=t.tripleDelimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length,this.type=i.TRIPLE},u.prototype=p.prototype={read:function(t){return this.sealed?!1:(this.value+=t,this.value.length>=this.minLength&&this.value.substr(-this.closingDelimiter.length)===this.closingDelimiter&&this.seal(),!0)},seal:function(){var t,e,n,r,s;this.sealed||(t=this.value.replace(this.openingDelimiter,"").replace(this.closingDelimiter,"").trim(),"="===t.charAt(0)&&(this.changeDelimiters(t),this.type=i.DELIMCHANGE),this.type||(e=t.charAt(0),f[e]?(this.type=f[e],t=t.substring(1).trim()):this.type=i.INTERPOLATOR),this.type===i.SECTION&&(r=/:\s*([a-zA-Z_$][a-zA-Z0-9_$]*)$/,s=r.exec(t),s&&(this.i=s[1],t=t.substr(0,t.length-s[0].length))),n=t.split("|"),this.ref=n.shift().trim(),n.length&&(this.formatters=n.map(function(t){return t.trim()})),this.sealed=!0)},changeDelimiters:function(e){var n,r;r=/\=\s*([^\s=]+)\s+([^\s=]+)\s*=/.exec(e),n=this.type===i.TRIPLE?t.tripleDelimiters:t.delimiters,n[0]=r[1],n[1]=r[2]}},c=function(){this.type=i.TAG,this.openingBracket=new m,this.closingTagSolidus=new y,this.tagName=new g,this.attributes=new v,this.selfClosingSolidus=new y,this.closingBracket=new w},c.prototype={read:function(t){var e;return this.sealed?!1:(e=this.openingBracket.read(t)||this.closingTagSolidus.read(t)||this.tagName.read(t)||this.attributes.read(t)||this.selfClosingSolidus.read(t)||this.closingBracket.read(t))?(this.closingBracket.sealed&&this.seal(),!0):(this.seal(),!1)},seal:function(){this.tag=this.tagName.value,this.closingTagSolidus.value&&(this.isClosingTag=!0),this.selfClosingSolidus.value&&(this.isSelfClosingTag=!0),this.sealed=!0}},m=function(){},m.prototype={read:function(t){if(this.sealed)return!1;if("<"===t)return this.value="<",this.seal(),!0;throw'Expected "<", saw "'+t+'"'},seal:function(){this.sealed=!0}},g=function(){},g.prototype={read:function(t){return this.sealed?!1:!this.value&&/[a-zA-Z]/.test(t)?(this.value=t,!0):/[a-zA-Z0-9\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},v=function(){this.items=[]},v.prototype={read:function(t){return this.sealed?!1:this.nextItem&&this.nextItem.read(t)?!0:n.test(t)?!0:(this.nextItem=new b,this.nextItem.read(t)?(this.items[this.items.length]=this.nextItem,!0):(this.seal(),!1))},seal:function(){this.sealed=!0}},b=function(){this.name=new N,this.value=new x},b.prototype={read:function(t){return this.sealed?!1:this.name.read(t)?!0:this.name.value?this.value.read(t)?!0:(this.seal(),!1):(this.seal(),!1)},seal:function(){this.sealed=!0}},N=function(){},N.prototype={read:function(t){return this.sealed?!1:this.value?/[_:a-zA-Z0-9\.\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1):/[a-zA-Z_:]/.test(t)?(this.value=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},x=function(){this.tokens=[],this.buffer=new h,this.isNull=!0},x.prototype={read:function(t){var e,i;if(this.sealed)return!1;if(this.isNull)return n.test(t)?!0:"="===t?(this.isNull=!1,!0):!1;if(!this.tokens.length&&!this.quoteMark){if(n.test(t))return!0;if('"'===t||"'"===t)return this.quoteMark=t,!0}if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(i=this.buffer.release(),this.currentToken){for(;i.length;){for(;i.length&&i.charAt(0)!==this.quoteMark&&this.currentToken.read(i.charAt(0));)i=i.substring(1);if(i.length){if(">"===i.charAt(0))return this.seal(),!1;if(i.charAt(0)===this.quoteMark)return this.currentToken.seal(),this.seal(),!0;this.currentToken=new d(this.quoteMark),this.currentToken.read(i.charAt(0)),this.tokens[this.tokens.length]=this.currentToken,i=i.substring(1)}}return!0}return this.currentToken=new d(this.quoteMark),this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,this.currentToken.sealed&&this.seal(),!0},seal:function(){this.sealed=!0}},d=function(t){this.type=i.ATTR_VALUE_TOKEN,this.quoteMark=t||"",this.value=""},d.prototype={read:function(t){return this.sealed?!1:t===this.quoteMark?(this.seal(),!0):this.quoteMark?(this.value+=t,!0):/[\s"'=<>`]/.test(t)?(this.seal(),!1):(this.value+=t,!0)},seal:function(){this.sealed=!0}},y=function(){},y.prototype={read:function(t){return this.sealed?!1:"/"===t?(this.value="/",this.seal(),!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},w=function(){},w.prototype={read:function(t){if(this.sealed)return!1;if(">"===t)return this.value=">",this.seal(),!0;throw'Expected ">", received "'+t+'"'},seal:function(){this.sealed=!0}},r=function(t){var e,i,n;for(n="";t.length;){if(e=t.indexOf("<!--"),i=t.indexOf("-->"),-1===e&&-1===i){n+=t;break}if(-1!==e&&-1===i)throw"Illegal HTML - expected closing comment sequence ('-->')";if(-1!==i&&-1===e||e>i)throw"Illegal HTML - unexpected closing comment sequence ('-->')";n+=t.substr(0,e),t=t.substring(i+3)}return n},s=function(t){var e,n,r,s,o,a;for(o=/^\s*\r?\n/,a=/\r?\n\s*$/,e=2;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e-2],n.type===i.TEXT&&r.type!==i.TAG&&s.type===i.TEXT&&a.test(s.value)&&o.test(n.value)&&(r.type!==i.INTERPOLATOR&&r.type!==i.TRIPLE&&(s.value=s.value.replace(a,"\n")),n.value=n.value.replace(o,""),""===n.value&&t.splice(e--,1));return t},o=function(t){var e,n,r,s;for(e=0;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e+1],n.type===i.COMMENT&&(t.splice(e,1),r&&s&&r.type===i.TEXT&&s.type===i.TEXT&&(r.value+=s.value,t.splice(e,1)),e-=1);return t},i=e.types,n=/\s/,f={"#":i.SECTION,"^":i.INVERTED,"/":i.CLOSING,">":i.PARTIAL,"!":i.COMMENT,"&":i.INTERPOLATOR}}(e,i),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t,e){var i,n,r,s,o,a,h,l,u,p,c;i=e.types,s={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},r="undefined"!=typeof window?window.document:null,n=function(t,e){var i,n=[];for(i=r.createElement("div"),i.innerHTML=t;i.firstChild;)n[n.length]=i.firstChild,e.appendChild(i.firstChild);return n},e.DomFragment=function(t){return this.docFrag=r.createDocumentFragment(),"string"==typeof t.model?(this.nodes=n(t.model,this.docFrag),void 0):(e._Fragment.call(this,t),void 0)},e.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new o(t,this.docFrag);switch(t.model.type){case i.INTERPOLATOR:return new u(t,this.docFrag);case i.SECTION:return new c(t,this.docFrag);case i.TRIPLE:return new p(t,this.docFrag);case i.ELEMENT:return new a(t,this.docFrag);case i.PARTIAL:return new h(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},h=function(t,i){this.fragment=new e.DomFragment({model:t.root.partials[t.model.ref]||[],root:t.root,parentNode:t.parentNode,contextStack:t.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},h.prototype={teardown:function(){this.fragment.teardown()}},o=function(t,e){this.node=r.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},o.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},a=function(t,i){var n,s,o,a,h,u,p;if(n=this.model=t.model,this.root=t.root,this.parentFragment=t.parentFragment,this.parentNode=t.parentNode,this.index=t.index,n.attrs&&n.attrs.xmlns){if(s=n.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=r.createElementNS(s,n.tag),n.frag&&("string"==typeof n.frag?this.node.innerHTML=n.frag:(this.children=new e.DomFragment({model:n.frag,root:t.root,parentNode:this.node,contextStack:t.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[];for(a in n.attrs)n.attrs.hasOwnProperty(a)&&(h=n.attrs[a],o=new l({parent:this,name:a,value:void 0===h?null:h,root:t.root,parentNode:this.node,contextStack:t.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?p=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);p&&(p.updateViewModel(),p.update()),i.appendChild(this.node)},a.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},l=function(t){var i,n,r,o,a,h,l,u;if(i=t.name,n=t.value,this.parent=t.parent,r=i.indexOf(":"),-1!==r&&(o=i.substr(0,r),"xmlns"!==o&&(i=i.substring(r+1),this.namespace=e.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?t.parentNode.setAttributeNS(this.namespace,i,n):t.parentNode.setAttribute(i,n),void 0):(this.root=t.root,this.parentNode=t.parentNode,this.name=i,this.children=[],this.namespace||t.parentNode.namespaceURI!==e.namespaces.html||(l=this.name.toLowerCase(),u=s[l]?s[l]:l,void 0!==t.parentNode[u]&&(this.propertyName=u),("boolean"==typeof t.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new e.TextFragment({model:n,root:this.root,parent:this,contextStack:t.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0) | ||
},l.prototype={bind:function(t){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==e.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),t||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root.deferredAttributes[this.root.deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(r.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},u=function(t,i){this.node=r.createTextNode(""),i.appendChild(this.node),e._Mustache.call(this,t)},u.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},p=function(t,i){this.nodes=[],this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},p.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=n(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},c=function(t,i){this.fragments=[],this.length=0,this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(t){e._sectionUpdate.call(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var i=new e.DomFragment(t);return this.docFrag.appendChild(i.docFrag),i}}}(e,i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t._Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t._Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t._Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t._sectionUpdate.call(this,e)},createFragment:function(e){return new t.TextFragment(e)},postUpdate:function(){this.value=this.fragments.join(""),this.parent.bubble()},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e){var i;for(i=0;t.length>i&&!r.requestAnimationFrame;++i)r.requestAnimationFrame=r[t[i]+"RequestAnimationFrame"],r.cancelAnimationFrame=r[t[i]+"CancelAnimationFrame"]||r[t[i]+"CancelRequestAnimationFrame"];r.requestAnimationFrame||(r.requestAnimationFrame=function(t){var i,n,s;return i=Date.now(),n=Math.max(0,16-(i-e)),s=r.setTimeout(function(){t(i+n)},n),e=i+n,s}),r.cancelAnimationFrame||(r.cancelAnimationFrame=function(t){r.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,p;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,p=e.splitKeypath(r),l=new i({keys:p,from:this.get(p),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this); | ||
(function(t){"use strict";var e,i;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this._observers={},this._pendingResolution=[],this._deferredAttributes=[],this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this._deferredAttributes.length;)this._deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o),a=this._pendingResolution.length;a--;)h=this._pendingResolution.splice(a,1)[0],this.resolveRef(h)||(this._pendingResolution[this._pendingResolution.length]=h)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,l;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(this._cache.hasOwnProperty(t))return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(this._cache.hasOwnProperty(n))return this._cache[n];if(r=e.pop(),a=e.length?this.get(e):this.data,s=/^⭆(.+)⭅$/.exec(r))l=i.getFormattersFromString(s[1]),h=this._format(a,l);else{if("object"!=typeof a||!a.hasOwnProperty(r))return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(t){return this._clearCache(t),this._notifyObservers(t),this.fire("update:"+t),this.fire("update",t),this},link:function(t){var e=this;return function(i){e.set(t,i)}},registerMustache:function(t){var e,i,n;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(n=t.parentFragment.indexRefs[t.model.ref],i=t.model.fmtrs?this._format(n,t.model.fmtrs):n,t.update(i),void 0):(e=this.resolveRef(t),e||(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this._pendingResolution[this._pendingResolution.length]=t),void 0)},resolveRef:function(t){var e,n,r,s,o,a,h,l;if(e=t.model.ref,n=t.contextStack,"."===e)l=n[n.length-1];else{for(r=i.splitKeypath(e),s=r.pop(),n=n.concat();n.length;)if(o=n.pop(),a=i.splitKeypath(o),h=this.get(a.concat(r)),"object"==typeof h&&h.hasOwnProperty(s)){l=o+"."+e;break}l||void 0===this.get(e)||(l=e)}return l?(t.keypath=t.model.fmtrs?l+"."+i.stringifyFormatters(t.model.fmtrs):l,t.observerRefs=this.observe(t),t.update(this.get(t.keypath)),!0):!1},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this._observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t){var e,n,r=this,s=[],o=t.model.p||0;for(e=function(e){var i;i=r._observers[e]=r._observers[e]||[],i=i[o]=i[o]||[],i[i.length]=t,s[s.length]={keypath:e,priority:o,mustache:t}},n=i.splitKeypath(t.keypath);n.length>1;)e(n.join(".")),n.pop();return e(n[0]),s},unobserve:function(t){var e,i,n,r,s;if(e=this._observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.mustache){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this._observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})(),function(){var t={},e={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var i,n,r,s,o,a,h,l;if(e[t])return e[t].concat();if(i=/⭆.+⭅/.test(t),!/\\\./.test(t)&&!i)return e[t]=t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split("."),e[t].concat();for(a=[],h=t,i&&(n=[],h=h.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),o=0;h.length;){if(s=h.indexOf(".",o),-1===s)l=h,h="";else{if("\\"===h.charAt(s-1)&&"\\"!==h.charAt(s-2)){o=s+1;continue}l=h.substr(0,s),o=0}/\[/.test(l)?a=a.concat(l.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):a[a.length]=l,h=h.substring(s+1)}if(i)for(r=a.length;r--;)"⭆x⭅"===a[r]&&(a[r]="⭆"+n.pop()+"⭅");return e[t]=a,a.concat()},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}}(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t.Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerMustache(this),!this.keypath&&this.model.inv&&this.update(this.model.fmtrs?this.root._format(!1,this.model.fmtrs):!1)},t.Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t.sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0}else if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0)}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype);var e=e||{},i=i||{};(function(t,e){var i,n,r,s,o,a,h,l,u,c,p,d,f,m;t.compile=function(i,r){var s,o,a;return r=r||{},r.sanitize===!0&&(r.sanitize={elements:["applet","base","basefont","body","frame","frameset","head","html","isindex","link","meta","noframes","noscript","object","param","script","style","title"],eventAttributes:!0}),t.delimiters=r.delimiters||["{{","}}"],t.tripleDelimiters=r.tripleDelimiters||["{{{","}}}"],s=e.tokenize(i),o=n(s,0,r,r.preserveWhitespace),a=o.toJson(),"string"==typeof a?[a]:a},c=e.types,p=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],d=["a","abbr","acronym","address","applet","area","b","base","basefont","bdo","big","blockquote","body","br","button","caption","center","cite","code","col","colgroup","dd","del","dfn","dir","div","dl","dt","em","fieldset","font","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","hr","html","i","iframe","img","input","ins","isindex","kbd","label","legend","li","link","map","menu","meta","noframes","noscript","object","ol","optgroup","option","p","param","pre","q","s","samp","script","select","small","span","strike","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","u","ul","var","article","aside","audio","bdi","canvas","command","data","datagrid","datalist","details","embed","eventsource","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","ruby","rp","rt","section","source","summary","time","track","video","wbr"],f=["li","dd","rt","rp","optgroup","option","tbody","tfoot","tr","td","th"],m={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:["address","article","aside","blockquote","dir","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","menu","nav","ol","p","pre","section","table","ul"],rt:["rt","rp"],rp:["rp","rt"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tr:["tr"],td:["td","th"],th:["td","th"]},u=function(t){var e,i,n,r;if(r=t.indexOf("["),-1!==r){e=t.substr(0,r),i=t.substring(r,t.length);try{n=JSON.parse(i)}catch(s){throw"Could not parse arguments ("+i+") using JSON.parse"}return{name:e,args:n}}return{name:t}},l={quot:34,amp:38,apos:39,lt:60,gt:62,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,copy:169,ordf:170,laquo:171,not:172,shy:173,reg:174,macr:175,deg:176,plusmn:177,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,sup1:185,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,Agrave:192,Aacute:193,Acirc:194,Atilde:195,Auml:196,Aring:197,AElig:198,Ccedil:199,Egrave:200,Eacute:201,Ecirc:202,Euml:203,Igrave:204,Iacute:205,Icirc:206,Iuml:207,ETH:208,Ntilde:209,Ograve:210,Oacute:211,Ocirc:212,Otilde:213,Ouml:214,times:215,Oslash:216,Ugrave:217,Uacute:218,Ucirc:219,Uuml:220,Yacute:221,THORN:222,szlig:223,agrave:224,aacute:225,acirc:226,atilde:227,auml:228,aring:229,aelig:230,ccedil:231,egrave:232,eacute:233,ecirc:234,euml:235,igrave:236,iacute:237,icirc:238,iuml:239,eth:240,ntilde:241,ograve:242,oacute:243,ocirc:244,otilde:245,ouml:246,divide:247,oslash:248,ugrave:249,uacute:250,ucirc:251,uuml:252,yacute:253,thorn:254,yuml:255,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,"int":8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},h=function(t){var e;return e=t.replace(/&([a-zA-Z]+);/,function(t,e){return l[e]?String.fromCharCode(l[e]):t}),e=e.replace(/&#x([0-9]+);/,function(t,e){return String.fromCharCode(parseInt(e,16))}),e=e.replace(/&#([0-9]+);/,function(t,e){return String.fromCharCode(e)})},r=function(t){this.type=c.TEXT,this.text=t.value},r.prototype={toJson:function(){return this.decoded||(this.decoded=h(this.text))},toString:function(){return this.text},decodeCharacterReferences:function(){}},s=function(t,e){var r,s,o,a,h,l;if(this.type=c.ELEMENT,this.tag=t.tag,this.parentFragment=e,this.parentElement=e.parentElement,r=t.attributes.items,o=r.length){for(s=[],a=0;o>a;a+=1)e.options.sanitize&&e.options.sanitize.eventAttributes&&"on"===r[a].name.value.toLowerCase().substr(0,2)||(h={name:r[a].name.value},r[a].value.isNull||(h.value=n(r[a].value.tokens,this.parentFragment.priority+1)),s[a]=h);this.attributes=s}t.isSelfClosingTag||-1!==p.indexOf(t.tag.toLowerCase())||(l=e.preserveWhitespace||"pre"===this.tag.toLowerCase(),this.fragment=new i(this,e.priority+1,e.options,l))},s.prototype={read:function(t){return this.fragment&&this.fragment.read(t)},toJson:function(t){var e,i,n,r,s;if(e={type:c.ELEMENT,tag:this.tag},this.attributes)for(e.attrs={},s=0;this.attributes.length>s;s+=1)i=this.attributes[s].name,void 0===this.attributes[s].value?n=null:(r=""+this.attributes[s].value,n=r!==!1?r:this.attributes[s].value.toJson()),e.attrs[i]=n;return this.fragment&&this.fragment.items.length&&(e.frag=this.fragment.toJson(t)),e},toString:function(){var t,e,i,n,r,s,o;if(-1===d.indexOf(this.tag.toLowerCase()))return!1;if(s=this.fragment?""+this.fragment:"",s===!1)return!1;if(o=-1!==p.indexOf(this.tag.toLowerCase()),t="<"+this.tag,this.attributes)for(e=0,i=this.attributes.length;i>e;e+=1){if(-1!==this.attributes[e].name.indexOf(":"))return!1;if(n=" "+this.attributes[e].name,void 0!==this.attributes[e].value){if(r=""+this.attributes[e].value,r===!1)return!1;""!==r&&(n+="=",n+=/[\s"'=<>`]/.test(r)?'"'+r.replace(/"/g,""")+'"':r)}t+=n}return this.isSelfClosing&&!o?t+="/>":(t+=">",o?t:(t+=s,t+="</"+this.tag+">"))}},o=function(t,e){this.type=c.SECTION,this.parentFragment=e,this.ref=t.ref,this.inverted=t.type===c.INVERTED,this.formatters=t.formatters,this.i=t.i,this.fragment=new i(this,e.priority+1,e.options,e.preserveWhitespace)},o.prototype={read:function(t){return this.fragment.read(t)},toJson:function(t){var e;return e={type:c.SECTION,ref:this.ref},this.fragment&&(e.frag=this.fragment.toJson(t)),this.formatters&&this.formatters.length&&(e.fmtrs=this.formatters.map(u)),this.inverted&&(e.inv=!0),this.priority&&(e.p=this.parentFragment.priority),this.i&&(e.i=this.i),e},toString:function(){return!1}},a=function(t,e){this.type=t.type,this.priority=e,this.ref=t.ref,this.formatters=t.formatters},a.prototype={toJson:function(){var t={type:this.type,ref:this.ref};return this.formatters&&(t.fmtrs=this.formatters.map(u)),this.priority&&(t.p=this.priority),t},toString:function(){return!1}},i=function(t,e,i,n){this.owner=t,this.items=[],this.options=i,this.preserveWhitespace=n,t&&(this.parentElement=t.type===c.ELEMENT?t:t.parentElement),this.priority=e},i.prototype={read:function(t){if(this.sealed)return!1;if(this.isImplicitlyClosedBy(t))return this.seal(),!1;if(this.currentChild){if(this.currentChild.read(t))return!0;this.currentChild=null}return this.isExplicitlyClosedBy(t)?(this.seal(),!0):t.type===c.CLOSING||t.type===c.DELIMCHANGE||t.type===c.COMMENT?!1:t.type===c.SECTION||t.type===c.INVERTED?(this.currentChild=new o(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===c.TAG?(this.currentChild=new s(t,this),this.options.sanitize&&this.options.sanitize.elements&&-1!==this.options.sanitize.elements.indexOf(t.tag.toLowerCase())?!0:(this.items[this.items.length]=this.currentChild,!0)):t.type===c.TEXT||t.type===c.ATTR_VALUE_TOKEN?(this.items[this.items.length]=new r(t),!0):(this.items[this.items.length]=new a(t,this.priority),!0)},isClosedBy:function(t){return this.isImplicitlyClosedBy(t)||this.isExplicitlyClosedBy(t)},isImplicitlyClosedBy:function(t){var e,i,n,r,s;return t.tag&&this.owner&&this.owner.type===c.ELEMENT?(r=this.owner.tag.toLowerCase(),s=t.tag.toLowerCase(),i=this.owner,n=i.parentElement||null,e=m[r],e&&!t.isClosingTag&&-1!==e.indexOf(s)?!0:-1!==f.indexOf(r)&&n&&n.fragment.isClosedBy(t)?!0:"p"===r&&n&&"a"===n.tag.toLowerCase()&&n.fragment.isClosedBy(t)?!0:void 0):!1},isExplicitlyClosedBy:function(t){return this.owner?this.owner.type===c.SECTION&&t.type===c.CLOSING&&t.ref===this.owner.ref?!0:this.owner.type===c.ELEMENT&&this.owner&&t.isClosingTag&&t.tag.toLowerCase()===this.owner.tag.toLowerCase()?!0:void 0:!1},toJson:function(t){var e,i,n,r=[];if(!t&&(n=""+this,n!==!1))return n;for(e=0,i=this.items.length;i>e;e+=1)r[e]=this.items[e].toJson(t);return r},toString:function(){var t,e,i,n="";for(t=0,e=this.items.length;e>t;t+=1){if(i=""+this.items[t],i===!1)return!1;n+=i}return n},seal:function(){var t,e,i,n;if(this.sealed=!0,!this.preserveWhitespace)for(this.owner.type===c.ELEMENT&&(t=this.items[0],t&&t.type===c.TEXT&&(t.text=t.text.replace(/^\s*/,""),""===t.text&&this.items.shift()),e=this.items[this.items.length-1],e&&e.type===c.TEXT&&(e.text=e.text.replace(/\s*$/,""),""===e.text&&this.items.pop())),i=this.items.length;i--;)n=this.items[i],n.type===c.TEXT&&(n.text=n.text.replace(/\s{2,}/g," "));this.items.length||delete this.owner.fragment}},n=function(t,e,n,r){for(var s,o=new i(null,e,n,r);t.length;)s=t.shift(),o.read(s);return o}})(e,i),function(t,e){var i,n,r,s,o,a,h,l,u,c,p,d,f,m,g,v,y,w,b,N,x;e.tokenize=function(t){var e=a.fromString(r(t));return o(s(e.tokens))},a=function(){this.tokens=[],this.buffer=new h},a.prototype={read:function(t){var e,n;if(this.currentToken&&this.currentToken.type!==i.TEXT&&this.currentToken.read(t))return!0;if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(n=this.buffer.release(),this.currentToken){for(;n.length;){for(;n.length&&this.currentToken.read(n.charAt(0));)n=n.substring(1);n.length&&("<"===n.charAt(0)?(this.currentToken=new p,this.currentToken.read("<")):(this.currentToken=new l,this.currentToken.read(n.charAt(0))),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1))}return!0}return this.currentToken="<"===t?new p:new l,this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,!0},end:function(){this.buffer.isEmpty()||(this.tokens[this.tokens.length]=this.buffer.convert())}},a.fromString=function(t){var e,i,n;for(e=new a,i=0,n=t.length;n>i;)e.read(t.charAt(i)),i+=1;return e.end(),e},h=function(){this.value=""},h.prototype={read:function(e){var i;return this.value+=e,i=this.isPartialMatchOf(t.delimiters[0])||this.isPartialMatchOf(t.tripleDelimiters[0])},convert:function(){var e,i,n,r,s,o;if(i=t.delimiters[0],n=t.tripleDelimiters[0],e=this.value,s=function(){return 0===e.indexOf(n)?new c:void 0},o=function(){return 0===e.indexOf(i)?new u:void 0},r=n.length>i.length?s()||o():o()||s()){for(;this.value.length;)r.read(this.value.charAt(0)),this.value=this.value.substring(1);return r}return!1},release:function(){var t=this.value;return this.value="",t},isEmpty:function(){return!this.value.length},isPartialMatchOf:function(t){return 0===t.indexOf(this.value)}},l=function(){this.type=i.TEXT,this.value=""},l.prototype={read:function(t){return this.sealed?!1:"<"===t?!1:(this.value+=t,!0)},seal:function(){this.sealed=!0}},u=function(){this.value="",this.openingDelimiter=t.delimiters[0],this.closingDelimiter=t.delimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length},c=function(){this.value="",this.openingDelimiter=t.tripleDelimiters[0],this.closingDelimiter=t.tripleDelimiters[1],this.minLength=this.openingDelimiter.length+this.closingDelimiter.length,this.type=i.TRIPLE},u.prototype=c.prototype={read:function(t){return this.sealed?!1:(this.value+=t,this.value.length>=this.minLength&&this.value.substr(-this.closingDelimiter.length)===this.closingDelimiter&&this.seal(),!0)},seal:function(){var t,e,n,r,s;this.sealed||(t=this.value.replace(this.openingDelimiter,"").replace(this.closingDelimiter,"").trim(),"="===t.charAt(0)&&(this.changeDelimiters(t),this.type=i.DELIMCHANGE),this.type||(e=t.charAt(0),f[e]?(this.type=f[e],t=t.substring(1).trim()):this.type=i.INTERPOLATOR),this.type===i.SECTION&&(r=/:\s*([a-zA-Z_$][a-zA-Z0-9_$]*)$/,s=r.exec(t),s&&(this.i=s[1],t=t.substr(0,t.length-s[0].length))),n=t.split("|"),this.ref=n.shift().trim(),n.length&&(this.formatters=n.map(function(t){return t.trim()})),this.sealed=!0)},changeDelimiters:function(e){var n,r;r=/\=\s*([^\s=]+)\s+([^\s=]+)\s*=/.exec(e),n=this.type===i.TRIPLE?t.tripleDelimiters:t.delimiters,n[0]=r[1],n[1]=r[2]}},p=function(){this.type=i.TAG,this.openingBracket=new m,this.closingTagSolidus=new y,this.tagName=new g,this.attributes=new v,this.selfClosingSolidus=new y,this.closingBracket=new w},p.prototype={read:function(t){var e;return this.sealed?!1:(e=this.openingBracket.read(t)||this.closingTagSolidus.read(t)||this.tagName.read(t)||this.attributes.read(t)||this.selfClosingSolidus.read(t)||this.closingBracket.read(t))?(this.closingBracket.sealed&&this.seal(),!0):(this.seal(),!1)},seal:function(){this.tag=this.tagName.value,this.closingTagSolidus.value&&(this.isClosingTag=!0),this.selfClosingSolidus.value&&(this.isSelfClosingTag=!0),this.sealed=!0}},m=function(){},m.prototype={read:function(t){if(this.sealed)return!1;if("<"===t)return this.value="<",this.seal(),!0;throw'Expected "<", saw "'+t+'"'},seal:function(){this.sealed=!0}},g=function(){},g.prototype={read:function(t){return this.sealed?!1:!this.value&&/[a-zA-Z]/.test(t)?(this.value=t,!0):/[a-zA-Z0-9\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},v=function(){this.items=[]},v.prototype={read:function(t){return this.sealed?!1:this.nextItem&&this.nextItem.read(t)?!0:n.test(t)?!0:(this.nextItem=new b,this.nextItem.read(t)?(this.items[this.items.length]=this.nextItem,!0):(this.seal(),!1))},seal:function(){this.sealed=!0}},b=function(){this.name=new N,this.value=new x},b.prototype={read:function(t){return this.sealed?!1:this.name.read(t)?!0:this.name.value?this.value.read(t)?!0:(this.seal(),!1):(this.seal(),!1)},seal:function(){this.sealed=!0}},N=function(){},N.prototype={read:function(t){return this.sealed?!1:this.value?/[_:a-zA-Z0-9\.\-]/.test(t)?(this.value+=t,!0):(this.seal(),!1):/[a-zA-Z_:]/.test(t)?(this.value=t,!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},x=function(){this.tokens=[],this.buffer=new h,this.isNull=!0},x.prototype={read:function(t){var e,i;if(this.sealed)return!1;if(this.isNull)return n.test(t)?!0:"="===t?(this.isNull=!1,!0):!1;if(!this.tokens.length&&!this.quoteMark){if(n.test(t))return!0;if('"'===t||"'"===t)return this.quoteMark=t,!0}if(this.buffer.read(t))return!0;if(e=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=e,!0;if(i=this.buffer.release(),this.currentToken){for(;i.length;){for(;i.length&&i.charAt(0)!==this.quoteMark&&this.currentToken.read(i.charAt(0));)i=i.substring(1);if(i.length){if(">"===i.charAt(0))return this.seal(),!1;if(i.charAt(0)===this.quoteMark)return this.currentToken.seal(),this.seal(),!0;this.currentToken=new d(this.quoteMark),this.currentToken.read(i.charAt(0)),this.tokens[this.tokens.length]=this.currentToken,i=i.substring(1)}}return!0}return this.currentToken=new d(this.quoteMark),this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,this.currentToken.sealed&&this.seal(),!0},seal:function(){this.sealed=!0}},d=function(t){this.type=i.ATTR_VALUE_TOKEN,this.quoteMark=t||"",this.value=""},d.prototype={read:function(t){return this.sealed?!1:t===this.quoteMark?(this.seal(),!0):this.quoteMark?(this.value+=t,!0):/[\s"'=<>`]/.test(t)?(this.seal(),!1):(this.value+=t,!0)},seal:function(){this.sealed=!0}},y=function(){},y.prototype={read:function(t){return this.sealed?!1:"/"===t?(this.value="/",this.seal(),!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},w=function(){},w.prototype={read:function(t){if(this.sealed)return!1;if(">"===t)return this.value=">",this.seal(),!0;throw'Expected ">", received "'+t+'"'},seal:function(){this.sealed=!0}},r=function(t){var e,i,n;for(n="";t.length;){if(e=t.indexOf("<!--"),i=t.indexOf("-->"),-1===e&&-1===i){n+=t;break}if(-1!==e&&-1===i)throw"Illegal HTML - expected closing comment sequence ('-->')";if(-1!==i&&-1===e||e>i)throw"Illegal HTML - unexpected closing comment sequence ('-->')";n+=t.substr(0,e),t=t.substring(i+3)}return n},s=function(t){var e,n,r,s,o,a;for(o=/^\s*\r?\n/,a=/\r?\n\s*$/,e=2;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e-2],n.type===i.TEXT&&r.type!==i.TAG&&s.type===i.TEXT&&a.test(s.value)&&o.test(n.value)&&(r.type!==i.INTERPOLATOR&&r.type!==i.TRIPLE&&(s.value=s.value.replace(a,"\n")),n.value=n.value.replace(o,""),""===n.value&&t.splice(e--,1));return t},o=function(t){var e,n,r,s;for(e=0;t.length>e;e+=1)n=t[e],r=t[e-1],s=t[e+1],n.type===i.COMMENT&&(t.splice(e,1),r&&s&&r.type===i.TEXT&&s.type===i.TEXT&&(r.value+=s.value,t.splice(e,1)),e-=1);return t},i=e.types,n=/\s/,f={"#":i.SECTION,"^":i.INVERTED,"/":i.CLOSING,">":i.PARTIAL,"!":i.COMMENT,"&":i.INTERPOLATOR}}(e,i),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t){var e,i,n,r,s,o,a,h,l,u,c;e=t.types,r={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},n="undefined"!=typeof window?window.document:null,i=function(t,e){var i,r=[];for(i=n.createElement("div"),i.innerHTML=t;i.firstChild;)r[r.length]=i.firstChild,e.appendChild(i.firstChild);return r},t.DomFragment=function(e){return this.docFrag=n.createDocumentFragment(),"string"==typeof e.model?(this.nodes=i(e.model,this.docFrag),void 0):(t.Fragment.call(this,e),void 0)},t.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new s(t,this.docFrag);switch(t.model.type){case e.INTERPOLATOR:return new l(t,this.docFrag);case e.SECTION:return new c(t,this.docFrag);case e.TRIPLE:return new u(t,this.docFrag);case e.ELEMENT:return new o(t,this.docFrag);case e.PARTIAL:return new a(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},a=function(e,i){this.fragment=new t.DomFragment({model:e.root.partials[e.model.ref]||[],root:e.root,parentNode:e.parentNode,contextStack:e.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},a.prototype={teardown:function(){this.fragment.teardown()}},s=function(t,e){this.node=n.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},s.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(e,i){var r,s,o,a,l,u,c;if(r=this.model=e.model,this.root=e.root,this.parentFragment=e.parentFragment,this.parentNode=e.parentNode,this.index=e.index,r.attrs&&r.attrs.xmlns){if(s=r.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=n.createElementNS(s,r.tag),r.frag&&("string"==typeof r.frag&&this.node.namespaceURI===t.namespaces.html?this.node.innerHTML=r.frag:(this.children=new t.DomFragment({model:r.frag,root:e.root,parentNode:this.node,contextStack:e.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],u=[];for(a in r.attrs)r.attrs.hasOwnProperty(a)&&(l=r.attrs[a],o=new h({parent:this,name:a,value:void 0===l?null:l,root:e.root,parentNode:this.node,contextStack:e.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&u.push(o),o.isTwowayNameAttr?c=o:o.update());for(;u.length;)u.pop().bind(this.root.lazy);c&&(c.updateViewModel(),c.update()),i.appendChild(this.node)},o.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},h=function(e){var i,n,s,o,a,h,l,u;if(i=e.name,n=e.value,this.parent=e.parent,s=i.indexOf(":"),-1!==s&&(o=i.substr(0,s),"xmlns"!==o&&(i=i.substring(s+1),this.namespace=t.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?e.parentNode.setAttributeNS(this.namespace,i,n):e.parentNode.setAttribute(i,n),void 0):(this.root=e.root,this.parentNode=e.parentNode,this.name=i,this.children=[],this.namespace||e.parentNode.namespaceURI!==t.namespaces.html||(l=this.name.toLowerCase(),u=r[l]||l,void 0!==e.parentNode[u]&&(this.propertyName=u),("boolean"==typeof e.parentNode[u]||"value"===u)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new t.TextFragment({model:n,root:this.root,parent:this,contextStack:e.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==u&&"value"!==u&&"checked"!==u||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===u&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0) | ||
},h.prototype={bind:function(e){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==t.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),e||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root._deferredAttributes[this.root._deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(n.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},l=function(e,i){this.node=n.createTextNode(""),i.appendChild(this.node),t.Mustache.call(this,e)},l.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},u=function(e,i){this.nodes=[],this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},u.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=i(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},c=function(e,i){this.fragments=[],this.length=0,this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(e){t.sectionUpdate.call(this,e),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(e){var i=new t.DomFragment(e);return this.docFrag.appendChild(i.docFrag),i}}}(i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t.Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t.Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t.Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t.sectionUpdate.call(this,e),this.value=this.fragments.join(""),this.parent.bubble()},createFragment:function(e){return new t.TextFragment(e)},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e,i){var n;for(n=0;t.length>n&&!i.requestAnimationFrame;++n)i.requestAnimationFrame=i[t[n]+"RequestAnimationFrame"],i.cancelAnimationFrame=i[t[n]+"CancelAnimationFrame"]||i[t[n]+"CancelRequestAnimationFrame"];i.requestAnimationFrame||(i.requestAnimationFrame=function(t){var n,r,s;return n=Date.now(),r=Math.max(0,16-(n-e)),s=i.setTimeout(function(){t(n+r)},r),e=n+r,s}),i.cancelAnimationFrame||(i.cancelAnimationFrame=function(t){i.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,l,u,c;for(o=o||{},u=n.animations.length;u--;)n.animations[u].keypath===r&&n.animations[u].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,c=e.splitKeypath(r),l=new i({keys:c,from:this.get(c),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(l)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this); |
@@ -1,2 +0,2 @@ | ||
/*! Ractive - v0.2.0 - 2013-04-18 | ||
/*! Ractive - v0.2.1 - 2013-04-20 | ||
* Faster, easier, better interactive web development | ||
@@ -15,3 +15,3 @@ | ||
var Ractive; | ||
var Ractive, _internal; | ||
@@ -69,13 +69,8 @@ (function () { | ||
// Set up observers | ||
this.observers = {}; | ||
this.pendingResolution = []; | ||
this._observers = {}; | ||
this._pendingResolution = []; | ||
// Create an array for deferred attributes | ||
this.deferredAttributes = []; | ||
this._deferredAttributes = []; | ||
// Initialise (or update) viewmodel with data | ||
if ( this.data ) { | ||
this.set( this.data ); | ||
} | ||
// If we were given uncompiled partials, compile them | ||
@@ -113,3 +108,3 @@ if ( this.partials ) { | ||
if ( this.el ) { | ||
this.render({ el: this.el, callback: this.callback, append: this.append }); | ||
this.render({ el: this.el, append: this.append }); | ||
} | ||
@@ -142,3 +137,3 @@ }; | ||
// Render our *root fragment* | ||
this.rendered = new _private.DomFragment({ | ||
this.rendered = new _internal.DomFragment({ | ||
model: this.template, | ||
@@ -159,3 +154,3 @@ root: this, | ||
set: function ( keypath, value ) { | ||
if ( _private.isObject( keypath ) ) { | ||
if ( _internal.isObject( keypath ) ) { | ||
this._setMultiple( keypath ); | ||
@@ -166,4 +161,7 @@ } else { | ||
while ( this.deferredAttributes.length ) { | ||
this.deferredAttributes.pop().update().updateDeferred = false; | ||
// Attributes don't reflect changes automatically if there is a possibility | ||
// that they will need to change again before the .set() cycle is complete | ||
// - they defer their updates until all values have been set | ||
while ( this._deferredAttributes.length ) { | ||
this._deferredAttributes.pop().update().updateDeferred = false; | ||
} | ||
@@ -173,8 +171,8 @@ }, | ||
_setSingle: function ( keypath, value ) { | ||
var keys, key, obj, normalised, i, resolved, unresolved; | ||
var keys, key, obj, normalised, i, unresolved; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); | ||
} else { | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
} | ||
@@ -184,3 +182,3 @@ | ||
// clear cache | ||
// Clear cache | ||
this._clearCache( normalised ); | ||
@@ -193,3 +191,3 @@ | ||
// if this branch doesn't exist yet, create a new one - if the next | ||
// If this branch doesn't exist yet, create a new one - if the next | ||
// key matches /^[0-9]+$/, assume we want an array branch rather | ||
@@ -208,3 +206,3 @@ // than an object | ||
// fire set event | ||
// Fire set event | ||
if ( !this.setting ) { | ||
@@ -217,21 +215,15 @@ this.setting = true; // short-circuit any potential infinite loops | ||
// Trigger updates of views that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised, value ); | ||
// Trigger updates of mustaches that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised ); | ||
// See if we can resolve any of the unresolved keypaths (if such there be) | ||
i = this.pendingResolution.length; | ||
i = this._pendingResolution.length; | ||
while ( i-- ) { // Work backwards, so we don't go in circles! | ||
unresolved = this.pendingResolution.splice( i, 1 )[0]; | ||
unresolved = this._pendingResolution.splice( i, 1 )[0]; | ||
resolved = this.resolveRef( unresolved.view.model.ref, unresolved.view.contextStack ); | ||
// If we were able to find a keypath, initialise the view | ||
if ( resolved ) { | ||
unresolved.callback( resolved.keypath, resolved.value ); | ||
// If we can't resolve the reference, add to the back of | ||
// the queue (this is why we're working backwards) | ||
if ( !this.resolveRef( unresolved ) ) { | ||
this._pendingResolution[ this._pendingResolution.length ] = unresolved; | ||
} | ||
// Otherwise add to the back of the queue (this is why we're working backwards) | ||
else { | ||
this.registerUnresolvedKeypath( unresolved ); | ||
} | ||
} | ||
@@ -265,5 +257,5 @@ }, | ||
get: function ( keypath ) { | ||
var keys, normalised, lastDotIndex, formula, match, parentKeypath, parentValue, propertyName, unformatted, unformattedKeypath, value, formatters; | ||
var keys, normalised, key, match, parentKeypath, parentValue, value, formatters; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); // clone | ||
@@ -275,7 +267,7 @@ normalised = keys.join( '.' ); | ||
// cache hit? great | ||
if ( keypath in this._cache ) { | ||
if ( this._cache.hasOwnProperty( keypath ) ) { | ||
return this._cache[ keypath ]; | ||
} | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
normalised = keys.join( '.' ); | ||
@@ -285,3 +277,3 @@ } | ||
// we may have a cache hit now that it's been normalised | ||
if ( normalised in this._cache ) { | ||
if ( this._cache.hasOwnProperty( normalised ) ) { | ||
return this._cache[ normalised ]; | ||
@@ -291,13 +283,8 @@ } | ||
// otherwise it looks like we need to do some work | ||
if ( keys.length > 1 ) { | ||
formula = keys.pop(); | ||
parentValue = this.get( keys ); | ||
} else { | ||
formula = keys.pop(); | ||
parentValue = this.data; | ||
} | ||
key = keys.pop(); | ||
parentValue = ( keys.length ? this.get( keys ) : this.data ); | ||
// is this a set of formatters? | ||
if ( match = /^⭆(.+)⭅$/.exec( formula ) ) { | ||
formatters = _private.getFormattersFromString( match[1] ); | ||
if ( match = /^⭆(.+)⭅$/.exec( key ) ) { | ||
formatters = _internal.getFormattersFromString( match[1] ); | ||
value = this._format( parentValue, formatters ); | ||
@@ -307,7 +294,7 @@ } | ||
else { | ||
if ( typeof parentValue !== 'object' ) { | ||
if ( typeof parentValue !== 'object' || !parentValue.hasOwnProperty( key ) ) { | ||
return; | ||
} | ||
value = parentValue[ formula ]; | ||
value = parentValue[ key ]; | ||
} | ||
@@ -325,4 +312,3 @@ | ||
// allow functions as values | ||
// TODO allow arguments, same as formatters? | ||
// Allow functions as values | ||
if ( typeof value === 'function' ) { | ||
@@ -332,3 +318,3 @@ value = value(); | ||
// update cache | ||
// Update cache | ||
this._cache[ normalised ] = value; | ||
@@ -339,5 +325,9 @@ | ||
update: function () { | ||
// TODO | ||
throw new Error( 'not implemented yet!' ); | ||
update: function ( keypath ) { | ||
this._clearCache( keypath ); | ||
this._notifyObservers( keypath ); | ||
this.fire( 'update:' + keypath ); | ||
this.fire( 'update', keypath ); | ||
return this; | ||
@@ -354,44 +344,28 @@ }, | ||
registerView: function ( view ) { | ||
var self = this, resolved, initialUpdate, value, index; | ||
registerMustache: function ( mustache ) { | ||
var resolved, value, index; | ||
if ( view.parentFragment && ( view.parentFragment.indexRefs.hasOwnProperty( view.model.ref ) ) ) { | ||
// this isn't a real keypath, it's an index reference | ||
index = view.parentFragment.indexRefs[ view.model.ref ]; | ||
if ( mustache.parentFragment && ( mustache.parentFragment.indexRefs.hasOwnProperty( mustache.model.ref ) ) ) { | ||
// This isn't a real keypath, it's an index reference | ||
index = mustache.parentFragment.indexRefs[ mustache.model.ref ]; | ||
value = ( view.model.fmtrs ? this._format( index, view.model.fmtrs ) : index ); | ||
view.update( value ); | ||
value = ( mustache.model.fmtrs ? this._format( index, mustache.model.fmtrs ) : index ); | ||
mustache.update( value ); | ||
return; // this value will never change, and doesn't have a keypath | ||
return; // This value will never change, and doesn't have a keypath | ||
} | ||
initialUpdate = function ( keypath, value ) { | ||
if ( view.model.fmtrs ) { | ||
view.keypath = keypath + '.' + _private.stringifyFormatters( view.model.fmtrs ); | ||
} else { | ||
view.keypath = keypath; | ||
} | ||
// See if we can resolve a keypath from this mustache's reference (e.g. | ||
// does 'bar' in {{#foo}}{{bar}}{{/foo}} mean 'bar' or 'foo.bar'?) | ||
resolved = this.resolveRef( mustache ); | ||
// create observers | ||
view.observerRefs = self.observe( view.model.p || 0, view ); | ||
view.update( self.get( view.keypath ) ); | ||
}; | ||
resolved = this.resolveRef( view.model.ref, view.contextStack ); | ||
if ( !resolved ) { | ||
// we may still need to do an update, if the view has formatters | ||
// that e.g. offer an alternative to undefined | ||
if ( view.model.fmtrs ) { | ||
view.update( this._format( undefined, view.model.fmtrs ) ); | ||
// We may still need to do an update, event with unresolved | ||
// references, if the mustache has formatters that (for example) | ||
// provide a fallback value from undefined | ||
if ( mustache.model.fmtrs ) { | ||
mustache.update( this._format( undefined, mustache.model.fmtrs ) ); | ||
} | ||
this.registerUnresolvedKeypath({ | ||
view: view, | ||
callback: initialUpdate | ||
}); | ||
} else { | ||
initialUpdate( resolved.keypath, resolved.value ); | ||
this._pendingResolution[ this._pendingResolution.length ] = mustache; | ||
} | ||
@@ -402,38 +376,51 @@ }, | ||
// `'bar.baz'` within the context stack `['foo']` might resolve to `'foo.bar.baz'` | ||
resolveRef: function ( ref, contextStack ) { | ||
resolveRef: function ( mustache ) { | ||
var innerMost, keypath, value; | ||
var ref, contextStack, keys, lastKey, innerMostContext, contextKeys, parentValue, keypath; | ||
ref = mustache.model.ref; | ||
contextStack = mustache.contextStack; | ||
// Implicit iterators - i.e. {{.}} - are a special case | ||
if ( ref === '.' ) { | ||
keypath = contextStack[ contextStack.length - 1 ]; | ||
value = this.get( keypath ); | ||
return { keypath: keypath, value: value }; | ||
} | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
else { | ||
keys = _internal.splitKeypath( ref ); | ||
lastKey = keys.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
innerMost = contextStack.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
keypath = innerMost + '.' + ref; | ||
value = this.get( keypath ); | ||
innerMostContext = contextStack.pop(); | ||
contextKeys = _internal.splitKeypath( innerMostContext ); | ||
if ( value !== undefined ) { | ||
return { keypath: keypath, value: value }; | ||
parentValue = this.get( contextKeys.concat( keys ) ); | ||
if ( typeof parentValue === 'object' && parentValue.hasOwnProperty( lastKey ) ) { | ||
keypath = innerMostContext + '.' + ref; | ||
break; | ||
} | ||
} | ||
if ( !keypath && this.get( ref ) !== undefined ) { | ||
keypath = ref; | ||
} | ||
} | ||
value = this.get( ref ); | ||
if ( value !== undefined ) { | ||
return { keypath: ref, value: value }; | ||
// If we have any formatters, we need to append them to the keypath | ||
if ( keypath ) { | ||
mustache.keypath = ( mustache.model.fmtrs ? keypath + '.' + _internal.stringifyFormatters( mustache.model.fmtrs ) : keypath ); | ||
mustache.observerRefs = this.observe( mustache ); | ||
mustache.update( this.get( mustache.keypath ) ); | ||
return true; // indicate success | ||
} | ||
}, | ||
registerUnresolvedKeypath: function ( unresolved ) { | ||
this.pendingResolution[ this.pendingResolution.length ] = unresolved; | ||
return false; // failure | ||
}, | ||
@@ -472,4 +459,4 @@ | ||
_notifyObservers: function ( keypath, value ) { | ||
var self = this, observersGroupedByPriority = this.observers[ keypath ] || [], i, j, priorityGroup, observer, actualValue; | ||
_notifyObservers: function ( keypath ) { | ||
var self = this, observersGroupedByPriority = this._observers[ keypath ] || [], i, j, priorityGroup, observer; | ||
@@ -488,29 +475,26 @@ for ( i=0; i<observersGroupedByPriority.length; i+=1 ) { | ||
observe: function ( priority, view ) { | ||
observe: function ( mustache ) { | ||
var self = this, keypath, originalKeypath = view.keypath, observerRefs = [], observe, keys; | ||
var self = this, observerRefs = [], observe, keys, priority = mustache.model.p || 0; | ||
if ( !originalKeypath ) { | ||
return undefined; | ||
} | ||
observe = function ( keypath ) { | ||
var observers, observer; | ||
var observers; | ||
observers = self.observers[ keypath ] = self.observers[ keypath ] || []; | ||
observers = self._observers[ keypath ] = self._observers[ keypath ] || []; | ||
observers = observers[ priority ] = observers[ priority ] || []; | ||
observers[ observers.length ] = view; | ||
observers[ observers.length ] = mustache; | ||
observerRefs[ observerRefs.length ] = { | ||
keypath: keypath, | ||
priority: priority, | ||
view: view | ||
mustache: mustache | ||
}; | ||
}; | ||
keys = _private.splitKeypath( view.keypath ); | ||
keys = _internal.splitKeypath( mustache.keypath ); | ||
while ( keys.length > 1 ) { | ||
observe( keys.join( '.' ) ); | ||
// remove the last item in the keypath, so that data.set( 'parent', { child: 'newValue' } ) affects views dependent on parent.child | ||
// remove the last item in the keypath, so that `data.set( 'parent', { child: 'newValue' } )` | ||
// affects mustaches dependent on `parent.child` | ||
keys.pop(); | ||
@@ -525,6 +509,6 @@ } | ||
unobserve: function ( observerRef ) { | ||
var priorities, observers, index, i, len; | ||
var priorityGroups, observers, index, i, len; | ||
priorities = this.observers[ observerRef.keypath ]; | ||
if ( !priorities ) { | ||
priorityGroups = this._observers[ observerRef.keypath ]; | ||
if ( !priorityGroups ) { | ||
// nothing to unobserve | ||
@@ -534,3 +518,3 @@ return; | ||
observers = priorities[ observerRef.priority ]; | ||
observers = priorityGroups[ observerRef.priority ]; | ||
if ( !observers ) { | ||
@@ -546,3 +530,3 @@ // nothing to unobserve | ||
for ( i=0, len=observers.length; i<len; i+=1 ) { | ||
if ( observers[i] === observerRef.view ) { | ||
if ( observers[i] === observerRef.mustache ) { | ||
index = i; | ||
@@ -565,7 +549,7 @@ break; | ||
if ( observers.length === 0 ) { | ||
delete priorities[ observerRef.priority ]; | ||
delete priorityGroups[ observerRef.priority ]; | ||
} | ||
if ( priorities.length === 0 ) { | ||
delete this.observers[ observerRef.keypath ]; | ||
if ( priorityGroups.length === 0 ) { | ||
delete this._observers[ observerRef.keypath ]; | ||
} | ||
@@ -628,4 +612,2 @@ }, | ||
}()); | ||
var _private; | ||
(function () { | ||
@@ -635,5 +617,5 @@ | ||
var formattersCache = {}; | ||
var formattersCache = {}, keypathCache = {}; | ||
_private = { | ||
_internal = { | ||
// thanks, http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ | ||
@@ -644,3 +626,2 @@ isArray: function ( obj ) { | ||
// TODO what about non-POJOs? | ||
isObject: function ( obj ) { | ||
@@ -655,10 +636,16 @@ return ( Object.prototype.toString.call( obj ) === '[object Object]' ) && ( typeof obj !== 'function' ); | ||
// TODO this is a bit regex-heavy... could be optimised maybe? | ||
splitKeypath: function ( keypath ) { | ||
var result, hasEscapedDots, hasFormatters, formatters, split, i, replacer, index, startIndex, key, keys, remaining, blanked, part; | ||
var hasFormatters, formatters, i, index, startIndex, keys, remaining, part; | ||
// if this string contains no escaped dots or formatters, | ||
// We should only have to do all the heavy regex stuff once... caching FTW | ||
if ( keypathCache[ keypath ] ) { | ||
return keypathCache[ keypath ].concat(); | ||
} | ||
// If this string contains no escaped dots or formatters, | ||
// we can just split on dots, after converting from array notation | ||
if ( !( hasEscapedDots = /\\\./.test( keypath ) ) && !( hasFormatters = /⭆.+⭅/.test( keypath ) ) ) { | ||
return keypath.replace( /\[\s*([0-9]+)\s*\]/g, '.$1' ).split( '.' ); | ||
hasFormatters = /⭆.+⭅/.test( keypath ); | ||
if ( !( /\\\./.test( keypath ) ) && !hasFormatters ) { | ||
keypathCache[ keypath ] = keypath.replace( /\[\s*([0-9]+)\s*\]/g, '.$1' ).split( '.' ); | ||
return keypathCache[ keypath ].concat(); | ||
} | ||
@@ -674,4 +661,2 @@ | ||
remaining = remaining.replace( /⭆(.+)⭅/g, function ( match, $1 ) { | ||
var blanked, i; | ||
formatters[ formatters.length ] = $1; | ||
@@ -685,10 +670,9 @@ return '⭆x⭅'; | ||
// split into keys | ||
// Split into keys | ||
while ( remaining.length ) { | ||
// find next dot | ||
// Find next dot | ||
index = remaining.indexOf( '.', startIndex ); | ||
// final part? | ||
// Final part? | ||
if ( index === -1 ) { | ||
// TODO tidy up! | ||
part = remaining; | ||
@@ -699,3 +683,3 @@ remaining = ''; | ||
else { | ||
// if this dot is preceded by a backslash, which isn't | ||
// If this dot is preceded by a backslash, which isn't | ||
// itself preceded by a backslash, we consider it escaped | ||
@@ -709,3 +693,3 @@ if ( remaining.charAt( index - 1) === '\\' && remaining.charAt( index - 2 ) !== '\\' ) { | ||
// otherwise, we have our next part | ||
// Otherwise, we have our next part | ||
part = remaining.substr( 0, index ); | ||
@@ -725,8 +709,4 @@ startIndex = 0; | ||
// then, reinstate formatters | ||
// Then, reinstate formatters | ||
if ( hasFormatters ) { | ||
replacer = function ( match ) { | ||
return '⭆' + formatters.pop() + '⭅'; | ||
}; | ||
i = keys.length; | ||
@@ -740,7 +720,8 @@ while ( i-- ) { | ||
return keys; | ||
keypathCache[ keypath ] = keys; | ||
return keys.concat(); | ||
}, | ||
getFormattersFromString: function ( str ) { | ||
var formatters, raw, remaining; | ||
var formatters, raw; | ||
@@ -789,3 +770,3 @@ if ( formattersCache[ str ] ) { | ||
}()); | ||
_private.types = { | ||
_internal.types = { | ||
TEXT: 1, | ||
@@ -805,7 +786,7 @@ INTERPOLATOR: 2, | ||
}; | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
'use strict'; | ||
_private._Mustache = function ( options ) { | ||
_internal.Mustache = function ( options ) { | ||
@@ -827,3 +808,3 @@ this.root = options.root; | ||
this.root.registerView( this ); | ||
this.root.registerMustache( this ); | ||
@@ -833,3 +814,3 @@ // if we have a failed keypath lookup, and this is an inverted section, | ||
if ( !this.keypath && this.model.inv ) { // test both section-hood and inverticity in one go | ||
this.update( false ); | ||
this.update( this.model.fmtrs ? this.root._format( false, this.model.fmtrs ) : false ); | ||
} | ||
@@ -840,3 +821,3 @@ | ||
_private._Fragment = function ( options ) { | ||
_internal.Fragment = function ( options ) { | ||
@@ -883,3 +864,3 @@ var numItems, i, itemOptions, parentRefs, ref; | ||
_private._sectionUpdate = function ( value ) { | ||
_internal.sectionUpdate = function ( value ) { | ||
var fragmentOptions, valueIsArray, emptyArray, i, itemsToRemove; | ||
@@ -899,7 +880,7 @@ | ||
valueIsArray = _private.isArray( value ); | ||
valueIsArray = _internal.isArray( value ); | ||
// modify the array to allow updates via push, pop etc | ||
if ( valueIsArray && this.root.modifyArrays ) { | ||
_private.modifyArray( value, this.keypath, this.root ); | ||
_internal.modifyArray( value, this.keypath, this.root ); | ||
} | ||
@@ -935,6 +916,2 @@ | ||
if ( this.postUpdate ) { | ||
this.postUpdate(); | ||
} | ||
return; | ||
@@ -982,3 +959,3 @@ } | ||
// if value is a hash... | ||
else if ( _private.isObject( value ) ) { | ||
else if ( _internal.isObject( value ) ) { | ||
// ...then if it isn't rendered, render it, adding this.keypath to the context stack | ||
@@ -1019,15 +996,6 @@ // (if it is already rendered, then any children dependent on the context stack | ||
} | ||
if ( this.postUpdate ) { | ||
this.postUpdate(); | ||
} | ||
}; | ||
}( _private )); | ||
}( _internal )); | ||
(function ( proto ) { | ||
@@ -1119,3 +1087,3 @@ | ||
}( Ractive )); | ||
(function ( R, _private ) { | ||
(function ( _internal ) { | ||
@@ -1127,3 +1095,3 @@ 'use strict'; | ||
types = _private.types; | ||
types = _internal.types; | ||
@@ -1170,3 +1138,3 @@ // the property name equivalents for element attributes, where they differ | ||
_private.DomFragment = function ( options ) { | ||
_internal.DomFragment = function ( options ) { | ||
this.docFrag = doc.createDocumentFragment(); | ||
@@ -1181,6 +1149,6 @@ | ||
// otherwise we need to make a proper fragment | ||
_private._Fragment.call( this, options ); | ||
_internal.Fragment.call( this, options ); | ||
}; | ||
_private.DomFragment.prototype = { | ||
_internal.DomFragment.prototype = { | ||
createItem: function ( options ) { | ||
@@ -1243,3 +1211,3 @@ if ( typeof options.model === 'string' ) { | ||
Partial = function ( options, docFrag ) { | ||
this.fragment = new _private.DomFragment({ | ||
this.fragment = new _internal.DomFragment({ | ||
model: options.root.partials[ options.model.ref ] || [], | ||
@@ -1287,4 +1255,3 @@ root: options.root, | ||
var binding, | ||
model, | ||
var model, | ||
namespace, | ||
@@ -1295,4 +1262,3 @@ attr, | ||
bindable, | ||
twowayNameAttr, | ||
i; | ||
twowayNameAttr; | ||
@@ -1327,3 +1293,3 @@ // stuff we'll need later | ||
if ( model.frag ) { | ||
if ( typeof model.frag === 'string' ) { | ||
if ( typeof model.frag === 'string' && this.node.namespaceURI === _internal.namespaces.html ) { | ||
// great! we can use innerHTML | ||
@@ -1334,3 +1300,3 @@ this.node.innerHTML = model.frag; | ||
else { | ||
this.children = new _private.DomFragment({ | ||
this.children = new _internal.DomFragment({ | ||
model: model.frag, | ||
@@ -1415,3 +1381,3 @@ root: options.root, | ||
var name, value, colonIndex, namespacePrefix, namespace, ancestor, tagName, bindingCandidate, lowerCaseName, propertyName; | ||
var name, value, colonIndex, namespacePrefix, tagName, bindingCandidate, lowerCaseName, propertyName; | ||
@@ -1433,3 +1399,3 @@ name = options.name; | ||
name = name.substring( colonIndex + 1 ); | ||
this.namespace = _private.namespaces[ namespacePrefix ]; | ||
this.namespace = _internal.namespaces[ namespacePrefix ]; | ||
@@ -1463,5 +1429,5 @@ if ( !this.namespace ) { | ||
// can we establish this attribute's property name equivalent? | ||
if ( !this.namespace && options.parentNode.namespaceURI === _private.namespaces.html ) { | ||
if ( !this.namespace && options.parentNode.namespaceURI === _internal.namespaces.html ) { | ||
lowerCaseName = this.name.toLowerCase(); | ||
propertyName = ( propertyNames[ lowerCaseName ] ? propertyNames[ lowerCaseName ] : lowerCaseName ); | ||
propertyName = propertyNames[ lowerCaseName ] || lowerCaseName; | ||
@@ -1482,3 +1448,3 @@ if ( options.parentNode[ propertyName ] !== undefined ) { | ||
this.fragment = new _private.TextFragment({ | ||
this.fragment = new _internal.TextFragment({ | ||
model: value, | ||
@@ -1525,3 +1491,3 @@ root: this.root, | ||
// two-way binding logic should go here | ||
var self = this, node = this.parentNode, setValue, keypath, index; | ||
var self = this, node = this.parentNode, keypath, index; | ||
@@ -1536,3 +1502,3 @@ if ( !this.fragment ) { | ||
this.fragment.items.length !== 1 || | ||
this.fragment.items[0].type !== _private.types.INTERPOLATOR | ||
this.fragment.items[0].type !== _internal.types.INTERPOLATOR | ||
) { | ||
@@ -1682,3 +1648,3 @@ throw 'Not a valid two-way data binding candidate - must be a single interpolator'; | ||
else if ( !this.updateDeferred ) { | ||
this.root.deferredAttributes[ this.root.deferredAttributes.length ] = this; | ||
this.root._deferredAttributes[ this.root._deferredAttributes.length ] = this; | ||
this.updateDeferred = true; | ||
@@ -1756,3 +1722,3 @@ } | ||
// extend Mustache | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -1792,3 +1758,3 @@ | ||
this.initialising = true; | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
docFrag.appendChild( this.docFrag ); | ||
@@ -1855,3 +1821,3 @@ this.initialising = false; | ||
this.initialising = true; | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
docFrag.appendChild( this.docFrag ); | ||
@@ -1896,3 +1862,3 @@ this.initialising = false; | ||
_private._sectionUpdate.call( this, value ); | ||
_internal.sectionUpdate.call( this, value ); | ||
@@ -1907,3 +1873,3 @@ if ( !this.initialising ) { | ||
createFragment: function ( options ) { | ||
var fragment = new _private.DomFragment( options ); | ||
var fragment = new _internal.DomFragment( options ); | ||
@@ -1915,5 +1881,5 @@ this.docFrag.appendChild( fragment.docFrag ); | ||
}( Ractive, _private )); | ||
}( _internal )); | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
@@ -1925,9 +1891,9 @@ 'use strict'; | ||
types = _private.types; | ||
types = _internal.types; | ||
_private.TextFragment = function ( options ) { | ||
_private._Fragment.call( this, options ); | ||
_internal.TextFragment = function ( options ) { | ||
_internal.Fragment.call( this, options ); | ||
}; | ||
_private.TextFragment.prototype = { | ||
_internal.TextFragment.prototype = { | ||
createItem: function ( options ) { | ||
@@ -2002,3 +1968,3 @@ if ( typeof options.model === 'string' ) { | ||
Interpolator = function ( options ) { | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -2034,3 +2000,3 @@ | ||
_private._Mustache.call( this, options ); | ||
_internal.Mustache.call( this, options ); | ||
}; | ||
@@ -2062,14 +2028,12 @@ | ||
update: function ( value ) { | ||
_private._sectionUpdate.call( this, value ); | ||
_internal.sectionUpdate.call( this, value ); | ||
this.value = this.fragments.join( '' ); | ||
this.parent.bubble(); | ||
}, | ||
createFragment: function ( options ) { | ||
return new _private.TextFragment( options ); | ||
return new _internal.TextFragment( options ); | ||
}, | ||
postUpdate: function () { | ||
this.value = this.fragments.join( '' ); | ||
this.parent.bubble(); | ||
}, | ||
toString: function () { | ||
@@ -2081,3 +2045,3 @@ return this.fragments.join( '' ); | ||
}( _private )); | ||
}( _internal )); | ||
(function ( R ) { | ||
@@ -2125,3 +2089,3 @@ | ||
}( Ractive )); | ||
(function ( _private ) { | ||
(function ( _internal ) { | ||
@@ -2132,3 +2096,3 @@ 'use strict'; | ||
_private.modifyArray = function ( array, keypath, root ) { | ||
_internal.modifyArray = function ( array, keypath, root ) { | ||
@@ -2196,3 +2160,3 @@ var roots, keypathsByIndex, rootIndex, keypaths; | ||
}( _private )); | ||
}( _internal )); | ||
(function ( R ) { | ||
@@ -2245,7 +2209,7 @@ | ||
}( Ractive )); | ||
(function ( R, _p ) { | ||
(function ( R, _i ) { | ||
'use strict'; | ||
var Animation, animationCollection, global, interpolators; | ||
var Animation, animationCollection, global; | ||
@@ -2255,3 +2219,3 @@ global = ( typeof window !== 'undefined' ? window : {} ); | ||
// https://gist.github.com/paulirish/1579671 | ||
(function( vendors, lastTime, window ) { | ||
(function( vendors, lastTime, global ) { | ||
@@ -2383,3 +2347,3 @@ var x; | ||
R.prototype.animate = function ( keypath, to, options ) { | ||
var easing, from, duration, animation, i, keys; | ||
var easing, duration, animation, i, keys; | ||
@@ -2420,3 +2384,3 @@ options = options || {}; | ||
keys = _p.splitKeypath( keypath ); | ||
keys = _i.splitKeypath( keypath ); | ||
@@ -2438,3 +2402,3 @@ animation = new Animation({ | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); | ||
(function ( R, _p ) { | ||
@@ -2545,4 +2509,4 @@ | ||
}( Ractive, _private )); | ||
_private.namespaces = { | ||
}( Ractive, _internal )); | ||
_internal.namespaces = { | ||
html: 'http://www.w3.org/1999/xhtml', | ||
@@ -2549,0 +2513,0 @@ mathml: 'http://www.w3.org/1998/Math/MathML', |
@@ -1,1 +0,1 @@ | ||
(function(t){"use strict";var e;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this.observers={},this.pendingResolution=[],this.deferredAttributes=[],this.data&&this.set(this.data),this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,callback:this.callback,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this.deferredAttributes.length;)this.deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h,p;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o,e),a=this.pendingResolution.length;a--;)p=this.pendingResolution.splice(a,1)[0],h=this.resolveRef(p.view.model.ref,p.view.contextStack),h?p.callback(h.keypath,h.value):this.registerUnresolvedKeypath(p)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,p;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(t in this._cache)return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(n in this._cache)return this._cache[n];if(e.length>1?(r=e.pop(),a=this.get(e)):(r=e.pop(),a=this.data),s=/^⭆(.+)⭅$/.exec(r))p=i.getFormattersFromString(s[1]),h=this._format(a,p);else{if("object"!=typeof a)return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(){throw Error("not implemented yet!")},link:function(t){var e=this;return function(i){e.set(t,i)}},registerView:function(t){var e,n,r,s,o=this;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(s=t.parentFragment.indexRefs[t.model.ref],r=t.model.fmtrs?this._format(s,t.model.fmtrs):s,t.update(r),void 0):(n=function(e){t.keypath=t.model.fmtrs?e+"."+i.stringifyFormatters(t.model.fmtrs):e,t.observerRefs=o.observe(t.model.p||0,t),t.update(o.get(t.keypath))},e=this.resolveRef(t.model.ref,t.contextStack),e?n(e.keypath,e.value):(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this.registerUnresolvedKeypath({view:t,callback:n})),void 0)},resolveRef:function(t,e){var i,n,r;if("."===t)return n=e[e.length-1],r=this.get(n),{keypath:n,value:r};for(e=e.concat();e.length;)if(i=e.pop(),n=i+"."+t,r=this.get(n),void 0!==r)return{keypath:n,value:r};return r=this.get(t),void 0!==r?{keypath:t,value:r}:void 0},registerUnresolvedKeypath:function(t){this.pendingResolution[this.pendingResolution.length]=t},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this.observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t,e){var n,r,s=this,o=e.keypath,a=[];if(!o)return void 0;for(n=function(i){var n;n=s.observers[i]=s.observers[i]||[],n=n[t]=n[t]||[],n[n.length]=e,a[a.length]={keypath:i,priority:t,view:e}},r=i.splitKeypath(e.keypath);r.length>1;)n(r.join(".")),r.pop();return n(r[0]),a},unobserve:function(t){var e,i,n,r,s;if(e=this.observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.view){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this.observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})();var i;(function(){var t={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var e,i,n,r,s,o,a,h,p,d;if(!(e=/\\\./.test(t))&&!(i=/⭆.+⭅/.test(t)))return t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".");for(h=[],p=t,i&&(n=[],p=p.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),a=0;p.length;){if(o=p.indexOf(".",a),-1===o)d=p,p="";else{if("\\"===p.charAt(o-1)&&"\\"!==p.charAt(o-2)){a=o+1;continue}d=p.substr(0,o),a=0}/\[/.test(d)?h=h.concat(d.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):h[h.length]=d,p=p.substring(o+1)}if(i)for(s=function(){return"⭆"+n.pop()+"⭅"},r=h.length;r--;)"⭆x⭅"===h[r]&&(h[r]="⭆"+n.pop()+"⭅");return h},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}})(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t._Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerView(this),!this.keypath&&this.model.inv&&this.update(!1)},t._Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t._sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0;return this.postUpdate&&this.postUpdate(),void 0}if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0);this.postUpdate&&this.postUpdate()}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t,e){var i,n,r,s,o,a,h,p,d,c,l;i=e.types,s={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},r="undefined"!=typeof window?window.document:null,n=function(t,e){var i,n=[];for(i=r.createElement("div"),i.innerHTML=t;i.firstChild;)n[n.length]=i.firstChild,e.appendChild(i.firstChild);return n},e.DomFragment=function(t){return this.docFrag=r.createDocumentFragment(),"string"==typeof t.model?(this.nodes=n(t.model,this.docFrag),void 0):(e._Fragment.call(this,t),void 0)},e.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new o(t,this.docFrag);switch(t.model.type){case i.INTERPOLATOR:return new d(t,this.docFrag);case i.SECTION:return new l(t,this.docFrag);case i.TRIPLE:return new c(t,this.docFrag);case i.ELEMENT:return new a(t,this.docFrag);case i.PARTIAL:return new h(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},h=function(t,i){this.fragment=new e.DomFragment({model:t.root.partials[t.model.ref]||[],root:t.root,parentNode:t.parentNode,contextStack:t.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},h.prototype={teardown:function(){this.fragment.teardown()}},o=function(t,e){this.node=r.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},o.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},a=function(t,i){var n,s,o,a,h,d,c;if(n=this.model=t.model,this.root=t.root,this.parentFragment=t.parentFragment,this.parentNode=t.parentNode,this.index=t.index,n.attrs&&n.attrs.xmlns){if(s=n.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=r.createElementNS(s,n.tag),n.frag&&("string"==typeof n.frag?this.node.innerHTML=n.frag:(this.children=new e.DomFragment({model:n.frag,root:t.root,parentNode:this.node,contextStack:t.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],d=[];for(a in n.attrs)n.attrs.hasOwnProperty(a)&&(h=n.attrs[a],o=new p({parent:this,name:a,value:void 0===h?null:h,root:t.root,parentNode:this.node,contextStack:t.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&d.push(o),o.isTwowayNameAttr?c=o:o.update());for(;d.length;)d.pop().bind(this.root.lazy);c&&(c.updateViewModel(),c.update()),i.appendChild(this.node)},a.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},p=function(t){var i,n,r,o,a,h,p,d;if(i=t.name,n=t.value,this.parent=t.parent,r=i.indexOf(":"),-1!==r&&(o=i.substr(0,r),"xmlns"!==o&&(i=i.substring(r+1),this.namespace=e.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?t.parentNode.setAttributeNS(this.namespace,i,n):t.parentNode.setAttribute(i,n),void 0):(this.root=t.root,this.parentNode=t.parentNode,this.name=i,this.children=[],this.namespace||t.parentNode.namespaceURI!==e.namespaces.html||(p=this.name.toLowerCase(),d=s[p]?s[p]:p,void 0!==t.parentNode[d]&&(this.propertyName=d),("boolean"==typeof t.parentNode[d]||"value"===d)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new e.TextFragment({model:n,root:this.root,parent:this,contextStack:t.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==d&&"value"!==d&&"checked"!==d||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===d&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},p.prototype={bind:function(t){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==e.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),t||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root.deferredAttributes[this.root.deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(r.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},d=function(t,i){this.node=r.createTextNode(""),i.appendChild(this.node),e._Mustache.call(this,t)},d.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},c=function(t,i){this.nodes=[],this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=n(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},l=function(t,i){this.fragments=[],this.length=0,this.docFrag=r.createDocumentFragment(),this.initialising=!0,e._Mustache.call(this,t),i.appendChild(this.docFrag),this.initialising=!1},l.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(t){e._sectionUpdate.call(this,t),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(t){var i=new e.DomFragment(t);return this.docFrag.appendChild(i.docFrag),i}}}(e,i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t._Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t._Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t._Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t._sectionUpdate.call(this,e)},createFragment:function(e){return new t.TextFragment(e)},postUpdate:function(){this.value=this.fragments.join(""),this.parent.bubble()},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e){var i;for(i=0;t.length>i&&!r.requestAnimationFrame;++i)r.requestAnimationFrame=r[t[i]+"RequestAnimationFrame"],r.cancelAnimationFrame=r[t[i]+"CancelAnimationFrame"]||r[t[i]+"CancelRequestAnimationFrame"];r.requestAnimationFrame||(r.requestAnimationFrame=function(t){var i,n,s;return i=Date.now(),n=Math.max(0,16-(i-e)),s=r.setTimeout(function(){t(i+n)},n),e=i+n,s}),r.cancelAnimationFrame||(r.cancelAnimationFrame=function(t){r.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,p,d,c;for(o=o||{},d=n.animations.length;d--;)n.animations[d].keypath===r&&n.animations[d].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,c=e.splitKeypath(r),p=new i({keys:c,from:this.get(c),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(p)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this); | ||
(function(t){"use strict";var e,i;(function(){var t;return e=function(i){var n,r;if(i)for(r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);n={preserveWhitespace:!1,append:!1,twoway:!0,formatters:{},modifyArrays:!0};for(r in n)n.hasOwnProperty(r)&&void 0===this[r]&&(this[r]=n[r]);if(void 0!==this.el&&(this.el=t(this.el)),this._subs={},this._cache={},this._cacheMap={},this._observers={},this._pendingResolution=[],this._deferredAttributes=[],this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!e.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=e.compile(this.partials[r],this)}if("string"==typeof this.template){if(!e.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=e.compile(this.template,this)}this.template&&1===this.template.length&&"string"==typeof this.template[0]&&(this.template=this.template[0]),this.el&&this.render({el:this.el,append:this.append})},e.prototype={render:function(e){var n=e.el?t(e.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");e.append||(n.innerHTML=""),e.callback&&(this.callback=e.callback),this.rendered=new i.DomFragment({model:this.template,root:this,parentNode:n}),n.appendChild(this.rendered.docFrag)},teardown:function(){this.rendered.teardown()},set:function(t,e){for(i.isObject(t)?this._setMultiple(t):this._setSingle(t,e);this._deferredAttributes.length;)this._deferredAttributes.pop().update().updateDeferred=!1},_setSingle:function(t,e){var n,r,s,o,a,h;for(n=i.isArray(t)?t.slice():i.splitKeypath(t),o=n.join("."),this._clearCache(o),s=this.data;n.length>1;)r=n.shift(),s[r]||(s[r]=/^[0-9]+$/.test(n[0])?[]:{}),s=s[r];for(r=n[0],s[r]=e,this.setting||(this.setting=!0,this.fire("set",o,e),this.fire("set:"+o,e),this.setting=!1),this._notifyObservers(o),a=this._pendingResolution.length;a--;)h=this._pendingResolution.splice(a,1)[0],this.resolveRef(h)||(this._pendingResolution[this._pendingResolution.length]=h)},_setMultiple:function(t){var e;for(e in t)t.hasOwnProperty(e)&&this._setSingle(e,t[e])},_clearCache:function(t){var e=this._cacheMap[t];if(delete this._cache[t],e)for(;e.length;)this._clearCache(e.pop())},get:function(t){var e,n,r,s,o,a,h,p;if(i.isArray(t))e=t.slice(),n=e.join(".");else{if(this._cache.hasOwnProperty(t))return this._cache[t];e=i.splitKeypath(t),n=e.join(".")}if(this._cache.hasOwnProperty(n))return this._cache[n];if(r=e.pop(),a=e.length?this.get(e):this.data,s=/^⭆(.+)⭅$/.exec(r))p=i.getFormattersFromString(s[1]),h=this._format(a,p);else{if("object"!=typeof a||!a.hasOwnProperty(r))return;h=a[r]}return e.length&&(o=e.join("."),this._cacheMap[o]||(this._cacheMap[o]=[]),this._cacheMap[o].push(n)),"function"==typeof h&&(h=h()),this._cache[n]=h,h},update:function(t){return this._clearCache(t),this._notifyObservers(t),this.fire("update:"+t),this.fire("update",t),this},link:function(t){var e=this;return function(i){e.set(t,i)}},registerMustache:function(t){var e,i,n;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(n=t.parentFragment.indexRefs[t.model.ref],i=t.model.fmtrs?this._format(n,t.model.fmtrs):n,t.update(i),void 0):(e=this.resolveRef(t),e||(t.model.fmtrs&&t.update(this._format(void 0,t.model.fmtrs)),this._pendingResolution[this._pendingResolution.length]=t),void 0)},resolveRef:function(t){var e,n,r,s,o,a,h,p;if(e=t.model.ref,n=t.contextStack,"."===e)p=n[n.length-1];else{for(r=i.splitKeypath(e),s=r.pop(),n=n.concat();n.length;)if(o=n.pop(),a=i.splitKeypath(o),h=this.get(a.concat(r)),"object"==typeof h&&h.hasOwnProperty(s)){p=o+"."+e;break}p||void 0===this.get(e)||(p=e)}return p?(t.keypath=t.model.fmtrs?p+"."+i.stringifyFormatters(t.model.fmtrs):p,t.observerRefs=this.observe(t),t.update(this.get(t.keypath)),!0):!1},_format:function(t,i){var n,r,s,o,a,h;if(!i)return t;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||e.formatters[o],h&&(t=h.apply(this,[t].concat(a)));return t},_notifyObservers:function(t){var e,i,n,r,s=this,o=this._observers[t]||[];for(e=0;o.length>e;e+=1)if(n=o[e])for(i=0;n.length>i;i+=1)r=n[i],r.update(s.get(r.keypath))},observe:function(t){var e,n,r=this,s=[],o=t.model.p||0;for(e=function(e){var i;i=r._observers[e]=r._observers[e]||[],i=i[o]=i[o]||[],i[i.length]=t,s[s.length]={keypath:e,priority:o,mustache:t}},n=i.splitKeypath(t.keypath);n.length>1;)e(n.join(".")),n.pop();return e(n[0]),s},unobserve:function(t){var e,i,n,r,s;if(e=this._observers[t.keypath],e&&(i=e[t.priority])){if(i.indexOf)n=i.indexOf(t.observer);else for(r=0,s=i.length;s>r;r+=1)if(i[r]===t.mustache){n=r;break}-1!==n&&(i.splice(n,1),0===i.length&&delete e[t.priority],0===e.length&&delete this._observers[t.keypath])}},unobserveAll:function(t){for(;t.length;)this.unobserve(t.shift())}},t=function(t){var e,i;if("undefined"!=typeof window){if(i=window.document,!t)throw Error("No container element specified");if(t.tagName)return t;if("string"==typeof t&&(e=i.getElementById(t),!e&&i.querySelector&&(e=i.querySelector(t)),e.tagName))return e;if(t[0]&&t[0].tagName)return t[0];throw Error("Could not find container element")}},e})(),function(){var t={},e={};i={isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},splitKeypath:function(t){var i,n,r,s,o,a,h,p;if(e[t])return e[t].concat();if(i=/⭆.+⭅/.test(t),!/\\\./.test(t)&&!i)return e[t]=t.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split("."),e[t].concat();for(a=[],h=t,i&&(n=[],h=h.replace(/⭆(.+)⭅/g,function(t,e){return n[n.length]=e,"⭆x⭅"})),o=0;h.length;){if(s=h.indexOf(".",o),-1===s)p=h,h="";else{if("\\"===h.charAt(s-1)&&"\\"!==h.charAt(s-2)){o=s+1;continue}p=h.substr(0,s),o=0}/\[/.test(p)?a=a.concat(p.replace(/\[\s*([0-9]+)\s*\]/g,".$1").split(".")):a[a.length]=p,h=h.substring(s+1)}if(i)for(r=a.length;r--;)"⭆x⭅"===a[r]&&(a[r]="⭆"+n.pop()+"⭅");return e[t]=a,a.concat()},getFormattersFromString:function(e){var i,n;return t[e]?t[e]:(n=e.split("⤋"),i=n.map(function(t){var e;return e=t.indexOf("["),-1===e?{name:t,args:[]}:{name:t.substr(0,e),args:JSON.parse(t.substring(e))}}),t[e]=i,i)},stringifyFormatters:function(t){var e=t.map(function(t){return t.args&&t.args.length?t.name+JSON.stringify(t.args):t.name});return"⭆"+e.join("⤋")+"⭅"}}}(),i.types={TEXT:1,INTERPOLATOR:2,TRIPLE:3,SECTION:4,INVERTED:5,CLOSING:6,ELEMENT:7,PARTIAL:8,COMMENT:9,DELIMCHANGE:10,MUSTACHE:11,TAG:12,ATTR_VALUE_TOKEN:13},function(t){t.Mustache=function(t){this.root=t.root,this.model=t.model,this.parent=t.parent,this.parentFragment=t.parentFragment,this.contextStack=t.contextStack||[],this.index=t.index||0,(t.parentNode||t.anchor)&&(this.parentNode=t.parentNode,this.anchor=t.anchor),this.type=t.model.type,this.root.registerMustache(this),!this.keypath&&this.model.inv&&this.update(this.model.fmtrs?this.root._format(!1,this.model.fmtrs):!1)},t.Fragment=function(t){var e,i,n,r,s;if(this.parent=t.parent,this.index=t.index,this.items=[],this.indexRefs={},this.parent&&this.parent.parentFragment){r=this.parent.parentFragment.indexRefs;for(s in r)r.hasOwnProperty(s)&&(this.indexRefs[s]=r[s])}for(t.indexRef&&(this.indexRefs[t.indexRef]=t.index),n={root:t.root,parentFragment:this,parent:this,parentNode:t.parentNode,contextStack:t.contextStack},e=t.model?t.model.length:0,i=0;e>i;i+=1)n.model=t.model[i],n.index=i,this.items[this.items.length]=this.createItem(n)},t.sectionUpdate=function(e){var i,n,r,s,o;if(i={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(i.anchor=this.parentFragment.findNextNode(this)),n=t.isArray(e),n&&this.root.modifyArrays&&t.modifyArray(e,this.keypath,this.root),n&&0===e.length&&(r=!0),this.model.inv){if(e&&!r)this.length&&(this.unrender(),this.length=0);else if(!this.length)return i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1,void 0}else if(n){if(e.length<this.length)for(o=this.fragments.splice(e.length,this.length-e.length);o.length;)o.pop().teardown();else if(e.length>this.length)for(s=this.length;e.length>s;s+=1)i.contextStack=this.contextStack.concat(this.keypath+"."+s),i.index=s,this.model.i&&(i.indexRef=this.model.i),this.fragments[s]=this.createFragment(i);this.length=e.length}else t.isObject(e)?this.length||(i.contextStack=this.contextStack.concat(this.keypath),i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):e&&!r?this.length||(i.contextStack=this.contextStack,i.index=0,this.fragments[0]=this.createFragment(i),this.length=1):this.length&&(this.unrender(),this.length=0)}}(i),function(t){t.on=function(t,e){var i=this;return this._subs[t]?this._subs[t].push(e):this._subs[t]=[e],{cancel:function(){i.off(t,e)}}},t.off=function(t,e){var i,n;e||(t?this._subs[t]=[]:this._subs={}),i=this._subs[t],i&&(n=i.indexOf(e),-1!==n&&i.splice(n,1))},t.fire=function(t){var e,i,n,r=this._subs[t];if(r)for(e=Array.prototype.slice.call(arguments,1),i=0,n=r.length;n>i;i+=1)r[i].apply(this,e)}}(e.prototype),function(t){t.formatters={equals:function(t,e){return t===e},greaterThan:function(t,e){return t>e},greaterThanEquals:function(t,e){return t>=e},lessThan:function(t,e){return e>t},lessThanEquals:function(t,e){return e>=t}}}(e),function(t){var e,i,n,r,s,o,a,h,p,c,d;e=t.types,r={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor","class":"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName","for":"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},n="undefined"!=typeof window?window.document:null,i=function(t,e){var i,r=[];for(i=n.createElement("div"),i.innerHTML=t;i.firstChild;)r[r.length]=i.firstChild,e.appendChild(i.firstChild);return r},t.DomFragment=function(e){return this.docFrag=n.createDocumentFragment(),"string"==typeof e.model?(this.nodes=i(e.model,this.docFrag),void 0):(t.Fragment.call(this,e),void 0)},t.DomFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new s(t,this.docFrag);switch(t.model.type){case e.INTERPOLATOR:return new p(t,this.docFrag);case e.SECTION:return new d(t,this.docFrag);case e.TRIPLE:return new c(t,this.docFrag);case e.ELEMENT:return new o(t,this.docFrag);case e.PARTIAL:return new a(t,this.docFrag);default:throw"WTF? not sure what happened here..."}},teardown:function(){var t;if(this.nodes)for(;this.nodes.length;)t=this.nodes.pop(),t.parentNode.removeChild(t);else for(;this.items.length;)this.items.pop().teardown()},firstNode:function(){return this.items[0]?this.items[0].firstNode():null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():null}},a=function(e,i){this.fragment=new t.DomFragment({model:e.root.partials[e.model.ref]||[],root:e.root,parentNode:e.parentNode,contextStack:e.contextStack,parent:this}),i.appendChild(this.fragment.docFrag)},a.prototype={teardown:function(){this.fragment.teardown()}},s=function(t,e){this.node=n.createTextNode(t.model),this.root=t.root,this.parentNode=t.parentNode,e.appendChild(this.node)},s.prototype={teardown:function(){this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(e,i){var r,s,o,a,p,c,d;if(r=this.model=e.model,this.root=e.root,this.parentFragment=e.parentFragment,this.parentNode=e.parentNode,this.index=e.index,r.attrs&&r.attrs.xmlns){if(s=r.attrs.xmlns,"string"!=typeof s)throw"Namespace attribute cannot contain mustaches"}else s=this.parentNode.namespaceURI;this.node=n.createElementNS(s,r.tag),r.frag&&("string"==typeof r.frag&&this.node.namespaceURI===t.namespaces.html?this.node.innerHTML=r.frag:(this.children=new t.DomFragment({model:r.frag,root:e.root,parentNode:this.node,contextStack:e.contextStack,parent:this}),this.node.appendChild(this.children.docFrag))),this.attributes=[],c=[];for(a in r.attrs)r.attrs.hasOwnProperty(a)&&(p=r.attrs[a],o=new h({parent:this,name:a,value:void 0===p?null:p,root:e.root,parentNode:this.node,contextStack:e.contextStack}),this.attributes[this.attributes.length]=o,o.isBindable&&c.push(o),o.isTwowayNameAttr?d=o:o.update());for(;c.length;)c.pop().bind(this.root.lazy);d&&(d.updateViewModel(),d.update()),i.appendChild(this.node)},o.prototype={teardown:function(){for(this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node),this.children&&this.children.teardown();this.attributes.length;)this.attributes.pop().teardown()},firstNode:function(){return this.node}},h=function(e){var i,n,s,o,a,h,p,c;if(i=e.name,n=e.value,this.parent=e.parent,s=i.indexOf(":"),-1!==s&&(o=i.substr(0,s),"xmlns"!==o&&(i=i.substring(s+1),this.namespace=t.namespaces[o],!this.namespace)))throw'Unknown namespace ("'+o+'")';return null===n||"string"==typeof n?(this.namespace?e.parentNode.setAttributeNS(this.namespace,i,n):e.parentNode.setAttribute(i,n),void 0):(this.root=e.root,this.parentNode=e.parentNode,this.name=i,this.children=[],this.namespace||e.parentNode.namespaceURI!==t.namespaces.html||(p=this.name.toLowerCase(),c=r[p]||p,void 0!==e.parentNode[c]&&(this.propertyName=c),("boolean"==typeof e.parentNode[c]||"value"===c)&&(this.useProperty=!0)),this.parentFragment=this.parent.parentFragment,this.fragment=new t.TextFragment({model:n,root:this.root,parent:this,contextStack:e.contextStack}),1===this.fragment.items.length&&(this.selfUpdating=!0),this.root.twoway&&(a=this.parent.model.tag.toLowerCase(),h=!("name"!==c&&"value"!==c&&"checked"!==c||"input"!==a&&"textarea"!==a&&"select"!==a)),h&&(this.isBindable=!0,"name"===c&&(this.isTwowayNameAttr=!0)),this.ready=!0,this.isTwowayNameAttr||this.update(),void 0)},h.prototype={bind:function(e){var i,n,r=this,s=this.parentNode;if(!this.fragment)return!1;if(1!==this.fragment.items.length||this.fragment.items[0].type!==t.types.INTERPOLATOR)throw"Not a valid two-way data binding candidate - must be a single interpolator";this.interpolator=this.fragment.items[0],i=this.interpolator.keypath||this.interpolator.model.ref,-1!==(n=i.indexOf(".⭆"))&&(i=i.substr(0,n)),"checkbox"===s.type||"radio"===s.type?"name"===this.propertyName?(s.name="{{"+i+"}}",this.updateViewModel=function(){s.checked&&r.root.set(i,s.value)}):"checked"===this.propertyName&&(this.updateViewModel=function(){r.root.set(i,s.checked)}):this.updateViewModel=function(){var t;t=r.interpolator.model.fmtrs?r.root._format(s.value,r.interpolator.model.fmtrs):s.value,"0"===t?t=0:""!==t&&(t=+t||t),r.root.set(i,t)},this.updateViewModel&&(this.twoway=!0,s.addEventListener("change",this.updateViewModel),s.addEventListener("click",this.updateViewModel),s.addEventListener("blur",this.updateViewModel),e||(s.addEventListener("keyup",this.updateViewModel),s.addEventListener("keydown",this.updateViewModel),s.addEventListener("keypress",this.updateViewModel),s.addEventListener("input",this.updateViewModel)))},teardown:function(){if(this.updateViewModel&&(this.node.removeEventListener("change",this.updateViewModel),this.node.removeEventListener("click",this.updateViewModel),this.node.removeEventListener("blur",this.updateViewModel),this.node.removeEventListener("keyup",this.updateViewModel),this.node.removeEventListener("keydown",this.updateViewModel),this.node.removeEventListener("keypress",this.updateViewModel),this.node.removeEventListener("input",this.updateViewModel)),this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.selfUpdating?this.update():this.updateDeferred||(this.root._deferredAttributes[this.root._deferredAttributes.length]=this,this.updateDeferred=!0)},update:function(){var t,e;if(!this.ready)return this;if(this.twoway){if(e=this.name.toLowerCase(),this.value=this.interpolator.value,"name"===e&&("checkbox"===this.parentNode.type||"radio"===this.parentNode.type))return this.parentNode.checked=this.value===this.parentNode.value?!0:!1,this;if(n.activeElement===this.parentNode)return this}return t=this.fragment.getValue(),void 0===t&&(t=""),this.useProperty?(this.parentNode[this.propertyName]=t,this):this.namespace?(this.parentNode.setAttributeNS(this.namespace,this.name,t),this):(this.parentNode.setAttribute(this.name,t),this)}},p=function(e,i){this.node=n.createTextNode(""),i.appendChild(this.node),t.Mustache.call(this,e)},p.prototype={teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this),this.root.el.contains(this.node)&&this.parentNode.removeChild(this.node)},update:function(t){t!==this.text&&(this.text=t,this.node.data=t)},firstNode:function(){return this.node}},c=function(e,i){this.nodes=[],this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},c.prototype={teardown:function(){if(this.root.el.contains(this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.nodes=i(t,this.docFrag),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))}}},d=function(e,i){this.fragments=[],this.length=0,this.docFrag=n.createDocumentFragment(),this.initialising=!0,t.Mustache.call(this,e),i.appendChild(this.docFrag),this.initialising=!1},d.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},firstNode:function(){return this.fragments[0]?this.fragments[0].firstNode():this.parentFragment.findNextNode(this)},findNextNode:function(t){return this.fragments[t.index+1]?this.fragments[t.index+1].firstNode():this.parentFragment.findNextNode(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown()},update:function(e){t.sectionUpdate.call(this,e),this.initialising||this.parentNode.insertBefore(this.docFrag,this.parentFragment.findNextNode(this))},createFragment:function(e){var i=new t.DomFragment(e);return this.docFrag.appendChild(i.docFrag),i}}}(i),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t.Fragment.call(this,e)},t.TextFragment.prototype={createItem:function(t){if("string"==typeof t.model)return new i(t.model);switch(t.model.type){case e.INTERPOLATOR:return new n(t);case e.TRIPLE:return new r(t);case e.SECTION:return new s(t);default:throw"Something went wrong in a rather interesting way"}},bubble:function(){this.value=this.getValue(),this.parent.bubble()},teardown:function(){var t,e;for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},getValue:function(){var t;return 1===this.items.length&&(t=this.items[0].value,void 0!==t)?t:""+this},toString:function(){return this.items.join("")}},i=function(t){this.text=t},i.prototype={toString:function(){return this.text},teardown:function(){}},n=function(e){t.Mustache.call(this,e)},n.prototype={update:function(t){this.value=t,this.parent.bubble()},teardown:function(){this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){this.fragments=[],this.length=0,t.Mustache.call(this,e)},s.prototype={teardown:function(){this.unrender(),this.observerRefs?this.root.unobserveAll(this.observerRefs):this.root.cancelKeypathResolution(this)},unrender:function(){for(;this.fragments.length;)this.fragments.shift().teardown();this.length=0},bubble:function(){this.value=this.fragments.join(""),this.parent.bubble()},update:function(e){t.sectionUpdate.call(this,e),this.value=this.fragments.join(""),this.parent.bubble()},createFragment:function(e){return new t.TextFragment(e)},toString:function(){return this.fragments.join("")}}}(i),function(t){t.extend=function(e){var i,n,r;i=this,n=function(){t.apply(this,arguments),this.init&&this.init.apply(this,arguments)};for(r in i.prototype)i.prototype.hasOwnProperty(r)&&(n.prototype[r]=i.prototype[r]);for(r in e)if(e.hasOwnProperty(r)){if(t.prototype.hasOwnProperty(r))throw Error('Cannot override "'+r+'" method or property of Ractive prototype');n.prototype[r]=e[r]}return n.extend=i.extend,n}}(e),function(t){var e;t.modifyArray=function(t,i,n){var r,s,o,a;t._ractive?(r=t._ractive.roots,s=t._ractive.keypathsByIndex,o=r.indexOf(n),-1===o&&(o=r.length,r[o]=n),a=s[o],-1===a.indexOf(i)&&(a[a.length]=i)):(t._ractive={roots:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.roots,i=t._ractive.keypathsByIndex,e.forEach(function(e,n){var r=i[n];r.forEach(function(i){e.set(i,t)})})};["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){t[i]=function(){var n=Array.prototype[i].apply(this,arguments);return e(t),n}})}}(i),function(t){t.easing={linear:function(t){return t},easeIn:function(t){return Math.pow(t,3)},easeOut:function(t){return Math.pow(t-1,3)+1},easeInOut:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}}}(e),function(t,e){var i,n,r;r="undefined"!=typeof window?window:{},function(t,e,i){var n;for(n=0;t.length>n&&!i.requestAnimationFrame;++n)i.requestAnimationFrame=i[t[n]+"RequestAnimationFrame"],i.cancelAnimationFrame=i[t[n]+"CancelAnimationFrame"]||i[t[n]+"CancelRequestAnimationFrame"];i.requestAnimationFrame||(i.requestAnimationFrame=function(t){var n,r,s;return n=Date.now(),r=Math.max(0,16-(n-e)),s=i.setTimeout(function(){t(n+r)},r),e=n+r,s}),i.cancelAnimationFrame||(i.cancelAnimationFrame=function(t){i.clearTimeout(t)})}(["ms","moz","webkit","o"],0,r),n={animations:[],tick:function(){var t,e;for(t=0;this.animations.length>t;t+=1)e=this.animations[t],e.tick()||this.animations.splice(t--,1);this.animations.length?r.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){n.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},i=function(e){var i;this.startTime=Date.now();for(i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);this.interpolator=t.interpolate(this.from,this.to),this.running=!0},i.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.root.set(this.keys,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.interpolator(e),this.root.set(this.keys,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(r,s,o){var a,h,p,c,d;for(o=o||{},c=n.animations.length;c--;)n.animations[c].keypath===r&&n.animations[c].stop();o.easing&&(a="function"==typeof o.easing?o.easing:this.easing&&this.easing[o.easing]?this.easing[o.easing]:t.easing[o.easing],"function"!=typeof a&&(a=null)),h=void 0===o.duration?400:o.duration,d=e.splitKeypath(r),p=new i({keys:d,from:this.get(d),to:s,root:this,duration:h,easing:a,step:o.step,complete:o.complete}),n.push(p)}}(e,i),function(t,e){t.interpolate=function(i,n){if(e.isNumeric(i)&&e.isNumeric(n))return t.interpolators.number(+i,+n);if(e.isArray(i)&&e.isArray(n))return t.interpolators.array(i,n);if(e.isObject(i)&&e.isObject(n))return t.interpolators.object(i,n);throw Error("Could not interpolate values")},t.interpolators={number:function(t,e){var i=e-t;return i?function(e){return t+e*i}:function(){return t}},array:function(e,i){var n,r,s,o;for(n=[],r=[],o=s=Math.min(e.length,i.length);o--;)r[o]=t.interpolate(e[o],i[o]);for(o=s;e.length>o;o+=1)n[o]=e[o];for(o=s;i.length>o;o+=1)n[o]=i[o];return function(t){for(var e=s;e--;)n[e]=r[e](t);return n}},object:function(e,i){var n,r,s,o,a=[];s={},r={};for(o in e)e.hasOwnProperty(o)&&(i.hasOwnProperty(o)?(a[a.length]=o,r[o]=t.interpolate(e[o],i[o])):s[o]=e[o]);for(o in i)i.hasOwnProperty(o)&&!e.hasOwnProperty(o)&&(s[o]=i[o]);return n=a.length,function(t){for(var e,i=n;i--;)e=a[i],s[e]=r[e](t);return s}}}}(e,i),i.namespaces={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this); |
@@ -38,2 +38,6 @@ Changelog | ||
* Major architectural overhaul. Data is now stored on the Ractive instance rather than on a separate viewmodel, allowing for cleaner and more efficient code (at the cost of the ability to share one viewmodel among many instances - a theoretical benefit at best). Data is flattened and cached, permitting lightning-fast lookups even with complex data. | ||
* Templates can be sanitized at compile-time to remove script tags and other hypothetical security risks. In lieu of documentation see issue #12 | ||
* Templates can be sanitized at compile-time to remove script tags and other hypothetical security risks. In lieu of documentation see issue #12 | ||
* 0.2.1 | ||
* Cleaned up some redundant code following 0.2.0 overhaul, some minor performance benefits | ||
* Linting and refactoring | ||
* Fixed bug where Ractive would attempt to use innerHTML with non-HTML elements (i.e. SVG text) |
@@ -42,3 +42,3 @@ /*global module:false*/ | ||
}, | ||
src: [ 'src/Ractive.js', 'src/_private.js', 'src/types.js', 'src/Views.js', 'src/events.js', 'src/formatters.js', 'src/ViewModel.js', 'src/DomViews.js', 'src/TextViews.js', 'src/extend.js', 'src/modifyArray.js', 'src/easing.js', 'src/animate.js', 'src/interpolators.js', 'src/namespaces.js' ], | ||
src: [ 'src/Ractive.js', 'src/_internal.js', 'src/types.js', 'src/fragment_utils.js', 'src/events.js', 'src/formatters.js', 'src/dom_fragment.js', 'src/text_fragment.js', 'src/extend.js', 'src/modify_array.js', 'src/easing.js', 'src/animate.js', 'src/interpolators.js', 'src/namespaces.js' ], | ||
dest: 'build/Ractive.runtime.js' | ||
@@ -51,3 +51,3 @@ }, | ||
}, | ||
src: [ 'src/Ractive.js', 'src/_private.js', 'src/types.js', 'src/Views.js', 'src/events.js', 'src/compile.js', 'src/tokenize.js', 'src/formatters.js', 'src/ViewModel.js', 'src/DomViews.js', 'src/TextViews.js', 'src/extend.js', 'src/modifyArray.js', 'src/easing.js', 'src/animate.js', 'src/interpolators.js', 'src/namespaces.js' ], | ||
src: [ 'src/Ractive.js', 'src/_internal.js', 'src/types.js', 'src/fragment_utils.js', 'src/events.js', 'src/compile.js', 'src/tokenize.js', 'src/formatters.js', 'src/dom_fragment.js', 'src/text_fragment.js', 'src/extend.js', 'src/modify_array.js', 'src/easing.js', 'src/animate.js', 'src/interpolators.js', 'src/namespaces.js' ], | ||
dest: 'build/Ractive.js' | ||
@@ -54,0 +54,0 @@ }, |
{ | ||
"name": "ractive", | ||
"description": "Faster, easier, better interactive web development", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "http://rich-harris.github.com/Ractive/", | ||
@@ -6,0 +6,0 @@ "main": "build/Ractive.js", |
@@ -1,6 +0,6 @@ | ||
(function ( R, _p ) { | ||
(function ( R, _i ) { | ||
'use strict'; | ||
var Animation, animationCollection, global, interpolators; | ||
var Animation, animationCollection, global; | ||
@@ -10,3 +10,3 @@ global = ( typeof window !== 'undefined' ? window : {} ); | ||
// https://gist.github.com/paulirish/1579671 | ||
(function( vendors, lastTime, window ) { | ||
(function( vendors, lastTime, global ) { | ||
@@ -138,3 +138,3 @@ var x; | ||
R.prototype.animate = function ( keypath, to, options ) { | ||
var easing, from, duration, animation, i, keys; | ||
var easing, duration, animation, i, keys; | ||
@@ -175,3 +175,3 @@ options = options || {}; | ||
keys = _p.splitKeypath( keypath ); | ||
keys = _i.splitKeypath( keypath ); | ||
@@ -193,2 +193,2 @@ animation = new Animation({ | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); |
@@ -1,4 +0,4 @@ | ||
var Ractive = Ractive || {}, _private = _private || {}; // in case we're not using the runtime | ||
var Ractive = Ractive || {}, _internal = _internal || {}; // in case we're not using the runtime | ||
(function ( R, _private ) { | ||
(function ( R, _internal ) { | ||
@@ -44,3 +44,3 @@ 'use strict'; | ||
tokens = _private.tokenize( template ); | ||
tokens = _internal.tokenize( template ); | ||
fragmentStub = getFragmentStubFromTokens( tokens, 0, options, options.preserveWhitespace ); | ||
@@ -58,3 +58,3 @@ | ||
types = _private.types; | ||
types = _internal.types; | ||
@@ -660,2 +660,2 @@ voidElementNames = [ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr' ]; | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); |
@@ -106,2 +106,2 @@ (function ( R, _p ) { | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); |
@@ -1,2 +0,2 @@ | ||
(function () { | ||
(function ( doc ) { | ||
@@ -11,4 +11,4 @@ 'use strict'; | ||
if ( !document.createElementNS ) { | ||
document.createElementNS = function ( ns, type ) { | ||
if ( !doc.createElementNS ) { | ||
doc.createElementNS = function ( ns, type ) { | ||
if ( ns !== null && ns !== 'http://www.w3.org/1999/xhtml' ) { | ||
@@ -18,3 +18,3 @@ throw 'This browser does not support namespaces other than http://www.w3.org/1999/xhtml'; | ||
return document.createElement( type ); | ||
return doc.createElement( type ); | ||
}; | ||
@@ -62,3 +62,5 @@ } | ||
WindowPrototype[removeEventListener] = DocumentPrototype[removeEventListener] = ElementPrototype[removeEventListener] = function (type, listener) { | ||
for (var index = 0, register; register = registry[index]; ++index) { | ||
var index, register; | ||
for ( index = 0, register; register = registry[index]; ++index ) { | ||
if ( register[0] === this && register[1] === type && register[2] === listener ) { | ||
@@ -95,3 +97,3 @@ return this.detachEvent("on" + type, registry.splice(index, 1)[0][3]); | ||
for ( len = this.length; i<len; i++ ) { | ||
if ( i in this && this[i] === needle ) { | ||
if ( this.hasOwnProperty( i ) && this[i] === needle ) { | ||
return i; | ||
@@ -110,3 +112,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this ) { | ||
if ( this.hasOwnProperty( i ) ) { | ||
callback.call( context, this[i], i, this ); | ||
@@ -123,3 +125,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this ) { | ||
if ( this.hasOwnProperty( i ) ) { | ||
mapped[i] = mapper.call( context, this[i], i, this ); | ||
@@ -138,3 +140,3 @@ } | ||
for ( i=0, len=this.length; i<len; i+=1 ) { | ||
if ( i in this && filter.call( context, this[i], i, this ) ) { | ||
if ( this.hasOwnProperty( i ) && filter.call( context, this[i], i, this ) ) { | ||
filtered[ filtered.length ] = this[i]; | ||
@@ -148,2 +150,2 @@ } | ||
}()); | ||
}( document )); |
@@ -1,2 +0,2 @@ | ||
_private.namespaces = { | ||
_internal.namespaces = { | ||
html: 'http://www.w3.org/1999/xhtml', | ||
@@ -3,0 +3,0 @@ mathml: 'http://www.w3.org/1998/Math/MathML', |
@@ -1,2 +0,2 @@ | ||
var Ractive; | ||
var Ractive, _internal; | ||
@@ -54,13 +54,8 @@ (function () { | ||
// Set up observers | ||
this.observers = {}; | ||
this.pendingResolution = []; | ||
this._observers = {}; | ||
this._pendingResolution = []; | ||
// Create an array for deferred attributes | ||
this.deferredAttributes = []; | ||
this._deferredAttributes = []; | ||
// Initialise (or update) viewmodel with data | ||
if ( this.data ) { | ||
this.set( this.data ); | ||
} | ||
// If we were given uncompiled partials, compile them | ||
@@ -98,3 +93,3 @@ if ( this.partials ) { | ||
if ( this.el ) { | ||
this.render({ el: this.el, callback: this.callback, append: this.append }); | ||
this.render({ el: this.el, append: this.append }); | ||
} | ||
@@ -127,3 +122,3 @@ }; | ||
// Render our *root fragment* | ||
this.rendered = new _private.DomFragment({ | ||
this.rendered = new _internal.DomFragment({ | ||
model: this.template, | ||
@@ -144,3 +139,3 @@ root: this, | ||
set: function ( keypath, value ) { | ||
if ( _private.isObject( keypath ) ) { | ||
if ( _internal.isObject( keypath ) ) { | ||
this._setMultiple( keypath ); | ||
@@ -151,4 +146,7 @@ } else { | ||
while ( this.deferredAttributes.length ) { | ||
this.deferredAttributes.pop().update().updateDeferred = false; | ||
// Attributes don't reflect changes automatically if there is a possibility | ||
// that they will need to change again before the .set() cycle is complete | ||
// - they defer their updates until all values have been set | ||
while ( this._deferredAttributes.length ) { | ||
this._deferredAttributes.pop().update().updateDeferred = false; | ||
} | ||
@@ -158,8 +156,8 @@ }, | ||
_setSingle: function ( keypath, value ) { | ||
var keys, key, obj, normalised, i, resolved, unresolved; | ||
var keys, key, obj, normalised, i, unresolved; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); | ||
} else { | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
} | ||
@@ -169,3 +167,3 @@ | ||
// clear cache | ||
// Clear cache | ||
this._clearCache( normalised ); | ||
@@ -178,3 +176,3 @@ | ||
// if this branch doesn't exist yet, create a new one - if the next | ||
// If this branch doesn't exist yet, create a new one - if the next | ||
// key matches /^[0-9]+$/, assume we want an array branch rather | ||
@@ -193,3 +191,3 @@ // than an object | ||
// fire set event | ||
// Fire set event | ||
if ( !this.setting ) { | ||
@@ -202,21 +200,15 @@ this.setting = true; // short-circuit any potential infinite loops | ||
// Trigger updates of views that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised, value ); | ||
// Trigger updates of mustaches that observe `keypaths` or its descendants | ||
this._notifyObservers( normalised ); | ||
// See if we can resolve any of the unresolved keypaths (if such there be) | ||
i = this.pendingResolution.length; | ||
i = this._pendingResolution.length; | ||
while ( i-- ) { // Work backwards, so we don't go in circles! | ||
unresolved = this.pendingResolution.splice( i, 1 )[0]; | ||
unresolved = this._pendingResolution.splice( i, 1 )[0]; | ||
resolved = this.resolveRef( unresolved.view.model.ref, unresolved.view.contextStack ); | ||
// If we were able to find a keypath, initialise the view | ||
if ( resolved ) { | ||
unresolved.callback( resolved.keypath, resolved.value ); | ||
// If we can't resolve the reference, add to the back of | ||
// the queue (this is why we're working backwards) | ||
if ( !this.resolveRef( unresolved ) ) { | ||
this._pendingResolution[ this._pendingResolution.length ] = unresolved; | ||
} | ||
// Otherwise add to the back of the queue (this is why we're working backwards) | ||
else { | ||
this.registerUnresolvedKeypath( unresolved ); | ||
} | ||
} | ||
@@ -250,5 +242,5 @@ }, | ||
get: function ( keypath ) { | ||
var keys, normalised, lastDotIndex, formula, match, parentKeypath, parentValue, propertyName, unformatted, unformattedKeypath, value, formatters; | ||
var keys, normalised, key, match, parentKeypath, parentValue, value, formatters; | ||
if ( _private.isArray( keypath ) ) { | ||
if ( _internal.isArray( keypath ) ) { | ||
keys = keypath.slice(); // clone | ||
@@ -260,7 +252,7 @@ normalised = keys.join( '.' ); | ||
// cache hit? great | ||
if ( keypath in this._cache ) { | ||
if ( this._cache.hasOwnProperty( keypath ) ) { | ||
return this._cache[ keypath ]; | ||
} | ||
keys = _private.splitKeypath( keypath ); | ||
keys = _internal.splitKeypath( keypath ); | ||
normalised = keys.join( '.' ); | ||
@@ -270,3 +262,3 @@ } | ||
// we may have a cache hit now that it's been normalised | ||
if ( normalised in this._cache ) { | ||
if ( this._cache.hasOwnProperty( normalised ) ) { | ||
return this._cache[ normalised ]; | ||
@@ -276,13 +268,8 @@ } | ||
// otherwise it looks like we need to do some work | ||
if ( keys.length > 1 ) { | ||
formula = keys.pop(); | ||
parentValue = this.get( keys ); | ||
} else { | ||
formula = keys.pop(); | ||
parentValue = this.data; | ||
} | ||
key = keys.pop(); | ||
parentValue = ( keys.length ? this.get( keys ) : this.data ); | ||
// is this a set of formatters? | ||
if ( match = /^⭆(.+)⭅$/.exec( formula ) ) { | ||
formatters = _private.getFormattersFromString( match[1] ); | ||
if ( match = /^⭆(.+)⭅$/.exec( key ) ) { | ||
formatters = _internal.getFormattersFromString( match[1] ); | ||
value = this._format( parentValue, formatters ); | ||
@@ -292,7 +279,7 @@ } | ||
else { | ||
if ( typeof parentValue !== 'object' ) { | ||
if ( typeof parentValue !== 'object' || !parentValue.hasOwnProperty( key ) ) { | ||
return; | ||
} | ||
value = parentValue[ formula ]; | ||
value = parentValue[ key ]; | ||
} | ||
@@ -310,4 +297,3 @@ | ||
// allow functions as values | ||
// TODO allow arguments, same as formatters? | ||
// Allow functions as values | ||
if ( typeof value === 'function' ) { | ||
@@ -317,3 +303,3 @@ value = value(); | ||
// update cache | ||
// Update cache | ||
this._cache[ normalised ] = value; | ||
@@ -324,5 +310,9 @@ | ||
update: function () { | ||
// TODO | ||
throw new Error( 'not implemented yet!' ); | ||
update: function ( keypath ) { | ||
this._clearCache( keypath ); | ||
this._notifyObservers( keypath ); | ||
this.fire( 'update:' + keypath ); | ||
this.fire( 'update', keypath ); | ||
return this; | ||
@@ -339,44 +329,28 @@ }, | ||
registerView: function ( view ) { | ||
var self = this, resolved, initialUpdate, value, index; | ||
registerMustache: function ( mustache ) { | ||
var resolved, value, index; | ||
if ( view.parentFragment && ( view.parentFragment.indexRefs.hasOwnProperty( view.model.ref ) ) ) { | ||
// this isn't a real keypath, it's an index reference | ||
index = view.parentFragment.indexRefs[ view.model.ref ]; | ||
if ( mustache.parentFragment && ( mustache.parentFragment.indexRefs.hasOwnProperty( mustache.model.ref ) ) ) { | ||
// This isn't a real keypath, it's an index reference | ||
index = mustache.parentFragment.indexRefs[ mustache.model.ref ]; | ||
value = ( view.model.fmtrs ? this._format( index, view.model.fmtrs ) : index ); | ||
view.update( value ); | ||
value = ( mustache.model.fmtrs ? this._format( index, mustache.model.fmtrs ) : index ); | ||
mustache.update( value ); | ||
return; // this value will never change, and doesn't have a keypath | ||
return; // This value will never change, and doesn't have a keypath | ||
} | ||
initialUpdate = function ( keypath, value ) { | ||
if ( view.model.fmtrs ) { | ||
view.keypath = keypath + '.' + _private.stringifyFormatters( view.model.fmtrs ); | ||
} else { | ||
view.keypath = keypath; | ||
} | ||
// See if we can resolve a keypath from this mustache's reference (e.g. | ||
// does 'bar' in {{#foo}}{{bar}}{{/foo}} mean 'bar' or 'foo.bar'?) | ||
resolved = this.resolveRef( mustache ); | ||
// create observers | ||
view.observerRefs = self.observe( view.model.p || 0, view ); | ||
view.update( self.get( view.keypath ) ); | ||
}; | ||
resolved = this.resolveRef( view.model.ref, view.contextStack ); | ||
if ( !resolved ) { | ||
// we may still need to do an update, if the view has formatters | ||
// that e.g. offer an alternative to undefined | ||
if ( view.model.fmtrs ) { | ||
view.update( this._format( undefined, view.model.fmtrs ) ); | ||
// We may still need to do an update, event with unresolved | ||
// references, if the mustache has formatters that (for example) | ||
// provide a fallback value from undefined | ||
if ( mustache.model.fmtrs ) { | ||
mustache.update( this._format( undefined, mustache.model.fmtrs ) ); | ||
} | ||
this.registerUnresolvedKeypath({ | ||
view: view, | ||
callback: initialUpdate | ||
}); | ||
} else { | ||
initialUpdate( resolved.keypath, resolved.value ); | ||
this._pendingResolution[ this._pendingResolution.length ] = mustache; | ||
} | ||
@@ -387,38 +361,51 @@ }, | ||
// `'bar.baz'` within the context stack `['foo']` might resolve to `'foo.bar.baz'` | ||
resolveRef: function ( ref, contextStack ) { | ||
resolveRef: function ( mustache ) { | ||
var innerMost, keypath, value; | ||
var ref, contextStack, keys, lastKey, innerMostContext, contextKeys, parentValue, keypath; | ||
ref = mustache.model.ref; | ||
contextStack = mustache.contextStack; | ||
// Implicit iterators - i.e. {{.}} - are a special case | ||
if ( ref === '.' ) { | ||
keypath = contextStack[ contextStack.length - 1 ]; | ||
value = this.get( keypath ); | ||
return { keypath: keypath, value: value }; | ||
} | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
else { | ||
keys = _internal.splitKeypath( ref ); | ||
lastKey = keys.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
// Clone the context stack, so we don't mutate the original | ||
contextStack = contextStack.concat(); | ||
innerMost = contextStack.pop(); | ||
// Take each context from the stack, working backwards from the innermost context | ||
while ( contextStack.length ) { | ||
keypath = innerMost + '.' + ref; | ||
value = this.get( keypath ); | ||
innerMostContext = contextStack.pop(); | ||
contextKeys = _internal.splitKeypath( innerMostContext ); | ||
if ( value !== undefined ) { | ||
return { keypath: keypath, value: value }; | ||
parentValue = this.get( contextKeys.concat( keys ) ); | ||
if ( typeof parentValue === 'object' && parentValue.hasOwnProperty( lastKey ) ) { | ||
keypath = innerMostContext + '.' + ref; | ||
break; | ||
} | ||
} | ||
if ( !keypath && this.get( ref ) !== undefined ) { | ||
keypath = ref; | ||
} | ||
} | ||
value = this.get( ref ); | ||
if ( value !== undefined ) { | ||
return { keypath: ref, value: value }; | ||
// If we have any formatters, we need to append them to the keypath | ||
if ( keypath ) { | ||
mustache.keypath = ( mustache.model.fmtrs ? keypath + '.' + _internal.stringifyFormatters( mustache.model.fmtrs ) : keypath ); | ||
mustache.observerRefs = this.observe( mustache ); | ||
mustache.update( this.get( mustache.keypath ) ); | ||
return true; // indicate success | ||
} | ||
}, | ||
registerUnresolvedKeypath: function ( unresolved ) { | ||
this.pendingResolution[ this.pendingResolution.length ] = unresolved; | ||
return false; // failure | ||
}, | ||
@@ -457,4 +444,4 @@ | ||
_notifyObservers: function ( keypath, value ) { | ||
var self = this, observersGroupedByPriority = this.observers[ keypath ] || [], i, j, priorityGroup, observer, actualValue; | ||
_notifyObservers: function ( keypath ) { | ||
var self = this, observersGroupedByPriority = this._observers[ keypath ] || [], i, j, priorityGroup, observer; | ||
@@ -473,29 +460,26 @@ for ( i=0; i<observersGroupedByPriority.length; i+=1 ) { | ||
observe: function ( priority, view ) { | ||
observe: function ( mustache ) { | ||
var self = this, keypath, originalKeypath = view.keypath, observerRefs = [], observe, keys; | ||
var self = this, observerRefs = [], observe, keys, priority = mustache.model.p || 0; | ||
if ( !originalKeypath ) { | ||
return undefined; | ||
} | ||
observe = function ( keypath ) { | ||
var observers, observer; | ||
var observers; | ||
observers = self.observers[ keypath ] = self.observers[ keypath ] || []; | ||
observers = self._observers[ keypath ] = self._observers[ keypath ] || []; | ||
observers = observers[ priority ] = observers[ priority ] || []; | ||
observers[ observers.length ] = view; | ||
observers[ observers.length ] = mustache; | ||
observerRefs[ observerRefs.length ] = { | ||
keypath: keypath, | ||
priority: priority, | ||
view: view | ||
mustache: mustache | ||
}; | ||
}; | ||
keys = _private.splitKeypath( view.keypath ); | ||
keys = _internal.splitKeypath( mustache.keypath ); | ||
while ( keys.length > 1 ) { | ||
observe( keys.join( '.' ) ); | ||
// remove the last item in the keypath, so that data.set( 'parent', { child: 'newValue' } ) affects views dependent on parent.child | ||
// remove the last item in the keypath, so that `data.set( 'parent', { child: 'newValue' } )` | ||
// affects mustaches dependent on `parent.child` | ||
keys.pop(); | ||
@@ -510,6 +494,6 @@ } | ||
unobserve: function ( observerRef ) { | ||
var priorities, observers, index, i, len; | ||
var priorityGroups, observers, index, i, len; | ||
priorities = this.observers[ observerRef.keypath ]; | ||
if ( !priorities ) { | ||
priorityGroups = this._observers[ observerRef.keypath ]; | ||
if ( !priorityGroups ) { | ||
// nothing to unobserve | ||
@@ -519,3 +503,3 @@ return; | ||
observers = priorities[ observerRef.priority ]; | ||
observers = priorityGroups[ observerRef.priority ]; | ||
if ( !observers ) { | ||
@@ -531,3 +515,3 @@ // nothing to unobserve | ||
for ( i=0, len=observers.length; i<len; i+=1 ) { | ||
if ( observers[i] === observerRef.view ) { | ||
if ( observers[i] === observerRef.mustache ) { | ||
index = i; | ||
@@ -550,7 +534,7 @@ break; | ||
if ( observers.length === 0 ) { | ||
delete priorities[ observerRef.priority ]; | ||
delete priorityGroups[ observerRef.priority ]; | ||
} | ||
if ( priorities.length === 0 ) { | ||
delete this.observers[ observerRef.keypath ]; | ||
if ( priorityGroups.length === 0 ) { | ||
delete this._observers[ observerRef.keypath ]; | ||
} | ||
@@ -557,0 +541,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
(function ( R, _private ) { | ||
(function ( R, _internal ) { | ||
@@ -32,3 +32,3 @@ 'use strict'; | ||
_private.tokenize = function ( template ) { | ||
_internal.tokenize = function ( template ) { | ||
var stream = TokenStream.fromString( stripHtmlComments( template ) ); | ||
@@ -875,3 +875,3 @@ | ||
stripCommentTokens = function ( tokens ) { | ||
var i, current, previous, next, removeNext; | ||
var i, current, previous, next; | ||
@@ -905,3 +905,3 @@ for ( i=0; i<tokens.length; i+=1 ) { | ||
types = _private.types; | ||
types = _internal.types; | ||
whitespace = /\s/; | ||
@@ -919,2 +919,2 @@ mustacheTypes = { | ||
}( Ractive, _private )); | ||
}( Ractive, _internal )); |
@@ -1,2 +0,2 @@ | ||
_private.types = { | ||
_internal.types = { | ||
TEXT: 1, | ||
@@ -3,0 +3,0 @@ INTERPOLATOR: 2, |
@@ -63,2 +63,7 @@ [ | ||
{ | ||
"name": "Element with unquoted mustache attributes", | ||
"template": "<div class={{myClass}}>contents</div>", | ||
"compiled": [{"attrs":{"class":[{"p":1,"ref":"myClass","type":2}]},"frag":"contents","tag":"div","type":7}] | ||
}, | ||
{ | ||
"name": "Template with blacklisted elements (sanitize)", | ||
@@ -98,3 +103,23 @@ "template": "<style type='text/css'>body { font-family: 'Comic Sans MS'; }</style>", | ||
"sanitize": false | ||
}, | ||
{ | ||
"name": "SVG", | ||
"template": "<svg xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"{{x}}\" cy=\"{{y}}\" r=\"{{r}}\"/></svg>", | ||
"compiled": [{"attrs":{"xmlns":"http://www.w3.org/2000/svg"},"frag":[{"attrs":{"cx":[{"p":2,"ref":"x","type":2}],"cy":[{"p":2,"ref":"y","type":2}],"r":[{"p":2,"ref":"r","type":2}]},"tag":"circle","type":7}],"tag":"svg","type":7}] | ||
}, | ||
{ | ||
"name": "SVG with non-mustache text", | ||
"template": "<svg xmlns=\"http://www.w3.org/2000/svg\"><text>some text</text></svg>", | ||
"compiled": [{"attrs":{"xmlns":"http://www.w3.org/2000/svg"},"frag":[{"frag":"some text","tag":"text","type":7}],"tag":"svg","type":7}] | ||
}, | ||
{ | ||
"name": "SVG with interpolator", | ||
"template": "<svg xmlns=\"http://www.w3.org/2000/svg\"><text>{{hello}}</text></svg>", | ||
"compiled": [{"attrs":{"xmlns":"http://www.w3.org/2000/svg"},"frag":[{"frag":[{"p":2,"ref":"hello","type":2}],"tag":"text","type":7}],"tag":"svg","type":7}] | ||
}, | ||
{ | ||
"name": "SVG with interpolator and static text", | ||
"template": "<svg xmlns=\"http://www.w3.org/2000/svg\"><text>Hello {{thing}}!</text></svg>", | ||
"compiled": [{"attrs":{"xmlns":"http://www.w3.org/2000/svg"},"frag":[{"frag":["Hello ",{"p":2,"ref":"thing","type":2},"!"],"tag":"text","type":7}],"tag":"svg","type":7}] | ||
} | ||
] |
@@ -151,2 +151,35 @@ // RENDERING TESTS | ||
new_result: '<div>before <em>italic</em> <strong>bold</strong> after</div>' | ||
}, | ||
{ | ||
name: 'SVG', | ||
template: '<svg xmlns="http://www.w3.org/2000/svg"><circle cx="{{x}}" cy="{{y}}" r="{{r}}"/></svg>', | ||
data: { x: 50, y: 50, r: 50 }, | ||
result: '<svg xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50"></circle></svg>' | ||
}, | ||
{ | ||
name: 'SVG with non-mustache text', | ||
template: '<svg xmlns="http://www.w3.org/2000/svg"><text>some text</text></svg>', | ||
data: {}, | ||
result: '<svg xmlns="http://www.w3.org/2000/svg"><text>some text</text></svg>' | ||
}, | ||
{ | ||
name: 'SVG with interpolator', | ||
template: '<svg xmlns="http://www.w3.org/2000/svg"><text>{{hello}}</text></svg>', | ||
data: { hello: 'Hello world!' }, | ||
result: '<svg xmlns="http://www.w3.org/2000/svg"><text>Hello world!</text></svg>' | ||
}, | ||
{ | ||
name: 'SVG with interpolator and static text', | ||
template: '<svg xmlns="http://www.w3.org/2000/svg"><text>Hello {{thing}}!</text></svg>', | ||
data: { thing: 'world' }, | ||
result: '<svg xmlns="http://www.w3.org/2000/svg"><text>Hello world!</text></svg>' | ||
}, | ||
{ | ||
name: 'Inverted section with formatters and failed lookup', | ||
template: '{{^section | opposite}}should not appear{{/section}}', | ||
data: {}, | ||
result: '', | ||
formatters: { | ||
opposite: function ( val ) { return !val; } | ||
} | ||
} | ||
@@ -153,0 +186,0 @@ ]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3775230
107
85041