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
bcc74618
Commit
bcc74618
authored
Feb 20, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
angular-perf: jshint style
parent
d62e2bd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
189 additions
and
173 deletions
+189
-173
architecture-examples/angularjs-perf/index.html
architecture-examples/angularjs-perf/index.html
+70
-70
architecture-examples/angularjs-perf/js/app.js
architecture-examples/angularjs-perf/js/app.js
+2
-0
architecture-examples/angularjs-perf/js/controllers/todoCtrl.js
...ecture-examples/angularjs-perf/js/controllers/todoCtrl.js
+86
-75
architecture-examples/angularjs-perf/js/directives/todoBlur.js
...tecture-examples/angularjs-perf/js/directives/todoBlur.js
+8
-7
architecture-examples/angularjs-perf/js/directives/todoFocus.js
...ecture-examples/angularjs-perf/js/directives/todoFocus.js
+11
-10
architecture-examples/angularjs-perf/js/services/todoStorage.js
...ecture-examples/angularjs-perf/js/services/todoStorage.js
+12
-11
No files found.
architecture-examples/angularjs-perf/index.html
View file @
bcc74618
<!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=
"../../assets/base.css"
>
<link
rel=
"stylesheet"
href=
"../../assets/base.css"
>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
<!--[if IE]>
<!--[if IE]>
<script src="../../assets/ie.js"></script>
<script src="../../assets/ie.js"></script>
<![endif]-->
<![endif]-->
</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"
ng-change=
"todoCompleted(todo)"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
ng-change=
"todoCompleted(todo)"
>
<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>
</section>
<footer
id=
"footer"
ng-show=
"todos.length"
ng-cloak
>
<footer
id=
"footer"
ng-show=
"todos.length"
ng-cloak
>
<span
id=
"todo-count"
><strong>
{{remainingCount}}
</strong>
<span
id=
"todo-count"
><strong>
{{remainingCount}}
</strong>
<ng-pluralize
count=
"remainingCount"
when=
"{ one: 'item left', other: 'items left' }"
></ng-pluralize>
<ng-pluralize
count=
"remainingCount"
when=
"{ one: 'item left', other: 'items left' }"
></ng-pluralize>
</span>
</span>
<ul
id=
"filters"
>
<ul
id=
"filters"
>
<li>
<li>
<a
ng-class=
"{selected: location.path() == '/'} "
href=
"#/"
>
All
</a>
<a
ng-class=
"{selected: location.path() == '/'} "
href=
"#/"
>
All
</a>
</li>
</li>
<li>
<li>
<a
ng-class=
"{selected: location.path() == '/active'}"
href=
"#/active"
>
Active
</a>
<a
ng-class=
"{selected: location.path() == '/active'}"
href=
"#/active"
>
Active
</a>
</li>
</li>
<li>
<li>
<a
ng-class=
"{selected: location.path() == '/completed'}"
href=
"#/completed"
>
Completed
</a>
<a
ng-class=
"{selected: location.path() == '/completed'}"
href=
"#/completed"
>
Completed
</a>
</li>
</li>
</ul>
</ul>
<button
id=
"clear-completed"
ng-click=
"clearDoneTodos()"
ng-show=
"remainingCount < todos.length"
>
Clear completed ({{todos.length - remainingCount}})
</button>
<button
id=
"clear-completed"
ng-click=
"clearDoneTodos()"
ng-show=
"remainingCount < todos.length"
>
Clear completed ({{todos.length - remainingCount}})
</button>
</footer>
</footer>
</section>
</section>
<footer
id=
"info"
>
<footer
id=
"info"
>
<p>
Double-click to edit a todo
</p>
<p>
Double-click to edit a todo
</p>
<p>
Credits:
<p>
Credits:
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
and
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
and
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
</p>
</p>
<p>
Part of
<a
href=
"http://todomvc.com"
>
TodoMVC
</a></p>
<p>
Part of
<a
href=
"http://todomvc.com"
>
TodoMVC
</a></p>
</footer>
</footer>
<script
src=
"../../assets/base.js"
></script>
<script
src=
"../../assets/base.js"
></script>
<script
src=
"js/libs/angular/angular.min.js"
></script>
<script
src=
"js/libs/angular/angular.min.js"
></script>
<script
src=
"js/app.js"
></script>
<script
src=
"js/app.js"
></script>
<script
src=
"js/controllers/todoCtrl.js"
></script>
<script
src=
"js/controllers/todoCtrl.js"
></script>
<script
src=
"js/services/todoStorage.js"
></script>
<script
src=
"js/services/todoStorage.js"
></script>
<script
src=
"js/directives/todoFocus.js"
></script>
<script
src=
"js/directives/todoFocus.js"
></script>
<script
src=
"js/directives/todoBlur.js"
></script>
<script
src=
"js/directives/todoBlur.js"
></script>
</body>
</body>
</html>
</html>
architecture-examples/angularjs-perf/js/app.js
View file @
bcc74618
/*global angular*/
/*jshint unused:false*/
'
use strict
'
;
'
use strict
'
;
/**
/**
...
...
architecture-examples/angularjs-perf/js/controllers/todoCtrl.js
View file @
bcc74618
/*global todomvc*/
'
use strict
'
;
'
use strict
'
;
/**
/**
...
@@ -5,79 +6,89 @@
...
@@ -5,79 +6,89 @@
* - retrieves and persist the model via the todoStorage service
* - retrieves and persist the model via the todoStorage service
* - exposes the model to the template and provides event handlers
* - exposes the model to the template and provides event handlers
*/
*/
todomvc
.
controller
(
'
TodoCtrl
'
,
function
TodoCtrl
(
$scope
,
$location
,
todoStorage
,
filterFilter
)
{
todomvc
.
controller
(
'
TodoCtrl
'
,
function
TodoCtrl
(
$scope
,
$location
,
todoStorage
,
filterFilter
)
{
var
todos
=
$scope
.
todos
=
todoStorage
.
get
();
var
todos
=
$scope
.
todos
=
todoStorage
.
get
();
$scope
.
newTodo
=
""
;
$scope
.
newTodo
=
''
;
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
editedTodo
=
null
;
$scope
.
editedTodo
=
null
;
if
(
$location
.
path
()
===
''
)
$location
.
path
(
'
/
'
);
if
(
$location
.
path
()
===
''
)
{
$scope
.
location
=
$location
;
$location
.
path
(
'
/
'
);
}
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
$scope
.
location
=
$location
;
$scope
.
statusFilter
=
(
path
==
'
/active
'
)
?
{
completed
:
false
}
:
(
path
==
'
/completed
'
)
?
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
{
completed
:
true
}
:
null
;
$scope
.
statusFilter
=
(
path
===
'
/active
'
)
?
});
{
completed
:
false
}
:
(
path
===
'
/completed
'
)
?
{
completed
:
true
}
:
null
;
$scope
.
$watch
(
'
remainingCount == 0
'
,
function
(
val
)
{
});
$scope
.
allChecked
=
val
;
});
$scope
.
$watch
(
'
remainingCount == 0
'
,
function
(
val
)
{
$scope
.
allChecked
=
val
;
});
$scope
.
addTodo
=
function
()
{
if
(
$scope
.
newTodo
.
length
===
0
)
return
;
$scope
.
addTodo
=
function
()
{
todos
.
push
({
if
(
$scope
.
newTodo
.
length
===
0
)
{
title
:
$scope
.
newTodo
,
return
;
completed
:
false
}
});
todoStorage
.
put
(
todos
);
todos
.
push
({
title
:
$scope
.
newTodo
,
$scope
.
newTodo
=
''
;
completed
:
false
$scope
.
remainingCount
++
;
});
};
todoStorage
.
put
(
todos
);
$scope
.
newTodo
=
''
;
$scope
.
editTodo
=
function
(
todo
)
{
$scope
.
remainingCount
++
;
$scope
.
editedTodo
=
todo
;
};
};
$scope
.
editTodo
=
function
(
todo
)
{
$scope
.
doneEditing
=
function
(
todo
)
{
$scope
.
editedTodo
=
todo
;
$scope
.
editedTodo
=
null
;
};
if
(
!
todo
.
title
)
$scope
.
removeTodo
(
todo
);
todoStorage
.
put
(
todos
);
};
$scope
.
doneEditing
=
function
(
todo
)
{
$scope
.
editedTodo
=
null
;
if
(
!
todo
.
title
)
{
$scope
.
removeTodo
=
function
(
todo
)
{
$scope
.
removeTodo
(
todo
);
$scope
.
remainingCount
-=
todo
.
completed
?
0
:
1
;
}
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
todoStorage
.
put
(
todos
);
todoStorage
.
put
(
todos
);
};
};
$scope
.
removeTodo
=
function
(
todo
)
{
$scope
.
todoCompleted
=
function
(
todo
)
{
$scope
.
remainingCount
-=
todo
.
completed
?
0
:
1
;
todo
.
completed
?
$scope
.
remainingCount
--
:
$scope
.
remainingCount
++
;
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
todoStorage
.
put
(
todos
);
todoStorage
.
put
(
todos
);
};
};
$scope
.
clearDoneTodos
=
function
()
{
$scope
.
todoCompleted
=
function
(
todo
)
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
if
(
todo
.
completed
)
{
return
!
val
.
completed
;
$scope
.
remainingCount
--
;
});
}
else
{
todoStorage
.
put
(
todos
);
$scope
.
remainingCount
++
;
};
}
todoStorage
.
put
(
todos
);
};
$scope
.
markAll
=
function
(
done
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
done
;
$scope
.
clearDoneTodos
=
function
()
{
});
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
$scope
.
remainingCount
=
done
?
0
:
todos
.
length
;
return
!
val
.
completed
;
todoStorage
.
put
(
todos
);
});
};
todoStorage
.
put
(
todos
);
};
$scope
.
markAll
=
function
(
done
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
done
;
});
$scope
.
remainingCount
=
done
?
0
:
todos
.
length
;
todoStorage
.
put
(
todos
);
};
});
});
architecture-examples/angularjs-perf/js/directives/todoBlur.js
View file @
bcc74618
/*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
)
{
elem
.
bind
(
'
blur
'
,
function
()
{
elem
.
bind
(
'
blur
'
,
function
()
{
scope
.
$apply
(
attrs
.
todoBlur
);
scope
.
$apply
(
attrs
.
todoBlur
);
});
});
};
};
});
});
architecture-examples/angularjs-perf/js/directives/todoFocus.js
View file @
bcc74618
/*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
(
$timeout
)
{
todomvc
.
directive
(
'
todoFocus
'
,
function
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newval
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newval
)
{
if
(
newval
)
{
if
(
newval
)
{
$timeout
(
function
()
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
elem
[
0
].
focus
();
},
0
,
false
);
},
0
,
false
);
}
}
});
});
};
};
});
});
architecture-examples/angularjs-perf/js/services/todoStorage.js
View file @
bcc74618
/*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-perf
'
;
var
STORAGE_ID
=
'
todos-angularjs-perf
'
;
return
{
return
{
get
:
function
()
{
get
:
function
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
},
},
put
:
function
(
todos
)
{
put
:
function
(
todos
)
{
localStorage
.
setItem
(
STORAGE_ID
,
JSON
.
stringify
(
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