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
c3a471b8
Commit
c3a471b8
authored
Jun 24, 2012
by
Stas SUȘCOV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add routing support by setting a context filter.
`TodosController` will filter the content based on router's filter.
parent
127c55a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletion
+55
-1
dependency-examples/emberjs_require/js/app/controllers/todos.js
...ency-examples/emberjs_require/js/app/controllers/todos.js
+14
-0
dependency-examples/emberjs_require/js/app/router.js
dependency-examples/emberjs_require/js/app/router.js
+40
-0
dependency-examples/emberjs_require/js/app/views/items.js
dependency-examples/emberjs_require/js/app/views/items.js
+1
-1
No files found.
dependency-examples/emberjs_require/js/app/controllers/todos.js
View file @
c3a471b8
...
...
@@ -6,8 +6,22 @@ define('app/controllers/todos', [ 'ember' ],
*/
function
()
{
return
Ember
.
Controller
.
extend
({
entries
:
function
()
{
var
filter
=
this
.
getPath
(
'
content.filterBy
'
);
if
(
Ember
.
empty
(
filter
)
)
{
return
this
.
get
(
'
content
'
);
}
if
(
!
Ember
.
compare
(
filter
,
'
completed
'
)
)
{
return
this
.
get
(
'
content
'
).
filterProperty
(
'
completed
'
,
true
);
}
if
(
!
Ember
.
compare
(
filter
,
'
active
'
)
)
{
return
this
.
get
(
'
content
'
).
filterProperty
(
'
completed
'
,
false
);
}
}.
property
(
'
content.remaining
'
)
});
}
);
dependency-examples/emberjs_require/js/app/router.js
View file @
c3a471b8
...
...
@@ -20,7 +20,10 @@ define('app/router', [ 'ember' ],
connectOutlets
:
function
(
router
)
{
var
controller
=
router
.
get
(
'
applicationController
'
);
var
context
=
controller
.
namespace
.
entriesController
;
context
.
set
(
'
filterBy
'
,
''
);
// This require was left here exclusively for design purposes
// Loads decoupled controller/view based on current route
require
([
'
app/controllers/todos
'
,
'
app/views/items
'
],
function
(
TodosController
,
ItemsView
)
{
controller
.
connectOutlet
({
...
...
@@ -30,15 +33,52 @@ define('app/router', [ 'ember' ],
});
}
);
}
}),
active
:
Ember
.
Route
.
extend
({
route
:
'
/active
'
,
connectOutlets
:
function
(
router
)
{
var
controller
=
router
.
get
(
'
applicationController
'
);
var
context
=
controller
.
namespace
.
entriesController
;
context
.
set
(
'
filterBy
'
,
'
active
'
);
// This require was left here exclusively for design purposes
// Loads decoupled controller/view based on current route
require
([
'
app/controllers/todos
'
,
'
app/views/items
'
],
function
(
TodosController
,
ItemsView
)
{
controller
.
connectOutlet
({
viewClass
:
ItemsView
,
controller
:
TodosController
.
create
(),
context
:
context
});
}
);
}
}),
completed
:
Ember
.
Route
.
extend
({
route
:
'
/completed
'
,
connectOutlets
:
function
(
router
)
{
var
controller
=
router
.
get
(
'
applicationController
'
);
var
context
=
controller
.
namespace
.
entriesController
;
context
.
set
(
'
filterBy
'
,
'
completed
'
);
// This require was left here exclusively for design purposes
// Loads decoupled controller/view based on current route
require
([
'
app/controllers/todos
'
,
'
app/views/items
'
],
function
(
TodosController
,
ItemsView
)
{
controller
.
connectOutlet
({
viewClass
:
ItemsView
,
controller
:
TodosController
.
create
(),
context
:
context
});
}
);
}
}),
specs
:
Ember
.
Route
.
extend
({
...
...
dependency-examples/emberjs_require/js/app/views/items.js
View file @
c3a471b8
...
...
@@ -10,7 +10,7 @@ define('app/views/items', [
*/
function
(
items_html
)
{
return
Ember
.
CollectionView
.
extend
({
contentBinding
:
'
controller.
content
'
,
contentBinding
:
'
controller.
entries
'
,
tagName
:
'
ul
'
,
elementId
:
'
todo-list
'
,
itemViewClass
:
Ember
.
View
.
extend
({
...
...
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