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
Eugene Shen
todomvc
Commits
c705f8b8
Commit
c705f8b8
authored
Dec 23, 2015
by
dmitriz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
angularjs-perf: Removed todo-escaped directive
Using the native `ng-keydown` instead
parent
6f8b0d9b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
35 deletions
+29
-35
examples/angularjs-perf/index.html
examples/angularjs-perf/index.html
+8
-3
examples/angularjs-perf/js/app.js
examples/angularjs-perf/js/app.js
+2
-2
examples/angularjs-perf/js/controllers/todoCtrl.js
examples/angularjs-perf/js/controllers/todoCtrl.js
+17
-5
examples/angularjs-perf/js/directives/todoEscape.js
examples/angularjs-perf/js/directives/todoEscape.js
+0
-25
examples/angularjs-perf/js/directives/todoFocus.js
examples/angularjs-perf/js/directives/todoFocus.js
+1
-0
examples/angularjs-perf/js/services/todoStorage.js
examples/angularjs-perf/js/services/todoStorage.js
+1
-0
No files found.
examples/angularjs-perf/index.html
View file @
c705f8b8
...
...
@@ -19,14 +19,20 @@
<input
id=
"toggle-all"
type=
"checkbox"
ng-model=
"TC.allChecked"
ng-click=
"TC.markAll(TC.allChecked)"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
>
<li
ng-repeat=
"todo in TC.todos | filter:TC.statusFilter track by $index"
ng-class=
"{completed: todo.completed, editing: todo === TC.editedTodo}"
>
<li
ng-repeat=
"todo in TC.todos | filter:TC.statusFilter track by $index"
ng-class=
"{completed: todo.completed, editing: todo === TC.editedTodo}"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
>
<label
ng-dblclick=
"TC.editTodo(todo)"
>
{{todo.title}}
</label>
<button
class=
"destroy"
ng-click=
"TC.removeTodo($index)"
></button>
</div>
<form
ng-submit=
"TC.doneEditing(todo, $index)"
>
<input
class=
"edit"
ng-trim=
"false"
ng-model=
"todo.title"
ng-blur=
"TC.doneEditing(todo, $index)"
todo-escape=
"TC.revertEditing($index)"
todo-focus=
"todo === TC.editedTodo"
>
<input
class=
"edit"
ng-trim=
"false"
ng-model=
"todo.title"
ng-blur=
"TC.doneEditing(todo, $index)"
ng-keydown=
"($event.keyCode === TC.ESCAPE_KEY) && TC.revertEditing($index)"
todo-focus=
"todo === TC.editedTodo"
>
</form>
</li>
</ul>
...
...
@@ -65,6 +71,5 @@
<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>
examples/angularjs-perf/js/app.js
View file @
c705f8b8
/* jshint undef: true, unused: true */
/*global angular */
/*jshint unused:false */
(
function
()
{
'
use strict
'
;
...
...
@@ -8,5 +8,5 @@
*
* @type {angular.Module}
*/
angular
.
module
(
'
todomvc
'
,
[
'
todoCtrl
'
,
'
todo
Escape
'
,
'
todo
Focus
'
,
'
todoStorage
'
]);
angular
.
module
(
'
todomvc
'
,
[
'
todoCtrl
'
,
'
todoFocus
'
,
'
todoStorage
'
]);
})();
examples/angularjs-perf/js/controllers/todoCtrl.js
View file @
c705f8b8
/* jshint undef: true, unused: true */
/*global angular */
/*
* Line below lets us save `this` as `TC`
* to make properties look exactly the same as in the template
*/
//jscs:disable safeContextKeyword
(
function
()
{
'
use strict
'
;
...
...
@@ -13,10 +20,15 @@
var
TC
=
this
;
var
todos
=
TC
.
todos
=
todoStorage
.
get
();
TC
.
newTodo
=
{
title
:
''
,
completed
:
false
};
TC
.
ESCAPE_KEY
=
27
;
TC
.
editedTodo
=
{};
function
resetTodo
()
{
TC
.
newTodo
=
{
title
:
''
,
completed
:
false
};
}
resetTodo
();
if
(
$location
.
path
()
===
''
)
{
$location
.
path
(
'
/
'
);
}
...
...
@@ -43,8 +55,7 @@
}
todos
.
push
(
TC
.
newTodo
);
TC
.
newTodo
=
{
title
:
''
,
completed
:
false
};
resetTodo
();
};
TC
.
editTodo
=
function
(
todo
)
{
...
...
@@ -64,8 +75,8 @@
};
TC
.
revertEditing
=
function
(
index
)
{
TC
.
editedTodo
=
{};
todos
[
index
]
=
TC
.
originalTodo
;
TC
.
doneEditing
(
TC
.
originalTodo
);
};
TC
.
removeTodo
=
function
(
index
)
{
...
...
@@ -85,3 +96,4 @@
};
});
})();
//jscs:enable
examples/angularjs-perf/js/directives/todoEscape.js
deleted
100644 → 0
View file @
6f8b0d9b
/*global angular */
(
function
()
{
'
use strict
'
;
angular
.
module
(
'
todoEscape
'
,
[])
/**
* Directive that executes an expression when the element it is applied to gets
* an `escape` keydown event.
*/
.
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
);
}
});
scope
.
$on
(
'
$destroy
'
,
function
()
{
elem
.
unbind
(
'
keydown
'
);
});
};
});
})();
examples/angularjs-perf/js/directives/todoFocus.js
View file @
c705f8b8
/* jshint undef: true, unused: true */
/*global angular */
(
function
()
{
'
use strict
'
;
...
...
examples/angularjs-perf/js/services/todoStorage.js
View file @
c705f8b8
/* jshint undef: true, unused: true */
/*global angular */
(
function
()
{
'
use strict
'
;
...
...
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