Commit dd13679a authored by Pascal Hartig's avatar Pascal Hartig

TypeScript+AngularJS: Recompile with latest tsc

parent 2522a26d
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
var todos; var todos;
(function (todos) { (function (todos) {
'use strict'; 'use strict';
var TodoItem = (function () { var TodoItem = (function () {
function TodoItem(title, completed) { function TodoItem(title, completed) {
this.title = title; this.title = title;
...@@ -18,7 +17,6 @@ var todos; ...@@ -18,7 +17,6 @@ var todos;
var todos; var todos;
(function (todos) { (function (todos) {
'use strict'; 'use strict';
/** /**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true. * Directive that places focus on the element it is applied to when the expression it binds to evaluates to true.
*/ */
...@@ -27,23 +25,19 @@ var todos; ...@@ -27,23 +25,19 @@ var todos;
link: function ($scope, element, attributes) { link: function ($scope, element, attributes) {
$scope.$watch(attributes.todoFocus, function (newval) { $scope.$watch(attributes.todoFocus, function (newval) {
if (newval) { if (newval) {
$timeout(function () { $timeout(function () { return element[0].focus(); }, 0, false);
return element[0].focus();
}, 0, false);
} }
}); });
} }
}; };
} }
todos.todoFocus = todoFocus; todos.todoFocus = todoFocus;
todoFocus.$inject = ['$timeout']; todoFocus.$inject = ['$timeout'];
})(todos || (todos = {})); })(todos || (todos = {}));
/// <reference path='../_all.ts' /> /// <reference path='../_all.ts' />
var todos; var todos;
(function (todos) { (function (todos) {
'use strict'; 'use strict';
/** /**
* Directive that executes an expression when the element it is applied to loses focus. * Directive that executes an expression when the element it is applied to loses focus.
*/ */
...@@ -60,9 +54,8 @@ var todos; ...@@ -60,9 +54,8 @@ var todos;
})(todos || (todos = {})); })(todos || (todos = {}));
/// <reference path='../_all.ts' /> /// <reference path='../_all.ts' />
var todos; var todos;
(function (todos) { (function (_todos) {
'use strict'; 'use strict';
/** /**
* Services that persists and retrieves TODOs from localStorage. * Services that persists and retrieves TODOs from localStorage.
*/ */
...@@ -73,19 +66,17 @@ var todos; ...@@ -73,19 +66,17 @@ var todos;
TodoStorage.prototype.get = function () { TodoStorage.prototype.get = function () {
return JSON.parse(localStorage.getItem(this.STORAGE_ID) || '[]'); return JSON.parse(localStorage.getItem(this.STORAGE_ID) || '[]');
}; };
TodoStorage.prototype.put = function (todos) { TodoStorage.prototype.put = function (todos) {
localStorage.setItem(this.STORAGE_ID, JSON.stringify(todos)); localStorage.setItem(this.STORAGE_ID, JSON.stringify(todos));
}; };
return TodoStorage; return TodoStorage;
})(); })();
todos.TodoStorage = TodoStorage; _todos.TodoStorage = TodoStorage;
})(todos || (todos = {})); })(todos || (todos = {}));
/// <reference path='../_all.ts' /> /// <reference path='../_all.ts' />
var todos; var todos;
(function (todos) { (function (todos) {
'use strict'; 'use strict';
/** /**
* The main controller for the app. The controller: * The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service * - retrieves and persists the model via the todoStorage service
...@@ -101,23 +92,15 @@ var todos; ...@@ -101,23 +92,15 @@ var todos;
this.todoStorage = todoStorage; this.todoStorage = todoStorage;
this.filterFilter = filterFilter; this.filterFilter = filterFilter;
this.todos = $scope.todos = todoStorage.get(); this.todos = $scope.todos = todoStorage.get();
$scope.newTodo = ''; $scope.newTodo = '';
$scope.editedTodo = null; $scope.editedTodo = null;
// 'vm' stands for 'view model'. We're adding a reference to the controller to the scope // 'vm' stands for 'view model'. We're adding a reference to the controller to the scope
// for its methods to be accessible from view / HTML // for its methods to be accessible from view / HTML
$scope.vm = this; $scope.vm = this;
// watching for events/changes in scope, which are caused by view/user input // watching for events/changes in scope, which are caused by view/user input
// if you subscribe to scope or event with lifetime longer than this controller, make sure you unsubscribe. // if you subscribe to scope or event with lifetime longer than this controller, make sure you unsubscribe.
$scope.$watch('todos', function () { $scope.$watch('todos', function () { return _this.onTodos(); }, true);
return _this.onTodos(); $scope.$watch('location.path()', function (path) { return _this.onPath(path); });
}, true);
$scope.$watch('location.path()', function (path) {
return _this.onPath(path);
});
if ($location.path() === '') if ($location.path() === '')
$location.path('/'); $location.path('/');
$scope.location = $location; $scope.location = $location;
...@@ -125,28 +108,23 @@ var todos; ...@@ -125,28 +108,23 @@ var todos;
TodoCtrl.prototype.onPath = function (path) { TodoCtrl.prototype.onPath = function (path) {
this.$scope.statusFilter = (path === '/active') ? { completed: false } : (path === '/completed') ? { completed: true } : null; this.$scope.statusFilter = (path === '/active') ? { completed: false } : (path === '/completed') ? { completed: true } : null;
}; };
TodoCtrl.prototype.onTodos = function () { TodoCtrl.prototype.onTodos = function () {
this.$scope.remainingCount = this.filterFilter(this.todos, { completed: false }).length; this.$scope.remainingCount = this.filterFilter(this.todos, { completed: false }).length;
this.$scope.doneCount = this.todos.length - this.$scope.remainingCount; this.$scope.doneCount = this.todos.length - this.$scope.remainingCount;
this.$scope.allChecked = !this.$scope.remainingCount; this.$scope.allChecked = !this.$scope.remainingCount;
this.todoStorage.put(this.todos); this.todoStorage.put(this.todos);
}; };
TodoCtrl.prototype.addTodo = function () { TodoCtrl.prototype.addTodo = function () {
var newTodo = this.$scope.newTodo.trim(); var newTodo = this.$scope.newTodo.trim();
if (!newTodo.length) { if (!newTodo.length) {
return; return;
} }
this.todos.push(new todos.TodoItem(newTodo, false)); this.todos.push(new todos.TodoItem(newTodo, false));
this.$scope.newTodo = ''; this.$scope.newTodo = '';
}; };
TodoCtrl.prototype.editTodo = function (todoItem) { TodoCtrl.prototype.editTodo = function (todoItem) {
this.$scope.editedTodo = todoItem; this.$scope.editedTodo = todoItem;
}; };
TodoCtrl.prototype.doneEditing = function (todoItem) { TodoCtrl.prototype.doneEditing = function (todoItem) {
this.$scope.editedTodo = null; this.$scope.editedTodo = null;
todoItem.title = todoItem.title.trim(); todoItem.title = todoItem.title.trim();
...@@ -154,22 +132,21 @@ var todos; ...@@ -154,22 +132,21 @@ var todos;
this.removeTodo(todoItem); this.removeTodo(todoItem);
} }
}; };
TodoCtrl.prototype.removeTodo = function (todoItem) { TodoCtrl.prototype.removeTodo = function (todoItem) {
this.todos.splice(this.todos.indexOf(todoItem), 1); this.todos.splice(this.todos.indexOf(todoItem), 1);
}; };
TodoCtrl.prototype.clearDoneTodos = function () { TodoCtrl.prototype.clearDoneTodos = function () {
this.$scope.todos = this.todos = this.todos.filter(function (todoItem) { this.$scope.todos = this.todos = this.todos.filter(function (todoItem) { return !todoItem.completed; });
return !todoItem.completed;
});
}; };
TodoCtrl.prototype.markAll = function (completed) { TodoCtrl.prototype.markAll = function (completed) {
this.todos.forEach(function (todoItem) { this.todos.forEach(function (todoItem) {
todoItem.completed = completed; todoItem.completed = completed;
}); });
}; };
// $inject annotation.
// It provides $injector with information about dependencies to be injected into constructor
// it is better to have it close to the constructor, because the parameters must match in count and type.
// See http://docs.angularjs.org/guide/di
TodoCtrl.$inject = [ TodoCtrl.$inject = [
'$scope', '$scope',
'$location', '$location',
...@@ -182,14 +159,13 @@ var todos; ...@@ -182,14 +159,13 @@ var todos;
})(todos || (todos = {})); })(todos || (todos = {}));
/// <reference path='_all.ts' /> /// <reference path='_all.ts' />
/** /**
* The main TodoMVC app module. * The main TodoMVC app module.
* *
* @type {angular.Module} * @type {angular.Module}
*/ */
var todos; var todos;
(function (todos) { (function (todos) {
'use strict'; 'use strict';
var todomvc = angular.module('todomvc', []).controller('todoCtrl', todos.TodoCtrl).directive('todoBlur', todos.todoBlur).directive('todoFocus', todos.todoFocus).service('todoStorage', todos.TodoStorage); var todomvc = angular.module('todomvc', []).controller('todoCtrl', todos.TodoCtrl).directive('todoBlur', todos.todoBlur).directive('todoFocus', todos.todoFocus).service('todoStorage', todos.TodoStorage);
})(todos || (todos = {})); })(todos || (todos = {}));
//# sourceMappingURL=Application.js.map //# sourceMappingURL=Application.js.map
\ No newline at end of file
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