Commit ad8a026c authored by Pascal Hartig's avatar Pascal Hartig

Ember: jshint style

parent 55065f19
/*global Ember*/
window.Todos = Ember.Application.create(); window.Todos = Ember.Application.create();
/*global Todos Ember*/
'use strict';
Todos.TodoController = Ember.ObjectController.extend({ Todos.TodoController = Ember.ObjectController.extend({
isEditing: false, isEditing: false,
editTodo: function() { editTodo: function () {
this.set('isEditing', true); this.set('isEditing', true);
}, },
removeTodo: function() { removeTodo: function () {
var todo = this.get('model'); var todo = this.get('model');
todo.deleteRecord(); todo.deleteRecord();
......
/*global Todos Ember*/
'use strict';
Todos.TodosController = Ember.ArrayController.extend({ Todos.TodosController = Ember.ArrayController.extend({
createTodo: function() { createTodo: function () {
// Get the todo title set by the "New Todo" text field // Get the todo title set by the "New Todo" text field
var title = this.get('newTitle'); var title = this.get('newTitle');
if (!title.trim()) { return; } if (!title.trim()) { return; }
...@@ -17,38 +20,38 @@ Todos.TodosController = Ember.ArrayController.extend({ ...@@ -17,38 +20,38 @@ Todos.TodosController = Ember.ArrayController.extend({
this.get('store').commit(); this.get('store').commit();
}, },
clearCompleted: function() { clearCompleted: function () {
var completed = this.filterProperty('isCompleted', true); var completed = this.filterProperty('isCompleted', true);
completed.invoke('deleteRecord'); completed.invoke('deleteRecord');
this.get('store').commit(); this.get('store').commit();
}, },
remaining: function() { remaining: function () {
return this.filterProperty( 'isCompleted', false ).get( 'length' ); return this.filterProperty('isCompleted', false).get('length');
}.property( '@each.isCompleted' ), }.property('@each.isCompleted'),
remainingFormatted: function() { remainingFormatted: function () {
var remaining = this.get('remaining'); var remaining = this.get('remaining');
var plural = remaining === 1 ? 'item' : 'items'; var plural = remaining === 1 ? 'item' : 'items';
return '<strong>%@</strong> %@ left'.fmt(remaining, plural); return '<strong>%@</strong> %@ left'.fmt(remaining, plural);
}.property('remaining'), }.property('remaining'),
completed: function() { completed: function () {
return this.filterProperty('isCompleted', true).get('length'); return this.filterProperty('isCompleted', true).get('length');
}.property('@each.isCompleted'), }.property('@each.isCompleted'),
hasCompleted: function() { hasCompleted: function () {
return this.get('completed') > 0; return this.get('completed') > 0;
}.property('completed'), }.property('completed'),
allAreDone: function( key, value ) { allAreDone: function (key, value) {
if ( value !== undefined ) { if (value !== undefined) {
this.setEach( 'isCompleted', value ); this.setEach('isCompleted', value);
return value; return value;
} else { } else {
return !!this.get( 'length' ) && return !!this.get('length') &&
this.everyProperty( 'isCompleted', true ); this.everyProperty('isCompleted', true);
} }
}.property( '@each.isCompleted' ) }.property('@each.isCompleted')
}); });
/*global Todos DS*/
'use strict';
Todos.Store = DS.Store.extend({ Todos.Store = DS.Store.extend({
revision: 11, revision: 11,
adapter: 'Todos.LSAdapter' adapter: 'Todos.LSAdapter'
......
/*global Todos DS Ember*/
'use strict';
Todos.Todo = DS.Model.extend({ Todos.Todo = DS.Model.extend({
title: DS.attr('string'), title: DS.attr('string'),
isCompleted: DS.attr('boolean'), isCompleted: DS.attr('boolean'),
todoDidChange: function() { todoDidChange: function () {
Ember.run.once(this, function() { Ember.run.once(this, function () {
this.get('store').commit(); this.get('store').commit();
}); });
}.observes('isCompleted', 'title') }.observes('isCompleted', 'title')
......
Todos.Router.map(function() { /*global Todos Ember*/
this.resource('todos', { path: '/' }, function() { 'use strict';
Todos.Router.map(function () {
this.resource('todos', { path: '/' }, function () {
this.route('active'); this.route('active');
this.route('completed'); this.route('completed');
}); });
}); });
Todos.TodosRoute = Ember.Route.extend({ Todos.TodosRoute = Ember.Route.extend({
model: function() { model: function () {
return Todos.Todo.find(); return Todos.Todo.find();
} }
}); });
Todos.TodosIndexRoute = Ember.Route.extend({ Todos.TodosIndexRoute = Ember.Route.extend({
setupController: function() { setupController: function () {
var todos = Todos.Todo.find(); var todos = Todos.Todo.find();
this.controllerFor('todos').set('filteredTodos', todos); this.controllerFor('todos').set('filteredTodos', todos);
} }
}); });
Todos.TodosActiveRoute = Ember.Route.extend({ Todos.TodosActiveRoute = Ember.Route.extend({
setupController: function() { setupController: function () {
var todos = Todos.Todo.filter(function(todo) { var todos = Todos.Todo.filter(function (todo) {
if (!todo.get('isCompleted')) { return true; } if (!todo.get('isCompleted')) { return true; }
}); });
...@@ -29,8 +32,8 @@ Todos.TodosActiveRoute = Ember.Route.extend({ ...@@ -29,8 +32,8 @@ Todos.TodosActiveRoute = Ember.Route.extend({
}); });
Todos.TodosCompletedRoute = Ember.Route.extend({ Todos.TodosCompletedRoute = Ember.Route.extend({
setupController: function() { setupController: function () {
var todos = Todos.Todo.filter(function(todo) { var todos = Todos.Todo.filter(function (todo) {
if (todo.get('isCompleted')) { return true; } if (todo.get('isCompleted')) { return true; }
}); });
......
/*global Todos Ember*/
'use strict';
Todos.EditTodoView = Ember.TextField.extend({ Todos.EditTodoView = Ember.TextField.extend({
classNames: ['edit'], classNames: ['edit'],
valueBinding: 'todo.title', valueBinding: 'todo.title',
change: function() { change: function () {
var value = this.get('value'); var value = this.get('value');
if (Ember.isEmpty(value)) { if (Ember.isEmpty(value)) {
...@@ -11,15 +14,15 @@ Todos.EditTodoView = Ember.TextField.extend({ ...@@ -11,15 +14,15 @@ Todos.EditTodoView = Ember.TextField.extend({
} }
}, },
focusOut: function() { focusOut: function () {
this.set('controller.isEditing', false); this.set('controller.isEditing', false);
}, },
insertNewline: function() { insertNewline: function () {
this.set('controller.isEditing', false); this.set('controller.isEditing', false);
}, },
didInsertElement: function() { didInsertElement: function () {
this.$().focus(); this.$().focus();
} }
}); });
/*global Todos Ember*/
'use strict';
Todos.TodoView = Ember.View.extend({ Todos.TodoView = Ember.View.extend({
tagName: 'li', tagName: 'li',
classNameBindings: ['todo.isCompleted:completed', 'isEditing:editing'], classNameBindings: ['todo.isCompleted:completed', 'isEditing:editing'],
doubleClick: function(event) { doubleClick: function () {
this.set('isEditing', true); this.set('isEditing', true);
} }
}); });
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