Commit 9e536a3c authored by Rhsy's avatar Rhsy Committed by Sindre Sorhus

Close #163: PlastronJS app

parent 2b4a9d49
# PlastronJS • [TodoMVC](http://todomvc.com)
A todo app using [PlastronJS](https://github.com/rhysbrettbowen/PlastronJS)
and [Closure Tools](https://developers.google.com/closure/)
## Run
Just open the index.html in your browser
## Run uncompiled
The app is built with [Plovr](http://plovr.com/). To run the unminified version you need to [download Plovr](http://plovr.com/download.html), create a directory called "build" and put the jar file in the build folder.
You will then need to [download PlastronJS](https://github.com/rhysbrettbowen/PlastronJS) to js/lib (you will need to create the folder).
Next open a command prompt in the base directory of the plastronjs todomvc example and type in.
```
java -jar build/plovr.jar serve plovr.json
```
Change the script src at the bottom of the index.html from js/compiled.js to:
```
http://localhost:9810/compile?id=todomvc&mode=raw
```
You can now view the uncompiled example and play around with it!
# Compilation
Once you have done the steps above you can compile any changes you make by running the below command:
```
java -jar build/plovr.jar build plovr.json
```
and view the compiled version fo the page by changing the bottom script src back to js/compiled.
## Need help?
shoot me a quick message on [twitter](https://twitter.com/#!/RhysBB)
## Credit
Created by [Rhys Brett-Bowen](http://rhysbrettbowen.com)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PlastronJS • TodoMVC</title>
<link rel="stylesheet" href="../../../assets/base.css">
<!--[if IE]>
<script src="../../../assets/ie.js"></script>
<![endif]-->
</head>
<body>
<section id="todoapp">
<header id="header">
<h1>todos</h1>
<input id="new-todo" class="todo-entry" placeholder="What needs to be done?" autofocus>
</header>
<section id="main">
<input id="toggle-all" class="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list"></ul>
</section>
<footer id="footer">
<span id="todo-count"><strong>0</strong> item left</span>
<ul id="filters">
<li>
<a class="selected" href="#/">All</a>
</li>
<li>
<a href="#/active">Active</a>
</li>
<li>
<a href="#/completed">Completed</a>
</li>
</ul>
<button id="clear-completed" class="clear-completed">Clear completed</button>
</footer>
</section>
<footer id="info">
<p>Double-click to edit a todo</p>
<p>Created by <a href="http://rhysbrettbowen.com">Rhys Brett-Bowen</a> (<a href="https://twitter.com/#!/RhysBB">RhysBB</a>).</p>
<p>Using <a href="https://github.com/rhysbrettbowen/PlastronJS">PlastronJS</a> and <a href="https://developers.google.com/closure/">Closure Tools</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a>.</p>
</footer>
<script src="../../../assets/base.js"></script>
<!-- <script src="http://localhost:9810/compile?id=todomvc&mode=raw"></script> -->
<script src="js/compiled.js"></script>
</body>
</html>
\ No newline at end of file
goog.require('goog.dom');
goog.require('goog.dom.classes');
goog.require('mvc.Collection');
goog.require('mvc.Router');
goog.require('todomvc.listcontrol');
goog.require('todomvc.listmodel');
var todolist = new todomvc.listmodel();
//create the control for the collection.
var todolistControl = new todomvc.listcontrol(todolist);
todolistControl.decorate(goog.dom.getElement('todoapp'));
//setup router
var router = new mvc.Router();
/**
* toggles selected class on filters list
*
* @param {string} chosenFilter selected filter by name.
*/
var toggleFilters = function(chosenFilter) {
var filters = goog.dom.getElementsByTagNameAndClass('A', undefined,
goog.dom.getElement('filters'));
goog.array.forEach(filters, function(filter) {
goog.dom.classes.enable(filter, 'selected',
goog.dom.getTextContent(filter) === chosenFilter);
});
};
router.route('/', function() {
todolistControl.setFilter(todomvc.listcontrol.Filter.ALL);
toggleFilters('All');
});
router.route('/active', function() {
todolistControl.setFilter(todomvc.listcontrol.Filter.ACTIVE);
toggleFilters('Active');
});
router.route('/completed', function() {
todolistControl.setFilter(todomvc.listcontrol.Filter.COMPLETED);
toggleFilters('Completed');
});
(function(){function g(a){throw a;}var i=void 0,j=!0,k=null,m=!1,n,o=this;function aa(){}
function ba(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function q(a){return a!==i}function r(a){return"array"==ba(a)}function s(a){var b=ba(a);return"array"==b||"object"==b&&"number"==typeof a.length}function u(a){return"string"==typeof a}function ca(a){return"number"==typeof a}function da(a){return"function"==ba(a)}function ea(a){var b=typeof a;return"object"==b&&a!=k||"function"==b}function v(a){return a[fa]||(a[fa]=++ga)}
var fa="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),ga=0;function ha(a,b,c){return a.call.apply(a.bind,arguments)}function ia(a,b,c){a||g(Error());if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}
function x(a,b,c){x=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ha:ia;return x.apply(k,arguments)}var ja=Date.now||function(){return+new Date};function y(a,b){function c(){}c.prototype=b.prototype;a.j=b.prototype;a.prototype=new c;a.prototype.constructor=a};function ka(a,b){for(var c=1;c<arguments.length;c++)var d=(""+arguments[c]).replace(/\$/g,"$$$$"),a=a.replace(/\%s/,d);return a}function la(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")}var ma=/^[a-zA-Z0-9\-_.!~*'()]*$/;function na(a){if(!oa.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(pa,"&amp;"));-1!=a.indexOf("<")&&(a=a.replace(qa,"&lt;"));-1!=a.indexOf(">")&&(a=a.replace(ra,"&gt;"));-1!=a.indexOf('"')&&(a=a.replace(sa,"&quot;"));return a}var pa=/&/g,qa=/</g,ra=/>/g,sa=/\"/g,oa=/[&<>\"]/;var z=Array.prototype,A=z.indexOf?function(a,b,c){return z.indexOf.call(a,b,c)}:function(a,b,c){c=c==k?0:0>c?Math.max(0,a.length+c):c;if(u(a))return!u(b)||1!=b.length?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},B=z.forEach?function(a,b,c){z.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=u(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},ta=z.filter?function(a,b,c){return z.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,h=u(a)?a.split(""):
a,l=0;l<d;l++)if(l in h){var p=h[l];b.call(c,p,l,a)&&(e[f++]=p)}return e},C=z.map?function(a,b,c){return z.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=u(a)?a.split(""):a,h=0;h<d;h++)h in f&&(e[h]=b.call(c,f[h],h,a));return e},ua=z.some?function(a,b,c){return z.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=u(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return j;return m};function va(a,b){var c=wa(a,b);return 0>c?k:u(a)?a.charAt(c):a[c]}
function wa(a,b){for(var c=a.length,d=u(a)?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(i,d[e],e,a))return e;return-1}function xa(a,b){for(var c=u(a)?a.split(""):a,d=a.length-1;0<=d;d--)if(d in c&&b.call(i,c[d],d,a))return d;return-1}function ya(a,b){0<=A(a,b)||a.push(b)}function za(a,b,c){Aa(a,c,0,b)}function Ba(a,b){var c=A(a,b);0<=c&&z.splice.call(a,c,1)}function Ca(a,b){var c=wa(a,b);return 0<=c?(z.splice.call(a,c,1),j):m}function Da(a){return z.concat.apply(z,arguments)}
function Ea(a){if(r(a))return Da(a);for(var b=[],c=0,d=a.length;c<d;c++)b[c]=a[c];return b}function Fa(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c],e;if(r(d)||(e=s(d))&&d.hasOwnProperty("callee"))a.push.apply(a,d);else if(e)for(var f=a.length,h=d.length,l=0;l<h;l++)a[f+l]=d[l];else a.push(d)}}function Aa(a,b,c,d){z.splice.apply(a,Ga(arguments,1))}function Ga(a,b,c){return 2>=arguments.length?z.slice.call(a,b):z.slice.call(a,b,c)}
function Ia(a,b){if(!s(a)||!s(b)||a.length!=b.length)return m;for(var c=a.length,d=Ja,e=0;e<c;e++)if(!d(a[e],b[e]))return m;return j}function Ja(a,b){return a===b};var D,Ka,La,Ma;function Na(){return o.navigator?o.navigator.userAgent:k}Ma=La=Ka=D=m;var Oa;if(Oa=Na()){var Pa=o.navigator;D=0==Oa.indexOf("Opera");Ka=!D&&-1!=Oa.indexOf("MSIE");La=!D&&-1!=Oa.indexOf("WebKit");Ma=!D&&!La&&"Gecko"==Pa.product}var Qa=D,F=Ka,G=Ma,H=La,Ra;
a:{var Sa="",Ta;if(Qa&&o.opera)var Ua=o.opera.version,Sa="function"==typeof Ua?Ua():Ua;else if(G?Ta=/rv\:([^\);]+)(\)|;)/:F?Ta=/MSIE\s+([^\);]+)(\)|;)/:H&&(Ta=/WebKit\/(\S+)/),Ta)var Va=Ta.exec(Na()),Sa=Va?Va[1]:"";if(F){var Wa,Xa=o.document;Wa=Xa?Xa.documentMode:i;if(Wa>parseFloat(Sa)){Ra=""+Wa;break a}}Ra=Sa}var Ya={};
function J(a){var b;if(!(b=Ya[a])){b=0;for(var c=la(""+Ra).split("."),d=la(""+a).split("."),e=Math.max(c.length,d.length),f=0;0==b&&f<e;f++){var h=c[f]||"",l=d[f]||"",p=RegExp("(\\d*)(\\D*)","g"),w=RegExp("(\\d*)(\\D*)","g");do{var E=p.exec(h)||["","",""],t=w.exec(l)||["","",""];if(0==E[0].length&&0==t[0].length)break;b=((0==E[1].length?0:parseInt(E[1],10))<(0==t[1].length?0:parseInt(t[1],10))?-1:(0==E[1].length?0:parseInt(E[1],10))>(0==t[1].length?0:parseInt(t[1],10))?1:0)||((0==E[2].length)<(0==
t[2].length)?-1:(0==E[2].length)>(0==t[2].length)?1:0)||(E[2]<t[2]?-1:E[2]>t[2]?1:0)}while(0==b)}b=Ya[a]=0<=b}return b}var Za={};function $a(){return Za[9]||(Za[9]=F&&!!document.documentMode&&9<=document.documentMode)};var ab,bb=!F||$a();!G&&!F||F&&$a()||G&&J("1.9.1");var cb=F&&!J("9");function db(a){return(a=a.className)&&"function"==typeof a.split?a.split(/\s+/):[]}function eb(a,b){var c=db(a),d=Ga(arguments,1),e;e=c;for(var f=0,h=0;h<d.length;h++)0<=A(e,d[h])||(e.push(d[h]),f++);e=f==d.length;a.className=c.join(" ");return e}function fb(a,b){for(var c=db(a),d=Ga(arguments,1),e=c,f=0,h=0;h<e.length;h++)0<=A(d,e[h])&&(Aa(e,h--,1),f++);a.className=c.join(" ")};function K(a,b,c){for(var d in a)b.call(c,a[d],d,a)}function gb(a,b,c){var d={},e;for(e in a)b.call(c,a[e],e,a)&&(d[e]=a[e]);return d}function hb(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}function ib(a,b){var c;(c=b in a)&&delete a[b];return c}function jb(a){var b=ba(a);if("object"==b||"array"==b){if(a.ob)return a.ob();var b="array"==b?[]:{},c;for(c in a)b[c]=jb(a[c]);return b}return a}var kb="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");
function lb(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<kb.length;f++)c=kb[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};function mb(a){return a?new nb(L(a)):ab||(ab=new nb)}function M(a){return u(a)?document.getElementById(a):a}
function ob(a,b,c){c=c||document;a=a&&"*"!=a?a.toUpperCase():"";if(c.querySelectorAll&&c.querySelector&&(!H||"CSS1Compat"==document.compatMode||J("528"))&&(a||b))return c.querySelectorAll(a+(b?"."+b:""));if(b&&c.getElementsByClassName){c=c.getElementsByClassName(b);if(a){for(var d={},e=0,f=0,h;h=c[f];f++)a==h.nodeName&&(d[e++]=h);d.length=e;return d}return c}c=c.getElementsByTagName(a||"*");if(b){d={};for(f=e=0;h=c[f];f++)a=h.className,"function"==typeof a.split&&0<=A(a.split(/\s+/),b)&&(d[e++]=h);
d.length=e;return d}return c}function pb(a,b){K(b,function(b,d){"style"==d?a.style.cssText=b:"class"==d?a.className=b:"for"==d?a.htmlFor=b:d in qb?a.setAttribute(qb[d],b):0==d.lastIndexOf("aria-",0)?a.setAttribute(d,b):a[d]=b})}var qb={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",height:"height",width:"width",usemap:"useMap",frameborder:"frameBorder",maxlength:"maxLength",type:"type"};
function rb(a,b,c){function d(c){c&&b.appendChild(u(c)?a.createTextNode(c):c)}for(var e=2;e<c.length;e++){var f=c[e];s(f)&&!(ea(f)&&0<f.nodeType)?B(sb(f)?Ea(f):f,d):d(f)}}function tb(a){for(var b;b=a.firstChild;)a.removeChild(b)}function ub(a){a&&a.parentNode&&a.parentNode.removeChild(a)}function L(a){return 9==a.nodeType?a:a.ownerDocument||a.document}var vb={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},wb={IMG:" ",BR:"\n"};
function xb(a,b,c){if(!(a.nodeName in vb))if(3==a.nodeType)c?b.push((""+a.nodeValue).replace(/(\r\n|\r|\n)/g,"")):b.push(a.nodeValue);else if(a.nodeName in wb)b.push(wb[a.nodeName]);else for(a=a.firstChild;a;)xb(a,b,c),a=a.nextSibling}function sb(a){if(a&&"number"==typeof a.length){if(ea(a))return"function"==typeof a.item||"string"==typeof a.item;if(da(a))return"function"==typeof a.item}return m}function yb(a,b){return zb(a,function(a){return!b||0<=A(db(a),b)})}
function zb(a,b){for(var c=0;a;){if(b(a))return a;a=a.parentNode;c++}return k}function nb(a){this.B=a||o.document||document}n=nb.prototype;n.w=function(a){return u(a)?this.B.getElementById(a):a};
n.xa=function(a,b,c){var d=this.B,e=arguments,f=e[0],h=e[1];if(!bb&&h&&(h.name||h.type)){f=["<",f];h.name&&f.push(' name="',na(h.name),'"');if(h.type){f.push(' type="',na(h.type),'"');var l={};lb(l,h);h=l;delete h.type}f.push(">");f=f.join("")}f=d.createElement(f);h&&(u(h)?f.className=h:r(h)?eb.apply(k,[f].concat(h)):pb(f,h));2<e.length&&rb(d,f,e);return f};n.createElement=function(a){return this.B.createElement(a)};n.createTextNode=function(a){return this.B.createTextNode(a)};
n.appendChild=function(a,b){a.appendChild(b)};n.$a=tb;function N(){}N.prototype.Pa=m;N.prototype.k=function(){this.Pa||(this.Pa=j,this.d())};N.prototype.d=function(){this.qb&&Ab.apply(k,this.qb)};function Ab(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];s(d)?Ab.apply(k,d):d&&"function"==typeof d.k&&d.k()}};function O(a,b){this.type=a;this.currentTarget=this.target=b}y(O,N);O.prototype.d=function(){delete this.type;delete this.target;delete this.currentTarget};O.prototype.H=m;O.prototype.oa=j;!F||$a();var Bb=!F||$a();F&&J("8");!H||J("528");G&&J("1.9b")||F&&J("8")||Qa&&J("9.5")||H&&J("528");!G||J("8");function Cb(a){Cb[" "](a);return a}Cb[" "]=aa;function Db(a,b){a&&this.ka(a,b)}y(Db,O);n=Db.prototype;n.target=k;n.relatedTarget=k;n.offsetX=0;n.offsetY=0;n.clientX=0;n.clientY=0;n.screenX=0;n.screenY=0;n.button=0;n.keyCode=0;n.charCode=0;n.ctrlKey=m;n.altKey=m;n.shiftKey=m;n.metaKey=m;n.za=k;
n.ka=function(a,b){var c=this.type=a.type;O.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var d=a.relatedTarget;if(d){if(G){var e;a:{try{Cb(d.nodeName);e=j;break a}catch(f){}e=m}e||(d=k)}}else"mouseover"==c?d=a.fromElement:"mouseout"==c&&(d=a.toElement);this.relatedTarget=d;this.offsetX=H||a.offsetX!==i?a.offsetX:a.layerX;this.offsetY=H||a.offsetY!==i?a.offsetY:a.layerY;this.clientX=a.clientX!==i?a.clientX:a.pageX;this.clientY=a.clientY!==i?a.clientY:a.pageY;this.screenX=a.screenX||
0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||("keypress"==c?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.state=a.state;this.za=a;delete this.oa;delete this.H};n.d=function(){Db.j.d.call(this);this.relatedTarget=this.currentTarget=this.target=this.za=k};function Eb(){}var Fb=0;n=Eb.prototype;n.key=0;n.P=m;n.Ja=m;n.ka=function(a,b,c,d,e,f){da(a)?this.Ua=j:a&&a.handleEvent&&da(a.handleEvent)?this.Ua=m:g(Error("Invalid listener argument"));this.W=a;this.Ya=b;this.src=c;this.type=d;this.capture=!!e;this.S=f;this.Ja=m;this.key=++Fb;this.P=m};n.handleEvent=function(a){return this.Ua?this.W.call(this.S||this.src,a):this.W.handleEvent.call(this.W,a)};var P={},Q={},R={},S={};
function T(a,b,c,d,e){if(b){if(r(b)){for(var f=0;f<b.length;f++)T(a,b[f],c,d,e);return k}var d=!!d,h=Q;b in h||(h[b]={q:0,p:0});h=h[b];d in h||(h[d]={q:0,p:0},h.q++);var h=h[d],l=v(a),p;h.p++;if(h[l]){p=h[l];for(f=0;f<p.length;f++)if(h=p[f],h.W==c&&h.S==e){if(h.P)break;return p[f].key}}else p=h[l]=[],h.q++;f=Gb();f.src=a;h=new Eb;h.ka(c,f,a,b,d,e);c=h.key;f.key=c;p.push(h);P[c]=h;R[l]||(R[l]=[]);R[l].push(h);a.addEventListener?(a==o||!a.Oa)&&a.addEventListener(b,f,d):a.attachEvent(b in S?S[b]:S[b]=
"on"+b,f);return c}g(Error("Invalid event type"))}function Gb(){var a=Hb,b=Bb?function(c){return a.call(b.src,b.key,c)}:function(c){c=a.call(b.src,b.key,c);if(!c)return c};return b}function Ib(a,b,c,d,e){if(r(b))for(var f=0;f<b.length;f++)Ib(a,b[f],c,d,e);else{d=!!d;a:{f=Q;if(b in f&&(f=f[b],d in f&&(f=f[d],a=v(a),f[a]))){a=f[a];break a}a=k}if(a)for(f=0;f<a.length;f++)if(a[f].W==c&&a[f].capture==d&&a[f].S==e){Jb(a[f].key);break}}}
function Jb(a){if(!P[a])return m;var b=P[a];if(b.P)return m;var c=b.src,d=b.type,e=b.Ya,f=b.capture;c.removeEventListener?(c==o||!c.Oa)&&c.removeEventListener(d,e,f):c.detachEvent&&c.detachEvent(d in S?S[d]:S[d]="on"+d,e);c=v(c);e=Q[d][f][c];if(R[c]){var h=R[c];Ba(h,b);0==h.length&&delete R[c]}b.P=j;e.Wa=j;Kb(d,f,c,e);delete P[a];return j}
function Kb(a,b,c,d){if(!d.la&&d.Wa){for(var e=0,f=0;e<d.length;e++)d[e].P?d[e].Ya.src=k:(e!=f&&(d[f]=d[e]),f++);d.length=f;d.Wa=m;0==f&&(delete Q[a][b][c],Q[a][b].q--,0==Q[a][b].q&&(delete Q[a][b],Q[a].q--),0==Q[a].q&&delete Q[a])}}function Lb(a){var b,c=0,d=b==k;b=!!b;if(a==k)K(R,function(a){for(var e=a.length-1;0<=e;e--){var f=a[e];if(d||b==f.capture)Jb(f.key),c++}});else if(a=v(a),R[a])for(var a=R[a],e=a.length-1;0<=e;e--){var f=a[e];if(d||b==f.capture)Jb(f.key),c++}}
function Mb(a,b,c,d,e){var f=1,b=v(b);if(a[b]){a.p--;a=a[b];a.la?a.la++:a.la=1;try{for(var h=a.length,l=0;l<h;l++){var p=a[l];p&&!p.P&&(f&=Nb(p,e)!==m)}}finally{a.la--,Kb(c,d,b,a)}}return Boolean(f)}function Nb(a,b){var c=a.handleEvent(b);a.Ja&&Jb(a.key);return c}
function Hb(a,b){if(!P[a])return j;var c=P[a],d=c.type,e=Q;if(!(d in e))return j;var e=e[d],f,h;if(!Bb){var l;if(!(l=b))a:{l=["window","event"];for(var p=o;f=l.shift();)if(p[f]!=k)p=p[f];else{l=k;break a}l=p}f=l;l=j in e;p=m in e;if(l){if(0>f.keyCode||f.returnValue!=i)return j;a:{var w=m;if(0==f.keyCode)try{f.keyCode=-1;break a}catch(E){w=j}if(w||f.returnValue==i)f.returnValue=j}}w=new Db;w.ka(f,this);f=j;try{if(l){for(var t=[],Ha=w.currentTarget;Ha;Ha=Ha.parentNode)t.push(Ha);h=e[j];h.p=h.q;for(var I=
t.length-1;!w.H&&0<=I&&h.p;I--)w.currentTarget=t[I],f&=Mb(h,t[I],d,j,w);if(p){h=e[m];h.p=h.q;for(I=0;!w.H&&I<t.length&&h.p;I++)w.currentTarget=t[I],f&=Mb(h,t[I],d,m,w)}}else f=Nb(c,w)}finally{t&&(t.length=0),w.k()}return f}d=new Db(b,this);try{f=Nb(c,d)}finally{d.k()}return f};function U(){}y(U,N);n=U.prototype;n.Oa=j;n.ma=k;n.Ga=function(a){this.ma=a};n.addEventListener=function(a,b,c,d){T(this,a,b,c,d)};n.removeEventListener=function(a,b,c,d){Ib(this,a,b,c,d)};
n.dispatchEvent=function(a){var b=a.type||a,c=Q;if(b in c){if(u(a))a=new O(a,this);else if(a instanceof O)a.target=a.target||this;else{var d=a,a=new O(b,this);lb(a,d)}var d=1,e,c=c[b],b=j in c,f;if(b){e=[];for(f=this;f;f=f.ma)e.push(f);f=c[j];f.p=f.q;for(var h=e.length-1;!a.H&&0<=h&&f.p;h--)a.currentTarget=e[h],d&=Mb(f,e[h],a.type,j,a)&&a.oa!=m}if(m in c)if(f=c[m],f.p=f.q,b)for(h=0;!a.H&&h<e.length&&f.p;h++)a.currentTarget=e[h],d&=Mb(f,e[h],a.type,m,a)&&a.oa!=m;else for(e=this;!a.H&&e&&f.p;e=e.ma)a.currentTarget=
e,d&=Mb(f,e,a.type,m,a)&&a.oa!=m;a=Boolean(d)}else a=j;return a};n.d=function(){U.j.d.call(this);Lb(this);this.ma=k};function V(a){var b={schema:{},sync:k,attr:{}};a||(a={});a.attr=a.attr||{};K(a,function(c,d){q(b[d])||(a.attr[d]=c)});K(b,function(c,d){b[d]=a[d]||b[d]});this.m={};this.G={};this.b=b.schema||{};this.aa=b.sync;this.ga=[];this.ua={};this.Fa=[];this.Sa=aa;T(this,"change",this.wa,m,this);this.La=""+v(this);this.set(b.attr);this.dispatchEvent("load")}y(V,U);
function Ob(a,b){var c=b;if(u(b)){var d={number:ca,string:u,array:s};return function(a){d[b.toLowerCase()](a)||g(new Pb);return a}}if(c.exec)return x(function(a,b){a.exec(b)===k&&g(new Pb);return b},a,b);da(c)&&hb(c.prototype).length&&(c=function(a){var c=Object.getPrototypeOf(a).constructor;if(Object.getPrototypeOf(a).constructor==b)return a;for(;c.j;)if(c=c.j.constructor,c==b)return a;g(new Pb)});return c}n=V.prototype;n.ra=function(){var a=this.m,b={},c;for(c in a)b[c]=a[c];return b};
n.get=function(a,b){if(this.b[a]&&this.b[a].get){var c=this.b[a].get.apply(this,C(this.b[a].Fb||[],function(c){if(c===a)return this.m[a];c=this.get(c);return q(c)?c:b},this));return q(c)?c:b}return q(this.m[a])?this.m[a]:b};
n.set=function(a,b,c){var d=m;if(u(a)){var e={};e[a]=b;a=e}else c=b;K(a,function(a,b){if(q(a))try{this.m[b]=this.b[b]&&this.b[b].set?Ob(this,this.b[b].set).call(this,a,this):a,d=j}catch(c){c.vb?this.Sa(c):g(c)}else this.m[b]=a,this.G[b]!=this.m[b]&&(d=j)},this);return d?(c||(this.dispatchEvent("change"),this.G=jb(this.m),this.m=gb(this.m,function(a){return q(a)})),j):m};n.u=function(){this.dispatchEvent("change");this.G=jb(this.m)};
function Qb(a,b){return a.b[b]&&a.b[b].get?a.b[b].get.apply(a,C(a.b[b].Fb||[],function(a){return a===b?this.G[b]:Qb(this,a)},a)):a.G[b]}function Rb(a,b){a.b.title=a.b.title||{};a.b.title.set=x(b,a)}function Sb(a){var b=hb(gb(a.b,function(a,b){if(this.b[b].pb)return!this.b[b].pb(Qb(this,b),this.get(b));var e=Qb(this,b);return r(e)?!Ia(e,this.get(b)):Qb(this,b)!=this.get(b)},a));Fa(b,hb(gb(a.m,function(a,b){return q(this.b[b])?m:r(a)?!Ia(a,this.G[b]):a!==this.G[b]},a)));return b}
n.k=function(a){a&&this.aa.qa.remove(this.get("id"));this.dispatchEvent("unload");B(Ea(this.Fa),function(a){a(this)},this);this.d()};function Tb(a,b){a.Sa=b}n.save=function(){this.aa&&(!q(this.get("id"))?this.aa.create(this):this.aa.update(this))};n.wa=function(){var a=Sb(this);B(this.ga,function(b){ua(b.da,function(b){return 0<=A(a,b)})&&b.ha.apply(b.Ta,Da(C(b.da,function(a){return this.get(a)},this)))},this);K(this.ua,function(a){a(this)},this)};
n.fa=function(a,b){var a=x(a,b||this),c=v(a);this.Fa.push(a);return c};n.bind=function(a,b,c){u(a)&&(a=[a]);a={da:a,ha:b,Ta:c||this};a.Ka=v(a);this.ga.push(a);return a.Ka};n.t=function(a){return Ca(this.ga,function(b){return b.Ka==a})||ib(this.ua,a)||Ca(this.Fa,function(b){return v(b)==a})};n.ea=function(a,b){var c=x(a,b||this),d=v(c);this.ua[""+d]=c;return d};function Pb(){this.vb=j}y(Pb,Error);function W(a){var a=a||{},b={comparator:a.comparator||k,modelType:a.modelType||V,models:a.models||[]};ib(a,"comparator");ib(a,"modelType");ib(a,"models");this.a=[];this.Ma=b.comparator;this.Ea=[];this.Ia=[];this.ca=[];this.kb=[];this.Z=[];this.Eb=[];this.z=m;this.Va=b.modelType;V.call(this,a);B(b.models,function(a){this.add(a,i,j)},this)}y(W,V);n=W.prototype;n.sort=function(a){var b=m;if(this.Ma){var c=this.Ma;this.a.sort(function(a,e){var f=c(a.g,e.g);0<f&&(b=j);return f});this.z=this.z||b}a||this.dispatchEvent("change")};
n.add=function(a,b,c){ca(b)&&0>b&&(b=this.a.length+b);var d=m;if(r(a))return d=B(a.reverse(),function(){if(!va(this.a,function(b){return b.g==a})){this.A=this.z=d=j;var c=a.ea(x(function(){this.A=j;this.sort()},this)),e=a.fa(function(){this.remove(a)},this);za(this.a,{g:a,Ha:e,u:c},b||this.a.length);ya(this.ca,a)}},this),this.length=this.a.length,this.sort(j),d&&!c&&this.u(),d;if(!va(this.a,function(b){return b.g==a})){this.A=this.z=d=j;var e=a.ea(x(function(){this.A=j;this.sort()},this,m)),f=a.fa(function(){this.remove(a)},
this);za(this.a,{g:a,Ha:f,u:e},b||this.a.length);ya(this.ca,a);this.sort(j);c||this.u()}this.length=this.a.length;return d};
n.remove=function(a,b){if(r(a)){var c=m;B(a,function(a){var b=va(this.a,function(b){return b.g==a});b&&(this.A=this.z=j,a.t(b.Ha),a.t(b.u),Ba(this.a,b),c=j,ya(this.Z,{g:a,id:a.get("id")||a.La}))},this);this.length=this.a.length;this.sort(j);c&&!b&&this.u();return c}var d=va(this.a,function(b){return b.g==a});d&&(this.A=this.z=j,a.t(d.Ha),a.t(d.u),ya(this.Z,d),Ba(this.a,d),ya(this.Z,{g:a,id:a.get("id")||a.La}),this.sort(j),b||this.dispatchEvent("change"));this.length=this.a.length;return!!d};
function Ub(a,b){var c=C(a.a,function(a){return a.g});return b?ta(c,b):c}n.Da=function(a,b){var c=x(a,b||this);this.Ea.push(c);return v(c)};n.ta=function(a,b){var c=x(a,b||this);this.Ia.push(c);return v(c)};n.t=function(a){return Ca(this.Ea,function(b){return v(b)==a})||W.j.t.call(this,a)};
n.wa=function(){W.j.wa.call(this);this.z&&(B(Ea(this.Ea),function(a){a(this)},this),this.z=m);this.A&&(B(Ea(this.Ia),function(a){a(this)},this),this.b&&K(this.b,function(a,b){a.wb&&B(this.ga,function(a){0<=A(a.da,b)&&a.ha.apply(a.Ta,Da(C(a.da,function(a){return this.get(a)},this)))},this)},this),this.A=m);B(this.Eb,function(a){B(this.Z,function(b){a(b.g,b.id)})},this);this.Z=[];B(this.kb,function(a){B(this.ca,function(b){a(b)})},this);this.ca=[]};function Vb(a,b){this.U=a||1;this.ba=b||Wb;this.va=x(this.Gb,this);this.Ba=ja()}y(Vb,U);Vb.prototype.enabled=m;var Wb=o.window;n=Vb.prototype;n.e=k;n.setInterval=function(a){this.U=a;this.e&&this.enabled?(this.stop(),this.start()):this.e&&this.stop()};n.Gb=function(){if(this.enabled){var a=ja()-this.Ba;0<a&&a<0.8*this.U?this.e=this.ba.setTimeout(this.va,this.U-a):(this.dispatchEvent(Xb),this.enabled&&(this.e=this.ba.setTimeout(this.va,this.U),this.Ba=ja()))}};
n.start=function(){this.enabled=j;this.e||(this.e=this.ba.setTimeout(this.va,this.U),this.Ba=ja())};n.stop=function(){this.enabled=m;this.e&&(this.ba.clearTimeout(this.e),this.e=k)};n.d=function(){Vb.j.d.call(this);this.stop();delete this.ba};var Xb="tick";function X(a){this.sb=a;this.Aa=[]}y(X,N);var Yb=[];function Zb(a,b,c,d,e){r(c)||(Yb[0]=c,c=Yb);for(var f=0;f<c.length;f++)a.Aa.push(T(b,c[f],d||a,e||m,a.sb||a));return a}function $b(a){B(a.Aa,Jb);a.Aa.length=0}X.prototype.d=function(){X.j.d.call(this);$b(this)};X.prototype.handleEvent=function(){g(Error("EventHandler.handleEvent not implemented"))};function ac(){O.call(this,"navigate")}y(ac,O);function Y(a,b,c,d){a&&!b&&g(Error("Can't use invisible history without providing a blank page."));var e;c?e=c:(e="history_state"+bc,document.write(ka(cc,e,e)),e=M(e));this.ia=e;this.c=c?L(c)?L(c).parentWindow||L(c).defaultView:window:window;this.lb=this.c.location.href.split("#")[0];this.ja=b;F&&!b&&(this.ja="https"==window.location.protocol?"https:///":'javascript:""');this.e=new Vb(dc);this.R=!a;this.D=new X(this);if(a||F&&!ec)d?a=d:(a="history_iframe"+bc,b=this.ja?'src="'+na(this.ja)+'"':"",document.write(ka(fc,
a,b)),a=M(a)),this.L=a,this.ib=j;F&&!ec&&(Zb(this.D,this.c,"load",this.zb),this.fb=this.ya=m);this.R?gc(this,this.s(),j):hc(this,this.ia.value);bc++}y(Y,U);Y.prototype.v=m;Y.prototype.M=m;Y.prototype.V=k;var ec=F&&8<=document.documentMode||G&&J("1.9.2")||H&&J("532.1");n=Y.prototype;n.X=k;n.d=function(){Y.j.d.call(this);this.D.k();this.Q(m)};
n.Q=function(a){if(a!=this.v)if(F&&!ec&&!this.ya)this.fb=a;else if(a)if(Qa?Zb(this.D,this.c.document,ic,this.Cb):G&&Zb(this.D,this.c,"pageshow",this.Bb),ec&&this.R)Zb(this.D,this.c,"hashchange",this.Ab),this.v=j,this.dispatchEvent(new ac(this.s()));else{if(!F||this.ya)Zb(this.D,this.e,Xb,x(this.nb,this,j)),this.v=j,F||(this.V=this.s()),this.e.start(),this.dispatchEvent(new ac(this.s()))}else this.v=m,$b(this.D),this.e.stop()};n.zb=function(){this.ya=j;this.ia.value&&hc(this,this.ia.value,j);this.Q(this.fb)};
n.Bb=function(a){a.za.persisted&&(this.Q(m),this.Q(j))};n.Ab=function(){var a=jc(this.c);a!=this.V&&kc(this,a)};n.s=function(){return this.X!=k?this.X:this.R?jc(this.c):lc(this)||""};function jc(a){var a=a.location.href,b=a.indexOf("#");return 0>b?"":a.substring(b+1)}function gc(a,b,c){var d=a.c.location,a=a.lb,e=-1!=d.href.indexOf("#");if(F||e||b)a+="#"+b;a!=d.href&&(c?d.replace(a):d.href=a)}
function hc(a,b,c){if(a.ib||b!=lc(a))if(a.ib=m,b=""+b,b=!ma.test(b)?encodeURIComponent(b):b,F){var d=a.L.contentDocument||a.L.contentWindow.document;d.open("text/html",c?"replace":i);d.write(ka(mc,na(a.c.document.title),b));d.close()}else if(b=a.ja+"#"+b,a=a.L.contentWindow)c?a.location.replace(b):a.location.href=b}
function lc(a){if(F)return a=a.L.contentDocument||a.L.contentWindow.document,a.body?decodeURIComponent(a.body.innerHTML.replace(/\+/g," ")):k;var b=a.L.contentWindow;if(b){var c;try{c=decodeURIComponent(jc(b).replace(/\+/g," "))}catch(d){return a.M||(a.M!=j&&a.e.setInterval(nc),a.M=j),k}a.M&&(a.M!=m&&a.e.setInterval(dc),a.M=m);return c||k}return k}
n.nb=function(){if(this.R){var a=jc(this.c);a!=this.V&&kc(this,a)}if(!this.R||F&&!ec)if(a=lc(this)||"",this.X==k||a==this.X)this.X=k,a!=this.V&&kc(this,a)};function kc(a,b){a.V=a.ia.value=b;a.R?(F&&!ec&&hc(a,b),gc(a,b)):hc(a,b);a.dispatchEvent(new ac(a.s()))}n.Cb=function(){this.e.stop();this.e.start()};
var ic=["mousedown","keydown","mousemove"],mc="<title>%s</title><body>%s</body>",fc='<iframe id="%s" style="display:none" %s></iframe>',cc='<input type="text" name="%s" id="%s" style="display:none">',bc=0,dc=150,nc=1E4;function oc(a,b){this.c=a||window;this.gb=b||k;T(this.c,"popstate",this.O,m,this);T(this.c,"hashchange",this.O,m,this)}y(oc,U);n=oc.prototype;n.v=m;n.sa=j;n.Xa="/";n.Q=function(a){a!=this.v&&(this.v=a)&&this.dispatchEvent(new ac(this.s()))};n.s=function(){if(this.sa){var a=this.c.location.href,b=a.indexOf("#");return 0>b?"":a.substring(b+1)}return this.gb?this.gb.Ib(this.Xa,this.c.location):this.c.location.pathname.substr(this.Xa.length)};
n.d=function(){Ib(this.c,"popstate",this.O,m,this);this.sa&&Ib(this.c,"hashchange",this.O,m,this)};n.eb=function(a){this.sa!=a&&(a?T(this.c,"hashchange",this.O,m,this):Ib(this.c,"hashchange",this.O,m,this),this.sa=a)};n.O=function(){this.v&&this.dispatchEvent(new ac(this.s()))};function pc(a,b){var c=window;this.T=c.history&&c.history.pushState?new oc:new Y(!(!b||!a),b);this.T.eb&&this.T.eb(!a);T(this.T,"navigate",this.yb,m,this);this.T.Q(j);this.ab=[]}pc.prototype.$=function(a,b){u(a)&&(a=RegExp("^"+(""+a).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08").replace(/\\:\w+/g,"(\\w+)").replace(/\\\*/g,"(.*)").replace(/\\\[/g,"(").replace(/\\\]/g,")?")+"$"));this.ab.push({$:a,mb:b})};
pc.prototype.yb=function(){var a=this.T.s();B(this.ab||[],function(b){var c=b.$.exec(a);c&&b.mb.apply(this,c)},this)};function qc(){}(function(a){a.Ra=function(){return a.ub||(a.ub=new a)}})(qc);qc.prototype.xb=0;qc.Ra();function rc(a){this.I=a||mb()}y(rc,U);n=rc.prototype;n.tb=qc.Ra();n.K=k;n.i=m;n.h=k;n.l=k;n.o=k;n.f=k;n.n=k;n.jb=m;function sc(a){return a.K||(a.K=":"+(a.tb.xb++).toString(36))}n.w=function(){return this.h};function tc(a,b){a==b&&g(Error("Unable to set parent component"));b&&a.o&&a.K&&a.o.n&&a.K&&a.K in a.o.n&&a.o.n[a.K]&&a.o!=b&&g(Error("Unable to set parent component"));a.o=b;rc.j.Ga.call(a,b)}n.getParent=function(){return this.o};
n.Ga=function(a){this.o&&this.o!=a&&g(Error("Method not supported"));rc.j.Ga.call(this,a)};n.xa=function(){this.h=this.I.createElement("div")};n.C=function(){this.i=j;uc(this,function(a){!a.i&&a.w()&&a.C()})};function vc(a){uc(a,function(a){a.i&&vc(a)});a.J&&$b(a.J);a.i=m}n.d=function(){rc.j.d.call(this);this.i&&vc(this);this.J&&(this.J.k(),delete this.J);uc(this,function(a){a.k()});!this.jb&&this.h&&ub(this.h);this.o=this.l=this.h=this.n=this.f=k};function uc(a,b){a.f&&B(a.f,b,i)}
n.removeChild=function(a,b){if(a){var c=u(a)?a:sc(a),a=this.n&&c?(c in this.n?this.n[c]:i)||k:k;c&&a&&(ib(this.n,c),Ba(this.f,a),b&&(vc(a),a.h&&ub(a.h)),tc(a,k))}a||g(Error("Child is not in parent component"));return a};n.$a=function(a){for(;this.f&&0!=this.f.length;)this.removeChild(this.f?this.f[0]||k:k,a)};function Z(a){this.I=mb();this.l=a;this.r={Ca:{},F:{}};this.N=[]}y(Z,rc);n=Z.prototype;n.remove=function(){ub(this.w());this.k()};n.rb=function(a,b){this.r.F[a]&&B(this.r.F[a],function(a){b.H||(!a.bb.length||ua(a.bb,function(a){return da(a)?a(b):yb(b.target,a)}))&&a.ha.call(a.S,b)})};
function wc(a,b,c,d,e,f){var h=["blur","focus"];a.r||(a.r={Ca:{},F:{}});a.r.F[b]||(a.r.F[b]=[]);a.r.Ca[b]||(a.r.Ca[b]=Zb(a.J||(a.J=new X(a)),a.w(),b,x(a.rb,a,b),0<=A(h,b)));q(d)||(d=[]);c={bb:r(d)?d:[d],ha:c,hb:k,S:e||a,Db:f||50};c.hb=v(c);za(a.r.F[b],c,xa(a.r.F[b],function(a){return a.Db<=(f||50)})+1);return c.hb}n.click=function(a,b,c,d){return wc(this,"click",a,b,c,d)};
function xc(a,b){"-"==b.charAt(0)&&(b="."+b.substring(1));var c;if("."==b.charAt(0)){c=b.substring(1);var d=a.w(),e=d||document;c=(e.querySelectorAll&&e.querySelector&&(!H||"CSS1Compat"==document.compatMode||J("528"))?e.querySelectorAll("."+c):e.getElementsByClassName?e.getElementsByClassName(c):ob("*",c,d))||[]}else"#"==b.charAt(0)?c=[M(b)]:(c=b.replace(/\s.*/,""),d=0<b.indexOf(".")?b.replace(/.*\./,""):k,c=ob(c,d,a.w()));return c}
n.bind=function(a,b,c){a=this.l.bind(a,b,c||this);this.N.push(a);return a};n.ea=function(a,b){var c=this.l.ea(a,b||this);this.N.push(c);return c};n.fa=function(a,b){var c=this.l.fa(a,b||this);this.N.push(c);return c};n.ta=function(a,b){var c=this.l.ta(a,b||this);this.N.push(c);return c};n.Da=function(a,b){var c=this.l.Da(a,b||this);this.N.push(c);return c};n.t=function(a){return this.l.t(a)};n.d=function(){B(this.N,function(a){this.t(a)},this);this.r=k;Z.j.d.call(this)};F&&J(8);var yc={};"ScriptEngine"in o&&"JScript"==o.ScriptEngine()&&(o.ScriptEngineMajorVersion(),o.ScriptEngineMinorVersion(),o.ScriptEngineBuildVersion());function zc(a){return"object"===typeof a&&a&&0===a.Hb?a.content:(""+a).replace(Ac,Bc)}var Cc={"\x00":"&#0;",'"':"&quot;","&":"&amp;","'":"&#39;","<":"&lt;",">":"&gt;","\t":"&#9;","\n":"&#10;","\x0B":"&#11;","\u000c":"&#12;","\r":"&#13;"," ":"&#32;","-":"&#45;","/":"&#47;","=":"&#61;","`":"&#96;","\u0085":"&#133;","\u00a0":"&#160;","\u2028":"&#8232;","\u2029":"&#8233;"};function Bc(a){return Cc[a]}var Ac=/[\x00\x22\x26\x27\x3c\x3e]/g;function Dc(a){Z.call(this,a)}y(Dc,Z);
Dc.prototype.xa=function(){var a={g:this.l.ra()},b=new nb(k)||mb(),a="<li "+((a||yc).g.completed?'class="completed"':"")+'><div class="view"><input class="toggle" type="checkbox" '+((a||yc).g.completed?"checked":"")+"><label>"+zc((a||yc).g.title)+'</label><button class="destroy"></button></div><input class="edit" type="text" value=""></li>';var c=b.B,b=c.createElement("div");F?(b.innerHTML="<br>"+a,b.removeChild(b.firstChild)):b.innerHTML=a;if(1==b.childNodes.length)a=b.removeChild(b.firstChild);
else for(a=c.createDocumentFragment();b.firstChild;)a.appendChild(b.firstChild);this.h=a};
Dc.prototype.C=function(){var a=this.l;this.click(function(b){a.set("completed",b.target.checked)},"toggle");this.click(function(){a.k()},"destroy");wc(this,"dblclick",function(){var a=xc(this,".edit")[0];eb(this.w(),"editing");a.value=this.l.get("title");a.select()},"view");var b=xc(this,".edit")[0];wc(this,"keyup",function(c){13===c.keyCode&&a.set("title",b.value)},"edit");wc(this,"blur",function(){a.set("title",b.value)},"edit")};function Ec(a){Z.call(this,a);this.Qa=Fc}y(Ec,Z);function Fc(){return j}function Gc(a){return!a.get("completed")}function Hc(a){return a.get("completed")}
Ec.prototype.C=function(){Ec.j.C.call(this);var a=this.l,b=xc(this,"input")[0];wc(this,"keyup",function(c){13===c.keyCode&&(c=la(b.value),""!==c&&(c=new a.Va({title:c}),a.add(c,0,i),b.value=""))},"todo-entry");this.click(function(){B(a.get("completed"),function(a){a.k()})},"clear-completed");this.click(function(b){var d=b.target.checked;B(Ub(a),function(a){a.set("completed",d)})},"toggle-all");this.ta(function(){this.refresh();a.save()},this);this.Da(function(){Ic(!!a.a.length)},this);Ic(!!a.a.length);
this.bind("completed",function(b){var d=M("todo-count"),e;e=a.a.length-b.length;e="<strong>"+zc(e)+"</strong> item"+(1!=e?"s":"")+" left";d.innerHTML=e;d=M("clear-completed");e="Clear completed ("+b.length+")";if("textContent"in d)d.textContent=e;else if(d.firstChild&&3==d.firstChild.nodeType){for(;d.lastChild!=d.firstChild;)d.removeChild(d.lastChild);d.firstChild.data=e}else tb(d),d.appendChild(L(d).createTextNode(e));d.style.display=b.length?"":"none";xc(this,".toggle-all")[0].checked=b.length===
a.a.length});a.aa.Za(a,i)};function Ic(a){var b=M("main"),c=ob("footer",i,i)[0];b.style.display=a?"":"none";c.style.display=a?"":"none"}function Jc(a){var b=Kc;b.Qa=a;b.refresh()}
Ec.prototype.refresh=function(){uc(this,function(a){a.k()});this.$a(j);B(Ub(this.l,this.Qa),function(a){var a=new Dc(a),b=this.f?this.f.length:0;a.i&&!this.i&&g(Error("Component already rendered"));(0>b||b>(this.f?this.f.length:0))&&g(Error("Child component index out of bounds"));if(!this.n||!this.f)this.n={},this.f=[];if(a.getParent()==this)this.n[sc(a)]=a,Ba(this.f,a);else{var c=this.n,d=sc(a);d in c&&g(Error('The object already contains the key "'+d+'"'));c[d]=a}tc(a,this);za(this.f,a,b);a.i&&
this.i&&a.getParent()==this?(c=this.h,c.insertBefore(a.w(),c.childNodes[b]||k)):this.i&&!a.i&&a.h&&a.C();b=M("todo-list");a.i&&g(Error("Component already rendered"));a.h||a.xa();b?b.insertBefore(a.h,k):a.I.B.body.appendChild(a.h);(!a.o||a.o.i)&&a.C()},this)};function Lc(a){a=""+a;if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}g(Error("Invalid JSON string: "+a))}function Mc(){this.na=i}function Nc(a,b){var c=[];Oc(a,b,c);return c.join("")}
function Oc(a,b,c){switch(typeof b){case "string":Pc(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==k){c.push("null");break}if(r(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],Oc(a,a.na?a.na.call(b,""+f,e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),Pc(f,c),c.push(":"),
Oc(a,a.na?a.na.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:g(Error("Unknown type: "+typeof b))}}var Qc={'"':'\\"',"\\":"\\\\","/":"\\/","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Rc=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function Pc(a,b){b.push('"',a.replace(Rc,function(a){if(a in Qc)return Qc[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return Qc[a]=e+b.toString(16)}),'"')};function Sc(){};function Tc(a){this.Y=a;this.cb=new Mc}n=Tc.prototype;n.Y=k;n.cb=k;n.set=function(a,b){q(b)?this.Y.set(a,Nc(this.cb,b)):this.Y.remove(a)};n.get=function(a){a=this.Y.get(a);if(a!==k)try{return Lc(a)}catch(b){g("Storage: Invalid value was encountered")}};n.remove=function(a){this.Y.remove(a)};function Uc(){}y(Uc,Sc);function Vc(a){this.pa=a}y(Vc,Uc);Vc.prototype.set=function(a,b){try{this.pa.setItem(a,b)}catch(c){g("Storage mechanism: Quota exceeded")}};Vc.prototype.get=function(a){a=this.pa.getItem(a);if(u(a)||a===k)return a;g("Storage mechanism: Invalid value was encountered")};Vc.prototype.remove=function(a){this.pa.removeItem(a)};function Wc(){var a=k;try{a=window.localStorage||k}catch(b){}this.pa=a}y(Wc,Vc);function Xc(){this.qa=new Tc(new Wc)}Xc.prototype.create=function(a){var b;this.Na=this.Na||0;b=this.Na++ +"|"+parseInt((new Date).getTime(),36);a.set("id",b)};Xc.prototype.Za=function(a){a.set(this.qa.get(a.get("id")))};Xc.prototype.update=function(a){this.qa.set(a.get("id"),a.ra())};function Yc(){Xc.call(this)}y(Yc,Xc);Yc.prototype.Za=function(a){var b=this.qa.get(a.get("id"))||[];B(b,function(b){b=new a.Va(b);a.add(b,0,j)});a.u()};function Zc(a){V.call(this,a);Rb(this,function(a){a=la(a);a.length||g(new Pb);return a});Tb(this,function(){this.k()})}y(Zc,V);function $c(){W.call(this,{id:"todos-plastronjs",sync:new Yc,schema:{completed:{get:function(){return Ub(this,function(a){return a.get("completed")})},wb:j}},modelType:Zc})}y($c,W);$c.prototype.ra=function(){return C(Ub(this),function(a){return a.ra()})};var ad=new $c,Kc=new Ec(ad),$=Kc,bd=M("todoapp");$.i&&g(Error("Component already rendered"));if(bd){$.jb=j;if(!$.I||$.I.B!=L(bd))$.I=mb(bd);$.h=bd;$.C()}else g(Error("Invalid element to decorate"));var cd=new pc;
function dd(a){var b=ob("A",i,M("filters"));B(b,function(b){var d;cb&&"innerText"in b?d=b.innerText.replace(/(\r\n|\r|\n)/g,"\n"):(d=[],xb(b,d,j),d=d.join(""));d=d.replace(/ \xAD /g," ").replace(/\xAD/g,"");d=d.replace(/\u200B/g,"");cb||(d=d.replace(/ +/g," "));" "!=d&&(d=d.replace(/^\s*/,""));d===a?eb(b,"selected"):fb(b,"selected")})}cd.$("/",function(){Jc(Fc);dd("All")});cd.$("/active",function(){Jc(Gc);dd("Active")});cd.$("/completed",function(){Jc(Hc);dd("Completed")});})();
\ No newline at end of file
goog.provide('todomvc.listcontrol');
goog.require('goog.dom');
goog.require('goog.events.KeyCodes');
goog.require('goog.string');
goog.require('mvc.Control');
goog.require('todomvc.templates');
goog.require('todomvc.todocontrol');
/**
* the control for the todo list, handles the page as well
*
* @constructor
* @param {mvc.Collection} list model for todo items.
* @extends {mvc.Control}
*/
todomvc.listcontrol = function(list) {
goog.base(this, list);
this.filter_ = todomvc.listcontrol.Filter.ALL;
};
goog.inherits(todomvc.listcontrol, mvc.Control);
/**
* @enum {Function}
*/
todomvc.listcontrol.Filter = {
ALL: function() {return true},
ACTIVE: function(model) {return !model.get('completed')},
COMPLETED: function(model) {return model.get('completed')}
};
/**
* setup for event listeners.
*
* @inheritDoc
*/
todomvc.listcontrol.prototype.enterDocument = function() {
goog.base(this, 'enterDocument');
var list = /** @type {Object} */(this.getModel());
// create new model from text box
var input = this.getEls('input')[0];
this.on(goog.events.EventType.KEYUP, function(e) {
// on return get trimmed text
if (e.keyCode !== goog.events.KeyCodes.ENTER) return;
var text = goog.string.trim(input.value);
if (text === '') return;
//create new model
list.newModel({'title': text});
input.value = '';
}, 'todo-entry');
// clear completed
this.click(function(e) {
goog.array.forEach(list.get('completed'), function(model) {
model.dispose();
});
}, 'clear-completed');
// toggle completed
this.click(function(e) {
var checked = e.target.checked;
goog.array.forEach(list.getModels(), function(model) {
model.set('completed', checked);
});
}, 'toggle-all');
// refresh the view on changes that effect the models order
this.anyModelChange(function() {
this.refresh();
list.save();
}, this);
// hide/show footer and main body
this.modelChange(function() {
this.showMainFooter(!!list.getLength());
}, this);
this.showMainFooter(!!list.getLength());
// update counts
this.bind('completed', function(completedModels) {
// update "left" count
soy.renderElement(goog.dom.getElement('todo-count'),
todomvc.templates.itemsLeft, {
left: list.getLength() - completedModels.length
});
// update clear button
var clearButton = goog.dom.getElement('clear-completed');
goog.dom.setTextContent(clearButton,
'Clear completed (' + completedModels.length + ')');
goog.style.showElement(clearButton, completedModels.length);
// update checkbox
var checkBox = this.getEls('.toggle-all')[0];
checkBox.checked = completedModels.length === list.getLength();
});
// get the saved todos
list.fetch();
};
/**
* show or hide the footer.
*
* @param {boolean=} opt_hide whether to hide the footer.
*/
todomvc.listcontrol.prototype.showMainFooter = function(opt_hide) {
var main = goog.dom.getElement('main');
var footer = goog.dom.getElementsByTagNameAndClass('footer')[0];
goog.style.showElement(main, opt_hide);
goog.style.showElement(footer, opt_hide);
};
/**
* sets the function to determine which children are returned by the control.
*
* @param {Function} filter to decide models returned.
*/
todomvc.listcontrol.prototype.setFilter = function(filter) {
this.filter_ = filter;
this.refresh();
};
/**
* refreshes the view of the childen.
*/
todomvc.listcontrol.prototype.refresh = function() {
// dispose and remove all the children.
this.forEachChild(function(child) {child.dispose();});
this.removeChildren(true);
// create new controls for the models
goog.array.forEach(this.getModel().getModels(this.filter_),
function(model) {
var newModelControl = new todomvc.todocontrol(model);
this.addChild(newModelControl);
newModelControl.render(goog.dom.getElement('todo-list'));
}, this);
};
goog.provide('todomvc.todocontrol');
goog.require('goog.dom');
goog.require('goog.events.KeyCodes');
goog.require('mvc.Control');
goog.require('todomvc.templates');
/**
* this is the control for a todo item.
*
* @constructor
* @param {mvc.Model} model for the control.
* @extends {mvc.Control}
*/
todomvc.todocontrol = function(model) {
goog.base(this, model);
};
goog.inherits(todomvc.todocontrol, mvc.Control);
/**
* overrides goog.ui.Component#createDom with the todo template.
*
* @inheritDoc
*/
todomvc.todocontrol.prototype.createDom = function() {
var el = soy.renderAsFragment(todomvc.templates.todoItem, {
model: this.getModel().toJson()
}, null);
this.setElementInternal(/** @type {Element} */(el));
};
/**
* setup for event listeners.
*
* @inheritDoc
*/
todomvc.todocontrol.prototype.enterDocument = function() {
var model = this.getModel();
// toggle complete
this.click(function(e) {
model.set('completed', e.target.checked);
}, 'toggle');
// delete the model
this.click(function(e) {
model.dispose();
}, 'destroy');
// dblclick to edit
this.on(goog.events.EventType.DBLCLICK, function(e) {
this.makeEditable(true);
}, 'view');
// save on edit
var inputEl = this.getEls('.edit')[0];
this.on(goog.events.EventType.KEYUP, function(e) {
if (e.keyCode === goog.events.KeyCodes.ENTER) {
model.set('title', inputEl.value);
}
}, 'edit');
this.on(goog.events.EventType.BLUR, function(e) {
model.set('title', inputEl.value);
}, 'edit');
};
/**
* make (un)editable
*
* @param {boolean} editable whether to make editable.
*/
todomvc.todocontrol.prototype.makeEditable = function(editable) {
var inputEl = this.getEls('.edit')[0];
goog.dom.classes.enable(this.getElement(), 'editing', editable);
if (editable) {
inputEl.value = this.getModel().get('title');
inputEl.select();
}
};
goog.provide('todomvc.listmodel');
goog.require('mvc.Collection');
goog.require('todomvc.listsync');
goog.require('todomvc.todomodel');
/**
* @constructor
* @extends {mvc.Collection}
*/
todomvc.listmodel = function() {
var todosSchema = {
'completed': {
get: function() {
return this.getModels(function(mod) {
return mod.get('completed');
});
},
models: true
}
};
goog.base(this, {
'id': 'todos-plastronjs',
'sync': new todomvc.listsync(),
'schema': todosSchema,
'modelType': todomvc.todomodel
});
};
goog.inherits(todomvc.listmodel, mvc.Collection);
/**
* @return {Object} todos as json.
*/
todomvc.listmodel.prototype.toJson = function() {
return goog.array.map(this.getModels(), function(mod) {
return mod.toJson();
});
};
goog.provide('todomvc.todomodel');
goog.require('goog.string');
goog.require('mvc.Model');
goog.require('mvc.Model.ValidateError');
/**
* @constructor
* @param {Object=} opt_options to be put on the model.
* @extends {mvc.Model}
*/
todomvc.todomodel = function(opt_options) {
goog.base(this, opt_options);
this.setter('title', function(title) {
var updated = goog.string.trim(title);
if (!updated.length)
throw new mvc.Model.ValidateError('null string');
return updated;
});
this.errorHandler(function() {
this.dispose();
});
};
goog.inherits(todomvc.todomodel, mvc.Model);
goog.provide('todomvc.listsync');
goog.require('mvc.LocalSync');
/**
* @constructor
* @extends {mvc.LocalSync}
*/
todomvc.listsync = function() {
goog.base(this);
};
goog.inherits(todomvc.listsync, mvc.LocalSync);
/**
* @inheritDoc
*/
todomvc.listsync.prototype.read = function(model, opt_callback) {
var id = /** @type {string} */(model.get('id'));
var todos = this.store_.get(id) || [];
goog.array.forEach(/** @type {Array} */(todos),
function(todo) {
model.newModel(todo, true);
});
model.change();
};
{
"id" : "todomvc",
"inputs" : "js/app.js",
"paths" : ["js/","template/"],
"output-wrapper" : "(function(){%output%})();",
"mode" : "ADVANCED",
"level" : "VERBOSE",
"output-file" : "js/compiled.js",
"define" : {
"goog.LOCALE": "en_GB"
},
"checks": {
// Unfortunately, the Closure Library violates these in many places.
// "accessControls": "ERROR",
// "visibility": "ERROR"
"checkRegExp": "WARNING",
"checkTypes": "WARNING",
"checkVars": "WARNING",
"deprecated": "WARNING",
"fileoverviewTags": "WARNING",
"invalidCasts": "WARNING",
"missingProperties": "WARNING",
"nonStandardJsDocs": "WARNING",
"undefinedVars": "WARNING"
}
}
{namespace todomvc.templates}
/**
* @param model
*/
{template .todoItem}
<li {if $model['completed']}class="completed"{/if}>
<div class="view">
<input class="toggle" type="checkbox" {if $model['completed']}checked{/if}>
<label>{$model['title']}</label>
<button class="destroy"></button>
</div>
<input class="edit" type="text" value="">
</li>
{/template}
/**
* @param left
*/
{template .itemsLeft}
<strong>{$left}</strong> item{if $left != 1}s{/if} left
{/template}
......@@ -89,6 +89,9 @@
<li>
<a href="architecture-examples/o_O/index.html" data-source="http://weepy.github.com/o_O/" data-content="o_O: HTML binding for teh lulz: &lt;br>- Elegantly binds objects to HTML&lt;br>- Proxies through jQuery, Ender, etc&lt;br>- Automatic dependency resolution&lt;br>- Plays well with others">Funnyface.js</a>
</li>
<li>
<a href="architecture-examples/plastronjs/index.html" data-source="https://github.com/rhysbrettbowen/PlastronJS" data-content="PlastronJS is an mvc framework built on top of the Closure Library and built to compile with projects that use the Closure Compiler.">PlastronJS</a>
</li>
</ul>
<ul class="nav nav-pills">
<li>
......@@ -176,4 +179,4 @@
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script>var _gaq=[['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'));</script>
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment