Skip to content

Commit

Permalink
Applied feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed May 21, 2016
1 parent c5a0e53 commit 24e4a1f
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 41 deletions.
12 changes: 6 additions & 6 deletions examples/ember-cli/todomvc/app/components/todo-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ export default Ember.Component.extend({
Ember.run.scheduleOnce('afterRender', this, 'focusInput');
},

doneEditing(e) {
let newTitle = e.target.value.trim();
if (Ember.isBlank(newTitle)) {
doneEditing(todoTitle) {
if (!this.get('editing')) { return; }
if (Ember.isBlank(todoTitle)) {
this.send('removeTodo');
} else if (this.get('editing')) {
this.set('todo.title', newTitle);
} else {
this.set('todo.title', todoTitle.trim());
this.set('editing', false);
this.get('onEndEdit')();
}
},

handleKeydown(e) {
if (e.keyCode === 13) {
this.send('doneEditing', e);
e.target.blur();
} else if (e.keyCode === 27) {
this.set('editing', false);
}
Expand Down
7 changes: 7 additions & 0 deletions examples/ember-cli/todomvc/app/helpers/gt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export function gt([n1, n2]/*, hash*/) {
return n1 > n2;
}

export default Ember.Helper.helper(gt);
7 changes: 4 additions & 3 deletions examples/ember-cli/todomvc/app/helpers/pluralize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Ember from 'ember';
import { pluralize } from 'ember-inflector';

export function pluralize([singular, count]/*, hash*/) {
return count === 1 ? singular : singular + 's';
export function pluralizeHelper([singular, count]/*, hash*/) {
return count === 1 ? singular : pluralize(singular);
}

export default Ember.Helper.helper(pluralize);
export default Ember.Helper.helper(pluralizeHelper);
15 changes: 7 additions & 8 deletions examples/ember-cli/todomvc/app/services/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@ import Ember from 'ember';

export default Ember.Service.extend({
lastId: 0,
data: null,
findAll() {
if (this.data) {
return this.data;
} else {
return this.data = JSON.parse(window.localStorage.getItem('todos') || '[]');
}
return this.get('data') ||
this.set('data', JSON.parse(window.localStorage.getItem('todos') || '[]'));
},

add(attrs) {
let todo = this.data.pushObject(Object.assign({ id: this.incrementProperty('lastId') }, attrs));
let todo = Object.assign({ id: this.incrementProperty('lastId') }, attrs);
this.get('data').pushObject(todo);
this.persist();
return todo;
},

delete(todo) {
this.data.removeObject(todo);
this.get('data').removeObject(todo);
this.persist();
},

persist() {
window.localStorage.setItem('todos', JSON.stringify(this.data));
window.localStorage.setItem('todos', JSON.stringify(this.get('data')));
}
});
2 changes: 1 addition & 1 deletion examples/ember-cli/todomvc/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<input type="text" id="new-todo" onkeydown={{action 'createTodo'}} placeholder="What needs to be done?" autofocus>
</header>
{{outlet}}
{{#if model.length}}
{{#if (gt model.length 0)}}
<footer id="footer">
<span id="todo-count"><strong>{{remaining.length}}</strong> {{pluralize 'item' remaining.length}} left</span>
<ul id="filters">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<label ondblclick={{action 'startEditing'}}>{{todo.title}}</label>
<button onclick={{action 'removeTodo'}} class="destroy"></button>
</div>
<input type="text" class="edit" value={{todo.title}} onblur={{action 'doneEditing'}} onkeydown={{action 'handleKeydown'}} autofocus>
<input type="text" class="edit" value={{todo.title}} onblur={{action 'doneEditing' value='target.value'}} onkeydown={{action 'handleKeydown'}} autofocus>

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/ember-cli/todomvc/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/examples/ember-cli/index.html" />

<meta name="todomvc/config/environment" content="%7B%22modulePrefix%22%3A%22todomvc%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3Anull%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22todomvc%22%2C%22version%22%3A%220.0.0+adaa9f98%22%7D%2C%22exportApplicationGlobal%22%3Afalse%7D" />
<meta name="todomvc/config/environment" content="%7B%22modulePrefix%22%3A%22todomvc%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3Anull%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22todomvc%22%2C%22version%22%3A%220.0.0+0a74b95b%22%7D%2C%22exportApplicationGlobal%22%3Afalse%7D" />

<link rel="stylesheet" href="assets/vendor-7b5c98520910afa58d74e05ec86cd873.css">
<link rel="stylesheet" href="assets/todomvc-d41d8cd98f00b204e9800998ecf8427e.css">
Expand All @@ -18,8 +18,8 @@
<body>


<script src="assets/vendor-4952549ec620c2cbeef706e218c82007.js"></script>
<script src="assets/todomvc-0dc9e3542835f34b2361ed2c343159ea.js"></script>
<script src="assets/vendor-cd836c7107e80c2c62ee7c8ce81fe8b9.js"></script>
<script src="assets/todomvc-0b9922e4e9938d7c0ab260b3e0cbeb9a.js"></script>


</body>
Expand Down
1 change: 1 addition & 0 deletions examples/ember-cli/todomvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-export-application-global": "^1.0.5",
"ember-inflector": "1.9.4",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.1"
Expand Down

0 comments on commit 24e4a1f

Please sign in to comment.