Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Updating to CanJS 1.1.0, adding Mustache views #330

Closed
wants to merge 3 commits into from

2 participants

@daffl

I updated and fixed the CanJS TodoMVC example to work with CanJS 1.1.0 (released yesterday, works with latest jQuery) and the new Mustache views. I also added a readme file explaining the connection between JavaScriptMVC and CanJS. Hope that works!

labs/architecture-examples/canjs/css/app.css
((11 lines not shown))
+}
+#filters.active li:first-child a{
+ font-weight: normal;
+}
+#filters.active .active{
+ font-weight: bold;
+}
+#filters.completed a{
+ font-weight: normal;
+}
+#filters.completed li:first-child a{
+ font-weight: normal;
+}
+#filters.completed .completed{
+ font-weight: bold;
+}
@sindresorhus Owner

I would rather see selected class applied to the filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
labs/architecture-examples/canjs/css/app.css
@@ -1,3 +1,24 @@
.hidden {
display: none;
@sindresorhus Owner

You can remove this. It's already in the base.css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sindresorhus

Thanks :)

Can you fix the merge conflicts?

@daffl

Merge conflict should be fixed. I also removed the CSS. Good point, that wasn't really necessary.

@sindresorhus

Still left:

#main isn't hidden when there are no todos

@daffl

Right, for some reason we were just hiding the buttons. I updated it but I don't think I can squash the new commit into the previous merge. Sorry, hope it will do anyway.

@sindresorhus

Thanks for the changes :)

@daffl

Thanks for pulling it in!

