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
508bc8a3
Commit
508bc8a3
authored
Jan 02, 2013
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #371 from hornairs/fix-355
Fix Issue #355 in Batman with a dynamic binding
parents
4a811d58
14f77b25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
24 deletions
+31
-24
labs/architecture-examples/batman/js/app.coffee
labs/architecture-examples/batman/js/app.coffee
+16
-11
labs/architecture-examples/batman/js/app.js
labs/architecture-examples/batman/js/app.js
+15
-13
No files found.
labs/architecture-examples/batman/js/app.coffee
View file @
508bc8a3
class
Alfred
extends
Batman
.
App
@
root
'todos#all'
@
route
'/completed'
,
'todos#completed'
@
route
'/active'
,
'todos#active'
@
root
'todos#all'
@
route
'/completed'
,
'todos#completed'
@
route
'/active'
,
'todos#active'
class
Alfred
.
TodosController
extends
Batman
.
Controller
constructor
:
->
super
@
set
'newTodo'
,
new
Alfred
.
Todo
(
completed
:
false
)
super
@
set
(
'newTodo'
,
new
Alfred
.
Todo
(
completed
:
false
)
)
all
:
->
@
set
'currentTodos'
,
Alfred
.
Todo
.
get
(
'all'
)
routingKey
:
'todos'
currentTodoSet
:
'all'
@
accessor
'currentTodos'
,
->
Alfred
.
Todo
.
get
(
@
get
(
'currentTodoSet'
))
all
:
->
@
set
(
'currentTodoSet'
,
'all'
)
completed
:
->
@
set
'currentTodo
s'
,
Alfred
.
Todo
.
get
(
'completed'
)
@
render
source
:
'todos/all'
@
set
'currentTodo
Set'
,
'completed'
@
render
(
source
:
'todos/all'
)
active
:
->
@
set
'currentTodo
s'
,
Alfred
.
Todo
.
get
(
'active'
)
@
render
source
:
'todos/all'
@
set
'currentTodo
Set'
,
'active'
@
render
(
source
:
'todos/all'
)
createTodo
:
->
@
get
(
'newTodo'
).
save
(
err
,
todo
)
=>
...
...
labs/architecture-examples/batman/js/app.js
View file @
508bc8a3
// Generated by CoffeeScript 1.3.
1
// Generated by CoffeeScript 1.3.
3
(
function
()
{
var
Alfred
,
__hasProp
=
{}.
hasOwnProperty
,
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
;
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
__extends
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
__hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
()
;
child
.
__super__
=
parent
.
prototype
;
return
child
;
};
Alfred
=
(
function
(
_super
)
{
__extends
(
Alfred
,
_super
);
Alfred
.
name
=
'
Alfred
'
;
function
Alfred
()
{
return
Alfred
.
__super__
.
constructor
.
apply
(
this
,
arguments
);
}
...
...
@@ -28,8 +26,6 @@
__extends
(
TodosController
,
_super
);
TodosController
.
name
=
'
TodosController
'
;
function
TodosController
()
{
TodosController
.
__super__
.
constructor
.
apply
(
this
,
arguments
);
this
.
set
(
'
newTodo
'
,
new
Alfred
.
Todo
({
...
...
@@ -37,19 +33,27 @@
}));
}
TodosController
.
prototype
.
all
=
function
()
{
return
this
.
set
(
'
currentTodos
'
,
Alfred
.
Todo
.
get
(
'
all
'
));
};
TodosController
.
prototype
.
routingKey
=
'
todos
'
;
TodosController
.
prototype
.
currentTodoSet
=
'
all
'
;
TodosController
.
accessor
(
'
currentTodos
'
,
function
()
{
return
Alfred
.
Todo
.
get
(
this
.
get
(
'
currentTodoSet
'
));
});
TodosController
.
prototype
.
all
=
function
()
{};
TodosController
.
set
(
'
currentTodoSet
'
,
'
all
'
);
TodosController
.
prototype
.
completed
=
function
()
{
this
.
set
(
'
currentTodo
s
'
,
Alfred
.
Todo
.
get
(
'
completed
'
)
);
this
.
set
(
'
currentTodo
Set
'
,
'
completed
'
);
return
this
.
render
({
source
:
'
todos/all
'
});
};
TodosController
.
prototype
.
active
=
function
()
{
this
.
set
(
'
currentTodo
s
'
,
Alfred
.
Todo
.
get
(
'
active
'
)
);
this
.
set
(
'
currentTodo
Set
'
,
'
active
'
);
return
this
.
render
({
source
:
'
todos/all
'
});
...
...
@@ -150,8 +154,6 @@
__extends
(
Todo
,
_super
);
Todo
.
name
=
'
Todo
'
;
function
Todo
()
{
return
Todo
.
__super__
.
constructor
.
apply
(
this
,
arguments
);
}
...
...
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