ractive
Version:
Next-generation DOM manipulation
2 lines • 39 kB
JavaScript
(function(t){"use strict";var e=function(){var t,e;return t=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=e(this.el)),this._subs={},void 0===this.viewmodel&&(this.viewmodel=new t.ViewModel),this.viewmodel.dependents.push(this),this.data&&this.viewmodel.set(this.data),this.partials)for(r in this.partials)if(this.partials.hasOwnProperty(r)&&"string"==typeof this.partials[r]){if(!t.compile)throw Error('Missing Ractive.compile - cannot compile partial "'+r+'". Either precompile or use the version that includes the compiler');this.partials[r]=t.compile(this.partials[r],this)}if("string"==typeof this.template){if(!t.compile)throw Error("Missing Ractive.compile - cannot compile template. Either precompile or use the version that includes the compiler");this.template=t.compile(this.template,this)}this.el&&this.render({el:this.el,callback:this.callback,append:this.append})},t.prototype={render:function(i){var n=i.el?e(i.el):this.el;if(!n)throw Error("You must specify a DOM element to render to");i.append||(n.innerHTML=""),i.callback&&(this.callback=i.callback),this.rendered=new t.DomFragment({model:this.template,root:this,parentNode:n})},teardown:function(){this.rendered.teardown()},set:function(){return this.viewmodel.set.apply(this.viewmodel,arguments),this},get:function(){return this.viewmodel.get.apply(this.viewmodel,arguments)},update:function(){return this.viewmodel.update.apply(this.viewmodel,arguments),this},_format:function(e,i){var n,r,s,o,a,h;if(!i)return e;for(r=i.length,n=0;r>n;n+=1)s=i[n],o=s.name,a=s.args||[],h=this.formatters[o]||t.formatters[o],h&&(e=h.apply(this,[e].concat(a)));return e}},e=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")}},t}();(function(t){t.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}})(e),function(t){var e,i;e=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t},t._Mustache=function(t){this.root=t.root,this.model=t.model,this.viewmodel=t.root.viewmodel,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.initialize&&this.initialize(),this.viewmodel.registerView(this),!this.keypath&&this.model.inv&&this.update(!1)},t._Fragment=function(t){var e,i,n,r,s;if(!this.preInit||!this.preInit(t)){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(n){var r,s,o,a,h;if(r={model:this.model.frag,root:this.root,parentNode:this.parentNode,parent:this},this.parentNode&&(r.anchor=this.parentFragment.findNextNode(this)),s=e(n),s&&this.root.modifyArrays&&t.modifyArray(n,this.keypath,this.root.viewmodel),s&&0===n.length&&(o=!0),this.model.inv){if(n&&!o)this.length&&(this.unrender(),this.length=0);else if(!this.length)return r.contextStack=this.contextStack,r.index=0,this.fragments[0]=this.createFragment(r),this.length=1,void 0;return this.postUpdate&&this.postUpdate(),void 0}if(s){if(n.length<this.length)for(h=this.views.splice(n.length,this.length-n.length);h.length;)h.pop().teardown();else if(n.length>this.length)for(a=this.length;n.length>a;a+=1)r.contextStack=this.contextStack.concat(this.keypath+"."+a),r.index=a,this.model.i&&(r.indexRef=this.model.i),this.fragments[a]=this.createFragment(r);this.length=n.length}else i(n)?this.length||(r.contextStack=this.contextStack.concat(this.keypath),r.index=0,this.fragments[0]=this.createFragment(r),this.length=1):n&&!o?this.length||(r.contextStack=this.contextStack,r.index=0,this.fragments[0]=this.createFragment(r),this.length=1):this.length&&(this.unrender(),this.length=0);this.postUpdate&&this.postUpdate()}}(e),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||{};(function(t){var e,i,n,r,s,o,a,h,u,l,c,f,d,p;t.compile=function(e,n){var r,s;return n=n||{},t.delimiters=n.delimiters||["{{","}}"],t.tripleDelimiters=n.tripleDelimiters||["{{{","}}}"],r=t.tokenize(e),s=i(r),s.toJson()},l=t.types,c=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],f=["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"],d=["li","dd","rt","rp","optgroup","option","tbody","tfoot","tr","td","th"],p={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}},h={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},a=function(t){var e;return e=t.replace(/&([a-zA-Z]+);/,function(t,e){return h[e]?String.fromCharCode(h[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)})},n=function(t){this.text=t.value},n.prototype={toJson:function(){return this.decoded||(this.decoded=a(this.text))},toString:function(){return this.text},decodeCharacterReferences:function(){}},r=function(t,n){var r,s,o,a;if(this.type=l.ELEMENT,this.tag=t.tag,this.parentFragment=n,this.parentElement=n.parentElement,r=t.attributes.items,o=r.length){for(s=[],a=0;o>a;a+=1)s[a]={name:r[a].name.value,value:i(r[a].value.tokens,this.parentFragment.priority+1)};this.attributes=s}t.isSelfClosingTag||-1!==c.indexOf(t.tag.toLowerCase())||(this.fragment=new e(this,n.priority+1))},r.prototype={read:function(t){return this.fragment&&this.fragment.read(t)},toJson:function(t){var e,i,n,r,s;if(e={type:l.ELEMENT,tag:this.tag},this.attributes)for(e.attrs={},s=0;this.attributes.length>s;s+=1)i=this.attributes[s].name,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===f.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,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+">"))}},s=function(t,i){this.type=l.SECTION,this.parentFragment=i,this.ref=t.ref,this.inverted=t.type===l.INVERTED,this.formatters=t.formatters,this.i=t.i,this.fragment=new e(this,i.priority+1)},s.prototype={read:function(t){return this.fragment.read(t)},toJson:function(t){var e;return e={type:l.SECTION,ref:this.ref,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}},o=function(t,e){this.type=t.type,this.priority=e,this.ref=t.ref,this.formatters=t.formatters},o.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}},e=function(t,e){this.owner=t,this.items=[],t&&(this.parentElement=t.type===l.ELEMENT?t:t.parentElement),this.priority=e},e.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===l.CLOSING||t.type===l.DELIMCHANGE||t.type===l.COMMENT?!1:t.type===l.SECTION||t.type===l.INVERTED?(this.currentChild=new s(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===l.TAG?(this.currentChild=new r(t,this),this.items[this.items.length]=this.currentChild,!0):t.type===l.TEXT||t.type===l.ATTR_VALUE_TOKEN?(this.items[this.items.length]=new n(t),!0):(this.items[this.items.length]=new o(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===l.ELEMENT?(r=this.owner.tag.toLowerCase(),s=t.tag.toLowerCase(),i=this.owner,n=i.parentElement||null,e=p[r],e&&!t.isClosingTag&&-1!==e.indexOf(s)?!0:-1!==d.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===l.SECTION&&t.type===l.CLOSING&&t.ref===this.owner.ref?!0:this.owner.type===l.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(){this.sealed=!0}},i=function(t,i){for(var n,r=new e(null,i||0);t.length;)n=t.shift(),r.read(n);return r}})(e),function(t){var e,i,n,r,s,o,a,h,u,l,c,f,d,p,m,g,v,w,y;t.tokenize=function(t){var e=r.fromString(n(t));return e.tokens},r=function(){this.tokens=[],this.buffer=new s},r.prototype={read:function(t){var i,n;if(this.currentToken&&this.currentToken.type===e.TAG&&this.currentToken.read(t))return!0;if(this.buffer.read(t))return!0;if(i=this.buffer.convert())return this.currentToken&&this.currentToken.seal(),this.currentToken=this.tokens[this.tokens.length]=i,!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 u,this.currentToken.read("<")):(this.currentToken=new o,this.currentToken.read(n.charAt(0))),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1))}return!0}return this.currentToken="<"===t?new u:new o,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())}},r.fromString=function(t){var e,i,n;for(e=new r,i=0,n=t.length;n>i;)e.read(t.charAt(i)),i+=1;return e.end(),e},s=function(){this.value=""},s.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 h:void 0},o=function(){return 0===e.indexOf(i)?new a: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)}},o=function(){this.type=e.TEXT,this.value=""},o.prototype={read:function(t){return this.sealed?!1:"<"===t?!1:(this.value+=t,!0)},seal:function(){this.sealed=!0}},a=function(){this.value="",this.openingDelimiter=t.delimiters[0],this.closingDelimiter=t.delimiters[1]},h=function(){this.value="",this.openingDelimiter=t.tripleDelimiters[0],this.closingDelimiter=t.tripleDelimiters[1],this.type=e.TRIPLE},a.prototype=h.prototype={read:function(t){return this.sealed?!1:(this.value+=t,this.value.substr(-this.closingDelimiter.length)===this.closingDelimiter&&this.seal(),!0)},seal:function(){var t,i,n,r,s;this.sealed||(t=this.value.replace(this.openingDelimiter,"").replace(this.closingDelimiter,"").trim(),"="===t.charAt(0)&&(this.changeDelimiters(t),this.type=e.DELIMCHANGE),this.type||(i=t.charAt(0),c[i]?(this.type=c[i],t=t.substring(1).trim()):this.type=e.INTERPOLATOR),this.type===e.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(i){var n,r;r=/\=([^\s=]+)\s+([^\s=]+)=/.exec(i),n=this.type===e.TRIPLE?t.tripleDelimiters:t.delimiters,n[0]=r[1],n[1]=r[2]}},u=function(){this.type=e.TAG,this.openingBracket=new f,this.closingTagSolidus=new m,this.tagName=new d,this.attributes=new p,this.selfClosingSolidus=new m,this.closingBracket=new g},u.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}},f=function(){},f.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}},d=function(){},d.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}},p=function(){this.items=[]},p.prototype={read:function(t){return this.sealed?!1:this.nextItem&&this.nextItem.read(t)?!0:i.test(t)?!0:(this.nextItem=new v,this.nextItem.read(t)?(this.items[this.items.length]=this.nextItem,!0):(this.seal(),!1))},seal:function(){this.sealed=!0}},v=function(){this.name=new w,this.value=new y},v.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}},w=function(){},w.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}},y=function(){this.tokens=[],this.buffer=new s,this.expected=!1},y.prototype={read:function(t){var e,n;if(this.sealed)return!1;if(!this.expected)return i.test(t)?!0:"="===t?(this.expected=!0,!0):!1;if(!this.tokens.length&&!this.quoteMark){if(i.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(n=this.buffer.release(),this.currentToken){for(;n.length;){for(;n.length&&n.charAt(0)!==this.quoteMark&&this.currentToken.read(n.charAt(0));)n=n.substring(1);if(n.length&&n.charAt(0)!==this.quoteMark&&(this.currentToken=new l(this.quoteMark),this.currentToken.read(n.charAt(0)),this.tokens[this.tokens.length]=this.currentToken,n=n.substring(1)),n.charAt(0)===this.quoteMark)return this.currentToken.seal(),this.seal(),!0}return!0}return this.currentToken=new l(this.quoteMark),this.currentToken.read(t),this.tokens[this.tokens.length]=this.currentToken,this.currentToken.sealed&&this.seal(),!0},seal:function(){this.sealed=!0}},l=function(t){this.type=e.ATTR_VALUE_TOKEN,this.quoteMark=t||"",this.value=""},l.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}},m=function(){},m.prototype={read:function(t){return this.sealed?!1:"/"===t?(this.value="/",this.seal(),!0):(this.seal(),!1)},seal:function(){this.sealed=!0}},g=function(){},g.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}},n=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},e=t.types,i=/\s/,c={"#":e.SECTION,"^":e.INVERTED,"/":e.CLOSING,">":e.PARTIAL,"!":e.COMMENT,"&":e.INTERPOLATOR}}(e),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;t.ViewModel=function(t){this.data=t||{},this.pendingResolution=[],this.observers={},this.dependents=[]},t.ViewModel.prototype={set:function(t,i){var n,r,s,o,a,h,u,l;if("object"!=typeof t){for(this.dependents.forEach(function(e){e.setting||(e.setting=!0,e.fire("set",t,i),e.fire("set:"+t,i),e.setting=!1)}),r=e(t),l=r.join("."),o=this.data;r.length>1;)s=r.shift(),o=o[s]||{};for(s=r[0],o[s]=i,this._notifyObservers(l,i),a=this.pendingResolution.length;a--;)h=this.pendingResolution.splice(a,1)[0],u=this.resolveRef(h.view.model.ref,h.view.contextStack),u?h.callback(u.keypath,u.value):this.registerUnresolvedKeypath(h)}else for(n in t)t.hasOwnProperty(n)&&this.set(n,t[n])},get:function(t){var i,n;if(!t)return void 0;for(i=e(t),n=this.data;i.length;)if(n&&(n=n[i.shift()]),void 0===n)return n;return"function"==typeof n?n.call(this,t):n},update:function(t){var e;if(t)this._notifyObservers(t,this.get(t));else for(e in this.data)this.data.hasOwnProperty(e)&&this._notifyObservers(e,this.get(e))},registerView:function(t){var e,i,n,r,s=this;return t.parentFragment&&t.parentFragment.indexRefs.hasOwnProperty(t.model.ref)?(r=t.parentFragment.indexRefs[t.model.ref],n=t.model.fmtrs?t.root._format(r,t.model.fmtrs):r,t.update(n),void 0):(i=function(e,i){t.keypath=e,t.observerRefs=s.observe({keypath:e,priority:t.model.p||0,view:t}),t.model.fmtrs&&(i=t.root._format(i,t.model.fmtrs)),t.update(i)},e=this.resolveRef(t.model.ref,t.contextStack),e?i(e.keypath,e.value):this.registerUnresolvedKeypath({view:t,callback:i}),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},_notifyObservers:function(t,e){var i,n,r,s,o,a=this,h=this.observers[t]||[];for(i=0;h.length>i;i+=1)if(r=h[i])for(n=0;r.length>n;n+=1)s=r[n],o=t!==s.originalAddress?a.get(s.originalAddress):e,s.view.model.fmtrs&&(o=s.view.root._format(o,s.view.model.fmtrs)),s.view.update(o)},observe:function(t){var e,i,n=this,r=t.keypath,s=t.priority,o=[];if(2===arguments.length&&"string"==typeof arguments[0]&&"function"==typeof arguments[1])return this.observe({keypath:arguments[0],callback:arguments[1],priority:0});if(!t.keypath)return void 0;for(i=function(e){var i,a;i=n.observers[e]=n.observers[e]||[],i=i[s]=i[s]||[],a={originalAddress:r},t.view&&(a.view=t.view),t.callback&&(a.callback=t.callback),i[i.length]=a,o[o.length]={keypath:e,priority:s,observer:a}},e=t.keypath;-1!==e.lastIndexOf(".");)i(e),e=e.substr(0,e.lastIndexOf("."));return i(e),o},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.observer){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.ViewModel.prototype.cancelKeypathResolution=Array.prototype.filter?function(t){this.pendingResolution=this.pendingResolution.filter(function(e){return e.view!==t})}:function(t){var e,i=[];for(e=0;this.pendingResolution.length>e;e+=1)this.pendingResolution[e].view!==t&&(i[i.length]=this.pendingResolution[e]);this.pendingResolution=i},i=/\[\s*([0-9]+)\s*\]/g,e=function(t){var e;return e=t.replace(i,".$1"),e.split(".")}}(e),function(t){var e,i,n,r,s,o,a,h,u,l,c;e=t.types,r="undefined"!=typeof window?window.document:null,n=function(t,e){return t.contains?t.contains(e):!0},i=function(t,e,i){var n,s,o,a=[];for(i=i||null,n=r.createElement("div"),n.innerHTML=t,o=n.childNodes.length,s=0;o>s;s+=1)a[s]=n.childNodes[s];for(s=0;o>s;s+=1)e.insertBefore(a[s],i);return a},t.DomFragment=function(e){t._Fragment.call(this,e)},t.DomFragment.prototype={preInit:function(t){return"string"==typeof t.model?(this.nodes=i(t.model,t.parentNode,t.anchor),!0):void 0},createItem:function(t){if("string"==typeof t.model)return new s(t);switch(t.model.type){case e.INTERPOLATOR:return new u(t);case e.SECTION:return new c(t);case e.TRIPLE:return new l(t);case e.ELEMENT:return new o(t);case e.PARTIAL:return new a(t);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():this.parentSection?this.parentSection.findNextNode(this):null},findNextNode:function(t){var e=t.index;return this.items[e+1]?this.items[e+1].firstNode():this.parentSection?this.parentSection.findNextNode(this):null}},a=function(e){this.fragment=new t.DomFragment({model:e.root.partials[e.model.ref]||[],root:e.root,parentNode:e.parentNode,contextStack:e.contextStack,anchor:e.anchor,parent:this})},a.prototype={teardown:function(){this.fragment.teardown()}},s=function(t){this.node=r.createTextNode(t.model),this.index=t.index,this.root=t.root,this.parentNode=t.parentNode,this.parentNode.insertBefore(this.node,t.anchor||null)},s.prototype={teardown:function(){n(this.root.el,this.node)&&this.parentNode.removeChild(this.node)},firstNode:function(){return this.node}},o=function(e){var i,n,s,o,a,u;if(n=this.model=e.model,this.root=e.root,this.viewmodel=e.root.viewmodel,this.parentFragment=e.parentFragment,this.parentNode=e.parentNode,this.index=e.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),this.attributes=[];for(a in n.attrs)n.attrs.hasOwnProperty(a)&&(u=n.attrs[a],o=new h({parent:this,name:a,value:u,root:e.root,parentNode:this.node,contextStack:e.contextStack}),"value"!==a||!this.root.twoway||"input"!==n.tag.toLowerCase()&&"textarea"!==n.tag.toLowerCase()||(i=o),this.attributes[this.attributes.length]=o);i&&this.bind(i,e.root.lazy),n.frag&&("string"==typeof n.frag?this.node.innerHTML=n.frag:this.children=new t.DomFragment({model:n.frag,root:e.root,parentNode:this.node,contextStack:e.contextStack,anchor:null,parent:this})),this.parentNode.insertBefore(this.node,e.anchor||null)},o.prototype={bind:function(e,i){var n,r,s,o,a=this.viewmodel,h=this.node;if(r=!0,!e.fragment||1!==e.fragment.items.length||e.fragment.items[0].type!==t.types.INTERPOLATOR||e.fragment.items[0].model.formatters&&e.fragment.items[0].model.formatters.length)throw"Not a valid two-way data binding candidate - must be a single interpolator with no formatters";s=e.fragment.items[0],o=s.keypath||s.model.partialKeypath,n=function(){var t=h.value;"0"===t?t=0:""!==t&&(t=+t||t),a.set(o,t)},n(),h.addEventListener("change",n),i||h.addEventListener("keyup",n)},teardown:function(){for(n(this.root.el,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,r,s,o,a;if(i=e.name,n=e.value,this.parent=e.parent,r=i.indexOf(":"),-1!==r){if(s=i.substr(0,r),"xmlns"===s)o=null;else for(a=e.parentNode;a&&!o;)o=a.getAttribute("xmlns:"+s),a=a.parentNode||e.parent.parentFragment.parent.node||e.parent.parentFragment.parent.parentNode;o&&(this.namespace=o)}return"string"==typeof n?(o?e.parentNode.setAttributeNS(o,i.replace(s+":",""),n):e.parentNode.setAttribute(i,n),void 0):(this.parentNode=e.parentNode,this.name=i,this.children=[],this.parentFragment=this.parent.parentFragment,this.fragment=new t.TextFragment({model:n,root:e.root,parent:this,contextStack:e.contextStack}),this.ready=!0,this.update(),void 0)},h.prototype={teardown:function(){if(this.children)for(;this.children.length;)this.children.pop().teardown()},bubble:function(){this.update()},update:function(){var t=this.value;this.ready&&(this.value=""+this.fragment,this.value!==t&&(this.namespace?this.parentNode.setAttributeNS(this.namespace,this.name,this.value):this.parentNode.setAttribute(this.name,this.value)))}},u=function(e){t._Mustache.call(this,e)},u.prototype={initialize:function(){this.node=r.createTextNode(""),this.parentNode.insertBefore(this.node,this.anchor||null)},teardown:function(){this.observerRefs?this.viewmodel.unobserveAll(this.observerRefs):this.viewmodel.cancelKeypathResolution(this),n(this.root.el,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}},l=function(e){t._Mustache.call(this,e)},l.prototype={initialize:function(){this.nodes=[]},teardown:function(){if(n(this.root.el,this.parentNode))for(;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());this.observerRefs?this.viewmodel.unobserveAll(this.observerRefs):this.viewmodel.cancelKeypathResolution(this)},firstNode:function(){return this.nodes[0]?this.nodes[0]:this.parentFragment.findNextNode(this)},update:function(t){var e;if(t!==this.html){for(this.html=t;this.nodes.length;)this.parentNode.removeChild(this.nodes.pop());e=this.anchor||this.parentFragment.findNextNode(this),this.nodes=i(t,this.parentNode,e)}}},c=function(e){t._Mustache.call(this,e)},c.prototype={initialize:function(){this.fragments=[],this.length=0},teardown:function(){this.unrender(),this.observerRefs?this.viewmodel.unobserveAll(this.observerRefs):this.viewmodel.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:t._sectionUpdate,createFragment:function(e){return new t.DomFragment(e)}}}(e),function(t){var e,i,n,r,s;e=t.types,t.TextFragment=function(e){t._Fragment.call(this,e)},t.TextFragment.prototype={init:function(){this.value=this.items.join("")},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.items.join(""),this.parent.bubble()},teardown:function(){var t,e;
for(t=this.items.length,e=0;t>e;e+=1)this.items[e].teardown()},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.viewmodel.unobserveAll(this.observerRefs):this.viewmodel.cancelKeypathResolution(this)},toString:function(){return void 0===this.value?"":this.value}},r=n,s=function(e){t._Mustache.call(this,e)},s.prototype={initialize:function(){this.fragments=[],this.length=0},teardown:function(){this.unrender(),this.observerRefs?this.viewmodel.unobserveAll(this.observerRefs):this.viewmodel.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("")}}}(e),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.viewmodels,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={viewmodels:[n],keypathsByIndex:[[i]]},e(t))},e=function(t){var e=function(t){var e,i;e=t._ractive.viewmodels,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}})}}(e),function(t){t.easing={easeInQuad:function(t){return Math.pow(t,2)},easeOutQuad:function(t){return-(Math.pow(t-1,2)-1)},easeInOutQuad:function(t){return 1>(t/=.5)?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},easeInCubic:function(t){return Math.pow(t,3)},easeOutCubic:function(t){return Math.pow(t-1,3)+1},easeInOutCubic:function(t){return 1>(t/=.5)?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},easeInQuart:function(t){return Math.pow(t,4)},easeOutQuart:function(t){return-(Math.pow(t-1,4)-1)},easeInOutQuart:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeInQuint:function(t){return Math.pow(t,5)},easeOutQuint:function(t){return Math.pow(t-1,5)+1},easeInOutQuint:function(t){return 1>(t/=.5)?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInSine:function(t){return-Math.cos(t*(Math.PI/2))+1},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:-Math.pow(2,-10*t)+1},easeInOutExpo:function(t){return 0===t?0:1===t?1:1>(t/=.5)?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-Math.pow(t-1,2))},easeInOutCirc:function(t){return 1>(t/=.5)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeOutBounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return 1>(t/=.5)?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},elastic:function(t){return-1*Math.pow(4,-8*t)*Math.sin((6*t-1)*2*Math.PI/2)+1},swingFromTo:function(t){var e=1.70158;return 1>(t/=.5)?.5*t*t*(((e*=1.525)+1)*t-e):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},swingFrom:function(t){var e=1.70158;return t*t*((e+1)*t-e)},swingTo:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},bounce:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bouncePast:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?2-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?2-(7.5625*(t-=2.25/2.75)*t+.9375):2-(7.5625*(t-=2.625/2.75)*t+.984375)},easeFromTo:function(t){return 1>(t/=.5)?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeFrom:function(t){return Math.pow(t,4)},easeTo:function(t){return Math.pow(t,.25)}}}(e),function(t){var e,i,n;n="undefined"!=typeof window?window:{},function(t,e){var i;for(i=0;t.length>i&&!n.requestAnimationFrame;++i)n.requestAnimationFrame=n[t[i]+"RequestAnimationFrame"],n.cancelAnimationFrame=n[t[i]+"CancelAnimationFrame"]||n[t[i]+"CancelRequestAnimationFrame"];n.requestAnimationFrame||(n.requestAnimationFrame=function(t){var i,r,s;return i=Date.now(),r=Math.max(0,16-(i-e)),s=n.setTimeout(function(){t(i+r)},r),e=i+r,s}),n.cancelAnimationFrame||(n.cancelAnimationFrame=function(t){n.clearTimeout(t)})}(["ms","moz","webkit","o"],0,n),e=function(t){var e;this.startTime=Date.now();for(e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);this.delta=this.to-this.from,this.running=!0},i={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?n.requestAnimationFrame(this.boundTick):this.running=!1},boundTick:function(){i.tick()},push:function(t){this.animations[this.animations.length]=t,this.running||(this.running=!0,this.tick())}},e.prototype={tick:function(){var t,e,i,n;return this.running?(n=Date.now(),t=n-this.startTime,t>=this.duration?(this.viewmodel.set(this.keypath,this.to),this.complete&&this.complete(1),this.running=!1,!1):(e=this.easing?this.easing(t/this.duration):t/this.duration,i=this.from+e*this.delta,this.viewmodel.set(this.keypath,i),this.step&&this.step(e,i),!0)):!1},stop:function(){this.running=!1}},t.prototype.animate=function(n,r,s){var o,a,h,u,l;if(r=parseFloat(r),isNaN(r))throw"Cannot animate to a non-numeric property";if(a=parseFloat(this.get(n)),isNaN(r))throw"Cannot animate from a non-numeric property";for(l=i.animations.length;l--;)i.animations[l].keypath===n&&i.animations[l].stop();s&&s.easing&&(o="function"==typeof s.easing?s.easing:this.easing&&this.easing[s.easing]?this.easing[s.easing]:t.easing[s.easing],"function"!=typeof o&&(o=null)),h=s&&void 0!==s.duration?s.duration:400,u=new e({keypath:n,from:a,to:r,viewmodel:this.viewmodel,duration:h,easing:o}),i.push(u)}}(e),"undefined"!=typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd?define(function(){return e}):t.Ractive=e})(this);