@gustaff-weldon gustaff-weldon referenced this pull request from a commit in gustaff-weldon/todomvc
@daffl daffl Updating to CanJS 1.1.0, adding Mustache views. Closes #330 dc5a391
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
30 labs/architecture-examples/canjs/index.html
@@ -10,18 +10,22 @@
<![endif]-->
</head>
<body>
- <section id="todoapp"></section>
- <div id="info">
- <p>Double-click to edit a todo</p>
- <p>Written by <a href="http://bitovi.com">Bitovi</a></p>
- <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
- </div>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
- <script src="../../../assets/base.js"></script>
- <script src="js/lib/can.jquery-1.0.7.min.js"></script>
- <script src="js/lib/can-localstorage.min.js"></script>
- <script src="js/models/todo.js"></script>
- <script src="js/todos/todos.js"></script>
- <script src="js/app.js"></script>
+<section id="todoapp">
+</section>
+<div id="info">
+ <p>Double-click to edit a todo</p>
+ <p>Written by <a href="http://bitovi.com">Bitovi</a></p>
+ <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
+</div>
+
+<script src="../../../assets/jquery.min.js"></script>
+<script src="../../../assets/base.js"></script>
+
+<script src="js/lib/can.jquery-1.1.0.min.js"></script>
+<script src="js/lib/can.mustache.min.js"></script>
+<script src="js/lib/can.localstorage.min.js"></script>
+<script src="js/models/todo.js"></script>
+<script src="js/todos/todos.js"></script>
+<script src="js/app.js"></script>
</body>
</html>
View
17 labs/architecture-examples/canjs/js/app.js
@@ -1,12 +1,25 @@
(function() {
$(function() {
- can.route(':filter');
+ // Set up a route that maps to the `filter` attribute
+ can.route( ':filter' );
+ // Delay routing until we initialized everything
+ can.route.ready(false);
+
+ // View helper for pluralizing strings
+ Mustache.registerHelper('plural', function(str, count) {
+ return str + (count !== 1 ? 's' : '');
+ });
+
// Initialize the app
Models.Todo.findAll({}, function(todos) {
new Todos('#todoapp', {
todos: todos,
- state: can.route
+ state : can.route,
+ view : 'views/todos.mustache'
});
});
+
+ // Now we can start routing
+ can.route.ready(true);
});
})();
View
52 labs/architecture-examples/canjs/js/lib/can.jquery-1.0.7.min.js
@@ -1,52 +0,0 @@
-(function(c,n,l){$.extend(c,jQuery,{trigger:function(a,b,d){a.trigger?a.trigger(b,d):$.event.trigger(b,d,a,!0)},addEvent:function(a,b){$([this]).bind(a,b);return this},removeEvent:function(a,b){$([this]).unbind(a,b);return this},buildFragment:function(a,b){var d=$.buildFragment([a],[b]);return d.cacheable?$.clone(d.fragment):d.fragment},$:jQuery});$.each(["bind","unbind","undelegate","delegate"],function(a,b){c[b]=function(){var a=this[b]?this:$([this]);a[b].apply(a,arguments);return this}});$.each("append filter addClass remove data get".split(" "),
- function(a,b){c[b]=function(a){return a[b].apply(a,c.makeArray(arguments).slice(1))}});var pa=$.cleanData;$.cleanData=function(a){$.each(a,function(a,d){c.trigger(d,"destroyed",[],!1)});pa(a)};c.each=function(a,b,d){var c=0,e;if(a)if("number"==typeof a.length&&a.pop){a.attr&&a.attr("length");for(e=a.length;c<e&&!1!==b.call(d||a[c],a[c],c,a);c++);}else for(e in a)if(!1===b.call(d||a[c],a[e],e,a))break;return a};var qa=/==/,ra=/([A-Z]+)([A-Z][a-z])/g,sa=/([a-z\d])([A-Z])/g,ta=/([a-z\d])([A-Z])/g,P=
- /\{([^\}]+)\}/g,s=/"/g,ua=/'/g;c.extend(c,{esc:function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(s,"&#34;").replace(ua,"&#39;")},getObject:function(a,b,d){var a=a?a.split("."):[],f=a.length,e,g=0,h,i,b=c.isArray(b)?b:[b||n];if(!f)return b[0];for(;e=b[g++];){for(i=0;i<f-1&&/^f|^o/.test(typeof e);i++)e=a[i]in e?e[a[i]]:d&&(e[a[i]]={});if(/^f|^o/.test(typeof e)&&(h=a[i]in e?e[a[i]]:d&&(e[a[i]]={}),h!==l))return!1===d&&delete e[a[i]],h}},capitalize:function(a){return a.charAt(0).toUpperCase()+
- a.slice(1)},underscore:function(a){return a.replace(qa,"/").replace(ra,"$1_$2").replace(sa,"$1_$2").replace(ta,"_").toLowerCase()},sub:function(a,b,d){var f=[];f.push(a.replace(P,function(a,g){var h=c.getObject(g,b,d===l?d:!d);return/^f|^o/.test(typeof h)?(f.push(h),""):""+h}));return 1>=f.length?f[0]:f},replacer:P,undHash:/_|-/});var F=0;c.Construct=function(){if(arguments.length)return c.Construct.extend.apply(c.Construct,arguments)};c.extend(c.Construct,{newInstance:function(){var a=this.instance(),
- b;a.setup&&(b=a.setup.apply(a,arguments));a.init&&a.init.apply(a,b||arguments);return a},_inherit:function(a,b,d){c.extend(d||a,a||{})},_overwrite:function(a,b,d,c){a[d]=c},setup:function(a){this.defaults=c.extend(!0,{},a.defaults,this.defaults)},instance:function(){F=1;var a=new this;F=0;return a},extend:function(a,b,d){function f(){if(!F)return this.constructor!==f&&arguments.length?arguments.callee.extend.apply(arguments.callee,arguments):this.constructor.newInstance.apply(this.constructor,arguments)}
- "string"!=typeof a&&(d=b,b=a,a=null);d||(d=b,b=null);var d=d||{},e=this.prototype,g,h,i,j;j=this.instance();c.Construct._inherit(d,e,j);for(g in this)this.hasOwnProperty(g)&&(f[g]=this[g]);c.Construct._inherit(b,this,f);if(a){i=a.split(".");h=i.pop();i=e=c.getObject(i.join("."),n,!0);var o=c.underscore(a.replace(/\./g,"_")),z=c.underscore(h);e[h]=f}c.extend(f,{constructor:f,prototype:j,namespace:i,shortName:h,_shortName:z,fullName:a,_fullName:o});f.prototype.constructor=f;h=[this].concat(c.makeArray(arguments));
- j=f.setup.apply(f,h);f.init&&f.init.apply(f,j||h);return f}});var q=function(a){return a&&"object"===typeof a&&!(a instanceof Date)},G=function(a,b){return c.each(a,function(a){a&&a.unbind&&a.unbind("change"+b)})},H=function(a,b,d){a instanceof u?G([a],d._namespace):a=c.isArray(a)?new u.List(a):new u(a);a.bind("change"+d._namespace,function(f,e){var g=c.makeArray(arguments),f=g.shift();g[0]="*"===b?d.indexOf(a)+"."+g[0]:b+"."+g[0];f.triggeredNS=f.triggeredNS||{};f.triggeredNS[d._namespace]||(f.triggeredNS[d._namespace]=
- !0,c.trigger(d,f,g),c.trigger(d,g[0],g))});return a},Q=0,v=l,R=function(){if(!v)return v=[],!0},p=function(a,b,d){if(!a._init)if(v)v.push([a,{type:b,batchNum:S},d]);else return c.trigger(a,b,d)},S=1,T=function(){var a=v.slice(0);v=l;S++;c.each(a,function(a){c.trigger.apply(c,a)})},C=function(a,b,d){a.each(function(a,e){d[e]=q(a)&&c.isFunction(a[b])?a[b]():a});return d},A=function(a){return function(){return c[a].apply(this,arguments)}},U=A("addEvent"),A=A("removeEvent"),I=function(a){return c.isArray(a)?
- a:(""+a).split(".")},u=c.Construct("can.Observe",{setup:function(){c.Construct.setup.apply(this,arguments)},bind:U,unbind:A,id:"id"},{setup:function(a){this._data={};this._namespace=".observe"+ ++Q;this._init=1;this.attr(a);delete this._init},attr:function(a,b){if(~"ns".indexOf((typeof a).charAt(0))){if(b===l)return u.__reading&&u.__reading(this,a),this._get(a);this._set(a,b);return this}return this._attrs(a,b)},each:function(){return c.each.apply(l,[this.__get()].concat(c.makeArray(arguments)))},
- removeAttr:function(a){var a=I(a),b=a.shift(),d=this._data[b];if(a.length)return d.removeAttr(a);delete this._data[b];b in this.constructor.prototype||delete this[b];p(this,"change",[b,"remove",l,d]);p(this,b,[l,d]);return d},_get:function(a){var a=I(a),b=this.__get(a.shift());return a.length?b?b._get(a):l:b},__get:function(a){return a?this._data[a]:this._data},_set:function(a,b){var d=I(a),c=d.shift(),e=this.__get(c);if(q(e)&&d.length)e._set(d,b);else{if(d.length)throw"can.Observe: Object does not exist";
- this.__convert&&(b=this.__convert(c,b));this.__set(c,b,e)}},__set:function(a,b,c){if(b!==c){var f=this.__get().hasOwnProperty(a)?"set":"add";this.___set(a,q(b)?H(b,a,this):b);p(this,"change",[a,f,b,c]);p(this,a,[b,c]);c&&G([c],this._namespace)}},___set:function(a,b){this._data[a]=b;a in this.constructor.prototype||(this[a]=b)},bind:U,unbind:A,serialize:function(){return C(this,"serialize",{})},_attrs:function(a,b){if(a===l)return C(this,"attr",{});var a=c.extend(!0,{},a),d,f=R(),e=this,g;this.each(function(c,
- d){g=a[d];g===l?b&&e.removeAttr(d):(q(c)&&q(g)?c.attr(g,b):c!=g&&e._set(d,g),delete a[d])});for(d in a)g=a[d],this._set(d,g);f&&T();return this}}),va=[].splice,J=u("can.Observe.List",{setup:function(a,b){this.length=0;this._namespace=".observe"+ ++Q;this._init=1;this.bind("change",c.proxy(this._changes,this));this.push.apply(this,c.makeArray(a||[]));c.extend(this,b);delete this._init},_changes:function(a,b,c,f,e){~b.indexOf(".")||("add"===c?(p(this,c,[f,+b]),p(this,"length",[this.length])):"remove"===
- c?(p(this,c,[e,+b]),p(this,"length",[this.length])):p(this,c,[f,+b]))},__get:function(a){return a?this[a]:this},___set:function(a,b){this[a]=b;+a>=this.length&&(this.length=+a+1)},serialize:function(){return C(this,"serialize",[])},splice:function(a,b){var d=c.makeArray(arguments),f;for(f=2;f<d.length;f++){var e=d[f];q(e)&&(d[f]=H(e,"*",this))}b===l&&(b=d[1]=this.length-a);f=va.apply(this,d);0<b&&(p(this,"change",[""+a,"remove",l,f]),G(f,this._namespace));2<d.length&&p(this,"change",[""+a,"add",d.slice(2),
- f]);return f},_attrs:function(a,b){if(a===l)return C(this,"attr",[]);var a=a.slice(0),c=Math.min(a.length,this.length),f=R(),e;for(e=0;e<c;e++){var g=this[e],h=a[e];q(g)&&q(h)?g.attr(h,b):g!=h&&this._set(e,h)}a.length>this.length?this.push(a.slice(this.length)):a.length<this.length&&b&&this.splice(a.length);f&&T()}});c.each({push:"length",unshift:0},function(a,b){J.prototype[b]=function(){for(var d=arguments[0]&&c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),f=a?this.length:0,e=0;e<d.length;e++){var g=
- d[e];q(g)&&(d[e]=H(g,"*",this))}e=[][b].apply(this,d);(!this.comparator||!d.length)&&p(this,"change",[""+f,"add",d,l]);return e}});c.each({pop:"length",shift:0},function(a,b){J.prototype[b]=function(){var d=arguments[0]&&c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),f=a&&this.length?this.length-1:0,d=[][b].apply(this,d);p(this,"change",[""+f,"remove",l,[d]]);d&&d.unbind&&d.unbind("change"+this._namespace);return d}});J.prototype.indexOf=[].indexOf||function(a){return c.inArray(a,this)};
- var wa=function(a,b,d){var f=new c.Deferred;a.then(function(){arguments[0]=b[d](arguments[0]);f.resolve.apply(f,arguments)},function(){f.rejectWith.apply(this,arguments)});return f},xa=0,V=/change.observe\d+/,W=function(a,b,c,f,e){var g;g=[a.serialize()];var h=a.constructor,i;"destroy"==b&&g.shift();"create"!==b&&g.unshift(a[a.constructor.id]);i=h[b].apply(h,g);g=i.pipe(function(c){a[e||b+"d"](c,i);return a});i.abort&&(g.abort=function(){i.abort()});return g.then(c,f)},ya={create:{url:"_shortName",
- type:"post"},update:{data:function(a,b){var b=b||{},d=this.id;b[d]&&b[d]!==a&&(b["new"+c.capitalize(a)]=b[d],delete b[d]);b[d]=a;return b},type:"put"},destroy:{type:"delete",data:function(a){var b={};b[this.id]=a;return b}},findAll:{url:"_shortName"},findOne:{}},X=function(a,b){return function(d){var d=a.data?a.data.apply(this,arguments):d,f=b||this[a.url||"_url"],e=d,g=a.type||"get";if("string"==typeof f){var h=f.split(" "),f={url:h.pop()};h.length&&(f.type=h.pop())}f.data="object"==typeof e&&!c.isArray(e)?
- c.extend(f.data||{},e):e;f.url=c.sub(f.url,f.data,!0);return c.ajax(c.extend({type:g||"post",dataType:"json",success:void 0,error:void 0},f))}};c.Observe("can.Model",{setup:function(a){c.Observe.apply(this,arguments);if(this!==c.Model){var b=this,d=c.proxy(this._clean,b);c.each(ya,function(f,e){c.isFunction(b[e])||(b[e]=X(f,b[e]));if(b["make"+c.capitalize(e)]){var g=b["make"+c.capitalize(e)](b[e]);c.Construct._overwrite(b,a,e,function(){this._super;this._reqs++;return g.apply(this,arguments).then(d,
- d)})}});if(!b.fullName||b.fullName==a.fullName)b.fullName=b._shortName="Model"+ ++xa;this.store={};this._reqs=0;this._url=this._shortName+"/{"+this.id+"}"}},_ajax:X,_clean:function(){this._reqs--;if(!this._reqs)for(var a in this.store)this.store[a]._bindings||delete this.store[a]},models:function(a){if(a){if(a instanceof this.List)return a;var b=this,d=new (b.List||Y),f=c.isArray(a),e=a instanceof Y,e=f?a:e?a.serialize():a.data;c.each(e,function(a){d.push(b.model(a))});f||c.each(a,function(a,b){"data"!==
- b&&(d[b]=a)});return d}},model:function(a){if(a){a instanceof this&&(a=a.serialize());var b=this.store[a[this.id]]?this.store[a[this.id]].attr(a):new this(a);this._reqs&&(this.store[a[this.id]]=b);return b}}},{isNew:function(){var a=this[this.constructor.id];return!(a||0===a)},save:function(a,b){return W(this,this.isNew()?"create":"update",a,b)},destroy:function(a,b){return W(this,"destroy",a,b,"destroyed")},bind:function(a){V.test(a)||(this._bindings||(this.constructor.store[this[this.constructor.id]]=
- this,this._bindings=0),this._bindings++);return c.Observe.prototype.bind.apply(this,arguments)},unbind:function(a){V.test(a)||(this._bindings--,this._bindings||delete this.constructor.store[this[this.constructor.id]]);return c.Observe.prototype.unbind.apply(this,arguments)},___set:function(a,b){c.Observe.prototype.___set.call(this,a,b);a===this.constructor.id&&this._bindings&&(this.constructor.store[this[this.constructor.id]]=this)}});c.each({makeFindAll:"models",makeFindOne:"model"},function(a,b){c.Model[b]=
- function(b){return function(c,e,g){return wa(b.call(this,c),this,a).then(e,g)}}});c.each(["created","updated","destroyed"],function(a){c.Model.prototype[a]=function(b){var d=this.constructor;b&&"object"==typeof b&&this.attr(b.attr?b.attr():b);c.trigger(this,a);c.trigger(this,"change",a);c.trigger(d,a,this)}});var Y=c.Observe.List("can.Model.List",{setup:function(){c.Observe.List.prototype.setup.apply(this,arguments);var a=this;this.bind("change",function(b,c){/\w+\.destroyed/.test(c)&&a.splice(a.indexOf(b.target),
- 1)})}}),za=/^\d+$/,Aa=/([^\[\]]+)|(\[\])/g,Ba=/([^?#]*)(#.*)?$/,Z=function(a){return decodeURIComponent(a.replace(/\+/g," "))};c.extend(c,{deparam:function(a){var b={},d;a&&Ba.test(a)&&(a=a.split("&"),c.each(a,function(a){var a=a.split("="),c=Z(a.shift()),g=Z(a.join("="));current=b;for(var a=c.match(Aa),c=0,h=a.length-1;c<h;c++)current[a[c]]||(current[a[c]]=za.test(a[c+1])||"[]"==a[c+1]?[]:{}),current=current[a[c]];d=a.pop();"[]"==d?current.push(g):current[d]=g}));return b}});var aa=/\:([\w\.]+)/g,
- ba=/^(?:&[^=]+=[^&]*)+/,Ca=function(a){var b=[];c.each(a,function(a,f){b.push(("className"===f?"class":f)+'="'+("href"===f?a:c.esc(a))+'"')});return b.join(" ")},ca=function(a,b){var c=0,f=0,e={},g;for(g in a.defaults)a.defaults[g]===b[g]&&(e[g]=1,c++);for(;f<a.names.length;f++){if(!b.hasOwnProperty(a.names[f]))return-1;e[a.names[f]]||c++}return c},da=!0,K=n.location,w=c.each,t=c.extend;c.route=function(a,b){var b=b||{},d=[],f=a.replace(aa,function(c,f,h){d.push(f);return"([^\\"+(a.substr(h+c.length,
- 1)||"&")+"]"+(b[f]?"*":"+")+")"});c.route.routes[a]={test:RegExp("^"+f+"($|&)"),route:a,names:d,defaults:b,length:a.split("/").length};return c.route};t(c.route,{param:function(a,b){var d,f=0,e,g=a.route,h=0;delete a.route;w(a,function(){h++});w(c.route.routes,function(c){e=ca(c,a);e>f&&(d=c,f=e);if(e>=h)return!1});c.route.routes[g]&&ca(c.route.routes[g],a)===f&&(d=c.route.routes[g]);if(d){var i=t({},a),g=d.route.replace(aa,function(c,b){delete i[b];return a[b]===d.defaults[b]?"":encodeURIComponent(a[b])}),
- j;w(d.defaults,function(a,b){i[b]===a&&delete i[b]});j=c.param(i);b&&c.route.attr("route",d.route);return g+(j?"&"+j:"")}return c.isEmptyObject(a)?"":"&"+c.param(a)},deparam:function(a){var b={length:-1};w(c.route.routes,function(c){c.test.test(a)&&c.length>b.length&&(b=c)});if(-1<b.length){var d=a.match(b.test),f=d.shift(),e=(f=a.substr(f.length-("&"===d[d.length-1]?1:0)))&&ba.test(f)?c.deparam(f.slice(1)):{},e=t(!0,{},b.defaults,e);w(d,function(a,c){a&&"&"!==a&&(e[b.names[c]]=decodeURIComponent(a))});
- e.route=b.route;return e}"&"!==a.charAt(0)&&(a="&"+a);return ba.test(a)?c.deparam(a.slice(1)):{}},data:new c.Observe({}),routes:{},ready:function(a){!1===a&&(da=a);(!0===a||!0===da)&&ea();return c.route},url:function(a,b){b&&(a=t({},L,a));return"#!"+c.route.param(a)},link:function(a,b,d,f){return"<a "+Ca(t({href:c.route.url(b,f)},d))+">"+a+"</a>"},current:function(a){return K.hash=="#!"+c.route.param(a)}});w("bind unbind delegate undelegate attr removeAttr".split(" "),function(a){c.route[a]=function(){return c.route.data[a].apply(c.route.data,
- arguments)}});var fa,L,ea=function(){var a=K.href.split(/#!?/)[1]||"";L=c.route.deparam(a);(!M||a!==ga)&&c.route.attr(L,!0)},ga,M;c.bind.call(n,"hashchange",ea);c.route.bind("change",function(){M=1;clearTimeout(fa);fa=setTimeout(function(){M=0;var a=c.route.data.serialize();K.hash="#!"+(ga=c.route.param(a,!0))},1)});c.bind.call(document,"ready",c.route.ready);(function(){var a=function(a,b,d){c.bind.call(a,b,d);return function(){c.unbind.call(a,b,d)}},b=c.isFunction,d=c.extend,f=c.each,e=[].slice,
- g=/\{([^\}]+)\}/g,h=c.getObject("$.event.special")||{},i=function(a,b,d,f){c.delegate.call(a,b,d,f);return function(){c.undelegate.call(a,b,d,f)}},j=function(a,d){var f="string"==typeof d?a[d]:d;b(f)||(f=a[f]);return function(){a.called=d;return f.apply(a,[this.nodeName?c.$(this):this].concat(e.call(arguments,0)))}},o;c.Construct("can.Control",{setup:function(){c.Construct.setup.apply(this,arguments);if(this!==c.Control){var a;this.actions={};for(a in this.prototype)this._isAction(a)&&(this.actions[a]=
- this._action(a))}},_isAction:function(a){var c=this.prototype[a],d=typeof c;return"constructor"!==a&&("function"==d||"string"==d&&b(this.prototype[c]))&&!(!h[a]&&!z[a]&&!/[^\w]/.test(a))},_action:function(a,b){g.lastIndex=0;if(b||!g.test(a)){var d=b?c.sub(a,[b,n]):a,f=c.isArray(d),e=(f?d[1]:d).match(/^(?:(.*?)\s)?([\w\.\:>]+)$/);return{processor:z[e[2]]||o,parts:e,delegate:f?d[0]:l}}},processors:{},defaults:{}},{setup:function(a,b){var f=this.constructor,e=f.pluginName||f._fullName;this.element=c.$(a);
- e&&"can_control"!==e&&this.element.addClass(e);(e=c.data(this.element,"controls"))||c.data(this.element,"controls",e=[]);e.push(this);this.options=d({},f.defaults,b);this.on();return[this.element,this.options]},on:function(b,d,f,e){if(!b){this.off();var b=this.constructor,d=this._bindings,f=b.actions,e=this.element,g=j(this,"destroy"),h,o;for(h in f)f.hasOwnProperty(h)&&(o=f[h]||b._action(h,this.options),d.push(o.processor(o.delegate||e,o.parts[2],o.parts[1],h,this)));c.bind.call(e,"destroyed",g);
- d.push(function(a){c.unbind.call(a,"destroyed",g)});return d.length}"string"==typeof b&&(e=f,f=d,d=b,b=this.element);"string"==typeof e&&(e=j(this,e));this._bindings.push(d?i(b,c.trim(d),f,e):a(b,f,e));return this._bindings.length},off:function(){var a=this.element[0];f(this._bindings||[],function(b){b(a)});this._bindings=[]},destroy:function(){var a=this.constructor,a=a.pluginName||a._fullName;this.off();a&&"can_control"!==a&&this.element.removeClass(a);a=c.data(this.element,"controls");a.splice(c.inArray(this,
- a),1);c.trigger(this,"destroyed");this.element=null}});var z=c.Control.processors;o=function(b,d,f,e,g){e=j(g,e);return f?i(b,c.trim(f),d,e):a(b,d,e)};f("change click contextmenu dblclick keydown keyup keypress mousedown mousemove mouseout mouseover mouseup reset resize scroll select submit focusin focusout mouseenter mouseleave".split(" "),function(a){z[a]=o})})();c.Control.processors.route=function(a,b,d,f,e){c.route(d||"");var g,h=function(a){if(c.route.attr("route")===(d||"")&&(a.batchNum===l||
- a.batchNum!==g))if(g=a.batchNum,a=c.route.attr(),delete a.route,c.isFunction(e[f]))e[f](a);else e[e[f]](a)};c.route.bind("change",h);return function(){c.route.unbind("change",h)}};var D=c.isFunction,Da=c.makeArray,ha=1,k=c.view=function(a,b,d,f){a=k.render(a,b,d,f);return c.isDeferred(a)?a.pipe(function(a){return k.frag(a)}):k.frag(a)};c.extend(k,{frag:function(a,b){return k.hookup(k.fragment(a),b)},fragment:function(a){a=c.buildFragment(a,document.body);a.childNodes.length||a.appendChild(document.createTextNode(""));
- return a},toId:function(a){return c.map(a.toString().split(/\/|\./g),function(a){if(a)return a}).join("_")},hookup:function(a,b){var d=[],f,e,g,h=0;for(c.each(a.childNodes?c.makeArray(a.childNodes):a,function(a){1===a.nodeType&&(d.push(a),d.push.apply(d,c.makeArray(a.getElementsByTagName("*"))))});g=d[h++];)if(g.getAttribute&&(f=g.getAttribute("data-view-id"))&&(e=k.hookups[f]))e(g,b,f),delete k.hookups[f],g.removeAttribute("data-view-id");return a},hookups:{},hook:function(a){k.hookups[++ha]=a;return" data-view-id='"+
- ha+"'"},cached:{},cache:!0,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(){},preload:function(){},render:function(a,b,d,f){D(d)&&(f=d,d=l);var e=Ea(b);if(e.length){var g=new c.Deferred;e.push(ia(a,!0));c.when.apply(c,e).then(function(a){var e=Da(arguments),h=e.pop();if(c.isDeferred(b))b=ja(a);else for(var l in b)c.isDeferred(b[l])&&(b[l]=ja(e.shift()));e=h(b,d);g.resolve(e);f&&f(e)});return g}var h,e=D(f),g=ia(a,e);e?(h=g,g.then(function(a){f(a(b,d))})):
- g.then(function(a){h=a(b,d)});return h}});c.isDeferred=function(a){return a&&D(a.then)&&D(a.pipe)};var ka=function(a,b){if(!a.length)throw"can.view: No template or empty template:"+b;},ia=function(a,b){var d=a.match(/\.[\w\d]+$/),f,e,g,h=function(a){var a=f.renderer(g,a),b=new c.Deferred;b.resolve(a);k.cache&&(k.cached[g]=b);return b};a.match(/^#/)&&(a=a.substr(1));if(e=document.getElementById(a))d="."+e.type.match(/\/(x\-)?(.+)/)[2];!d&&!k.cached[a]&&(a+=d=k.ext);c.isArray(d)&&(d=d[0]);g=c.view.toId(a);
- if(a.match(/^\/\//))var i=a.substr(2),a=!n.steal?"/"+i:steal.root.mapJoin(i);f=k.types[d];if(k.cached[g])return k.cached[g];if(e)return h(e.innerHTML);var j=new c.Deferred;c.ajax({async:b,url:a,dataType:"text",error:function(b){ka("",a);j.reject(b)},success:function(b){ka(b,a);j.resolve(f.renderer(g,b));k.cache&&(k.cached[g]=j)}});return j},Ea=function(a){var b=[];if(c.isDeferred(a))return[a];for(var d in a)c.isDeferred(a[d])&&b.push(a[d]);return b},ja=function(a){return c.isArray(a)&&"success"===
- a[1]?a[0]:a};n.steal&&steal.type("view js",function(a,b){var d=c.view.types["."+a.type],f=c.view.toId(a.rootSrc);a.text="steal('"+(d.plugin||"can/view/"+a.type)+"').then(function($){can.view.preload('"+f+"',"+a.text+");\n})";b()});c.extend(c.view,{register:function(a){this.types["."+a.suffix]=a;n.steal&&steal.type(a.suffix+" view js",function(a,d){var f=c.view.types["."+a.type],e=c.view.toId(a.rootSrc+"");a.text=f.script(e,a.text);d()});c.view[a.suffix]=function(b,c){k.preload(b,a.renderer(b,c))}},
- registerScript:function(a,b,c){return"can.view.preload('"+b+"',"+k.types["."+a].script(b,c)+");"},preload:function(a,b){c.view.cached[a]=(new c.Deferred).resolve(function(a,c){return b.call(a,a,c)})}});var Fa=function(a,b){var d;c.Observe&&(d=c.Observe.__reading,c.Observe.__reading=function(a,b){f.push({obj:a,attr:b})});var f=[],e=a.call(b);c.Observe&&(c.Observe.__reading=d);return{value:e,observed:f}},la=function(a,b,d){var f={},e=!0,g={value:l,teardown:function(){for(var a in f){var b=f[a];b.observe.obj.unbind(b.observe.attr,
- h);delete f[a]}}},h=function(){var a=g.value,b=i();g.value=b;b!==a&&d(b,a)},i=function(){var d=Fa(a,b),g=d.observed,d=d.value;e=!e;c.each(g,function(a){f[a.obj._namespace+"|"+a.attr]?f[a.obj._namespace+"|"+a.attr].matched=e:(f[a.obj._namespace+"|"+a.attr]={matched:e,observe:a},a.obj.bind(a.attr,h))});for(var i in f)g=f[i],g.matched!==e&&(g.observe.obj.unbind(g.observe.attr,h),delete f[i]);return d};g.value=i();g.isListening=!c.isEmptyObject(f);return g};c.compute=function(a,b){if(a.isComputed)return a;
- var d,f=0,e,g=!0;"function"===typeof a?e=function(c){return c===l?d?d.value:a.call(b||this):a.apply(b||this,arguments)}:(e=function(b){if(b===l)return a;var d=a;a=b;d!==b&&c.trigger(e,"change",[b,d]);return b},g=!1);e.isComputed=!0;e.bind=function(h,i){c.addEvent.apply(e,arguments);f===0&&g&&(d=la(a,b||this,function(a,b){c.trigger(e,"change",[a,b])}));f++};e.unbind=function(a,b){c.removeEvent.apply(e,arguments);f--;f===0&&g&&d.teardown()};return e};c.compute.binder=la;var Ga=function(a){eval(a)},
- t=c.extend,ma=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,na=/([^\s]+)=$/,Ha=/(\r|\n)+/g,Ia=/__!!__/g,Ja={"":"span",table:"tr",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr"},B={"class":"className"},oa=c.each(["checked","disabled","readonly","required"],function(a){B[a]=a}),N=function(a,b,d){B[b]?a[B[b]]=-1<c.inArray(b,oa)?!0:d:a.setAttribute(b,d)},Ka=function(a){return"string"==typeof a||"number"==typeof a?c.esc(a):O(a)},O=function(a){if("string"==typeof a)return a;if(!a&&0!=a)return"";var b=a.hookup&&
- function(b,c){a.hookup.call(a,b,c)}||"function"==typeof a&&a;return b?(x.push(b),""):""+a},m=function(a){if(this.constructor!=m){var b=new m(a);return function(a,c){return b.render(a,c)}}"function"==typeof a?this.template={fn:a}:(t(this,a),this.template=La(this.text,this.name))};c.EJS=m;m.prototype.render=function(a,b){a=a||{};return this.template.fn.call(a,a,new m.Helpers(a,b||{}))};t(m,{txt:function(a,b,d,f,e){var g=c.compute.binder(e,f,function(a,b){o(a,b)});if(!g.isListening)return(a||0!==d?Ka:
- O)(g.value);var h,i=function(a){c.bind.call(a,"destroyed",g.teardown);h=a},j=function(a){a||(g.teardown(),c.unbind.call(h,"destroyed",g.teardown))},b=Ja[b]||"span",o;if(0==d)return"<"+b+c.view.hook(a?function(a,b){o=function(a){d.nodeValue=""+a;j(d.parentNode)};var c=b&&11===a.parentNode.nodeType?b:a.parentNode,d=document.createTextNode(g.value);c.insertBefore(d,a);c.removeChild(a);i(c)}:function(a,b){o=function(a){e[0].parentNode&&(e=d(a,e));j(e[0].parentNode)};var b=b&&11===a.parentNode.nodeType?
- b:a.parentNode,d=function(a,d){var e=c.view.frag(a,b),f=c.map(e.childNodes,function(a){return a}),g=d[d.length-1];g.nextSibling?g.parentNode.insertBefore(e,g.nextSibling):g.parentNode.appendChild(e);c.remove(c.$(d));return f},e=d(g.value,[a]);i(b)})+"></"+b+">";if(1===d){var k=g.value.replace(/['"]/g,"").split("=")[0];x.push(function(a){o=function(b){var b=(b||"").replace(/['"]/g,"").split("="),d=b[0];if(d!=k&&k){var e=k;-1<c.inArray(e,oa)?a[e]=!1:a.removeAttribute(e)}d&&(N(a,d,b[1]),k=d)};i(a)});
- return g.value}x.push(function(a){o=function(){N(a,d,h.render())};var b=c.$(a),e;(e=c.data(b,"hooks"))||c.data(b,"hooks",e={});var f=B[d]?a[B[d]]:a.getAttribute(d),b=f.split("__!!__"),h;e[d]?e[d].bindings.push(g):e[d]={render:function(){var a=0;return f.replace(Ia,function(){return O(h.bindings[a++].value)})},bindings:[g],batchNum:l};h=e[d];b.splice(1,0,g.value);N(a,d,b.join(""));i(a)});return"__!!__"},pending:function(){if(x.length){var a=x.slice(0);x=[];return c.view.hook(function(b){c.each(a,function(a){a(b)})})}return""}});
- var Ma=RegExp("(<%%|%%>|<%==|<%=|<%#|<%|%>|<|>|\"|')","g"),y=null,E=s=null,x=[],La=function(a,b){var c=[],f=0,a=a.replace(Ha,"\n");a.replace(Ma,function(b,e,g){g>f&&c.push(a.substring(f,g));c.push(e);f=g+e.length});f<a.length&&c.push(a.substr(f));var e="",g=["var ___v1ew = [];"],h=function(a,b){g.push("___v1ew.push(",'"',a.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split("\t").join("\\t"),'"'+(b||"")+");")},i=[],j,k=null,p=!1,m="",n=[],q=0,r;for(y=s=E=null;(r=c[q++])!==
- l;){if(null===k)switch(r){case "<%":case "<%=":case "<%==":p=1;case "<%#":k=r;e.length&&h(e);e="";break;case "<%%":e+="<%";break;case "<":0!==c[q].indexOf("!--")&&(y=1,p=0);e+=r;break;case ">":y=0;p?(h(e,',can.EJS.pending(),">"'),e=""):e+=r;"/"==j.substr(-1)&&(n.pop(),m=n[n.length-1]);break;case "'":case '"':y&&(s&&s===r?s=null:null===s&&(s=r,E=j));default:"<"===j&&(m=r.split(" ")[0],0===m.indexOf("/")&&n.pop()===m.substr(1)?m=n[n.length-1]||m.substr(1):n.push(m)),e+=r}else switch(r){case "%>":switch(k){case "<%":j=
- --e.split("{").length- --e.split("}").length;1==j?(g.push("___v1ew.push(","can.EJS.txt(0,'"+m+"',"+(s?"'"+E.match(na)[1]+"'":y?1:0)+",this,function(){","var ___v1ew = [];",e),i.push({before:"",after:"return ___v1ew.join('')}));\n"})):(f=i.length&&-1==j?i.pop():{after:";"},f.before&&g.push(f.before),g.push(e,";",f.after));break;case "<%=":case "<%==":(j=--e.split("{").length- --e.split("}").length)&&i.push({before:"return ___v1ew.join('')",after:"}));"}),ma.test(e)&&(e=e.match(ma),e="function(__){var "+
- e[1]+"=can.$(__);"+e[2]+"}"),g.push("___v1ew.push(","can.EJS.txt("+("<%="===k?1:0)+",'"+m+"',"+(s?"'"+E.match(na)[1]+"'":y?1:0)+",this,function(){ return ",e,j?"var ___v1ew = [];":"}));")}k=null;e="";break;case "<%%":e+="<%";break;default:e+=r}j=r}e.length&&h(e);g.push(";");h={out:"with(_VIEW) { with (_CONTEXT) {"+g.join("")+" return ___v1ew.join('')}}"};Ga.call(h,"this.fn = (function(_CONTEXT,_VIEW){"+h.out+"});\r\n//@ sourceURL="+b+".js");return h};m.Helpers=function(a,b){this._data=a;this._extras=
- b;t(this,b)};m.Helpers.prototype={list:function(a,b){c.each(a,function(c,f){b(c,f,a)})}};c.view.register({suffix:"ejs",script:function(a,b){return"can.EJS(function(_CONTEXT,_VIEW) { "+(new m({text:b,name:a})).template.out+" })"},renderer:function(a,b){return m({text:b,name:a})}});"function"===typeof define&&define.amd?define("can",[],function(){return c}):n.can=c})(can={},this);
View
64 labs/architecture-examples/canjs/js/lib/can.jquery-1.1.0.min.js
@@ -0,0 +1,64 @@
+(function(u,n,l){var c=u.can||{};if("undefined"===typeof GLOBALCAN||!1!==GLOBALCAN)u.can=c;c.isDeferred=function(a){var b=this.isFunction;return a&&b(a.then)&&b(a.pipe)};c.each=function(a,b,d){var c=0,f;if(a)if("number"===typeof a.length&&a.pop){a.attr&&a.attr("length");for(f=a.length;c<f&&!1!==b.call(d||a[c],a[c],c,a);c++);}else if(a.hasOwnProperty)for(f in a)if(a.hasOwnProperty(f)&&!1===b.call(d||a[f],a[f],f,a))break;return a};n.extend(c,jQuery,{trigger:function(a,b,d){a.trigger?a.trigger(b,d):
+ n.event.trigger(b,d,a,!0)},addEvent:function(a,b){n([this]).bind(a,b);return this},removeEvent:function(a,b){n([this]).unbind(a,b);return this},buildFragment:function(a,b){var d=n.buildFragment([a],n(b));return d.cacheable?n.clone(d.fragment):d.fragment},$:jQuery,each:c.each});n.each(["bind","unbind","undelegate","delegate"],function(a,b){c[b]=function(){var a=this[b]?this:n([this]);a[b].apply(a,arguments);return this}});n.each("append filter addClass remove data get".split(" "),function(a,b){c[b]=
+ function(a){return a[b].apply(a,c.makeArray(arguments).slice(1))}});var Ha=n.cleanData;n.cleanData=function(a){n.each(a,function(a,d){d&&c.trigger(d,"destroyed",[],!1)});Ha(a)};var Ia=/\=\=/,Ja=/([A-Z]+)([A-Z][a-z])/g,Ka=/([a-z\d])([A-Z])/g,La=/([a-z\d])([A-Z])/g,ka=/\{([^\}]+)\}/g,x=/"/g,Ma=/'/g;c.extend(c,{esc:function(a){return(""+(null===a||a===l||isNaN(a)&&"NaN"===""+a?"":a)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(x,"&#34;").replace(Ma,"&#39;")},getObject:function(a,
+ b,d){var a=a?a.split("."):[],e=a.length,f,h=0,g,i,b=c.isArray(b)?b:[b||u];if(!e)return b[0];for(;b[h];){f=b[h];for(i=0;i<e-1&&/^f|^o/.test(typeof f);i++)f=a[i]in f?f[a[i]]:d&&(f[a[i]]={});if(/^f|^o/.test(typeof f)&&(g=a[i]in f?f[a[i]]:d&&(f[a[i]]={}),g!==l))return!1===d&&delete f[a[i]],g;h++}},capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},underscore:function(a){return a.replace(Ia,"/").replace(Ja,"$1_$2").replace(Ka,"$1_$2").replace(La,"_").toLowerCase()},sub:function(a,b,d){var e=
+ [];e.push(a.replace(ka,function(a,h){var g=c.getObject(h,b,d===l?d:!d);return/^f|^o/.test(typeof g)?(e.push(g),""):""+g}));return 1>=e.length?e[0]:e},replacer:ka,undHash:/_|-/});var R=0;c.Construct=function(){if(arguments.length)return c.Construct.extend.apply(c.Construct,arguments)};c.extend(c.Construct,{newInstance:function(){var a=this.instance(),b;a.setup&&(b=a.setup.apply(a,arguments));a.init&&a.init.apply(a,b||arguments);return a},_inherit:function(a,b,d){c.extend(d||a,a||{})},_overwrite:function(a,
+ b,d,c){a[d]=c},setup:function(a){this.defaults=c.extend(!0,{},a.defaults,this.defaults)},instance:function(){R=1;var a=new this;R=0;return a},extend:function(a,b,d){function e(){if(!R)return this.constructor!==e&&arguments.length?arguments.callee.extend.apply(arguments.callee,arguments):this.constructor.newInstance.apply(this.constructor,arguments)}"string"!=typeof a&&(d=b,b=a,a=null);d||(d=b,b=null);var d=d||{},f=this.prototype,h,g,i,y;y=this.instance();c.Construct._inherit(d,f,y);for(h in this)this.hasOwnProperty(h)&&
+(e[h]=this[h]);c.Construct._inherit(b,this,e);if(a){i=a.split(".");g=i.pop();i=f=c.getObject(i.join("."),u,!0);var j=c.underscore(a.replace(/\./g,"_")),s=c.underscore(g);f[g]=e}c.extend(e,{constructor:e,prototype:y,namespace:i,shortName:g,_shortName:s,fullName:a,_fullName:j});e.prototype.constructor=e;g=[this].concat(c.makeArray(arguments));y=e.setup.apply(e,g);e.init&&e.init.apply(e,y||g);return e}});var v=function(a){return a&&(c.isArray(a)||c.isPlainObject(a)||a instanceof c.Observe)},M=function(a,
+ b){return c.each(a,function(a){a&&a.unbind&&a.unbind("change"+b)})},S=function(a,b,d,e,f){e=e||j;f=f||j.List;a instanceof j?M([a],d._cid):a=c.isArray(a)?new f(a):new e(a);a.bind("change"+d._cid,function(){var e=c.makeArray(arguments),f=e.shift();e[0]=("*"===b?[d.indexOf(a),e[0]]:[b,e[0]]).join(".");f.triggeredNS=f.triggeredNS||{};f.triggeredNS[d._cid]||(f.triggeredNS[d._cid]=!0,c.trigger(d,f,e))});return a},N=function(a,b,d){a.each(function(a,f){d[f]=v(a)&&c.isFunction(a[b])?a[b]():a});return d},
+ F=function(a){return function(){return c[a].apply(this,arguments)}},G=F("addEvent"),F=F("removeEvent"),T=function(a){return c.isArray(a)?a:(""+a).split(".")},la=1,H=0,U=[],V=[],Na=0;c.cid=function(a,b){return a._cid?a._cid:a._cid=(b||"")+ ++Na};var j=c.Observe=c.Construct({bind:G,unbind:F,id:"id",canMakeObserve:v,startBatch:function(a){H++;a&&V.push(a)},stopBatch:function(a,b){a?H=0:H--;if(0==H){var d=U.slice(0),e=V.slice(0);U=[];V=[];la++;b&&this.startBatch();c.each(d,function(a){c.trigger.apply(c,
+ a)});c.each(e,function(a){a})}},triggerBatch:function(a,b,d){if(!a._init){if(0==H)return c.trigger(a,b,d);U.push([a,{type:b,batchNum:la},d])}},keys:function(a){var b=[];j.__reading&&j.__reading(a,"__keys");for(var d in a._data)b.push(d);return b}},{setup:function(a){this._data={};c.cid(this,".observe");this._init=1;this.attr(a);this.bind("change"+this._cid,c.proxy(this._changes,this));delete this._init},_changes:function(a,b,d,c,f){j.triggerBatch(this,{type:b,batchNum:a.batchNum},[c,f])},attr:function(a,
+ b){var d=typeof a;if("string"!==d&&"number"!==d)return this._attrs(a,b);if(b===l)return j.__reading&&j.__reading(this,a),this._get(a);this._set(a,b);return this},each:function(){j.__reading&&j.__reading(this,"__keys");return c.each.apply(l,[this.__get()].concat(c.makeArray(arguments)))},removeAttr:function(a){var a=T(a),b=a.shift(),d=this._data[b];if(a.length)return d.removeAttr(a);b in this._data&&(delete this._data[b],b in this.constructor.prototype||delete this[b],j.triggerBatch(this,"__keys",
+ l),j.triggerBatch(this,"change",[b,"remove",l,d]),j.triggerBatch(this,b,[l,d]));return d},_get:function(a){var a=T(a),b=this.__get(a.shift());return a.length?b?b._get(a):l:b},__get:function(a){return a?this._data[a]:this._data},_set:function(a,b){var d=T(a),c=d.shift(),f=this.__get(c);if(v(f)&&d.length)f._set(d,b);else{if(d.length)throw"can.Observe: Object does not exist";this.__convert&&(b=this.__convert(c,b));f||j.triggerBatch(this,"__keys",l);this.__set(c,b,f)}},__set:function(a,b,d){if(b!==d){var c=
+ this.__get().hasOwnProperty(a)?"set":"add";this.___set(a,v(b)?S(b,a,this):b);j.triggerBatch(this,"change",[a,c,b,d]);d&&M([d],this._cid)}},___set:function(a,b){this._data[a]=b;a in this.constructor.prototype||(this[a]=b)},bind:G,unbind:F,serialize:function(){return N(this,"serialize",{})},_attrs:function(a,b){if(a===l)return N(this,"attr",{});var a=c.extend(!0,{},a),d,e=this,f;j.startBatch();this.each(function(d,g){f=a[g];f===l?b&&e.removeAttr(g):(e.__convert&&(f=e.__convert(g,f)),d!==f&&(d instanceof
+ c.Observe&&f instanceof c.Observe&&M([d],e._cid),f instanceof c.Observe?e._set(g,f):v(d)&&v(f)?d.attr(f,b):d!=f&&e._set(g,f)),delete a[g])});for(d in a)f=a[d],this._set(d,f);j.stopBatch();return this}}),Oa=[].splice,O=j({setup:function(a,b){this.length=0;c.cid(this,".observe");this._init=1;this.push.apply(this,c.makeArray(a||[]));this.bind("change"+this._cid,c.proxy(this._changes,this));c.extend(this,b);delete this._init},_changes:function(a,b,d,c,f){~b.indexOf(".")||("add"===d?(j.triggerBatch(this,
+ d,[c,+b]),j.triggerBatch(this,"length",[this.length])):"remove"===d?(j.triggerBatch(this,d,[f,+b]),j.triggerBatch(this,"length",[this.length])):j.triggerBatch(this,d,[c,+b]));j.prototype._changes.apply(this,arguments)},__get:function(a){return a?this[a]:this},___set:function(a,b){this[a]=b;+a>=this.length&&(this.length=+a+1)},serialize:function(){return N(this,"serialize",[])},splice:function(a,b){var d=c.makeArray(arguments),e;for(e=2;e<d.length;e++){var f=d[e];v(f)&&(d[e]=S(f,"*",this))}b===l&&
+(b=d[1]=this.length-a);e=Oa.apply(this,d);0<b&&(j.triggerBatch(this,"change",[""+a,"remove",l,e]),M(e,this._cid));2<d.length&&j.triggerBatch(this,"change",[""+a,"add",d.slice(2),e]);return e},_attrs:function(a,b){if(a===l)return N(this,"attr",[]);a=c.makeArray(a);j.startBatch();this._updateAttrs(a,b);j.stopBatch()},_updateAttrs:function(a,b){for(var d=Math.min(a.length,this.length),c=0;c<d;c++){var f=this[c],h=a[c];v(f)&&v(h)?f.attr(h,b):f!=h&&this._set(c,h)}a.length>this.length?this.push.apply(this,
+ a.slice(this.length)):a.length<this.length&&b&&this.splice(a.length)}});c.each({push:"length",unshift:0},function(a,b){O.prototype[b]=function(){for(var d=arguments[0]&&c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),e=a?this.length:0,f=0;f<d.length;f++){var h=d[f];v(h)&&(d[f]=S(h,"*",this,this.constructor.Observe,this.constructor))}f=[][b].apply(this,d);(!this.comparator||!d.length)&&j.triggerBatch(this,"change",[""+e,"add",d,l]);return f}});c.each({pop:"length",shift:0},function(a,b){O.prototype[b]=
+ function(){var d=arguments[0]&&c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),e=a&&this.length?this.length-1:0,d=[][b].apply(this,d);j.triggerBatch(this,"change",[""+e,"remove",l,[d]]);d&&d.unbind&&d.unbind("change"+this._cid);return d}});c.extend(O.prototype,{indexOf:function(a){this.attr("length");return c.inArray(a,this)},join:[].join,slice:function(){return new this.constructor(Array.prototype.slice.apply(this,arguments))},concat:function(){var a=[];c.each(c.makeArray(arguments),
+ function(b,d){a[d]=b instanceof c.Observe.List?b.serialize():b});return new this.constructor(Array.prototype.concat.apply(this.serialize(),a))},forEach:function(a,b){c.each(this,a,b||this)}});j.List=O;j.setup=function(){c.Construct.setup.apply(this,arguments);this.List=j.List({Observe:this},{})};var Pa=function(a,b,d){var e=new c.Deferred;a.then(function(){var a=c.makeArray(arguments);a[0]=b[d](a[0]);e.resolveWith(e,a)},function(){e.rejectWith(this,arguments)});"function"===typeof a.abort&&(e.abort=
+ function(){return a.abort()});return e},Qa=0,ma=/change.observe\d+/,I=function(a){c.Observe.__reading&&c.Observe.__reading(a,a.constructor.id);return a.__get(a.constructor.id)},na=function(a,b,d,c,f){var h;h=[a.serialize()];var g=a.constructor,i;"destroy"==b&&h.shift();"create"!==b&&h.unshift(I(a));i=g[b].apply(g,h);h=i.pipe(function(c){a[f||b+"d"](c,i);return a});i.abort&&(h.abort=function(){i.abort()});h.then(d,c);return h},Ra={create:{url:"_shortName",type:"post"},update:{data:function(a,b){var b=
+ b||{},d=this.id;b[d]&&b[d]!==a&&(b["new"+c.capitalize(a)]=b[d],delete b[d]);b[d]=a;return b},type:"put"},destroy:{type:"delete",data:function(a){var b={};b.id=b[this.id]=a;return b}},findAll:{url:"_shortName"},findOne:{}},oa=function(a,b){return function(d){var d=a.data?a.data.apply(this,arguments):d,e=b||this[a.url||"_url"],f=d,h=a.type||"get",g={};"string"==typeof e?(e=e.split(/\s/),g.url=e.pop(),e.length&&(g.type=e.pop())):c.extend(g,e);g.data="object"==typeof f&&!c.isArray(f)?c.extend(g.data||
+{},f):f;g.url=c.sub(g.url,g.data,!0);return c.ajax(c.extend({type:h||"post",dataType:"json",success:void 0,error:void 0},g))}};c.Model=c.Observe({fullName:"can.Model",setup:function(a){this.store={};c.Observe.setup.apply(this,arguments);if(c.Model){this.List=W({Observe:this},{});var b=this,d=c.proxy(this._clean,b);c.each(Ra,function(e,f){c.isFunction(b[f])||(b[f]=oa(e,b[f]));if(b["make"+c.capitalize(f)]){var h=b["make"+c.capitalize(f)](b[f]);c.Construct._overwrite(b,a,f,function(){this._reqs++;var a=
+ h.apply(this,arguments),b=a.then(d,d);b.abort=a.abort;return b})}});if("can.Model"==b.fullName||!b.fullName)b.fullName="Model"+ ++Qa;this._reqs=0;this._url=this._shortName+"/{"+this.id+"}"}},_ajax:oa,_clean:function(a){this._reqs--;if(!this._reqs)for(var b in this.store)this.store[b]._bindings||delete this.store[b];return a},models:function(a){if(a){if(a instanceof this.List)return a;var b=this,d=new (b.List||W),e=c.isArray(a),f=a instanceof W,f=e?a:f?a.serialize():a.data;c.each(f,function(a){d.push(b.model(a))});
+ e||c.each(a,function(a,b){"data"!==b&&d.attr(b,a)});return d}},model:function(a){if(a){a instanceof this&&(a=a.serialize());var b=a[this.id],b=b&&this.store[b]?this.store[b].attr(a):new this(a);this._reqs&&(this.store[a[this.id]]=b);return b}}},{isNew:function(){var a=I(this);return!(a||0===a)},save:function(a,b){return na(this,this.isNew()?"create":"update",a,b)},destroy:function(a,b){return na(this,"destroy",a,b,"destroyed")},bind:function(a){ma.test(a)||(this._bindings||(this.constructor.store[I(this)]=
+ this,this._bindings=0),this._bindings++);return c.Observe.prototype.bind.apply(this,arguments)},unbind:function(a){ma.test(a)||(this._bindings--,this._bindings||delete this.constructor.store[I(this)]);return c.Observe.prototype.unbind.apply(this,arguments)},___set:function(a,b){c.Observe.prototype.___set.call(this,a,b);a===this.constructor.id&&this._bindings&&(this.constructor.store[I(this)]=this)}});c.each({makeFindAll:"models",makeFindOne:"model"},function(a,b){c.Model[b]=function(b){return function(c,
+ f,h){c=Pa(b.call(this,c),this,a);c.then(f,h);return c}}});c.each(["created","updated","destroyed"],function(a){c.Model.prototype[a]=function(b){var d=this.constructor;b&&"object"==typeof b&&this.attr(b.attr?b.attr():b);c.trigger(this,a);c.trigger(this,"change",a);c.trigger(d,a,this)}});var W=c.Model.List=c.Observe.List({setup:function(){c.Observe.List.prototype.setup.apply(this,arguments);var a=this;this.bind("change",function(b,c){if(/\w+\.destroyed/.test(c)){var e=a.indexOf(b.target);-1!=e&&a.splice(e,
+ 1)}})}}),Sa=/^\d+$/,Ta=/([^\[\]]+)|(\[\])/g,Ua=/([^?#]*)(#.*)?$/,pa=function(a){return decodeURIComponent(a.replace(/\+/g," "))};c.extend(c,{deparam:function(a){var b={},d;a&&Ua.test(a)&&(a=a.split("&"),c.each(a,function(a){var a=a.split("="),c=pa(a.shift()),h=pa(a.join("="));current=b;for(var a=c.match(Ta),c=0,g=a.length-1;c<g;c++)current[a[c]]||(current[a[c]]=Sa.test(a[c+1])||"[]"==a[c+1]?[]:{}),current=current[a[c]];d=a.pop();"[]"==d?current.push(h):current[d]=h}));return b}});var qa=/\:([\w\.]+)/g,
+ Va=function(a){var b=[];c.each(a,function(a,e){b.push(("className"===e?"class":e)+'="'+("href"===e?a:c.esc(a))+'"')});return b.join(" ")},ra=function(a,b){var c=0,e=0,f={},h;for(h in a.defaults)a.defaults[h]===b[h]&&(f[h]=1,c++);for(;e<a.names.length;e++){if(!b.hasOwnProperty(a.names[e]))return-1;f[a.names[e]]||c++}return c},sa=!0,X=u.location,z=c.each,o=c.extend;c.route=function(a,b){var b=b||{},d=[],e=a.replace(qa,function(e,h,g){d.push(h);return"([^\\"+(a.substr(g+e.length,1)||c.route._querySeparator)+
+ "]"+(b[h]?"*":"+")+")"});c.route.routes[a]={test:RegExp("^"+e+"($|"+(c.route._querySeparator+"").replace(/([.?*+\^$\[\]\\(){}|\-])/g,"\\$1")+")"),route:a,names:d,defaults:b,length:a.split("/").length};return c.route};o(c.route,{_querySeparator:"&",_paramsMatcher:/^(?:&[^=]+=[^&]*)+/,param:function(a,b){var d,e=0,f,h=a.route,g=0;delete a.route;z(a,function(){g++});z(c.route.routes,function(b){f=ra(b,a);f>e&&(d=b,e=f);if(f>=g)return!1});c.route.routes[h]&&ra(c.route.routes[h],a)===e&&(d=c.route.routes[h]);
+ if(d){var i=o({},a),h=d.route.replace(qa,function(b,c){delete i[c];return a[c]===d.defaults[c]?"":encodeURIComponent(a[c])}),y;z(d.defaults,function(a,b){i[b]===a&&delete i[b]});y=c.param(i);b&&c.route.attr("route",d.route);return h+(y?c.route._querySeparator+y:"")}return c.isEmptyObject(a)?"":c.route._querySeparator+c.param(a)},deparam:function(a){var b={length:-1};z(c.route.routes,function(c){c.test.test(a)&&c.length>b.length&&(b=c)});if(-1<b.length){var d=a.match(b.test),e=d.shift(),f=(e=a.substr(e.length-
+ (d[d.length-1]===c.route._querySeparator?1:0)))&&c.route._paramsMatcher.test(e)?c.deparam(e.slice(1)):{},f=o(!0,{},b.defaults,f);z(d,function(a,d){a&&a!==c.route._querySeparator&&(f[b.names[d]]=decodeURIComponent(a))});f.route=b.route;return f}a.charAt(0)!==c.route._querySeparator&&(a=c.route._querySeparator+a);return c.route._paramsMatcher.test(a)?c.deparam(a.slice(1)):{}},data:new c.Observe({}),routes:{},ready:function(a){!1===a&&(sa=a);if(!0===a||!0===sa)c.route._setup(),ta();return c.route},url:function(a,
+ b){b&&(a=o({},Y,a));return"#!"+c.route.param(a)},link:function(a,b,d,e){return"<a "+Va(o({href:c.route.url(b,e)},d))+">"+a+"</a>"},current:function(a){return X.hash=="#!"+c.route.param(a)},_setup:function(){c.bind.call(u,"hashchange",ta)},_getHash:function(){return X.href.split(/#!?/)[1]||""},_setHash:function(a){a=c.route.param(a,!0);X.hash="#!"+a;return a}});z("bind unbind delegate undelegate attr removeAttr".split(" "),function(a){c.route[a]=function(){return c.route.data[a].apply(c.route.data,
+ arguments)}});var ua,Y,ta=c.route.setState=function(){var a=c.route._getHash();Y=c.route.deparam(a);(!Z||a!==va)&&c.route.attr(Y,!0)},va,Z;c.route.bind("change",function(){Z=1;clearTimeout(ua);ua=setTimeout(function(){Z=0;var a=c.route.data.serialize();va=c.route._setHash(a)},1)});c.bind.call(document,"ready",c.route.ready);c.route.constructor.canMakeObserve=c.Observe.canMakeObserve;var G=function(a,b,d){c.bind.call(a,b,d);return function(){c.unbind.call(a,b,d)}},D=c.isFunction,o=c.extend,z=c.each,
+ Wa=[].slice,wa=/\{([^\}]+)\}/g,Xa=c.getObject("$.event.special")||{},xa=function(a,b,d,e){c.delegate.call(a,b,d,e);return function(){c.undelegate.call(a,b,d,e)}},$;c.Control=c.Construct({setup:function(){c.Construct.setup.apply(this,arguments);if(c.Control){var a;this.actions={};for(a in this.prototype)this._isAction(a)&&(this.actions[a]=this._action(a))}},_shifter:function(a,b){var d="string"==typeof b?a[b]:b;D(d)||(d=a[d]);return function(){a.called=b;return d.apply(a,[this.nodeName?c.$(this):this].concat(Wa.call(arguments,
+ 0)))}},_isAction:function(a){var b=this.prototype[a],c=typeof b;return"constructor"!==a&&("function"==c||"string"==c&&D(this.prototype[b]))&&!(!Xa[a]&&!aa[a]&&!/[^\w]/.test(a))},_action:function(a,b){wa.lastIndex=0;if(b||!wa.test(a)){var d=b?c.sub(a,[b,u]):a,e=c.isArray(d),f=e?d[1]:d,h=f.split(/\s+/g),g=h.pop();return{processor:aa[g]||$,parts:[f,h.join(" "),g],delegate:e?d[0]:l}}},processors:{},defaults:{}},{setup:function(a,b){var d=this.constructor,e=d.pluginName||d._fullName;this.element=c.$(a);
+ e&&"can_control"!==e&&this.element.addClass(e);(e=c.data(this.element,"controls"))||c.data(this.element,"controls",e=[]);e.push(this);this.options=o({},d.defaults,b);this.on();return[this.element,this.options]},on:function(a,b,d,e){if(!a){this.off();var a=this.constructor,b=this._bindings,d=a.actions,e=this.element,f=c.Control._shifter(this,"destroy"),h,g;for(h in d)d.hasOwnProperty(h)&&(g=d[h]||a._action(h,this.options),b.push(g.processor(g.delegate||e,g.parts[2],g.parts[1],h,this)));c.bind.call(e,
+ "destroyed",f);b.push(function(a){c.unbind.call(a,"destroyed",f)});return b.length}"string"==typeof a&&(e=d,d=b,b=a,a=this.element);e===l&&(e=d,d=b,b=null);"string"==typeof e&&(e=c.Control._shifter(this,e));this._bindings.push(b?xa(a,c.trim(b),d,e):G(a,d,e));return this._bindings.length},off:function(){var a=this.element[0];z(this._bindings||[],function(b){b(a)});this._bindings=[]},destroy:function(){var a=this.constructor,a=a.pluginName||a._fullName;this.off();a&&"can_control"!==a&&this.element.removeClass(a);
+ a=c.data(this.element,"controls");a.splice(c.inArray(this,a),1);c.trigger(this,"destroyed");this.element=null}});var aa=c.Control.processors;$=function(a,b,d,e,f){e=c.Control._shifter(f,e);return d?xa(a,c.trim(d),b,e):G(a,b,e)};z("change click contextmenu dblclick keydown keyup keypress mousedown mousemove mouseout mouseover mouseup reset resize scroll select submit focusin focusout mouseenter mouseleave touchstart touchmove touchcancel touchend touchleave".split(" "),function(a){aa[a]=$});c.Control.processors.route=
+ function(a,b,d,e,f){d=d||"";c.route(d);var h,g=function(a){if(c.route.attr("route")===d&&(a.batchNum===l||a.batchNum!==h))if(h=a.batchNum,a=c.route.attr(),delete a.route,c.isFunction(f[e]))f[e](a);else f[f[e]](a)};c.route.bind("change",g);return function(){c.route.unbind("change",g)}};var D=c.isFunction,Ya=c.makeArray,ya=1,k=c.view=function(a,b,d,e){a=k.render(a,b,d,e);return D(a)?a:c.isDeferred(a)?a.pipe(function(a){return k.frag(a)}):k.frag(a)};c.extend(k,{frag:function(a,b){return k.hookup(k.fragment(a),
+ b)},fragment:function(a){a=c.buildFragment(a,document.body);a.childNodes.length||a.appendChild(document.createTextNode(""));return a},toId:function(a){return c.map(a.toString().split(/\/|\./g),function(a){if(a)return a}).join("_")},hookup:function(a,b){var d=[],e,f;c.each(a.childNodes?c.makeArray(a.childNodes):a,function(a){1===a.nodeType&&(d.push(a),d.push.apply(d,c.makeArray(a.getElementsByTagName("*"))))});c.each(d,function(a){if(a.getAttribute&&(e=a.getAttribute("data-view-id"))&&(f=k.hookups[e]))f(a,
+ b,e),delete k.hookups[e],a.removeAttribute("data-view-id")});return a},hookups:{},hook:function(a){k.hookups[++ya]=a;return" data-view-id='"+ya+"'"},cached:{},cachedRenderers:{},cache:!0,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(){},preload:function(){},render:function(a,b,d,e){D(d)&&(e=d,d=l);var f=Za(b);if(f.length){var h=new c.Deferred;f.push(za(a,!0));c.when.apply(c,f).then(function(a){var f=Ya(arguments),g=f.pop();if(c.isDeferred(b))b=Aa(a);
+else for(var j in b)c.isDeferred(b[j])&&(b[j]=Aa(f.shift()));f=g(b,d);h.resolve(f);e&&e(f)});return h}var g,f=D(e),h=za(a,f);if(f)g=h,h.then(function(a){e(b?a(b,d):a)});else{if("resolved"===h.state()&&h.__view_id)return a=k.cachedRenderers[h.__view_id],b?a(b,d):a;h.then(function(a){g=b?a(b,d):a})}return g},registerView:function(a,b,d,e){b=(d||k.types[k.ext]).renderer(a,b);e=e||new c.Deferred;k.cache&&(k.cached[a]=e,e.__view_id=a,k.cachedRenderers[a]=b);return e.resolve(b)}});var Ba=function(a,b){if(!a.length)throw"can.view: No template or empty template:"+
+ b;},za=function(a,b){var d=a.match(/\.[\w\d]+$/),e,f,h;a.match(/^#/)&&(a=a.substr(1));if(f=document.getElementById(a))d="."+f.type.match(/\/(x\-)?(.+)/)[2];!d&&!k.cached[a]&&(a+=d=k.ext);c.isArray(d)&&(d=d[0]);h=k.toId(a);if(a.match(/^\/\//))var g=a.substr(2),a=!u.steal?g:steal.config().root.mapJoin(g);e=k.types[d];if(k.cached[h])return k.cached[h];if(f)return k.registerView(h,f.innerHTML,e);var i=new c.Deferred;c.ajax({async:b,url:a,dataType:"text",error:function(b){Ba("",a);i.reject(b)},success:function(b){Ba(b,
+ a);k.registerView(h,b,e,i)}});return i},Za=function(a){var b=[];if(c.isDeferred(a))return[a];for(var d in a)c.isDeferred(a[d])&&b.push(a[d]);return b},Aa=function(a){return c.isArray(a)&&"success"===a[1]?a[0]:a};u.steal&&steal.type("view js",function(a,b){var c=k.types["."+a.type],e=k.toId(a.id);a.text="steal('"+(c.plugin||"can/view/"+a.type)+"',function(can){return can.view.preload('"+e+"',"+a.text+");\n})";b()});c.extend(k,{register:function(a){this.types["."+a.suffix]=a;u.steal&&steal.type(a.suffix+
+ " view js",function(a,c){var e=k.types["."+a.type],f=k.toId(a.id+"");a.text=e.script(f,a.text);c()});k[a.suffix]=function(b,c){k.preload(b,a.renderer(b,c))}},registerScript:function(a,b,c){return"can.view.preload('"+b+"',"+k.types["."+a].script(b,c)+");"},preload:function(a,b){k.cached[a]=(new c.Deferred).resolve(function(a,c){return b.call(a,a,c)});return function(){return k.frag(b.apply(this,arguments))}}});var $a=function(a,b){var d;c.Observe&&(d=c.Observe.__reading,c.Observe.__reading=function(a,
+ b){e.push({obj:a,attr:b})});var e=[],f=a.call(b);c.Observe&&(c.Observe.__reading=d);return{value:f,observed:e}},Ca=function(a,b,d){var e={},f=!0,h={value:l,teardown:function(){for(var a in e){var b=e[a];b.observe.obj.unbind(b.observe.attr,i);delete e[a]}}},g,i=function(a){if(a.batchNum===l||a.batchNum!==g){var b=h.value,c=j();h.value=c;c!==b&&d(c,b);g=g=a.batchNum}},j=function(){var d=$a(a,b),g=d.observed,d=d.value;f=!f;c.each(g,function(a){e[a.obj._cid+"|"+a.attr]?e[a.obj._cid+"|"+a.attr].matched=
+ f:(e[a.obj._cid+"|"+a.attr]={matched:f,observe:a},a.obj.bind(a.attr,i))});for(var h in e)g=e[h],g.matched!==f&&(g.observe.obj.unbind(g.observe.attr,i),delete e[h]);return d};h.value=j();h.isListening=!c.isEmptyObject(e);return h};c.compute=function(a,b){if(a&&a.isComputed)return a;var d,e=0,f,h=!0;"function"===typeof a?f=function(g){return g===l?d?(e&&c.Observe.__reading&&c.Observe.__reading(f,"change"),d.value):a.call(b||this):a.apply(b||this,arguments)}:(f=function(b){if(b===l)return c.Observe.__reading&&
+ c.Observe.__reading(f,"change"),a;var d=a;a=b;d!==b&&c.Observe.triggerBatch(f,"change",[b,d]);return b},h=!1);f.isComputed=!0;f.bind=function(g,i){c.addEvent.apply(f,arguments);e===0&&h&&(d=Ca(a,b||this,function(a,b){c.Observe.triggerBatch(f,"change",[a,b])}));e++};f.unbind=function(a,b){c.removeEvent.apply(f,arguments);e--;e===0&&h&&d.teardown()};return f};c.compute.binder=Ca;var ab=/(\r|\n)+/g,ba={option:"textContent",textarea:"value"},Da={tr:"tbody",option:"select",td:"tr",li:"ul"},bb=function(a,
+ b,c){if(a)return a;for(;c<b.length;){if("<"==b[c]&&Da[b[c+1]])return Da[b[c+1]];c++}},cb=function(a){eval(a)},db=/([^\s]+)[\s]*=[\s]*$/,B=null,ca=x=null,q=null,da=function(){return x?"'"+ca.match(db)[1]+"'":B?1:0};c.view.Scanner=Scanner=function(a){c.extend(this,{text:{},tokens:[]},a);this.tokenReg=[];this.tokenSimple={"<":"<",">":">",'"':'"',"'":"'"};this.tokenComplex=[];this.tokenMap={};for(var a=0,b;b=this.tokens[a];a++)b[2]?(this.tokenReg.push(b[2]),this.tokenComplex.push({abbr:b[1],re:RegExp(b[2]),
+ rescan:b[3]})):(this.tokenReg.push(b[1]),this.tokenSimple[b[1]]=b[0]),this.tokenMap[b[0]]=b[1];this.tokenReg=RegExp("("+this.tokenReg.slice(0).concat(["<",">",'"',"'"]).join("|")+")","g")};Scanner.prototype={helpers:[{name:/\s*\(([\$\w]+)\)\s*->([^\n]*)/,fn:function(a){a=a.match(/\s*\(([\$\w]+)\)\s*->([^\n]*)/);return"function(__){var "+a[1]+"=can.$(__);"+a[2]+"}"}}],scan:function(a,b){var c=[],e=0,f=this.tokenSimple,h=this.tokenComplex,a=a.replace(ab,"\n");a.replace(this.tokenReg,function(b,g){var i=
+ arguments[arguments.length-2];i>e&&c.push(a.substring(e,i));if(f[b])c.push(b);else for(var j=0,m;m=h[j];j++)if(m.re.test(b)){c.push(m.abbr);m.rescan&&c.push(m.rescan(g));break}e=i+g.length});e<a.length&&c.push(a.substr(e));var g="",i=["var ___v1ew = [];"+(this.text.start||"")],j=function(a,b){i.push("___v1ew.push(",'"',a.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split("\t").join("\\t"),'"'+(b||"")+");")},k=[],s,A=null,n=!1,r="",p=[],J=0,t,m=this.tokenMap;for(B=x=ca=null;(t=
+ c[J++])!==l;){if(null===A)switch(t){case m.left:case m.escapeLeft:case m.returnLeft:n=B&&1;case m.commentLeft:A=t;g.length&&j(g);g="";break;case m.escapeFull:n=B&&1;q=1;A=m.escapeLeft;g.length&&j(g);q=c[J++];g=q.content||q;q.before&&j(q.before);c.splice(J,0,m.right);break;case m.commentFull:break;case m.templateLeft:g+=m.left;break;case "<":0!==c[J].indexOf("!--")&&(B=1,n=0);g+=t;break;case ">":B=0;s="/"==g.substr(g.length-1);n||ba[p[p.length-1]]?(s?j(g.substr(0,g.length-1),',can.view.pending(),"/>"'):
+ j(g,',can.view.pending(),">"'),g=""):g+=t;s&&(p.pop(),r=p[p.length-1]);break;case "'":case '"':B&&(x&&x===t?x=null:null===x&&(x=t,ca=s));default:"<"===s&&(r=t.split(/\s/)[0],0===r.indexOf("/")&&p.pop()===r.substr(1)?r=p[p.length-1]:p.push(r)),g+=t}else switch(t){case m.right:case m.returnRight:switch(A){case m.left:s=--g.split("{").length- --g.split("}").length;1==s?(i.push("___v1ew.push(","can.view.txt(0,'"+bb(r,c,J)+"',"+da()+",this,function(){","var ___v1ew = [];",g),k.push({before:"",after:"return ___v1ew.join('')}));\n"})):
+ (e=k.length&&-1==s?k.pop():{after:";"},e.before&&i.push(e.before),i.push(g,";",e.after));break;case m.escapeLeft:case m.returnLeft:(s=--g.split("{").length- --g.split("}").length)&&k.push({before:"return ___v1ew.join('')",after:"}));"});for(var A=A===m.escapeLeft?1:0,eb={insert:"___v1ew.push(",tagName:r,status:da()},ea=0;ea<this.helpers.length;ea++){var o=this.helpers[ea];if(o.name.test(g)){g=o.fn(g,eb);o.name.source==/^>[\s|\w]\w*/.source&&(A=0);break}}"object"==typeof g?g.raw&&i.push(g.raw):i.push("___v1ew.push(",
+ "can.view.txt("+A+",'"+r+"',"+da()+",this,function(){ "+(this.text.escape||"")+"return ",g,s?"var ___v1ew = [];":"}));");q&&(q.after&&q.after.length)&&(j(q.after.length),q=null)}A=null;g="";break;case m.templateLeft:g+=m.left;break;default:g+=t}s=t}g.length&&j(g);i.push(";");g={out:"with(_VIEW) { with (_CONTEXT) {"+i.join("")+" return ___v1ew.join('')}}"};cb.call(g,"this.fn = (function(_CONTEXT,_VIEW){"+g.out+"});\r\n//@ sourceURL="+b+".js");return g}};var fa=!0;try{document.createTextNode()._=0}catch(ib){fa=
+ !1}var K={"class":"className",value:"value",textContent:"textContent"},fb={"":"span",table:"tr",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr",select:"option",optgroup:"option"},gb=/__!!__/g,ba={option:"textContent",textarea:"value"},Ea=c.each(["checked","disabled","readonly","required"],function(a){K[a]=a}),ga=function(a,b,d){K[b]?a[K[b]]=-1<c.inArray(b,Ea)?!0:d:a.setAttribute(b,d)},L=[],ha=function(a){if("string"==typeof a)return a;if(!a&&0!==a)return"";var b=a.hookup&&function(b,c){a.hookup.call(a,
+ b,c)}||"function"==typeof a&&a;return b?(L.push(b),""):""+a},hb=function(a){return"string"==typeof a||"number"==typeof a?c.esc(a):ha(a)},E={},P={},Q={},ia="ejs_"+Math.random(),ja=0,C=function(a){if(fa||3!==a.nodeType)return a[ia]?a[ia]:a[ia]=(a.nodeName?"element_":"obj_")+ ++ja;for(var b in P)if(P[b]===a)return b;P["text_"+ ++ja]=a;return"text_"+ja},Fa=function(a,b){var d=E[C(a)];if(d){var e=c.inArray(b,d);0<=e&&d.splice(e,1);d.length||delete E[C(a)]}},Ga=function(a,b){var c=E[C(a)];c||(c=E[C(a)]=
+ []);c.push(b)};c.extend(c.view,{pending:function(){var a=L.slice(0);lastHookups=a;L=[];return c.view.hook(function(b){c.each(a,function(a){a(b)})})},registerNode:function(a){var b=C(a);Q[b]=a;c.each(a,function(a){Ga(a,b)})},unregisterNode:function(a){var b=C(a);c.each(a,function(a){Fa(a,b)});delete Q[b]},txt:function(a,b,d,e,f){var h=c.compute.binder(f,e,function(a,b){o(a,b)});if(!h.isListening)return(a||0!==d?hb:ha)(h.value);var g,i,j=function(){h.teardown();i&&c.view.unregisterNode(i)},k=function(a){c.bind.call(a,
+ "destroyed",j);g=a},n=function(a){a||(j(),c.unbind.call(g,"destroyed",j))},e=fb[b]||"span",o,q=ba[b];if(0===d&&!q)return"<"+e+c.view.hook(a?function(a,b){o=function(a){d.nodeValue=""+a;n(d.parentNode)};var c=b&&11===a.parentNode.nodeType?b:a.parentNode,d=document.createTextNode(h.value);c.insertBefore(d,a);c.removeChild(a);k(c)}:function(a,b){o=function(a){d[0].parentNode&&e(a);n(d[0].parentNode)};var b=b&&11===a.parentNode.nodeType?b:a.parentNode,d,e=function(e){var e=c.view.frag(e,b),f=c.makeArray(e.childNodes),
+ g=d?d[d.length-1]:a;g.nextSibling?g.parentNode.insertBefore(e,g.nextSibling):g.parentNode.appendChild(e);d?(c.remove(c.$(d)),c.view.replace(d,f)):(c.remove(c.$(a)),i=d=f,c.view.registerNode(d))};e(h.value,[a]);k(b)})+">@@!!@@</"+e+">";if(1===d){var r=h.value.replace(/['"]/g,"").split("=")[0];L.push(function(a){o=function(b){var b=(b||"").replace(/['"]/g,"").split("="),d=b[0];if(d!=r&&r){var e=r;-1<c.inArray(e,Ea)?a[e]=!1:a.removeAttribute(e)}d&&(ga(a,d,b[1]),r=d)};k(a)});return h.value}var p=0===
+ d?q:d;(0===d?lastHookups:L).push(function(a){o=function(){ga(a,p,g.render(),q)};var b=c.$(a),d;(d=c.data(b,"hooks"))||c.data(b,"hooks",d={});var e=(K[p]?a[K[p]]:a.getAttribute(p))||"",b=e.split("__!!__"),f=[],g;f.push(b.shift(),b.join("__!!__"));d[p]?d[p].bindings.push(h):d[p]={render:function(){var a=0;return e.replace(gb,function(){return ha(g.bindings[a++].value)})},bindings:[h],batchNum:l};g=d[p];f.splice(1,0,h.value);ga(a,p,f.join(""),q);k(a)});return"__!!__"},replace:function(a,b){a=c.makeArray(a);
+ c.each(a,function(d){c.each(c.makeArray(E[C(d)]),function(e){var f=Q[e],h=c.inArray(d,f),g=c.inArray(a[a.length-1],f);if(0<=h&&0<=g){for(var i=h;i<=g;i++)Fa(f[i],e);f.splice.apply(f,[h,g-h+1].concat(b));c.each(b,function(a){Ga(a,e)})}else c.view.unregisterNode(f)})})},canExpando:fa,textNodeMap:P,nodeMap:E,nodeListMap:Q});var o=c.extend,w=function(a){if(this.constructor!=w){var b=new w(a);return function(a,c){return b.render(a,c)}}"function"==typeof a?this.template={fn:a}:(o(this,a),this.template=
+ this.scanner.scan(this.text,this.name))};c.EJS=w;w.prototype.render=function(a,b){a=a||{};return this.template.fn.call(a,a,new w.Helpers(a,b||{}))};o(w.prototype,{scanner:new c.view.Scanner({tokens:[["templateLeft","<%%"],["templateRight","%>"],["returnLeft","<%=="],["escapeLeft","<%="],["commentLeft","<%#"],["left","<%"],["right","%>"],["returnRight","%>"]]})});w.Helpers=function(a,b){this._data=a;this._extras=b;o(this,b)};w.Helpers.prototype={list:function(a,b){c.each(a,function(c,e){b(c,e,a)})}};
+ c.view.register({suffix:"ejs",script:function(a,b){return"can.EJS(function(_CONTEXT,_VIEW) { "+(new w({text:b,name:a})).template.out+" })"},renderer:function(a,b){return w({text:b,name:a})}})})(this,jQuery);
View
0  ...ure-examples/canjs/js/lib/can-localstorage.min.js → ...ure-examples/canjs/js/lib/can.localstorage.min.js
File renamed without changes
View
10 labs/architecture-examples/canjs/js/lib/can.mustache.min.js
@@ -0,0 +1,10 @@
+(function(i,m,l){i.view.ext=".mustache";var n=function(a){return i.isFunction(a.attr)&&a.constructor&&!!a.constructor.canMakeObserve},o=function(a){return a&&a.splice&&"number"==typeof a.length},h=function(a){if(this.constructor!=h){var c=new h(a);return function(a){return c.render(a)}}"function"==typeof a?this.template={fn:a}:(i.extend(this,a),this.template=this.scanner.scan(this.text,this.name))};i.Mustache=m.Mustache=h;h.prototype.render=function(a){a=a||{};return this.template.fn.call(a,a,{_data:a})};
+i.extend(h.prototype,{scanner:new i.view.Scanner({text:{start:"var ___c0nt3xt = []; ___c0nt3xt.___st4ck = true;var ___st4ck = function(context, self) {var s;if (arguments.length == 1 && context) {s = !context.___st4ck ? [context] : context;} else {s = context && context.___st4ck ? context.concat([self]) : ___st4ck(context).concat([self]);}return (s.___st4ck = true) && s;};"},tokens:[["returnLeft","{{{","{{[{&]"],["commentFull","{{!}}","^[\\s\\t]*{{!.+?}}\\n"],["commentLeft","{{!","(\\n[\\s\\t]*{{!|{{!)"],
+["escapeFull","{{}}","(^[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}\\n|\\n[\\s\\t]*{{[#/^][^}]+?}}$)",function(a){return{before:/^\n.+?\n$/.test(a)?"\n":"",content:a.match(/\{\{(.+?)\}\}/)[1]||""}}],["escapeLeft","{{"],["returnRight","}}}"],["right","}}"]],helpers:[{name:/^>[\s|\w]\w*/,fn:function(a){return"can.view.render('"+i.trim(a.replace(/^>\s?/,""))+"', ___st4ck(___c0nt3xt,this).pop())"}},{name:/^\s?data\s/,fn:function(a){return"can.proxy(function(__){can.data(can.$(__),'"+a.replace(/(^\s?data\s)|(["'])/g,
+"")+"', this.pop()); }, ___st4ck(___c0nt3xt,this))"}},{name:/^.*$/,fn:function(a,c){var b=!1,d=[],a=i.trim(a);if(a.length&&(b=a.match(/^([#^/]|else$)/))){b=b[0];switch(b){case "#":case "^":d.push(c.insert+"can.view.txt(0,'"+c.tagName+"',"+c.status+",this,function(){ return ");break;case "/":return{raw:'return ___v1ew.join("");}}])}));'}}a=a.substring(1)}if("else"!=b){var j=[],f=0,g=!1,h,e;(i.trim(a)+" ").replace(/((([^\s]+?=)?('.*?'|".*?"))|.*?)\s/g,function(a,b){j.push(b)});for(d.push("can.Mustache.txt(___st4ck(___c0nt3xt,this),"+
+(b?'"'+b+'"':"null")+",");h=j[f];f++)f&&d.push(","),f&&(e=h.match(/^(('.*?'|".*?"|[0-9.]+|true|false)|((.+?)=(('.*?'|".*?"|[0-9.]+|true|false)|(.+))))$/))?e[2]?d.push(e[0]):(g||(g=!0,d.push("{___h4sh:{")),d.push(e[4],":",e[6]?e[6]:'can.Mustache.get("'+e[5].replace(/"/g,'\\"')+'",___st4ck(___c0nt3xt,this))'),f==j.length-1&&d.push("}}")):d.push('can.Mustache.get("'+h.replace(/"/g,'\\"')+'",___st4ck(___c0nt3xt,this)'+(0==f&&1<j.length?",true":"")+")")}b&&"else"!=b&&d.push(",[{_:function(){");switch(b){case "#":d.push('return ___v1ew.join("");}},{fn:function(___c0nt3xt){var ___v1ew = [];');
+break;case "else":case "^":d.push('return ___v1ew.join("");}},{inverse:function(___c0nt3xt){var ___v1ew = [];');break;default:d.push(");")}d=d.join("");return b?{raw:d}:d}}]})});for(var m=i.view.Scanner.prototype.helpers,p=0;p<m.length;p++)h.prototype.scanner.helpers.unshift(m[p]);h.registerHelper=function(a,c){this._helpers.push({name:a,fn:c})};h.getHelper=function(a){for(var c=0,b;b=this._helpers[c];c++)if(b.name==a)return b;return null};h.txt=function(a,c,b){var d=Array.prototype.slice.call(arguments,
+3),j=i.extend.apply(i,[{fn:function(){},inverse:function(){}}].concat(c?d.pop():[])),f=d.length?d:[b],g=!0,k=[],e;if(c)for(e=0;e<f.length;e++)g=o(f[e])?"#"==c?g&&!!f[e].length:"^"==c?g&&!f[e].length:g:"#"==c?g&&!!f[e]:"^"==c?g&&!f[e]:g;if(f=h.getHelper(b)||i.isFunction(b)&&{fn:b}){a=a.___st4ck&&a[a.length-1]||a;j={fn:i.proxy(j.fn,a),inverse:i.proxy(j.inverse,a)};if((g=d[d.length-1])&&g.___h4sh)j.hash=d.pop().___h4sh;d.push(j);return f.fn.apply(a,d)||""}if(g)switch(c){case "#":if(o(b)){for(e=0;e<b.length;e++)k.push(j.fn.call(b[e]||
+{},a)||"");return k.join("")}return j.fn.call(b||{},a)||"";case "^":return j.inverse.call(b||{},a)||"";default:return""+(b!==l?b:"")}return""};h.get=function(a,c,b){var d=a.split("."),j=c[c.length-1],f=c[c.length-2],g,k,e;if(/^\.|this$/.test(a)){if(/^object|undefined$/.test(typeof f)){for(;b=c.pop();)if("undefined"!==typeof b)return b;return""}return f||""}if(!b)for(f=c.length-1;0<=f;f--){b=c[f];if(b!==l)for(e=0;e<d.length;e++)if("undefined"!=typeof b[d[e]])g=b,b=b[k=d[e]];else{n(b)?(g=b,k=d[e]):
+g=b=l;break}if(b!==l){if(i.isFunction(g[k]))return g[k]();if(n(g))return g.attr(k);n(b)&&o(b)&&b.attr("length");return b}}return j!==l&&i.isFunction(j[a])?j[a]:h.getHelper(a)?a:""};h._helpers=[{name:"if",fn:function(a,c){return a?c.fn(this):c.inverse(this)}},{name:"unless",fn:function(a,c){if(!a)return c.fn(this)}},{name:"each",fn:function(a,c){if(a&&a.length){for(var b=[],d=0;d<a.length;d++)b.push(c.fn(a[d]));return b.join("")}}},{name:"with",fn:function(a,c){if(a)return c.fn(a)}}];i.view.register({suffix:"mustache",
+contentType:"x-mustache-template",script:function(a,c){return"can.Mustache(function(_CONTEXT,_VIEW) { "+(new h({text:c,name:a})).template.out+" })"},renderer:function(a,c){return h({text:c,name:a})}})})(can,this);
View
3  labs/architecture-examples/canjs/js/models/todo.js
@@ -9,7 +9,8 @@
}, {
// Returns if this instance matches a given filter
// (currently `active` and `complete`)
- matches: function(filter) {
+ matches : function() {
+ var filter = can.route.attr('filter');
return !filter || (filter === 'active' && !this.attr('complete'))
|| (filter === 'completed' && this.attr('complete'));
}
View
34 labs/architecture-examples/canjs/js/todos/todos.js
@@ -4,14 +4,15 @@
var ENTER_KEY = 13;
var Todos = can.Control({
-
+ // Default options
+ defaults : {
+ view : 'views/todos.ejs'
+ }
+ }, {
// Initialize the Todos list
init: function() {
// Render the Todos
- this.element.append(can.view('todos.ejs', this.options));
-
- // Clear the new todo field
- $('#new-todo').val('').focus();
+ this.element.append(can.view(this.options.view, this.options));
},
// Listen for when a new Todo has been entered
@@ -22,8 +23,8 @@
text : value,
complete : false
}).save(function () {
- el.val('');
- });
+ el.val('');
+ });
}
},
@@ -31,7 +32,14 @@
'{Models.Todo} created': function(list, e, item) {
this.options.todos.push(item);
// Reset the filter so that you always see your new todo
- this.options.state.removeAttr('filter');
+ this.options.state.attr('filter', '');
+ },
+
+ // Listener for when the route changes
+ '{state} change' : function() {
+ // Remove the `selected` class from the old link and add it to the link for the current location hash
+ this.element.find('#filters').find('a').removeClass('selected')
+ .end().find('[href="' + window.location.hash + '"]').addClass('selected');
},
// Listen for editing a Todo
@@ -46,6 +54,9 @@
var value = can.trim(el.val()),
todo = el.closest('.todo').data('todo');
+ // If we don't have a todo we don't need to do anything
+ if(!todo) return;
+
if (value === '') {
todo.destroy();
} else {
@@ -62,9 +73,8 @@
this.updateTodo(el);
}
},
- '.todo .edit focusout': function(el) {
- this.updateTodo(el);
- },
+
+ '.todo .edit focusout' : "updateTodo",
// Listen for the toggled completion of a Todo
'.todo .toggle click': function(el) {
@@ -93,8 +103,6 @@
todo.destroy();
}
}
- // Reset the filter
- this.options.state.removeAttr('filter');
}
});
View
40 labs/architecture-examples/canjs/readme.md
@@ -0,0 +1,40 @@
+# CanJS
+
+CanJS is a client-side, JavaScript framework that makes building rich web applications easy. It provides:
+
+ - *can.Model* - for connecting to RESTful JSON interfaces
+ - *can.View* - for template loading and caching
+ - *can.Observe* - for key-value binding
+ - *can.EJS* - live binding templates
+ - *can.Control* - declarative event bindings
+ - *can.route* - routing support
+
+And works with jQuery, Zepto, YUI, Dojo and Mootools.
+
+## CanJS and JavaScriptMVC
+
+*CanJS* is the extracted, more modern and more library-like MVC parts of [JavaScriptMVC](http://javascriptmvc.com)
+(formerly known as *jQueryMX*).
+
+*JavaScriptMVC 3.3* uses CanJS for the MVC structure so this TodoMVC example **applies to JavaScriptMVC** as well.
+Additionally JavaScriptMVC contains:
+
+- [CanJS](http://canjs.us) - For the MVC parts
+- [jQuery++](http://jquerypp.com) - jQuery's missing utils and special events
+- [StealJS](http://javascriptmvc.com/docs.html#!stealjs) - A JavaScript package manager
+- [DocumentJS](http://javascriptmvc.com/docs.html#!DocumentJS) - A documentation engine
+- [FuncUnit](http://funcunit.com) - jQuery style functional unit testing
+
+## View engines
+
+CanJS supports both live binding [EJS](http://canjs.us/#can_ejs) and [Mustache/Handlebars](http://canjs.us/#can_mustache)
+templates. By default the Mustache view will be used but an EJS example is available as well.
+You can easily change it by modifying the `view` option in the `js/app.js` file:
+
+ Models.Todo.findAll({}, function(todos) {
+ new Todos('#todoapp', {
+ todos: todos,
+ state : can.route,
+ view : 'views/todos.ejs'
+ });
+ });
View
49 labs/architecture-examples/canjs/todos.ejs
@@ -1,49 +0,0 @@
-<header id="header">
- <h1>todos</h1>
- <input id="new-todo" placeholder="What needs to be done?" autofocus>
-</header>
-<section id="main" class="<%= todos.attr("length") > 0 ? 'show' : '' %>">
-<input id="toggle-all" type="checkbox" <%= todos.allComplete() ? 'checked' : '' %>>
-<label for="toggle-all">Mark all as complete</label>
-<ul id="todo-list">
- <% todos.each(function( todo ) { %>
- <li class="todo
- <%= todo.matches(state.attr('filter')) ? '' : 'hidden' %>
- <%= todo.attr('complete') ? 'completed' : '' %>
- <%= todo.attr('editing') ? 'editing' : '' %>"
- <%= (el)-> el.data('todo', todo) %>>
- <div class="view">
- <input class="toggle" type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
- <label><%= todo.attr('text') %></label>
- <button class="destroy"></button>
- </div>
- <input class="edit" value="<%= todo.attr('text') %>">
- </li>
- <% }) %>
-</ul>
-</section>
-<footer id="footer" class="<%= todos.attr('length') === 0 ? 'hidden' : '' %>">
- <span id="todo-count">
- <strong><%= todos.remaining() %></strong>
- item<%= todos.remaining() == 1 ? '' : 's' %> left
- </span>
- <ul id="filters">
- <li>
- <a class="<%= !state.attr('filter') ? 'selected' : '' %>" href="#!">All</a>
- </li>
- <li>
- <a class="<%= state.attr('filter') === 'active' ? 'selected' : '' %>" href="#!active">
- Active
- </a>
- </li>
- <li>
- <a class="<%= state.attr('filter') === 'completed' ? 'selected' : '' %>" href="#!completed">
- Completed
- </a>
- </li>
- </ul>
- <button id="clear-completed" class="<%= todos.completed() === 0 ? 'hidden' : '' %>">
- Clear <%= todos.completed() %>
- completed item<%= todos.completed() === 1 ? '' : 's' %>
- </button>
-</footer>
View
40 labs/architecture-examples/canjs/views/todos.ejs
@@ -0,0 +1,40 @@
+<header id="header">
+ <h1>todos</h1>
+ <input id="new-todo" placeholder="What needs to be done?" autofocus>
+</header>
+
+<section id="main" class="<%= todos.attr("length") === 0 ? "hidden" : "" %>">
+ <input id="toggle-all" type="checkbox" <%= todos.allComplete() ? "checked" : "" %>>
+ <label for="toggle-all">Mark all as complete</label>
+ <ul id="todo-list">
+ <% todos.each(function( todo ) { %>
+ <li class="todo
+ <%= todo.matches(state.attr('filter')) ? '' : 'hidden' %>
+ <%= todo.attr('complete') ? 'completed' : '' %>
+ <%= todo.attr('editing') ? 'editing' : '' %>"
+ <%= (el)-> el.data('todo', todo) %>>
+ <div class="view">
+ <input class="toggle" type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
+ <label><%= todo.attr('text') %></label>
+ <button class="destroy"></button>
+ </div>
+ <input class="edit" value="<%= todo.attr('text') %>">
+ </li>
+ <% }) %>
+ </ul>
+</section>
+<footer id="footer" class="<%= todos.attr('length') === 0 ? 'hidden' : '' %>">
+ <span id="todo-count">
+ <strong><%= todos.remaining() %></strong>
+ item<%= todos.remaining() == 1 ? "" : "s" %> 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="<%= todos.completed() === 0 ? 'hidden' : '' %>">
+ Clear <%= todos.completed() %>
+ completed item<%= todos.completed() == 1 ? "" : "s" %>
+ </button>
+</footer>
View
41 labs/architecture-examples/canjs/views/todos.mustache
@@ -0,0 +1,41 @@
+<header id="header">
+ <h1>todos</h1>
+ <input id="new-todo" {{ (el) -> el.val('').focus() }} placeholder="What needs to be done?" autofocus="">
+</header>
+
+<section id="main" class="{{^todos}}hidden{{/todos}}">
+ <input id="toggle-all" type="checkbox" {{#todos.allComplete}}checked="checked"{{/todos.allComplete}}>
+ <label for="toggle-all" >Mark all as complete</label>
+ <ul id="todo-list">
+ {{#todos}}
+ <li class="todo {{^matches}}hidden{{/matches}} {{#complete}}completed{{/complete}} {{#editing}}editing{{/editing}}" {{data 'todo'}}>
+ <div class="view">
+ <input class="toggle" type="checkbox" {{#complete}}checked="checked"{{/complete}}>
+ <label>{{text}}</label>
+ <button class="destroy"></button>
+ </div>
+ <input class="edit" type="text" value="{{text}}">
+ </li>
+ {{/todos}}
+ </ul>
+</section>
+
+<footer id="footer" class="{{^todos}}hidden{{/todos}}">
+ <span id="todo-count">
+ <strong>{{todos.remaining}}</strong> {{plural "item" todos.remaining}} 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>
+ <a href="#!" id="clear-completed" class="{{^todos.completed}}hidden{{/todos.completed}}">
+ Clear {{todos.completed}} completed {{plural "item" todos.completed}}
+ </a>
+</footer>
Something went wrong with that request. Please try again.