Commit a4980d18 authored by Pascal Hartig's avatar Pascal Hartig

Merge pull request #690 from thorn0/gh-pages

TypeScript/Angular example was outdated
parents b3dc68d3 e6785ede
......@@ -2,7 +2,7 @@
"name": "todomvc-typescript-angular",
"version": "0.0.0",
"dependencies": {
"todomvc-common": "~0.1.6"
"angular": "~1.0.5",
"todomvc-common": "~0.1.6"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,22 +11,22 @@
<section id="todoapp" ng-controller="todoCtrl">
<header id="header">
<h1>todos</h1>
<form id="todo-form" ng-submit="addTodo()">
<form id="todo-form" ng-submit="vm.addTodo()">
<input id="new-todo" placeholder="What needs to be done?" ng-model="newTodo" autofocus>
</form>
</header>
<section id="main" ng-show="todos.length" ng-cloak>
<input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll(allChecked)">
<input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="vm.markAll(allChecked)">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
<li ng-repeat="todo in todos | filter:statusFilter" ng-class="{completed: todo.completed, editing: todo == editedTodo}">
<div class="view">
<input class="toggle" type="checkbox" ng-model="todo.completed">
<label ng-dblclick="editTodo(todo)">{{todo.title}}</label>
<button class="destroy" ng-click="removeTodo(todo)"></button>
<label ng-dblclick="vm.editTodo(todo)">{{todo.title}}</label>
<button class="destroy" ng-click="vm.removeTodo(todo)"></button>
</div>
<form ng-submit="doneEditing(todo)">
<input class="edit" ng-model="todo.title" todo-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
<form ng-submit="vm.doneEditing(todo)">
<input class="edit" ng-model="todo.title" todo-blur="vm.doneEditing(todo)" todo-focus="todo == editedTodo">
</form>
</li>
</ul>
......@@ -46,7 +46,7 @@
<a ng-class="{selected: location.path() == '/completed'}" href="#/completed">Completed</a>
</li>
</ul>
<button id="clear-completed" ng-click="clearDoneTodos()" ng-show="doneCount">Clear completed ({{doneCount}})</button>
<button id="clear-completed" ng-click="vm.clearDoneTodos()" ng-show="doneCount">Clear completed ({{doneCount}})</button>
</footer>
</section>
<footer id="info">
......@@ -61,11 +61,6 @@
</footer>
<script src="bower_components/todomvc-common/base.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="js/models/TodoItem.js"></script>
<script src="js/controllers/TodoCtrl.js"></script>
<script src="js/services/TodoStorage.js"></script>
<script src="js/directives/TodoFocus.js"></script>
<script src="js/directives/TodoBlur.js"></script>
<script src="js/Application.js"></script>
</body>
</html>
/// <reference path='../_all.ts' />
var todos;
(function (todos) {
'use strict';
var todomvc = angular.module('todomvc', []).controller('todoCtrl', todos.TodoCtrl.prototype.injection()).directive('todoBlur', todos.TodoBlur.prototype.injection()).directive('todoFocus', todos.TodoFocus.prototype.injection()).service('todoStorage', todos.TodoStorage.prototype.injection());
var TodoItem = (function () {
function TodoItem(title, completed) {
this.title = title;
this.completed = completed;
}
return TodoItem;
})();
todos.TodoItem = TodoItem;
})(todos || (todos = {}));
//@ sourceMappingURL=Application.js.map
/// <reference path='../_all.ts' />
/// <reference path='../_all.ts' />
/// <reference path='../_all.ts' />
var todos;
(function (todos) {
'use strict';
/**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true.
*/
function todoFocus($timeout) {
return {
link: function ($scope, element, attributes) {
$scope.$watch(attributes.todoFocus, function (newval) {
if (newval) {
$timeout(function () {
return element[0].focus();
}, 0, false);
}
});
}
};
}
todos.todoFocus = todoFocus;
todoFocus.$inject = ['$timeout'];
})(todos || (todos = {}));
/// <reference path='../_all.ts' />
var todos;
(function (todos) {
'use strict';
/**
* Directive that executes an expression when the element it is applied to loses focus.
*/
function todoBlur() {
return {
link: function ($scope, element, attributes) {
element.bind('blur', function () {
$scope.$apply(attributes.todoBlur);
});
}
};
}
todos.todoBlur = todoBlur;
})(todos || (todos = {}));
/// <reference path='../_all.ts' />
var todos;
(function (todos) {
'use strict';
/**
* Services that persists and retrieves TODOs from localStorage.
*/
var TodoStorage = (function () {
function TodoStorage() {
this.STORAGE_ID = 'todos-angularjs-typescript';
}
TodoStorage.prototype.get = function () {
return JSON.parse(localStorage.getItem(this.STORAGE_ID) || '[]');
};
TodoStorage.prototype.put = function (todos) {
localStorage.setItem(this.STORAGE_ID, JSON.stringify(todos));
};
return TodoStorage;
})();
todos.TodoStorage = TodoStorage;
})(todos || (todos = {}));
/// <reference path='../_all.ts' />
var todos;
(function (todos) {
'use strict';
/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
var TodoCtrl = (function () {
// dependencies are injected via AngularJS $injector
// controller's name is registered in Application.ts and specified from ng-controller attribute in index.html
function TodoCtrl($scope, $location, todoStorage, filterFilter) {
var _this = this;
this.$scope = $scope;
this.$location = $location;
this.todoStorage = todoStorage;
this.filterFilter = filterFilter;
this.todos = $scope.todos = todoStorage.get();
$scope.newTodo = '';
$scope.editedTodo = null;
// '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
$scope.vm = this;
// 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.
$scope.$watch('todos', function () {
return _this.onTodos();
}, true);
$scope.$watch('location.path()', function (path) {
return _this.onPath(path);
});
if ($location.path() === '')
$location.path('/');
$scope.location = $location;
}
TodoCtrl.prototype.onPath = function (path) {
this.$scope.statusFilter = (path === '/active') ? { completed: false } : (path === '/completed') ? { completed: true } : null;
};
TodoCtrl.prototype.onTodos = function () {
this.$scope.remainingCount = this.filterFilter(this.todos, { completed: false }).length;
this.$scope.doneCount = this.todos.length - this.$scope.remainingCount;
this.$scope.allChecked = !this.$scope.remainingCount;
this.todoStorage.put(this.todos);
};
TodoCtrl.prototype.addTodo = function () {
if (!this.$scope.newTodo.length) {
return;
}
this.todos.push(new todos.TodoItem(this.$scope.newTodo, false));
this.$scope.newTodo = '';
};
TodoCtrl.prototype.editTodo = function (todoItem) {
this.$scope.editedTodo = todoItem;
};
TodoCtrl.prototype.doneEditing = function (todoItem) {
this.$scope.editedTodo = null;
if (!todoItem.title) {
this.removeTodo(todoItem);
}
};
TodoCtrl.prototype.removeTodo = function (todoItem) {
this.todos.splice(this.todos.indexOf(todoItem), 1);
};
TodoCtrl.prototype.clearDoneTodos = function () {
this.$scope.todos = this.todos = this.todos.filter(function (todoItem) {
return !todoItem.completed;
});
};
TodoCtrl.prototype.markAll = function (completed) {
this.todos.forEach(function (todoItem) {
todoItem.completed = completed;
});
};
TodoCtrl.$inject = [
'$scope',
'$location',
'todoStorage',
'filterFilter'
];
return TodoCtrl;
})();
todos.TodoCtrl = TodoCtrl;
})(todos || (todos = {}));
/// <reference path='_all.ts' />
/**
* The main TodoMVC app module.
*
* @type {angular.Module}
*/
var todos;
(function (todos) {
'use strict';
var todomvc = angular.module('todomvc', []).controller('todoCtrl', todos.TodoCtrl).directive('todoBlur', todos.todoBlur).directive('todoFocus', todos.todoFocus).service('todoStorage', todos.TodoStorage);
})(todos || (todos = {}));
//# sourceMappingURL=Application.js.map
{"version":3,"file":"Application.js","sources":["Application.ts"],"names":["todos"],"mappings":"AAAA,IAOO,KAAK;AAQX,CARD,UAAO,KAAK;IACRA,YAAaA;IAEbA,IAAIA,OAAOA,GAAGA,OAAOA,CAACA,MAAMA,CAACA,SAASA,EAAEA,EAAEA,CAACA,CAClCA,UAAUA,CAACA,UAAUA,EAAEA,cAAQA,CAACA,SAASA,CAACA,SAASA,EAAEA,CAACA,CACtDA,SAASA,CAACA,UAAUA,EAAEA,cAAQA,CAACA,SAASA,CAACA,SAASA,EAAEA,CAACA,CACrDA,SAASA,CAACA,WAAWA,EAAEA,eAASA,CAACA,SAASA,CAACA,SAASA,EAAEA,CAACA,CACvDA,OAAOA,CAACA,aAAaA,EAAEA,iBAAWA,CAACA,SAASA,CAACA,SAASA,EAAEA,CAACA,CAACA;AACvEA,CAACA;AAAA"}
\ No newline at end of file
{"version":3,"file":"Application.js","sourceRoot":"","sources":["file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/models/TodoItem.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/interfaces/ITodoScope.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/interfaces/ITodoStorage.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/directives/TodoFocus.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/directives/TodoBlur.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/services/TodoStorage.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/controllers/TodoCtrl.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/Application.ts","file:///d:/dev/todomvc/labs/architecture-examples/typescript-angular/js/_all.ts"],"names":["todos","todos.TodoItem","todos.TodoItem.constructor","todos","todos.todoFocus","todos.todoFocus.link","","","todos","todos.todoBlur","todos.todoBlur.link","","todos","todos.TodoStorage","todos.TodoStorage.constructor","todos.TodoStorage.get","todos.TodoStorage.put","todos","todos.TodoCtrl","todos.TodoCtrl.constructor","","","todos.TodoCtrl.onPath","todos.TodoCtrl.onTodos","todos.TodoCtrl.addTodo","todos.TodoCtrl.editTodo","todos.TodoCtrl.doneEditing","todos.TodoCtrl.removeTodo","todos.TodoCtrl.clearDoneTodos","","todos.TodoCtrl.markAll","","todos"],"mappings":"AAAA,mCAAmC;AAEnC,IAAO,KAAK;AASX,CATD,UAAO,KAAK;IACRA,YAAYA,CAACA;;IAEbA;QACIC,kBACIA,KAAoBA,EACpBA,SAAyBA;YADzBC,UAAYA,GAALA,KAAKA;AAAQA,YACpBA,cAAgBA,GAATA,SAASA;AAASA,QACrBA,CAACA;QACbD;AAACA,IAADA,CAACA,IAAAD;IALDA,0BAKCA;AACLA,CAACA,yBAAA;ACXD,mCAAmC;ACAnC,mCAAmC;ACAnC,mCAAmC;AAEnC,IAAO,KAAK;AAoBX,CApBD,UAAO,KAAK;IACXG,YAAYA,CAACA;;IAKbA;;MADGA;IACHA,SAAgBA,SAASA,CAACA,QAA4B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A,CAChCA,SAASA,CAACA,UAAUA,EAAEA,cAAQA,CAACA,CAC/BA,SAASA,CAACA,WAAWA,EAAEA,eAASA,CAACA,CACjCA,OAAOA,CAACA,aAAaA,EAAEA,iBAAWA,CAACA,CAACA;AACjDA,CAACA,yBAAA"}
\ No newline at end of file
......@@ -9,8 +9,8 @@ module todos {
'use strict';
var todomvc = angular.module('todomvc', [])
.controller('todoCtrl', TodoCtrl.prototype.injection())
.directive('todoBlur', TodoBlur.prototype.injection())
.directive('todoFocus', TodoFocus.prototype.injection())
.service('todoStorage', TodoStorage.prototype.injection());
.controller('todoCtrl', TodoCtrl)
.directive('todoBlur', todoBlur)
.directive('todoFocus', todoFocus)
.service('todoStorage', TodoStorage);
}
\ No newline at end of file
/// <reference path='libs/jquery-1.8.d.ts' />
/// <reference path='libs/angular-1.0.d.ts' />
/// <reference path='libs/jquery.d.ts' />
/// <reference path='libs/angular.d.ts' />
/// <reference path='models/TodoItem.ts' />
/// <reference path='interfaces/ITodoScope.ts' />
/// <reference path='interfaces/ITodoStorage.ts' />
......
var todos;
(function (todos) {
'use strict';
var TodoCtrl = (function () {
function TodoCtrl($scope, $location, todoStorage, filterFilter) {
this.$scope = $scope;
this.$location = $location;
this.todoStorage = todoStorage;
this.filterFilter = filterFilter;
var _this = this;
this.todos = $scope.todos = todoStorage.get();
$scope.newTodo = '';
$scope.editedTodo = null;
$scope.addTodo = function () {
return _this.addTodo();
};
$scope.editTodo = function (todoItem) {
return _this.editTodo(todoItem);
};
$scope.doneEditing = function (todoItem) {
return _this.doneEditing(todoItem);
};
$scope.removeTodo = function (todoItem) {
return _this.removeTodo(todoItem);
};
$scope.clearDoneTodos = function () {
return _this.clearDoneTodos();
};
$scope.markAll = function (completed) {
return _this.markAll(completed);
};
$scope.$watch('todos', function () {
return _this.onTodos();
}, true);
$scope.$watch('location.path()', function (path) {
return _this.onPath(path);
});
if($location.path() === '') {
$location.path('/');
}
$scope.location = $location;
}
TodoCtrl.prototype.injection = function () {
return [
'$scope',
'$location',
'todoStorage',
'filterFilter',
TodoCtrl
];
};
TodoCtrl.prototype.onPath = function (path) {
this.$scope.statusFilter = (path == '/active') ? {
completed: false
} : (path == '/completed') ? {
completed: true
} : null;
};
TodoCtrl.prototype.onTodos = function () {
this.$scope.remainingCount = this.filterFilter(this.todos, {
completed: false
}).length;
this.$scope.doneCount = this.todos.length - this.$scope.remainingCount;
this.$scope.allChecked = !this.$scope.remainingCount;
this.todoStorage.put(this.todos);
};
TodoCtrl.prototype.addTodo = function () {
if(!this.$scope.newTodo.length) {
return;
}
this.todos.push(new todos.TodoItem(this.$scope.newTodo, false));
this.$scope.newTodo = '';
};
TodoCtrl.prototype.editTodo = function (todoItem) {
this.$scope.editedTodo = todoItem;
};
TodoCtrl.prototype.doneEditing = function (todoItem) {
this.$scope.editedTodo = null;
if(!todoItem.title) {
this.$scope.removeTodo(todoItem);
}
};
TodoCtrl.prototype.removeTodo = function (todoItem) {
this.todos.splice(this.todos.indexOf(todoItem), 1);
};
TodoCtrl.prototype.clearDoneTodos = function () {
this.$scope.todos = this.todos = this.todos.filter(function (todoItem) {
return !todoItem.completed;
});
};
TodoCtrl.prototype.markAll = function (completed) {
this.todos.forEach(function (todoItem) {
todoItem.completed = completed;
});
};
return TodoCtrl;
})();
todos.TodoCtrl = TodoCtrl;
})(todos || (todos = {}));
//@ sourceMappingURL=TodoCtrl.js.map
{"version":3,"file":"TodoCtrl.js","sources":["TodoCtrl.ts"],"names":["todos","todos.TodoCtrl","todos.TodoCtrl.constructor","todos.TodoCtrl.constructor.addTodo","todos.TodoCtrl.constructor.editTodo","todos.TodoCtrl.constructor.doneEditing","todos.TodoCtrl.constructor.removeTodo","todos.TodoCtrl.constructor.clearDoneTodos","todos.TodoCtrl.constructor.markAll","","","todos.TodoCtrl.injection","todos.TodoCtrl.onPath","todos.TodoCtrl.onTodos","todos.TodoCtrl.addTodo","todos.TodoCtrl.editTodo","todos.TodoCtrl.doneEditing","todos.TodoCtrl.removeTodo","todos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,GAAGA,SAASA;YAClCA,CAACA,CAACD;QACNA,CAACA;QACLnB;AAACA,IAADA,CAACA,IAAAD;IAnGDA,0BAmGCA,IAAAA;AAELA,CAACA;AAAA"}
\ No newline at end of file
/// <reference path='../_all.ts' />
module todos {
'use strict';
/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
export class TodoCtrl {
private todos: TodoItem[];
// this method is called on prototype during registration into IoC container.
// 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.
public injection(): any[] {
return [
'$scope',
'$location',
'todoStorage',
'filterFilter',
TodoCtrl
]
}
// dependencies are injected via AngularJS $injector
// controller's name is registered in App.ts and invoked from ng-controller attribute in index.html
constructor(
private $scope: ITodoScope,
private $location: ng.ILocationService,
private todoStorage: ITodoStorage,
private filterFilter
) {
this.todos = $scope.todos = todoStorage.get();
$scope.newTodo = '';
$scope.editedTodo = null;
// adding event handlers to the scope, so they could be bound from view/HTML
// these lambdas fix this keyword in JS world
$scope.addTodo = () => this.addTodo();
$scope.editTodo = (todoItem) => this.editTodo(todoItem);
$scope.doneEditing = (todoItem) => this.doneEditing(todoItem);
$scope.removeTodo = (todoItem) => this.removeTodo(todoItem);
$scope.clearDoneTodos = () => this.clearDoneTodos();
$scope.markAll = (completed) => this.markAll(completed);
// 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.
$scope.$watch('todos', () => this.onTodos(), true);
$scope.$watch('location.path()', (path) => this.onPath(path))
if ($location.path() === '') $location.path('/');
$scope.location = $location;
}
onPath(path: string) {
this.$scope.statusFilter =
(path == '/active')
? { completed: false }
: (path == '/completed')
? { completed: true }
: null;
}
onTodos() {
this.$scope.remainingCount = this.filterFilter(this.todos, { completed: false }).length;
this.$scope.doneCount = this.todos.length - this.$scope.remainingCount;
this.$scope.allChecked = !this.$scope.remainingCount
this.todoStorage.put(this.todos);
}
addTodo() {
if (!this.$scope.newTodo.length) {
return;
}
this.todos.push(new TodoItem(this.$scope.newTodo, false));
this.$scope.newTodo = '';
};
editTodo(todoItem: TodoItem) {
this.$scope.editedTodo = todoItem;
};
doneEditing(todoItem: TodoItem) {
this.$scope.editedTodo = null;
if (!todoItem.title) {
this.$scope.removeTodo(todoItem);
}
};
removeTodo(todoItem: TodoItem) {
this.todos.splice(this.todos.indexOf(todoItem), 1);
};
clearDoneTodos() {
this.$scope.todos = this.todos = this.todos.filter((todoItem) => {
return !todoItem.completed;
});
};
markAll(completed: bool) {
this.todos.forEach((todoItem: TodoItem) => {
todoItem.completed = completed;
});
};
}
'use strict';
/**
* The main controller for the app. The controller:
* - retrieves and persists the model via the todoStorage service
* - exposes the model to the template and provides event handlers
*/
export class TodoCtrl {
private todos: TodoItem[];
// $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
public static $inject = [
'$scope',
'$location',
'todoStorage',
'filterFilter'
];
// dependencies are injected via AngularJS $injector
// controller's name is registered in Application.ts and specified from ng-controller attribute in index.html
constructor(
private $scope: ITodoScope,
private $location: ng.ILocationService,
private todoStorage: ITodoStorage,
private filterFilter
) {
this.todos = $scope.todos = todoStorage.get();
$scope.newTodo = '';
$scope.editedTodo = null;
// '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
$scope.vm = this;
// 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.
$scope.$watch('todos', () => this.onTodos(), true);
$scope.$watch('location.path()', path => this.onPath(path))
if ($location.path() === '') $location.path('/');
$scope.location = $location;
}
onPath(path: string) {
this.$scope.statusFilter = (path === '/active') ?
{ completed: false } : (path === '/completed') ?
{ completed: true } : null;
}
onTodos() {
this.$scope.remainingCount = this.filterFilter(this.todos, { completed: false }).length;
this.$scope.doneCount = this.todos.length - this.$scope.remainingCount;
this.$scope.allChecked = !this.$scope.remainingCount
this.todoStorage.put(this.todos);
}
addTodo() {
if (!this.$scope.newTodo.length) {
return;
}
this.todos.push(new TodoItem(this.$scope.newTodo, false));
this.$scope.newTodo = '';
}
editTodo(todoItem: TodoItem) {
this.$scope.editedTodo = todoItem;
}
doneEditing(todoItem: TodoItem) {
this.$scope.editedTodo = null;
if (!todoItem.title) {
this.removeTodo(todoItem);
}
}
removeTodo(todoItem: TodoItem) {
this.todos.splice(this.todos.indexOf(todoItem), 1);
}
clearDoneTodos() {
this.$scope.todos = this.todos = this.todos.filter(todoItem => !todoItem.completed);
}
markAll(completed: boolean) {
this.todos.forEach(todoItem => { todoItem.completed = completed; });
}
}
}
var todos;
(function (todos) {
'use strict';
var TodoBlur = (function () {
function TodoBlur() {
var _this = this;
this.link = function ($scope, element, attributes) {
return _this.linkFn($scope, element, attributes);
};
}
TodoBlur.prototype.injection = function () {
return [
function () {
return new TodoBlur();
} ];
};
TodoBlur.prototype.linkFn = function ($scope, element, attributes) {
element.bind('blur', function () {
$scope.$apply(attributes.todoBlur);
});
};
return TodoBlur;
})();
todos.TodoBlur = TodoBlur;
})(todos || (todos = {}));
//@ sourceMappingURL=TodoBlur.js.map
{"version":3,"file":"TodoBlur.js","sources":["TodoBlur.ts"],"names":["todos","todos.TodoBlur","todos.TodoBlur.constructor","todos.TodoBlur.constructor.link","todos.TodoBlur.injection","","todos.TodoBlur.linkFn",""],"mappings":"AAAA,IAEO,KAAK;AAyBX,CAzBD,UAAO,KAAK;IACRA,YAAaA;IAKbA;QASIC,SATSA,QAAQA;YASjBC,iBAECA;YADGA,IAAIA,CAACA,IAAIA,GAAGA,UAACA,MAAMA,EAAEA,OAAOA,EAAEA,UAAWA;gBAAIC,OAAAA,KAAIA,CAACA,MAAMA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,UAAUA,CAACA,CAAAA;YAAxCA,CAAwCA;QACzFD,CAACA;QARDD,+BAAAA;YACIG,OAAOA;gBACHA;oBAAQC,OAAOA,IAAIA,QAAQA,EAAEA,CAACA;gBAACA,CAACA,aACnCD,CAAAA;QACLA,CAACA;QAMDH,4BAAAA,UAAOA,MAAiBA,EAAEA,OAAeA,EAAEA,UAAeA;YACtDK,OAAOA,CAACA,IAAIA,CAACA,MAAMA,EAAEA;gBACjBC,MAAMA,CAACA,MAAMA,CAACA,UAAUA,CAACA,QAAQA,CAACA;YACtCA,CAACA,CAACD;QACNA,CAACA;QACLL;AAACA,IAADA,CAACA,IAAAD;IAlBDA,0BAkBCA,IAAAA;AACLA,CAACA;AAAA"}
\ No newline at end of file
......@@ -2,27 +2,15 @@
module todos {
'use strict';
/**
* Directive that executes an expression when the element it is applied to loses focus.
*/
export class TodoBlur {
public link: ($scope: ng.IScope, element: JQuery, attributes: any) => any;
public injection(): any[] {
return [
() => { return new TodoBlur(); }
]
}
constructor() {
this.link = ($scope, element, attributes) => this.linkFn($scope, element, attributes);
}
linkFn($scope: ng.IScope, element: JQuery, attributes: any): any {
element.bind('blur', () => {
$scope.$apply(attributes.todoBlur);
});
export function todoBlur(): ng.IDirective {
return {
link: ($scope: ng.IScope, element: JQuery, attributes: any) => {
element.bind('blur', () => { $scope.$apply(attributes.todoBlur); });
}
};
}
}
\ No newline at end of file
var todos;
(function (todos) {
'use strict';
var TodoFocus = (function () {
function TodoFocus($timeout) {
this.$timeout = $timeout;
var _this = this;
this.link = function ($scope, element, attributes) {
return _this.linkFn($scope, element, attributes);
};
}
TodoFocus.prototype.injection = function () {
return [
'$timeout',
function ($timeout) {
return new TodoFocus($timeout);
} ];
};
TodoFocus.prototype.linkFn = function ($scope, element, attributes) {
var _this = this;
$scope.$watch(attributes.todoFocus, function (newval) {
if(newval) {
_this.$timeout(function () {
element[0].focus();
}, 0, false);
}
});
};
return TodoFocus;
})();
todos.TodoFocus = TodoFocus;
})(todos || (todos = {}));
//@ sourceMappingURL=TodoFocus.js.map
{"version":3,"file":"TodoFocus.js","sources":["TodoFocus.ts"],"names":["todos","todos.TodoFocus","todos.TodoFocus.constructor","todos.TodoFocus.constructor.link","todos.TodoFocus.injection","","todos.TodoFocus.linkFn","",""],"mappings":"AAAA,IAEO,KAAK;AA+BX,CA/BD,UAAO,KAAK;IACRA,YAAaA;IAKbA;QAWIC,SAXSA,SAASA,CAWNA,QAAoCA;YAApCC,aAAgBA,GAARA,QAAQA;AAAoBA,YAAhDA,iBAECA;YADGA,IAAIA,CAACA,IAAIA,GAAGA,UAACA,MAAMA,EAAEA,OAAOA,EAAEA,UAAWA;gBAAIC,OAAAA,KAAIA,CAACA,MAAMA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,UAAUA,CAACA,CAAAA;YAAxCA,CAAwCA;QACzFD,CAACA;QATDD,gCAAAA;YACIG,OAAOA;gBACHA,UAAUA;gBACVA,UAACA,QAASA;oBAAMC,OAAOA,IAAIA,SAASA,CAACA,QAAQA,CAACA,CAACA;gBAACA,CAACA,aACpDD,CAAAA;QACLA,CAACA;QAMDH,6BAAAA,UAAOA,MAAiBA,EAAEA,OAAeA,EAAEA,UAAeA;YAA1DK,iBAQCA;YAPGA,MAAMA,CAACA,MAAMA,CAACA,UAAUA,CAACA,SAASA,EAAEA,UAACA,MAAOA;gBACxCC,GAAIA,MAAMA,CAACA;oBACPA,KAAIA,CAACA,QAAQA,CAACA;wBACVC,OAAOA,CAACA,CAACA,CAACA,CAACA,KAAKA,EAAEA;oBACtBA,CAACA,EAAED,CAACA,EAAEA,KAAKA,CAACA;iBACfA;YACLA,CAACA,CAACD;QACNA,CAACA;QACLL;AAACA,IAADA,CAACA,IAAAD;IAxBDA,4BAwBCA,IAAAA;AACLA,CAACA;AAAA"}
\ No newline at end of file
/// <reference path='../_all.ts' />
module 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.
*/
export class TodoFocus {
/**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true.
*/
export function todoFocus($timeout: ng.ITimeoutService): ng.IDirective {
return {
link: ($scope: ng.IScope, element: JQuery, attributes: any) => {
$scope.$watch(attributes.todoFocus, newval => {
if (newval) {
$timeout(() => element[0].focus(), 0, false);
}
});
}
};
}
public link: ($scope: ng.IScope, element: JQuery, attributes: any) => any;
todoFocus.$inject = ['$timeout'];
public injection(): any[] {
return [
'$timeout',
($timeout) => { return new TodoFocus($timeout); }
]
}
constructor(private $timeout: ng.ITimeoutService) {
this.link = ($scope, element, attributes) => this.linkFn($scope, element, attributes);
}
linkFn($scope: ng.IScope, element: JQuery, attributes: any): any {
$scope.$watch(attributes.todoFocus, (newval) => {
if (newval) {
this.$timeout(() => {
element[0].focus();
}, 0, false);
}
});
};
}
}
\ No newline at end of file
var todos;
(function (todos) {
'use strict';
})(todos || (todos = {}));
//@ sourceMappingURL=ITodoScope.js.map
{"version":3,"file":"ITodoScope.js","sources":["ITodoScope.ts"],"names":["todos"],"mappings":"AAAA,IAEO,KAAK;AAoBX,CApBD,UAAO,KAAK;IACRA,YAAaA;AAmBjBA,CAACA;AAAA"}
\ No newline at end of file
/// <reference path='../_all.ts' />
module todos {
'use strict';
export interface ITodoScope extends ng.IScope {
todos: TodoItem[];
newTodo: string;
editedTodo: TodoItem;
remainingCount: number;
doneCount: number;
allChecked: bool;
statusFilter: { completed: bool; };
location: ng.ILocationService;
addTodo: () => void;
editTodo: (todoItem: TodoItem) => void;
doneEditing: (todoItem: TodoItem) => void;
removeTodo: (todoItem: TodoItem) => void;
clearDoneTodos: () => void;
markAll: (completed: bool) => void;
}
export interface ITodoScope extends ng.IScope {
todos: TodoItem[];
newTodo: string;
editedTodo: TodoItem;
remainingCount: number;
doneCount: number;
allChecked: boolean;
statusFilter: { completed: boolean; };
location: ng.ILocationService;
vm: TodoCtrl;
}
}
\ No newline at end of file
var todos;
(function (todos) {
'use strict';
})(todos || (todos = {}));
//@ sourceMappingURL=ITodoStorage.js.map
{"version":3,"file":"ITodoStorage.js","sources":["ITodoStorage.ts"],"names":["todos"],"mappings":"AAAA,IAEO,KAAK;AAOX,CAPD,UAAO,KAAK;IACRA,YAAaA;AAMjBA,CAACA;AAAA"}
\ No newline at end of file
/// <reference path='../_all.ts' />
module todos {
'use strict';
export interface ITodoStorage {
get (): TodoItem[];
put(todos: TodoItem[]);
}
export interface ITodoStorage {
get (): TodoItem[];
put(todos: TodoItem[]);
}
}
\ No newline at end of file
var todos;
(function (todos) {
'use strict';
var TodoItem = (function () {
function TodoItem(title, completed) {
this.title = title;
this.completed = completed;
}
return TodoItem;
})();
todos.TodoItem = TodoItem;
})(todos || (todos = {}));
//@ sourceMappingURL=TodoItem.js.map
{"version":3,"file":"TodoItem.js","sources":["TodoItem.ts"],"names":["todos","todos.TodoItem","todos.TodoItem.constructor"],"mappings":"AAAA,IAEO,KAAK;AASX,CATD,UAAO,KAAK;IACRA,YAAaA;IAEbA;QACIC,SADSA,QAAQA,CAEbA,KAAoBA,EACpBA,SAAsBA;YADtBC,UAAYA,GAALA,KAAKA;AAAQA,YACpBA,cAAgBA,GAATA,SAASA;AAAMA,QAClBA,CAACA;QACbD;AAACA,IAADA,CAACA,IAAAD;IALDA,0BAKCA,IAAAA;AACLA,CAACA;AAAA"}
\ No newline at end of file
......@@ -6,7 +6,7 @@ module todos {
export class TodoItem {
constructor(
public title: string,
public completed: bool
public completed: boolean
) { }
}
}
var todos;
(function (todos) {
'use strict';
var TodoStorage = (function () {
function TodoStorage() {
this.STORAGE_ID = 'todos-angularjs-typescript';
}
TodoStorage.prototype.injection = function () {
return [
TodoStorage
];
};
TodoStorage.prototype.get = function () {
return JSON.parse(localStorage.getItem(this.STORAGE_ID) || '[]');
};
TodoStorage.prototype.put = function (todos) {
localStorage.setItem(this.STORAGE_ID, JSON.stringify(todos));
};
return TodoStorage;
})();
todos.TodoStorage = TodoStorage;
})(todos || (todos = {}));
//@ sourceMappingURL=TodoStorage.js.map
{"version":3,"file":"TodoStorage.js","sources":["TodoStorage.ts"],"names":["todos","todos.TodoStorage","todos.TodoStorage.constructor","todos.TodoStorage.injection","todos.TodoStorage.get","todos.TodoStorage.put"],"mappings":"AAAA,IAEO,KAAK;AA2BX,CA3BD,UAAO,KAAK;IACRA,YAAaA;IAKbA;QAQIC,SARSA,WAAWA;YAWpBC,KAAAA,UAAUA,GAAGA,4BAA4BA,CAAAA;QAFzCA,CAACA;QAPDD,kCAAAA;YACIE,OAAOA;gBACHA,WAAWA;aACdA,CAAAA;QACLA,CAACA;QAODF,4BAAAA;YACIG,OAAOA,IAAIA,CAACA,KAAKA,CAACA,YAAYA,CAACA,OAAOA,CAACA,IAAIA,CAACA,UAAUA,CAACA,IAAIA,IAAIA,CAACA,CAACA;QACrEA,CAACA;QAEDH,4BAAAA,UAAIA,KAAiBA;YACjBI,YAAYA,CAACA,OAAOA,CAACA,IAAIA,CAACA,UAAUA,EAAEA,IAAIA,CAACA,SAASA,CAACA,KAAKA,CAACA,CAACA;QAChEA,CAACA;QACLJ;AAACA,IAADA,CAACA,IAAAD;IApBDA,gCAoBCA,IAAAA;AACLA,CAACA;AAAA"}
\ No newline at end of file
......@@ -8,15 +8,6 @@ module todos {
*/
export class TodoStorage implements ITodoStorage {
public injection(): any[] {
return [
TodoStorage
]
}
constructor() {
}
STORAGE_ID = 'todos-angularjs-typescript';
get (): TodoItem[] {
......
......@@ -80,4 +80,6 @@ A standalone TypeScript compiler is available on NPM.
To compile the TypeScript in this project:
# from labs/architecture-examples/typescript-angular
tsc -sourcemap js/_all.ts
tsc --sourcemap --out js/Application.js js/_all.ts
Or use Visual Studio with the TypeScript plugin.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0A2B594A-1E06-46A8-A3B8-4E58C1071815}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>todo</RootNamespace>
<AssemblyName>todo</AssemblyName>
<OutputPath>bin</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>todo</RootNamespace>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
......@@ -62,95 +42,44 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<ItemGroup>
<Content Include="index.html" />
<Content Include="js\app.js">
<DependentUpon>Application.ts</DependentUpon>
</Content>
<Content Include="js\Application.ts" />
<Content Include="js\controllers\TodoCtrl.js">
<DependentUpon>TodoCtrl.ts</DependentUpon>
</Content>
<Content Include="js\controllers\TodoCtrl.ts" />
<Content Include="js\directives\TodoBlur.js">
<DependentUpon>TodoBlur.ts</DependentUpon>
</Content>
<Content Include="js\directives\TodoBlur.ts" />
<Content Include="js\directives\TodoFocus.js">
<DependentUpon>TodoFocus.ts</DependentUpon>
</Content>
<Content Include="js\directives\TodoFocus.ts" />
<Content Include="js\interfaces\ITodoScope.js">
<DependentUpon>ITodoScope.ts</DependentUpon>
</Content>
<Content Include="js\interfaces\ITodoScope.ts" />
<Content Include="js\interfaces\ITodoStorage.js">
<DependentUpon>ITodoStorage.ts</DependentUpon>
</Content>
<Content Include="js\interfaces\ITodoStorage.ts" />
<Content Include="js\libs\angular-1.0.d.ts" />
<Content Include="js\libs\angular\angular.min.js" />
<Content Include="js\libs\jquery-1.8.d.ts" />
<Content Include="js\models\TodoItem.js">
<DependentUpon>TodoItem.ts</DependentUpon>
</Content>
<Content Include="js\models\TodoItem.ts" />
<Content Include="js\services\TodoStorage.ts" />
<Content Include="js\_all.js">
<DependentUpon>_all.ts</DependentUpon>
</Content>
<Content Include="js\_all.ts" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.md" />
</ItemGroup>
<ItemGroup>
<Content Include="js\directives\TodoBlur.js.map">
<DependentUpon>TodoBlur.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="js\directives\TodoFocus.js.map">
<DependentUpon>TodoFocus.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="js\app.js.map">
<DependentUpon>Application.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="js\controllers\TodoCtrl.js.map">
<DependentUpon>TodoCtrl.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="js\_all.js.map">
<DependentUpon>_all.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="js\_all.ts" />
<TypeScriptCompile Include="js\libs\angular.d.ts" />
<TypeScriptCompile Include="js\libs\jquery.d.ts" />
<TypeScriptCompile Include="js\Application.ts" />
<TypeScriptCompile Include="js\controllers\TodoCtrl.ts" />
<TypeScriptCompile Include="js\directives\TodoBlur.ts" />
<TypeScriptCompile Include="js\directives\TodoFocus.ts" />
<TypeScriptCompile Include="js\interfaces\ITodoScope.ts" />
<TypeScriptCompile Include="js\interfaces\ITodoStorage.ts" />
<TypeScriptCompile Include="js\models\TodoItem.ts" />
<TypeScriptCompile Include="js\services\TodoStorage.ts" />
</ItemGroup>
<ItemGroup>
<Content Include="js\models\TodoItem.js.map">
<DependentUpon>TodoItem.ts</DependentUpon>
</Content>
<None Include="ReadMe.md" />
<Content Include="web.config" />
<None Include="web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
<None Include="web.Release.config">
<DependentUpon>web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="js\interfaces\ITodoScope.js.map">
<DependentUpon>ITodoScope.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="js\interfaces\ITodoStorage.js.map">
<DependentUpon>ITodoStorage.ts</DependentUpon>
</Content>
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<TypeScriptOutFile>js\Application.js</TypeScriptOutFile>
<TypeScriptTarget>ES3</TypeScriptTarget>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
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