Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
687f280d
Commit
687f280d
authored
Mar 09, 2013
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Angular app - code style and some variable name fixes
parent
107c0e6c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
81 deletions
+82
-81
architecture-examples/angularjs/index.html
architecture-examples/angularjs/index.html
+65
-65
architecture-examples/angularjs/js/app.js
architecture-examples/angularjs/js/app.js
+3
-3
architecture-examples/angularjs/js/controllers/todoCtrl.js
architecture-examples/angularjs/js/controllers/todoCtrl.js
+6
-5
architecture-examples/angularjs/js/directives/todoBlur.js
architecture-examples/angularjs/js/directives/todoBlur.js
+2
-2
architecture-examples/angularjs/js/directives/todoFocus.js
architecture-examples/angularjs/js/directives/todoFocus.js
+4
-4
architecture-examples/angularjs/js/services/todoStorage.js
architecture-examples/angularjs/js/services/todoStorage.js
+2
-2
No files found.
architecture-examples/angularjs/index.html
View file @
687f280d
<!doctype html>
<!doctype html>
<html
lang=
"en"
ng-app=
"todomvc"
>
<html
lang=
"en"
ng-app=
"todomvc"
>
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
AngularJS • TodoMVC
</title>
<title>
AngularJS • TodoMVC
</title>
<link
rel=
"stylesheet"
href=
"components/todomvc-common/base.css"
>
<link
rel=
"stylesheet"
href=
"components/todomvc-common/base.css"
>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
</head>
</head>
<body>
<body>
<section
id=
"todoapp"
ng-controller=
"TodoCtrl"
>
<section
id=
"todoapp"
ng-controller=
"TodoCtrl"
>
<header
id=
"header"
>
<header
id=
"header"
>
<h1>
todos
</h1>
<h1>
todos
</h1>
<form
id=
"todo-form"
ng-submit=
"addTodo()"
>
<form
id=
"todo-form"
ng-submit=
"addTodo()"
>
<input
id=
"new-todo"
placeholder=
"What needs to be done?"
ng-model=
"newTodo"
autofocus
>
<input
id=
"new-todo"
placeholder=
"What needs to be done?"
ng-model=
"newTodo"
autofocus
>
</form>
</form>
</header>
</header>
<section
id=
"main"
ng-show=
"todos.length"
ng-cloak
>
<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=
"markAll(allChecked)"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
>
<ul
id=
"todo-list"
>
<li
ng-repeat=
"todo in todos | filter:statusFilter"
ng-class=
"{completed: todo.completed, editing: todo == editedTodo}"
>
<li
ng-repeat=
"todo in todos | filter:statusFilter"
ng-class=
"{completed: todo.completed, editing: todo == editedTodo}"
>
<div
class=
"view"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
>
<label
ng-dblclick=
"editTodo(todo)"
>
{{todo.title}}
</label>
<label
ng-dblclick=
"editTodo(todo)"
>
{{todo.title}}
</label>
<button
class=
"destroy"
ng-click=
"removeTodo(todo)"
></button>
<button
class=
"destroy"
ng-click=
"removeTodo(todo)"
></button>
</div>
</div>
<form
ng-submit=
"doneEditing(todo)"
>
<form
ng-submit=
"doneEditing(todo)"
>
<input
class=
"edit"
ng-model=
"todo.title"
todo-blur=
"doneEditing(todo)"
todo-focus=
"todo == editedTodo"
>
<input
class=
"edit"
ng-model=
"todo.title"
todo-blur=
"doneEditing(todo)"
todo-focus=
"todo == editedTodo"
>
</form>
</form>
</li>
</li>
</ul>
</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>
</section>
<footer
id=
"footer"
ng-show=
"todos.length"
ng-cloak
>
<footer
id=
"info"
>
<span
id=
"todo-count"
><strong>
{{remainingCount}}
</strong>
<p>
Double-click to edit a todo
</p>
<ng-pluralize
count=
"remainingCount"
when=
"{ one: 'item left', other: 'items left' }"
></ng-pluralize>
<p>
Credits:
</span>
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<ul
id=
"filters"
>
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<li>
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
and
<a
ng-class=
"{selected: location.path() == '/'} "
href=
"#/"
>
All
</a>
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
</li>
</p>
<li>
<p>
Part of
<a
href=
"http://todomvc.com"
>
TodoMVC
</a></p>
<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>
</footer>
</section>
<script
src=
"components/todomvc-common/base.js"
></script>
<footer
id=
"info"
>
<script
src=
"components/angular/angular.js"
></script>
<p>
Double-click to edit a todo
</p>
<script
src=
"js/app.js"
></script>
<p>
Credits:
<script
src=
"js/controllers/todoCtrl.js"
></script>
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<script
src=
"js/services/todoStorage.js"
></script>
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<script
src=
"js/directives/todoFocus.js"
></script>
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
and
<script
src=
"js/directives/todoBlur.js"
></script>
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
</body>
</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>
</html>
</html>
architecture-examples/angularjs/js/app.js
View file @
687f280d
/*global angular*/
/*global angular
*/
/*jshint unused:false*/
/*jshint unused:false
*/
'
use strict
'
;
'
use strict
'
;
/**
/**
* The main TodoMVC app module
.
* The main TodoMVC app module
*
*
* @type {angular.Module}
* @type {angular.Module}
*/
*/
...
...
architecture-examples/angularjs/js/controllers/todoCtrl.js
View file @
687f280d
/*global todomvc*/
/*global todomvc
*/
'
use strict
'
;
'
use strict
'
;
/**
/**
...
@@ -14,7 +14,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
...
@@ -14,7 +14,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
$scope
.
$watch
(
'
todos
'
,
function
()
{
$scope
.
$watch
(
'
todos
'
,
function
()
{
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
done
Count
=
todos
.
length
-
$scope
.
remainingCount
;
$scope
.
completed
Count
=
todos
.
length
-
$scope
.
remainingCount
;
$scope
.
allChecked
=
!
$scope
.
remainingCount
;
$scope
.
allChecked
=
!
$scope
.
remainingCount
;
todoStorage
.
put
(
todos
);
todoStorage
.
put
(
todos
);
},
true
);
},
true
);
...
@@ -22,6 +22,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
...
@@ -22,6 +22,7 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
if
(
$location
.
path
()
===
''
)
{
if
(
$location
.
path
()
===
''
)
{
$location
.
path
(
'
/
'
);
$location
.
path
(
'
/
'
);
}
}
$scope
.
location
=
$location
;
$scope
.
location
=
$location
;
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
...
@@ -58,15 +59,15 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
...
@@ -58,15 +59,15 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
};
};
$scope
.
clear
Done
Todos
=
function
()
{
$scope
.
clear
Completed
Todos
=
function
()
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
return
!
val
.
completed
;
return
!
val
.
completed
;
});
});
};
};
$scope
.
markAll
=
function
(
done
)
{
$scope
.
markAll
=
function
(
completed
)
{
todos
.
forEach
(
function
(
todo
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
done
;
todo
.
completed
=
completed
;
});
});
};
};
});
});
architecture-examples/angularjs/js/directives/todoBlur.js
View file @
687f280d
/*global todomvc*/
/*global todomvc
*/
'
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
*/
*/
todomvc
.
directive
(
'
todoBlur
'
,
function
()
{
todomvc
.
directive
(
'
todoBlur
'
,
function
()
{
return
function
(
scope
,
elem
,
attrs
)
{
return
function
(
scope
,
elem
,
attrs
)
{
...
...
architecture-examples/angularjs/js/directives/todoFocus.js
View file @
687f280d
/*global todomvc*/
/*global todomvc
*/
'
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
*/
*/
todomvc
.
directive
(
'
todoFocus
'
,
function
todoFocus
(
$timeout
)
{
todomvc
.
directive
(
'
todoFocus
'
,
function
todoFocus
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
new
v
al
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
new
V
al
)
{
if
(
new
v
al
)
{
if
(
new
V
al
)
{
$timeout
(
function
()
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
elem
[
0
].
focus
();
},
0
,
false
);
},
0
,
false
);
...
...
architecture-examples/angularjs/js/services/todoStorage.js
View file @
687f280d
/*global todomvc*/
/*global todomvc
*/
'
use strict
'
;
'
use strict
'
;
/**
/**
* Services that persists and retrieves TODOs from localStorage
.
* Services that persists and retrieves TODOs from localStorage
*/
*/
todomvc
.
factory
(
'
todoStorage
'
,
function
()
{
todomvc
.
factory
(
'
todoStorage
'
,
function
()
{
var
STORAGE_ID
=
'
todos-angularjs
'
;
var
STORAGE_ID
=
'
todos-angularjs
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment