Commit 193752e8 authored by Peter Müller's avatar Peter Müller Committed by Sindre Sorhus

Close GH-847: Ember: Prevent global leakage of 'use strict' directive.

parent 64af0c87
/*global Ember*/ /*global Ember*/
/*global DS*/ /*global DS*/
'use strict'; (function () {
'use strict';
DS.LSAdapter = DS.Adapter.extend(Ember.Evented, { DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
init: function () { init: function () {
this._loadData(); this._loadData();
...@@ -125,4 +126,5 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, { ...@@ -125,4 +126,5 @@ DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
var data = record.serialize({includeId: true}); var data = record.serialize({includeId: true});
namespace.records[data.id] = data; namespace.records[data.id] = data;
} }
}); });
})();
/*global Todos, Ember */ /*global Todos, Ember */
'use strict'; (function () {
'use strict';
Todos.TodoController = Ember.ObjectController.extend({ Todos.TodoController = Ember.ObjectController.extend({
isEditing: false, isEditing: false,
// We use the bufferedTitle to store the original value of // We use the bufferedTitle to store the original value of
...@@ -55,4 +55,5 @@ Todos.TodoController = Ember.ObjectController.extend({ ...@@ -55,4 +55,5 @@ Todos.TodoController = Ember.ObjectController.extend({
saveWhenCompleted: function () { saveWhenCompleted: function () {
this.get('model').save(); this.get('model').save();
}.observes('isCompleted') }.observes('isCompleted')
}); });
})();
/*global Todos, Ember */ /*global Todos, Ember */
'use strict'; (function () {
'use strict';
Todos.TodosController = Ember.ArrayController.extend({ Todos.TodosController = Ember.ArrayController.extend({
actions: { actions: {
createTodo: function () { createTodo: function () {
var title, todo; var title, todo;
...@@ -46,4 +47,5 @@ Todos.TodosController = Ember.ArrayController.extend({ ...@@ -46,4 +47,5 @@ Todos.TodosController = Ember.ArrayController.extend({
return length > 0 && length === completedLength; return length > 0 && length === completedLength;
} }
}.property('length', 'completed.length') }.property('length', 'completed.length')
}); });
})();
/*global Todos, Ember */ /*global Todos, Ember */
'use strict'; (function () {
'use strict';
Ember.Handlebars.helper('pluralize', function (singular, count) { Ember.Handlebars.helper('pluralize', function (singular, count) {
/* From Ember-Data */ /* From Ember-Data */
var inflector = new Ember.Inflector(Ember.Inflector.defaultRules); var inflector = new Ember.Inflector(Ember.Inflector.defaultRules);
return count === 1 ? singular : inflector.pluralize(singular); return count === 1 ? singular : inflector.pluralize(singular);
}); });
})();
/*global Todos, DS */ /*global Todos, DS */
'use strict'; (function () {
'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')
}); });
})();
/*global Ember, Todos */ /*global Ember, Todos */
'use strict'; (function () {
'use strict';
Todos.Router.map(function () { Todos.Router.map(function () {
this.resource('todos', { path: '/' }, 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 this.store.find('todo'); return this.store.find('todo');
} }
}); });
Todos.TodosIndexRoute = Ember.Route.extend({ Todos.TodosIndexRoute = Ember.Route.extend({
setupController: function () { setupController: function () {
this.controllerFor('todos').set('filteredTodos', this.modelFor('todos')); this.controllerFor('todos').set('filteredTodos', this.modelFor('todos'));
} }
}); });
Todos.TodosActiveRoute = Ember.Route.extend({ Todos.TodosActiveRoute = Ember.Route.extend({
setupController: function () { setupController: function () {
var todos = this.store.filter('todo', function (todo) { var todos = this.store.filter('todo', function (todo) {
return !todo.get('isCompleted'); return !todo.get('isCompleted');
...@@ -28,9 +29,9 @@ Todos.TodosActiveRoute = Ember.Route.extend({ ...@@ -28,9 +29,9 @@ Todos.TodosActiveRoute = Ember.Route.extend({
this.controllerFor('todos').set('filteredTodos', todos); this.controllerFor('todos').set('filteredTodos', todos);
} }
}); });
Todos.TodosCompletedRoute = Ember.Route.extend({ Todos.TodosCompletedRoute = Ember.Route.extend({
setupController: function () { setupController: function () {
var todos = this.store.filter('todo', function (todo) { var todos = this.store.filter('todo', function (todo) {
return todo.get('isCompleted'); return todo.get('isCompleted');
...@@ -38,4 +39,5 @@ Todos.TodosCompletedRoute = Ember.Route.extend({ ...@@ -38,4 +39,5 @@ Todos.TodosCompletedRoute = Ember.Route.extend({
this.controllerFor('todos').set('filteredTodos', todos); this.controllerFor('todos').set('filteredTodos', todos);
} }
}); });
})();
/*global Todos, Ember */ /*global Todos, Ember */
'use strict'; (function () {
'use strict';
Todos.EditTodoView = Ember.TextField.extend({ Todos.EditTodoView = Ember.TextField.extend({
focusOnInsert: function () { focusOnInsert: function () {
// Re-set input value to get rid of a reduntant text selection // Re-set input value to get rid of a reduntant text selection
this.$().val(this.$().val()); this.$().val(this.$().val());
this.$().focus(); this.$().focus();
}.on('didInsertElement') }.on('didInsertElement')
}); });
Ember.Handlebars.helper('edit-todo', Todos.EditTodoView); Ember.Handlebars.helper('edit-todo', Todos.EditTodoView);
})();
/*global Todos, Ember */ /*global Todos, Ember */
'use strict'; (function () {
'use strict';
Todos.TodosView = Ember.View.extend({ Todos.TodosView = Ember.View.extend({
focusInput: function () { focusInput: function () {
this.$('#new-todo').focus(); this.$('#new-todo').focus();
}.on('didInsertElement') }.on('didInsertElement')
}); });
})();
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