Permalink
Browse files

Angular app - code style and some variable name fixes

  • Loading branch information...
1 parent 107c0e6 commit 687f280dcd8b80032ec49784f012c762bea21498 @sindresorhus sindresorhus committed Mar 9, 2013
View
130 architecture-examples/angularjs/index.html
@@ -1,70 +1,70 @@
<!doctype html>
<html lang="en" ng-app="todomvc">
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title>AngularJS • TodoMVC</title>
- <link rel="stylesheet" href="components/todomvc-common/base.css">
- <style>[ng-cloak] {display: none}</style>
-</head>
-<body>
- <section id="todoapp" ng-controller="TodoCtrl">
- <header id="header">
- <h1>todos</h1>
- <form id="todo-form" ng-submit="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)">
- <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>
- </div>
- <form ng-submit="doneEditing(todo)">
- <input class="edit" ng-model="todo.title" todo-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
- </form>
- </li>
- </ul>
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <title>AngularJS • TodoMVC</title>
+ <link rel="stylesheet" href="components/todomvc-common/base.css">
+ <style>[ng-cloak] {display: none}</style>
+ </head>
+ <body>
+ <section id="todoapp" ng-controller="TodoCtrl">
+ <header id="header">
+ <h1>todos</h1>
+ <form id="todo-form" ng-submit="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)">
+ <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>
+ </div>
+ <form ng-submit="doneEditing(todo)">
+ <input class="edit" ng-model="todo.title" todo-blur="doneEditing(todo)" todo-focus="todo == editedTodo">
+ </form>
+ </li>
+ </ul>
+ </section>
+ <footer id="footer" ng-show="todos.length" ng-cloak>
+ <span id="todo-count"><strong>{{remainingCount}}</strong>
+ <ng-pluralize count="remainingCount" when="{ one: 'item left', other: 'items left' }"></ng-pluralize>
+ </span>
+ <ul id="filters">
+ <li>
+ <a ng-class="{selected: location.path() == '/'} " href="#/">All</a>
+ </li>
+ <li>
+ <a ng-class="{selected: location.path() == '/active'}" href="#/active">Active</a>
+ </li>
+ <li>
+ <a ng-class="{selected: location.path() == '/completed'}" href="#/completed">Completed</a>
+ </li>
+ </ul>
+ <button id="clear-completed" ng-click="clearCompletedTodos()" ng-show="completedCount">Clear completed ({{doneCount}})</button>
+ </footer>
</section>
- <footer id="footer" ng-show="todos.length" ng-cloak>
- <span id="todo-count"><strong>{{remainingCount}}</strong>
- <ng-pluralize count="remainingCount" when="{ one: 'item left', other: 'items left' }"></ng-pluralize>
- </span>
- <ul id="filters">
- <li>
- <a ng-class="{selected: location.path() == '/'} " href="#/">All</a>
- </li>
- <li>
- <a ng-class="{selected: location.path() == '/active'}" href="#/active">Active</a>
- </li>
- <li>
- <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>
+ <footer id="info">
+ <p>Double-click to edit a todo</p>
+ <p>Credits:
+ <a href="http://twitter.com/cburgdorf">Christoph Burgdorf</a>,
+ <a href="http://ericbidelman.com">Eric Bidelman</a>,
+ <a href="http://jacobmumm.com">Jacob Mumm</a> and
+ <a href="http://igorminar.com">Igor Minar</a>
+ </p>
+ <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
- </section>
- <footer id="info">
- <p>Double-click to edit a todo</p>
- <p>Credits:
- <a href="http://twitter.com/cburgdorf">Christoph Burgdorf</a>,
- <a href="http://ericbidelman.com">Eric Bidelman</a>,
- <a href="http://jacobmumm.com">Jacob Mumm</a> and
- <a href="http://igorminar.com">Igor Minar</a>
- </p>
- <p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
- </footer>
- <script src="components/todomvc-common/base.js"></script>
- <script src="components/angular/angular.js"></script>
- <script src="js/app.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>
-</body>
+ <script src="components/todomvc-common/base.js"></script>
+ <script src="components/angular/angular.js"></script>
+ <script src="js/app.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>
+ </body>
</html>
View
6 architecture-examples/angularjs/js/app.js
@@ -1,9 +1,9 @@
-/*global angular*/
-/*jshint unused:false*/
+/*global angular */
+/*jshint unused:false */
'use strict';
/**
- * The main TodoMVC app module.
+ * The main TodoMVC app module
*
* @type {angular.Module}
*/
View
11 architecture-examples/angularjs/js/controllers/todoCtrl.js
@@ -1,4 +1,4 @@
-/*global todomvc*/
+/*global todomvc */
'use strict';
/**
@@ -14,14 +14,15 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
$scope.$watch('todos', function () {
$scope.remainingCount = filterFilter(todos, {completed: false}).length;
- $scope.doneCount = todos.length - $scope.remainingCount;
+ $scope.completedCount = todos.length - $scope.remainingCount;
$scope.allChecked = !$scope.remainingCount;
todoStorage.put(todos);
}, true);
if ($location.path() === '') {
$location.path('/');
}
+
$scope.location = $location;
$scope.$watch('location.path()', function (path) {
@@ -58,15 +59,15 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
todos.splice(todos.indexOf(todo), 1);
};
- $scope.clearDoneTodos = function () {
+ $scope.clearCompletedTodos = function () {
$scope.todos = todos = todos.filter(function (val) {
return !val.completed;
});
};
- $scope.markAll = function (done) {
+ $scope.markAll = function (completed) {
todos.forEach(function (todo) {
- todo.completed = done;
+ todo.completed = completed;
});
};
});
View
4 architecture-examples/angularjs/js/directives/todoBlur.js
@@ -1,8 +1,8 @@
-/*global todomvc*/
+/*global todomvc */
'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
*/
todomvc.directive('todoBlur', function () {
return function (scope, elem, attrs) {
View
8 architecture-examples/angularjs/js/directives/todoFocus.js
@@ -1,13 +1,13 @@
-/*global todomvc*/
+/*global todomvc */
'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
*/
todomvc.directive('todoFocus', function todoFocus($timeout) {
return function (scope, elem, attrs) {
- scope.$watch(attrs.todoFocus, function (newval) {
- if (newval) {
+ scope.$watch(attrs.todoFocus, function (newVal) {
+ if (newVal) {
$timeout(function () {
elem[0].focus();
}, 0, false);
View
4 architecture-examples/angularjs/js/services/todoStorage.js
@@ -1,8 +1,8 @@
-/*global todomvc*/
+/*global todomvc */
'use strict';
/**
- * Services that persists and retrieves TODOs from localStorage.
+ * Services that persists and retrieves TODOs from localStorage
*/
todomvc.factory('todoStorage', function () {
var STORAGE_ID = 'todos-angularjs';

0 comments on commit 687f280

Please sign in to comment.