Commit af1fbbe1 authored by Sindre Sorhus's avatar Sindre Sorhus

CanJS + RequireJS: code style and changelog

parent 11f1ca56
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
- Updates since 1.2: - Updates since 1.2:
- CanJS 2.0 - CanJS 2.0
- CanJS 2.0 + RequireJS
## 1.2 - 2013-08-06 ## 1.2 - 2013-08-06
......
{ {
"name": "todomvc-canjs_require", "name": "todomvc-canjs-require",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"todomvc-common": "~0.1.6", "todomvc-common": "~0.1.6",
"requirejs": "~2.1.6", "requirejs": "~2.1.6",
"canjs": "~2.0.0", "canjs": "~2.0.0",
"canjs-localstorage": "~0.2.0", "canjs-localstorage": "~0.2.0",
"jquery": "~1.10.0" "jquery": "~1.10.0"
} }
} }
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
<link rel="stylesheet" href="bower_components/todomvc-common/base.css"> <link rel="stylesheet" href="bower_components/todomvc-common/base.css">
</head> </head>
<body> <body>
<section id="todoapp"> <section id="todoapp"></section>
</section>
<footer id="info"> <footer id="info">
<p>Double-click to edit a todo</p> <p>Double-click to edit a todo</p>
<p>Written by <a href="http://bitovi.com">Bitovi</a></p> <p>Written by <a href="http://bitovi.com">Bitovi</a></p>
...@@ -37,7 +36,6 @@ ...@@ -37,7 +36,6 @@
{{/each}} {{/each}}
</ul> </ul>
</section> </section>
<footer id="footer" class="{{^if todos.length}}hidden{{/if}}"> <footer id="footer" class="{{^if todos.length}}hidden{{/if}}">
<span id="todo-count"> <span id="todo-count">
<strong>{{todos.remaining}}</strong> {{plural "item" todos.remaining}} left <strong>{{todos.remaining}}</strong> {{plural "item" todos.remaining}} left
...@@ -52,7 +50,7 @@ ...@@ -52,7 +50,7 @@
</button> </button>
</footer> </footer>
</todo-app> </todo-app>
</script> </script>
<script src="bower_components/todomvc-common/base.js"></script> <script src="bower_components/todomvc-common/base.js"></script>
<script data-main="js/app" src="bower_components/requirejs/require.js"></script> <script data-main="js/app" src="bower_components/requirejs/require.js"></script>
</body> </body>
......
/* global define */ /* global define */
define(['can/util/library', 'can/component', '../models/Todo', 'can/route'], function (can, Component, Todo, route) { define([
'can/util/library',
'can/component',
'../models/Todo',
'can/route'
], function (can, Component, Todo, route) {
'use strict'; 'use strict';
var ESCAPE_KEY = 27; var ESCAPE_KEY = 27;
return Component.extend({ return Component.extend({
// Create this component on a tag like `<todo-app>`. // Create this component on a tag like `<todo-app>`
tag: 'todo-app', tag: 'todo-app',
scope: { scope: {
// Store the Todo model in the scope // Store the Todo model in the scope
...@@ -17,8 +22,8 @@ define(['can/util/library', 'can/component', '../models/Todo', 'can/route'], fun ...@@ -17,8 +22,8 @@ define(['can/util/library', 'can/component', '../models/Todo', 'can/route'], fun
todo.attr('editing', true); todo.attr('editing', true);
el.parents('.todo').find('.edit').focus(); el.parents('.todo').find('.edit').focus();
}, },
cancelEditing: function (todo, el, ev) { cancelEditing: function (todo, el, e) {
if (ev.which === ESCAPE_KEY) { if (e.which === ESCAPE_KEY) {
el.val(todo.attr('text')); el.val(todo.attr('text'));
todo.attr('editing', false); todo.attr('editing', false);
} }
......
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