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
efe2fcea
Commit
efe2fcea
authored
Dec 24, 2015
by
TasteBot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update the build files for gh-pages [ci skip]
parent
86863803
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
165 additions
and
163 deletions
+165
-163
examples/angularjs-perf/index.html
examples/angularjs-perf/index.html
+24
-19
examples/angularjs-perf/js/app.js
examples/angularjs-perf/js/app.js
+10
-8
examples/angularjs-perf/js/controllers/todoCtrl.js
examples/angularjs-perf/js/controllers/todoCtrl.js
+89
-83
examples/angularjs-perf/js/directives/todoEscape.js
examples/angularjs-perf/js/directives/todoEscape.js
+0
-21
examples/angularjs-perf/js/directives/todoFocus.js
examples/angularjs-perf/js/directives/todoFocus.js
+21
-16
examples/angularjs-perf/js/services/todoStorage.js
examples/angularjs-perf/js/services/todoStorage.js
+21
-16
No files found.
examples/angularjs-perf/index.html
View file @
efe2fcea
...
...
@@ -8,45 +8,51 @@
<style>
[
ng-cloak
]
{
display
:
none
;
}
</style>
</head>
<body>
<section
id=
"todoapp"
ng-controller=
"TodoCtrl"
>
<section
id=
"todoapp"
ng-controller=
"TodoCtrl
as TC
"
>
<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
id=
"todo-form"
ng-submit=
"
TC.
addTodo()"
>
<input
id=
"new-todo"
placeholder=
"What needs to be done?"
ng-model=
"
TC.newTodo.title
"
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)"
>
<section
id=
"main"
ng-show=
"
TC.
todos.length"
ng-cloak
>
<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 todos | filter:statusFilter track by $index"
ng-class=
"{completed: todo.completed, editing: todo == 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"
ng-change=
"todoCompleted(todo)"
>
<label
ng-dblclick=
"editTodo(todo)"
>
{{todo.title}}
</label>
<button
class=
"destroy"
ng-click=
"
removeTodo(todo
)"
></button>
<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=
"doneEditing(todo)"
>
<input
class=
"edit"
ng-trim=
"false"
ng-model=
"todo.title"
ng-blur=
"doneEditing(todo)"
todo-escape=
"revertEditing(todo)"
todo-focus=
"todo == editedTodo"
>
<form
ng-submit=
"TC.doneEditing(todo, $index)"
>
<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>
</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>
<footer
id=
"footer"
ng-show=
"
TC.
todos.length"
ng-cloak
>
<span
id=
"todo-count"
><strong>
{{
TC.
remainingCount}}
</strong>
<ng-pluralize
count=
"
TC.
remainingCount"
when=
"{ one: 'item left', other: 'items left' }"
></ng-pluralize>
</span>
<ul
id=
"filters"
>
<li>
<a
ng-class=
"{selected: location.path() == '/'} "
href=
"#/"
>
All
</a>
<a
ng-class=
"{selected:
TC.
location.path() == '/'} "
href=
"#/"
>
All
</a>
</li>
<li>
<a
ng-class=
"{selected: location.path() == '/active'}"
href=
"#/active"
>
Active
</a>
<a
ng-class=
"{selected:
TC.
location.path() == '/active'}"
href=
"#/active"
>
Active
</a>
</li>
<li>
<a
ng-class=
"{selected: location.path() == '/completed'}"
href=
"#/completed"
>
Completed
</a>
<a
ng-class=
"{selected:
TC.
location.path() == '/completed'}"
href=
"#/completed"
>
Completed
</a>
</li>
</ul>
<button
id=
"clear-completed"
ng-click=
"
clearCompletedTodos()"
ng-show=
"remainingCount <
todos.length"
>
Clear completed
</button>
<button
id=
"clear-completed"
ng-click=
"
TC.clearCompletedTodos()"
ng-show=
"TC.remainingCount < TC.
todos.length"
>
Clear completed
</button>
</footer>
</section>
<footer
id=
"info"
>
...
...
@@ -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 @
efe2fcea
/* jshint undef: true, unused: true */
/*global angular */
/*jshint unused:false */
'
use strict
'
;
(
function
()
{
'
use strict
'
;
/**
* The main TodoMVC app module
*
* @type {angular.Module}
*/
var
todomvc
=
angular
.
module
(
'
todomvc
'
,
[]);
/**
* The main TodoMVC app module that pulls all dependency modules declared in same named files
*
* @type {angular.Module}
*/
angular
.
module
(
'
todomvc
'
,
[
'
todoCtrl
'
,
'
todoFocus
'
,
'
todoStorage
'
]);
})();
examples/angularjs-perf/js/controllers/todoCtrl.js
View file @
efe2fcea
/*
global todomvc, angular
*/
'
use strict
'
;
/*
jshint undef: true, unused: true
*/
/*global angular */
/**
* 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
/*
* Line below lets us save `this` as `TC`
* to make properties look exactly the same as in the template
*/
todomvc
.
controller
(
'
TodoCtrl
'
,
function
TodoCtrl
(
$scope
,
$location
,
$filter
,
todoStorage
)
{
var
todos
=
$scope
.
todos
=
todoStorage
.
get
();
$scope
.
newTodo
=
''
;
$scope
.
remainingCount
=
$filter
(
'
filter
'
)(
todos
,
{
completed
:
false
}).
length
;
$scope
.
editedTodo
=
null
;
if
(
$location
.
path
()
===
''
)
{
$location
.
path
(
'
/
'
);
}
$scope
.
location
=
$location
;
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
$scope
.
statusFilter
=
{
'
/active
'
:
{
completed
:
false
},
'
/completed
'
:
{
completed
:
true
}
}[
path
];
});
$scope
.
$watch
(
'
remainingCount == 0
'
,
function
(
val
)
{
$scope
.
allChecked
=
val
;
});
$scope
.
addTodo
=
function
()
{
var
newTodo
=
$scope
.
newTodo
.
trim
();
if
(
newTodo
.
length
===
0
)
{
return
;
//jscs:disable safeContextKeyword
(
function
()
{
'
use strict
'
;
angular
.
module
(
'
todoCtrl
'
,
[])
/**
* 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
*/
.
controller
(
'
TodoCtrl
'
,
function
TodoCtrl
(
$scope
,
$location
,
todoStorage
)
{
var
TC
=
this
;
var
todos
=
TC
.
todos
=
todoStorage
.
get
();
TC
.
ESCAPE_KEY
=
27
;
TC
.
editedTodo
=
{};
function
resetTodo
()
{
TC
.
newTodo
=
{
title
:
''
,
completed
:
false
};
}
todos
.
push
({
title
:
newTodo
,
completed
:
false
});
todoStorage
.
put
(
todos
);
resetTodo
();
$scope
.
newTodo
=
''
;
$scope
.
remainingCount
++
;
};
$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
)
{
$scope
.
editedTodo
=
null
;
todo
.
title
=
todo
.
title
.
trim
();
if
(
!
todo
.
title
)
{
$scope
.
removeTodo
(
todo
);
if
(
$location
.
path
()
===
''
)
{
$location
.
path
(
'
/
'
);
}
todoStorage
.
put
(
todos
);
};
$scope
.
revertEditing
=
function
(
todo
)
{
todos
[
todos
.
indexOf
(
todo
)]
=
$scope
.
originalTodo
;
$scope
.
doneEditing
(
$scope
.
originalTodo
);
};
TC
.
location
=
$location
;
$scope
.
removeTodo
=
function
(
todo
)
{
$scope
.
remainingCount
-=
todo
.
completed
?
0
:
1
;
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
todoStorage
.
put
(
todos
);
};
$scope
.
todoCompleted
=
function
(
todo
)
{
$scope
.
remainingCount
+=
todo
.
completed
?
-
1
:
1
;
todoStorage
.
put
(
todos
);
};
$scope
.
clearCompletedTodos
=
function
()
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
return
!
val
.
completed
;
$scope
.
$watch
(
'
TC.location.path()
'
,
function
(
path
)
{
TC
.
statusFilter
=
{
'
/active
'
:
{
completed
:
false
},
'
/completed
'
:
{
completed
:
true
}
}[
path
];
});
todoStorage
.
put
(
todos
);
};
$scope
.
markAll
=
function
(
completed
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
completed
;
});
$scope
.
remainingCount
=
completed
?
0
:
todos
.
length
;
todoStorage
.
put
(
todos
);
};
});
// 3rd argument `true` for deep object watching
$scope
.
$watch
(
'
TC.todos
'
,
function
()
{
TC
.
remainingCount
=
todos
.
filter
(
function
(
todo
)
{
return
!
todo
.
completed
;
}).
length
;
TC
.
allChecked
=
(
TC
.
remainingCount
===
0
);
// Save any changes to localStorage
todoStorage
.
put
(
todos
);
},
true
);
TC
.
addTodo
=
function
()
{
var
newTitle
=
TC
.
newTodo
.
title
=
TC
.
newTodo
.
title
.
trim
();
if
(
newTitle
.
length
===
0
)
{
return
;
}
todos
.
push
(
TC
.
newTodo
);
resetTodo
();
};
TC
.
editTodo
=
function
(
todo
)
{
TC
.
editedTodo
=
todo
;
// Clone the original todo to restore it on demand.
TC
.
originalTodo
=
angular
.
copy
(
todo
);
};
TC
.
doneEditing
=
function
(
todo
,
index
)
{
TC
.
editedTodo
=
{};
todo
.
title
=
todo
.
title
.
trim
();
if
(
!
todo
.
title
)
{
TC
.
removeTodo
(
index
);
}
};
TC
.
revertEditing
=
function
(
index
)
{
TC
.
editedTodo
=
{};
todos
[
index
]
=
TC
.
originalTodo
;
};
TC
.
removeTodo
=
function
(
index
)
{
todos
.
splice
(
index
,
1
);
};
TC
.
clearCompletedTodos
=
function
()
{
TC
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
return
!
val
.
completed
;
});
};
TC
.
markAll
=
function
(
completed
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
completed
;
});
};
});
})();
//jscs:enable
examples/angularjs-perf/js/directives/todoEscape.js
deleted
100644 → 0
View file @
86863803
/*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
);
}
});
scope
.
$on
(
'
$destroy
'
,
function
()
{
elem
.
unbind
(
'
keydown
'
);
});
};
});
examples/angularjs-perf/js/directives/todoFocus.js
View file @
efe2fcea
/*global todomvc */
'
use strict
'
;
/* jshint undef: true, unused: true */
/*global angular */
(
function
()
{
'
use strict
'
;
/**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true
*/
todomvc
.
directive
(
'
todoFocus
'
,
function
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newVal
)
{
if
(
newVal
)
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
},
0
,
false
);
}
});
};
});
angular
.
module
(
'
todoFocus
'
,
[])
/**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true
*/
.
directive
(
'
todoFocus
'
,
function
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newVal
)
{
if
(
newVal
)
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
},
0
,
false
);
}
});
};
});
})();
examples/angularjs-perf/js/services/todoStorage.js
View file @
efe2fcea
/*global todomvc */
'
use strict
'
;
/* jshint undef: true, unused: true */
/*global angular */
(
function
()
{
'
use strict
'
;
/**
* Services that persists and retrieves TODOs from localStorage
*/
todomvc
.
factory
(
'
todoStorage
'
,
function
()
{
var
STORAGE_ID
=
'
todos-angularjs-perf
'
;
angular
.
module
(
'
todoStorage
'
,
[])
return
{
get
:
function
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
},
/**
* Services that persists and retrieves TODOs from localStorage
*/
.
factory
(
'
todoStorage
'
,
function
()
{
var
STORAGE_ID
=
'
todos-angularjs-perf
'
;
put
:
function
(
todos
)
{
localStorage
.
setItem
(
STORAGE_ID
,
JSON
.
stringify
(
todos
));
}
};
});
return
{
get
:
function
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
},
put
:
function
(
todos
)
{
localStorage
.
setItem
(
STORAGE_ID
,
JSON
.
stringify
(
todos
));
}
};
});
})();
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