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
e21ab81b
Commit
e21ab81b
authored
Jan 24, 2014
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Angular-Perf: Add revert on escape (#789)
parent
ca448df0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
architecture-examples/angularjs-perf/index.html
architecture-examples/angularjs-perf/index.html
+2
-1
architecture-examples/angularjs-perf/js/controllers/todoCtrl.js
...ecture-examples/angularjs-perf/js/controllers/todoCtrl.js
+8
-1
architecture-examples/angularjs-perf/js/directives/todoEscape.js
...cture-examples/angularjs-perf/js/directives/todoEscape.js
+17
-0
No files found.
architecture-examples/angularjs-perf/index.html
View file @
e21ab81b
...
...
@@ -26,7 +26,7 @@
<button
class=
"destroy"
ng-click=
"removeTodo(todo)"
></button>
</div>
<form
ng-submit=
"doneEditing(todo)"
>
<input
class=
"edit"
ng-trim=
"false"
ng-model=
"todo.title"
ng-blur=
"doneEditing(todo)"
todo-focus=
"todo == editedTodo"
>
<input
class=
"edit"
ng-trim=
"false"
ng-model=
"todo.title"
ng-blur=
"doneEditing(todo)"
todo-
escape=
"revertEditing(todo)"
todo-
focus=
"todo == editedTodo"
>
</form>
</li>
</ul>
...
...
@@ -65,5 +65,6 @@
<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/todoEscape.js"
></script>
</body>
</html>
architecture-examples/angularjs-perf/js/controllers/todoCtrl.js
View file @
e21ab81b
/*global todomvc */
/*global todomvc
, angular
*/
'
use strict
'
;
/**
...
...
@@ -45,6 +45,8 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
$scope
.
editTodo
=
function
(
todo
)
{
$scope
.
editedTodo
=
todo
;
// Clone the original todo to restore it on demand.
$scope
.
originalTodo
=
angular
.
extend
({},
todo
);
};
$scope
.
doneEditing
=
function
(
todo
)
{
...
...
@@ -58,6 +60,11 @@ todomvc.controller('TodoCtrl', function TodoCtrl($scope, $location, todoStorage,
todoStorage
.
put
(
todos
);
};
$scope
.
revertEditing
=
function
(
todo
)
{
todos
[
todos
.
indexOf
(
todo
)]
=
$scope
.
originalTodo
;
$scope
.
doneEditing
(
$scope
.
originalTodo
);
};
$scope
.
removeTodo
=
function
(
todo
)
{
$scope
.
remainingCount
-=
todo
.
completed
?
0
:
1
;
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
...
...
architecture-examples/angularjs-perf/js/directives/todoEscape.js
0 → 100644
View file @
e21ab81b
/*global todomvc */
'
use strict
'
;
/**
* Directive that executes an expression when the element it is applied to gets
* an `escape` keydown event.
*/
todomvc
.
directive
(
'
todoEscape
'
,
function
()
{
var
ESCAPE_KEY
=
27
;
return
function
(
scope
,
elem
,
attrs
)
{
elem
.
bind
(
'
keydown
'
,
function
(
event
)
{
if
(
event
.
keyCode
===
ESCAPE_KEY
)
{
scope
.
$apply
(
attrs
.
todoEscape
);
}
});
};
});
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