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
6e43c8dd
Commit
6e43c8dd
authored
Feb 24, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AngularJS + require.js: jshint style
parent
9b5e8b15
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
174 additions
and
166 deletions
+174
-166
labs/dependency-examples/angularjs_require/index.html
labs/dependency-examples/angularjs_require/index.html
+72
-73
labs/dependency-examples/angularjs_require/js/app.js
labs/dependency-examples/angularjs_require/js/app.js
+2
-1
labs/dependency-examples/angularjs_require/js/controllers/todo.js
...endency-examples/angularjs_require/js/controllers/todo.js
+56
-52
labs/dependency-examples/angularjs_require/js/directives/todoBlur.js
...ency-examples/angularjs_require/js/directives/todoBlur.js
+9
-8
labs/dependency-examples/angularjs_require/js/directives/todoFocus.js
...ncy-examples/angularjs_require/js/directives/todoFocus.js
+13
-12
labs/dependency-examples/angularjs_require/js/main.js
labs/dependency-examples/angularjs_require/js/main.js
+10
-9
labs/dependency-examples/angularjs_require/js/services/todoStorage.js
...ncy-examples/angularjs_require/js/services/todoStorage.js
+12
-11
No files found.
labs/dependency-examples/angularjs_require/index.html
View file @
6e43c8dd
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
AngularJS • TodoMVC
</title>
<link
rel=
"stylesheet"
href=
"../../../assets/base.css"
>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
<!--[if IE]>
<script src="../../../assets/ie.js"></script>
<![endif]-->
<script>
// Include angular-loader to allow modules to be loaded in any order.
/*
AngularJS v1.0.2
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(
function
(
i
){
'
use strict
'
;
function
d
(
c
,
b
,
e
){
return
c
[
b
]
||
(
c
[
b
]
=
e
())}
return
d
(
d
(
i
,
"
angular
"
,
Object
),
"
module
"
,
function
(){
var
c
=
{};
return
function
(
b
,
e
,
f
){
e
&&
c
.
hasOwnProperty
(
b
)
&&
(
c
[
b
]
=
null
);
return
d
(
c
,
b
,
function
(){
function
a
(
a
,
b
,
d
){
return
function
(){
c
[
d
||
"
push
"
]([
a
,
b
,
arguments
]);
return
g
}}
if
(
!
e
)
throw
Error
(
"
No module:
"
+
b
);
var
c
=
[],
d
=
[],
h
=
a
(
"
$injector
"
,
"
invoke
"
),
g
=
{
_invokeQueue
:
c
,
_runBlocks
:
d
,
requires
:
e
,
name
:
b
,
provider
:
a
(
"
$provide
"
,
"
provider
"
),
factory
:
a
(
"
$provide
"
,
"
factory
"
),
service
:
a
(
"
$provide
"
,
"
service
"
),
value
:
a
(
"
$provide
"
,
"
value
"
),
constant
:
a
(
"
$provide
"
,
"
constant
"
,
"
unshift
"
),
filter
:
a
(
"
$filterProvider
"
,
"
register
"
),
controller
:
a
(
"
$controllerProvider
"
,
"
register
"
),
directive
:
a
(
"
$compileProvider
"
,
"
directive
"
),
config
:
h
,
run
:
function
(
a
){
d
.
push
(
a
);
return
this
}};
f
&&
h
(
f
);
return
g
})}})})(
window
);
</script>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
AngularJS • TodoMVC
</title>
<link
rel=
"stylesheet"
href=
"../../../assets/base.css"
>
<style>
[
ng-cloak
]
{
display
:
none
}
</style>
<!--[if IE]>
<script src="../../../assets/ie.js"></script>
<![endif]-->
<script>
// Include angular-loader to allow modules to be loaded in any order.
/*
AngularJS v1.0.2
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(
function
(
i
){
'
use strict
'
;
function
d
(
c
,
b
,
e
){
return
c
[
b
]
||
(
c
[
b
]
=
e
())}
return
d
(
d
(
i
,
"
angular
"
,
Object
),
"
module
"
,
function
(){
var
c
=
{};
return
function
(
b
,
e
,
f
){
e
&&
c
.
hasOwnProperty
(
b
)
&&
(
c
[
b
]
=
null
);
return
d
(
c
,
b
,
function
(){
function
a
(
a
,
b
,
d
){
return
function
(){
c
[
d
||
"
push
"
]([
a
,
b
,
arguments
]);
return
g
}}
if
(
!
e
)
throw
Error
(
"
No module:
"
+
b
);
var
c
=
[],
d
=
[],
h
=
a
(
"
$injector
"
,
"
invoke
"
),
g
=
{
_invokeQueue
:
c
,
_runBlocks
:
d
,
requires
:
e
,
name
:
b
,
provider
:
a
(
"
$provide
"
,
"
provider
"
),
factory
:
a
(
"
$provide
"
,
"
factory
"
),
service
:
a
(
"
$provide
"
,
"
service
"
),
value
:
a
(
"
$provide
"
,
"
value
"
),
constant
:
a
(
"
$provide
"
,
"
constant
"
,
"
unshift
"
),
filter
:
a
(
"
$filterProvider
"
,
"
register
"
),
controller
:
a
(
"
$controllerProvider
"
,
"
register
"
),
directive
:
a
(
"
$compileProvider
"
,
"
directive
"
),
config
:
h
,
run
:
function
(
a
){
d
.
push
(
a
);
return
this
}};
f
&&
h
(
f
);
return
g
})}})})(
window
);
</script>
</head>
<body>
<section
id=
"todoapp"
ng-controller=
"TodoController"
>
<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>
</header>
<section
id=
"main"
ng-show=
"todos.length"
ng-cloak
>
<input
id=
"toggle-all"
type=
"checkbox"
ng-model=
"allChecked"
ng-click=
"markAll(allChecked)"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
>
<li
ng-repeat=
"todo in todos | filter:statusFilter"
ng-class=
"{completed: todo.completed, editing: todo == editedTodo}"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
>
<label
ng-dblclick=
"editTodo(todo)"
>
{{todo.title}}
</label>
<button
class=
"destroy"
ng-click=
"removeTodo(todo)"
></button>
</div>
<form
ng-submit=
"doneEditing(todo)"
>
<input
class=
"edit"
ng-model=
"todo.title"
todo-blur=
"doneEditing(todo)"
todo-focus=
"todo == 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>
</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=
"clearDoneTodos()"
ng-show=
"remainingCount < todos.length"
>
Clear completed ({{todos.length - remainingCount}})
</button>
</footer>
</section>
<footer
id=
"info"
>
<p>
Double-click to edit a todo
</p>
<p>
Credits:
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
,
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
and
<a
href=
"http://twitter.com/passy"
>
Pascal Hartig
</a>
</p>
<p>
Part of
<a
href=
"http://todomvc.com"
>
TodoMVC
</a></p>
</footer>
<script
src=
"../../../assets/base.js"
></script>
<script
data-main=
"js/main"
src=
"../../../assets/require.min.js"
></script>
<section
id=
"todoapp"
ng-controller=
"TodoController"
>
<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>
</header>
<section
id=
"main"
ng-show=
"todos.length"
ng-cloak
>
<input
id=
"toggle-all"
type=
"checkbox"
ng-model=
"allChecked"
ng-click=
"markAll(allChecked)"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
>
<li
ng-repeat=
"todo in todos | filter:statusFilter"
ng-class=
"{completed: todo.completed, editing: todo == editedTodo}"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
ng-model=
"todo.completed"
>
<label
ng-dblclick=
"editTodo(todo)"
>
{{todo.title}}
</label>
<button
class=
"destroy"
ng-click=
"removeTodo(todo)"
></button>
</div>
<form
ng-submit=
"doneEditing(todo)"
>
<input
class=
"edit"
ng-model=
"todo.title"
todo-blur=
"doneEditing(todo)"
todo-focus=
"todo == 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>
</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=
"clearDoneTodos()"
ng-show=
"remainingCount < todos.length"
>
Clear completed ({{todos.length - remainingCount}})
</button>
</footer>
</section>
<footer
id=
"info"
>
<p>
Double-click to edit a todo
</p>
<p>
Credits:
<a
href=
"http://twitter.com/cburgdorf"
>
Christoph Burgdorf
</a>
,
<a
href=
"http://ericbidelman.com"
>
Eric Bidelman
</a>
,
<a
href=
"http://jacobmumm.com"
>
Jacob Mumm
</a>
,
<a
href=
"http://igorminar.com"
>
Igor Minar
</a>
and
<a
href=
"http://twitter.com/passy"
>
Pascal Hartig
</a>
</p>
<p>
Part of
<a
href=
"http://todomvc.com"
>
TodoMVC
</a></p>
</footer>
<script
src=
"../../../assets/base.js"
></script>
<script
data-main=
"js/main"
src=
"../../../assets/require.min.js"
></script>
</body>
</html>
labs/dependency-examples/angularjs_require/js/app.js
View file @
6e43c8dd
/*global define*/
'
use strict
'
;
define
([
'
angular
'
],
function
(
angular
)
{
return
angular
.
module
(
'
todomvc
'
,
[]);
return
angular
.
module
(
'
todomvc
'
,
[]);
});
labs/dependency-examples/angularjs_require/js/controllers/todo.js
View file @
6e43c8dd
/*global define*/
'
use strict
'
;
/**
...
...
@@ -7,74 +8,77 @@
*/
define
([
'
app
'
,
'
services/todoStorage
'
],
function
(
app
)
{
return
app
.
controller
(
'
TodoController
'
,
[
'
$scope
'
,
'
$location
'
,
'
todoStorage
'
,
'
filterFilter
'
,
function
TodoController
(
$scope
,
$location
,
todoStorage
,
filterFilter
)
{
var
todos
=
$scope
.
todos
=
todoStorage
.
get
();
return
app
.
controller
(
'
TodoController
'
,
[
'
$scope
'
,
'
$location
'
,
'
todoStorage
'
,
'
filterFilter
'
,
function
TodoController
(
$scope
,
$location
,
todoStorage
,
filterFilter
)
{
var
todos
=
$scope
.
todos
=
todoStorage
.
get
();
$scope
.
newTodo
=
""
;
$scope
.
editedTodo
=
null
;
$scope
.
newTodo
=
''
;
$scope
.
editedTodo
=
null
;
$scope
.
$watch
(
'
todos
'
,
function
()
{
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
doneCount
=
todos
.
length
-
$scope
.
remainingCount
;
$scope
.
allChecked
=
!
$scope
.
remainingCount
todoStorage
.
put
(
todos
);
},
true
);
$scope
.
$watch
(
'
todos
'
,
function
()
{
$scope
.
remainingCount
=
filterFilter
(
todos
,
{
completed
:
false
}).
length
;
$scope
.
doneCount
=
todos
.
length
-
$scope
.
remainingCount
;
$scope
.
allChecked
=
!
$scope
.
remainingCount
;
todoStorage
.
put
(
todos
);
},
true
);
if
(
$location
.
path
()
===
''
)
$location
.
path
(
'
/
'
);
$scope
.
location
=
$location
;
if
(
$location
.
path
()
===
''
)
{
$location
.
path
(
'
/
'
);
}
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
$scope
.
statusFilter
=
(
path
==
'
/active
'
)
?
{
completed
:
false
}
:
(
path
==
'
/completed
'
)
?
{
completed
:
true
}
:
null
;
});
$scope
.
location
=
$location
;
$scope
.
$watch
(
'
location.path()
'
,
function
(
path
)
{
$scope
.
statusFilter
=
(
path
===
'
/active
'
)
?
{
completed
:
false
}
:
(
path
===
'
/completed
'
)
?
{
completed
:
true
}
:
null
;
});
$scope
.
addTodo
=
function
()
{
if
(
!
$scope
.
newTodo
.
length
)
{
return
;
}
todos
.
push
(
{
title
:
$scope
.
newTodo
,
completed
:
false
});
$scope
.
addTodo
=
function
()
{
if
(
!
$scope
.
newTodo
.
length
)
{
return
;
}
$scope
.
newTodo
=
''
;
};
todos
.
push
({
title
:
$scope
.
newTodo
,
completed
:
false
});
$scope
.
newTodo
=
''
;
};
$scope
.
editTodo
=
function
(
todo
)
{
$scope
.
editedTodo
=
todo
;
};
$scope
.
editTodo
=
function
(
todo
)
{
$scope
.
editedTodo
=
todo
;
};
$scope
.
doneEditing
=
function
(
todo
)
{
$scope
.
editedTodo
=
null
;
if
(
!
todo
.
title
)
{
$scope
.
removeTodo
(
todo
);
}
};
$scope
.
doneEditing
=
function
(
todo
)
{
$scope
.
editedTodo
=
null
;
if
(
!
todo
.
title
)
{
$scope
.
removeTodo
(
todo
);
}
};
$scope
.
removeTodo
=
function
(
todo
)
{
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
};
$scope
.
removeTodo
=
function
(
todo
)
{
todos
.
splice
(
todos
.
indexOf
(
todo
),
1
);
};
$scope
.
clearDoneTodos
=
function
()
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
return
!
val
.
completed
;
});
};
$scope
.
clearDoneTodos
=
function
()
{
$scope
.
todos
=
todos
=
todos
.
filter
(
function
(
val
)
{
return
!
val
.
completed
;
});
};
$scope
.
markAll
=
function
(
done
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
done
;
});
};
}
]);
$scope
.
markAll
=
function
(
done
)
{
todos
.
forEach
(
function
(
todo
)
{
todo
.
completed
=
done
;
});
};
}
]);
});
labs/dependency-examples/angularjs_require/js/directives/todoBlur.js
View file @
6e43c8dd
/*global define*/
'
use strict
'
;
/**
* Directive that executes an expression when the element it is applied to loses focus.
*/
define
([
'
app
'
],
function
(
app
)
{
app
.
directive
(
'
todoBlur
'
,
function
()
{
return
function
(
scope
,
elem
,
attrs
)
{
elem
.
bind
(
'
blur
'
,
function
()
{
scope
.
$apply
(
attrs
.
todoBlur
);
});
};
});
define
([
'
app
'
],
function
(
app
)
{
app
.
directive
(
'
todoBlur
'
,
function
()
{
return
function
(
scope
,
elem
,
attrs
)
{
elem
.
bind
(
'
blur
'
,
function
()
{
scope
.
$apply
(
attrs
.
todoBlur
);
});
};
});
});
labs/dependency-examples/angularjs_require/js/directives/todoFocus.js
View file @
6e43c8dd
/*global define*/
'
use strict
'
;
/**
* Directive that places focus on the element it is applied to when the expression it binds to evaluates to true.
*/
define
([
'
app
'
],
function
(
app
)
{
app
.
directive
(
'
todoFocus
'
,
[
'
$timeout
'
,
function
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newval
)
{
if
(
newval
)
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
},
0
,
false
);
}
});
};
}]);
define
([
'
app
'
],
function
(
app
)
{
app
.
directive
(
'
todoFocus
'
,
[
'
$timeout
'
,
function
(
$timeout
)
{
return
function
(
scope
,
elem
,
attrs
)
{
scope
.
$watch
(
attrs
.
todoFocus
,
function
(
newval
)
{
if
(
newval
)
{
$timeout
(
function
()
{
elem
[
0
].
focus
();
},
0
,
false
);
}
});
};
}]);
});
labs/dependency-examples/angularjs_require/js/main.js
View file @
6e43c8dd
/*global require*/
'
use strict
'
;
require
.
config
({
paths
:
{
angular
:
'
libs/angular/angular.min
'
},
shim
:
{
angular
:
{
exports
:
'
angular
'
}
}
paths
:
{
angular
:
'
libs/angular/angular.min
'
},
shim
:
{
angular
:
{
exports
:
'
angular
'
}
}
});
require
([
'
angular
'
,
'
app
'
,
'
controllers/todo
'
,
'
directives/todoFocus
'
,
'
directives/todoBlur
'
],
function
(
angular
)
{
angular
.
bootstrap
(
document
,
[
'
todomvc
'
]);
angular
.
bootstrap
(
document
,
[
'
todomvc
'
]);
});
labs/dependency-examples/angularjs_require/js/services/todoStorage.js
View file @
6e43c8dd
/*global define*/
'
use strict
'
;
/**
* Services that persists and retrieves TODOs from localStorage.
*/
define
([
'
app
'
],
function
(
app
)
{
app
.
factory
(
'
todoStorage
'
,
function
()
{
var
STORAGE_ID
=
'
todos-angularjs-requirejs
'
;
app
.
factory
(
'
todoStorage
'
,
function
()
{
var
STORAGE_ID
=
'
todos-angularjs-requirejs
'
;
return
{
get
:
function
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
},
return
{
get
:
function
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
STORAGE_ID
)
||
'
[]
'
);
},
put
:
function
(
todos
)
{
localStorage
.
setItem
(
STORAGE_ID
,
JSON
.
stringify
(
todos
));
}
};
});
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