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
757e78ae
Commit
757e78ae
authored
Sep 01, 2014
by
Sam Saccone
Committed by
Sindre Sorhus
Sep 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close GH-991: Fix Marionette Example to comply to spec 100%.
parent
79f5c1f9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
3377 additions
and
2252 deletions
+3377
-2252
labs/architecture-examples/backbone_marionette/bower.json
labs/architecture-examples/backbone_marionette/bower.json
+1
-1
labs/architecture-examples/backbone_marionette/bower_components/backbone.marionette/lib/backbone.marionette.js
...components/backbone.marionette/lib/backbone.marionette.js
+3328
-2227
labs/architecture-examples/backbone_marionette/index.html
labs/architecture-examples/backbone_marionette/index.html
+3
-3
labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js
...tecture-examples/backbone_marionette/js/TodoMVC.Layout.js
+4
-5
labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js
...examples/backbone_marionette/js/TodoMVC.TodoList.Views.js
+16
-14
labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.js
...cture-examples/backbone_marionette/js/TodoMVC.TodoList.js
+2
-1
labs/architecture-examples/backbone_marionette/js/TodoMVC.Todos.js
...itecture-examples/backbone_marionette/js/TodoMVC.Todos.js
+12
-0
labs/architecture-examples/backbone_marionette/js/TodoMVC.js
labs/architecture-examples/backbone_marionette/js/TodoMVC.js
+11
-1
No files found.
labs/architecture-examples/backbone_marionette/bower.json
View file @
757e78ae
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
"todomvc-common"
:
"~0.1.7"
,
"todomvc-common"
:
"~0.1.7"
,
"underscore"
:
"~1.4.4"
,
"underscore"
:
"~1.4.4"
,
"backbone.localStorage"
:
"~1.1.6"
,
"backbone.localStorage"
:
"~1.1.6"
,
"backbone.marionette"
:
"~
1.0.4
"
"backbone.marionette"
:
"~
2.1.0
"
}
}
}
}
labs/architecture-examples/backbone_marionette/bower_components/backbone.marionette/lib/backbone.marionette.js
View file @
757e78ae
This source diff could not be displayed because it is too large. You can
view the blob
instead.
labs/architecture-examples/backbone_marionette/index.html
View file @
757e78ae
...
@@ -27,13 +27,13 @@
...
@@ -27,13 +27,13 @@
<
/span
>
<
/span
>
<
ul
id
=
"
filters
"
>
<
ul
id
=
"
filters
"
>
<
li
class
=
"
all
"
>
<
li
class
=
"
all
"
>
<
a
href
=
"
#
"
>
All
<
/a
>
<
a
href
=
"
#
/
"
>
All
<
/a
>
<
/li
>
<
/li
>
<
li
class
=
"
active
"
>
<
li
class
=
"
active
"
>
<
a
href
=
"
#active
"
>
Active
<
/a
>
<
a
href
=
"
#
/
active
"
>
Active
<
/a
>
<
/li
>
<
/li
>
<
li
class
=
"
completed
"
>
<
li
class
=
"
completed
"
>
<
a
href
=
"
#completed
"
>
Completed
<
/a
>
<
a
href
=
"
#
/
completed
"
>
Completed
<
/a
>
<
/li
>
<
/li
>
<
/ul
>
<
/ul
>
<
button
id
=
"
clear-completed
"
<%
if
(
!
completedCount
)
{
%>
class
=
"
hidden
"
<%
}
%>>
<
button
id
=
"
clear-completed
"
<%
if
(
!
completedCount
)
{
%>
class
=
"
hidden
"
<%
}
%>>
...
...
labs/architecture-examples/backbone_marionette/js/TodoMVC.Layout.js
View file @
757e78ae
...
@@ -60,7 +60,7 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
...
@@ -60,7 +60,7 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
},
},
initialize
:
function
()
{
initialize
:
function
()
{
this
.
listenTo
(
App
.
vent
,
'
todoList
:filter
'
,
this
.
updateFilterSelection
,
this
);
this
.
listenTo
(
App
.
request
(
'
filterState
'
),
'
change
:filter
'
,
this
.
updateFilterSelection
,
this
);
},
},
serializeData
:
function
()
{
serializeData
:
function
()
{
...
@@ -80,9 +80,8 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
...
@@ -80,9 +80,8 @@ TodoMVC.module('Layout', function (Layout, App, Backbone) {
},
},
updateFilterSelection
:
function
()
{
updateFilterSelection
:
function
()
{
this
.
ui
.
filters
this
.
ui
.
filters
.
removeClass
(
'
selected
'
);
.
removeClass
(
'
selected
'
)
this
.
ui
[
App
.
request
(
'
filterState
'
).
get
(
'
filter
'
)]
.
filter
(
'
[href="
'
+
(
location
.
hash
||
'
#
'
)
+
'
"]
'
)
.
addClass
(
'
selected
'
);
.
addClass
(
'
selected
'
);
},
},
...
...
labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.Views.js
View file @
757e78ae
...
@@ -16,7 +16,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
...
@@ -16,7 +16,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
},
},
events
:
{
events
:
{
'
click .destroy
'
:
'
de
stroy
'
,
'
click .destroy
'
:
'
de
leteModel
'
,
'
dblclick label
'
:
'
onEditClick
'
,
'
dblclick label
'
:
'
onEditClick
'
,
'
keydown .edit
'
:
'
onEditKeypress
'
,
'
keydown .edit
'
:
'
onEditKeypress
'
,
'
focusout .edit
'
:
'
onEditFocusout
'
,
'
focusout .edit
'
:
'
onEditFocusout
'
,
...
@@ -37,7 +37,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
...
@@ -37,7 +37,7 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
}
}
},
},
de
stroy
:
function
()
{
de
leteModel
:
function
()
{
this
.
model
.
destroy
();
this
.
model
.
destroy
();
},
},
...
@@ -83,8 +83,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
...
@@ -83,8 +83,8 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
// filtering of activs vs completed items for display.
// filtering of activs vs completed items for display.
Views
.
ListView
=
Backbone
.
Marionette
.
CompositeView
.
extend
({
Views
.
ListView
=
Backbone
.
Marionette
.
CompositeView
.
extend
({
template
:
'
#template-todoListCompositeView
'
,
template
:
'
#template-todoListCompositeView
'
,
item
View
:
Views
.
ItemView
,
child
View
:
Views
.
ItemView
,
item
ViewContainer
:
'
#todo-list
'
,
child
ViewContainer
:
'
#todo-list
'
,
ui
:
{
ui
:
{
toggle
:
'
#toggle-all
'
toggle
:
'
#toggle-all
'
...
@@ -98,6 +98,18 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
...
@@ -98,6 +98,18 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
'
all
'
:
'
update
'
'
all
'
:
'
update
'
},
},
initialize
:
function
()
{
this
.
listenTo
(
App
.
request
(
'
filterState
'
),
'
change:filter
'
,
this
.
render
,
this
);
},
addChild
:
function
(
child
)
{
var
filteredOn
=
App
.
request
(
'
filterState
'
).
get
(
'
filter
'
);
if
(
child
.
matchesFilter
(
filteredOn
))
{
Backbone
.
Marionette
.
CompositeView
.
prototype
.
addChild
.
apply
(
this
,
arguments
);
}
},
onRender
:
function
()
{
onRender
:
function
()
{
this
.
update
();
this
.
update
();
},
},
...
@@ -121,14 +133,4 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
...
@@ -121,14 +133,4 @@ TodoMVC.module('TodoList.Views', function (Views, App, Backbone, Marionette, $)
});
});
}
}
});
});
// Application Event Handlers
// --------------------------
//
// Handler for filtering the list of items by showing and
// hiding through the use of various CSS classes
App
.
vent
.
on
(
'
todoList:filter
'
,
function
(
filter
)
{
filter
=
filter
||
'
all
'
;
$
(
'
#todoapp
'
).
attr
(
'
class
'
,
'
filter-
'
+
filter
);
});
});
});
labs/architecture-examples/backbone_marionette/js/TodoMVC.TodoList.js
View file @
757e78ae
...
@@ -53,7 +53,8 @@ TodoMVC.module('TodoList', function (TodoList, App, Backbone, Marionette, $, _)
...
@@ -53,7 +53,8 @@ TodoMVC.module('TodoList', function (TodoList, App, Backbone, Marionette, $, _)
// Set the filter to show complete or all items
// Set the filter to show complete or all items
filterItems
:
function
(
filter
)
{
filterItems
:
function
(
filter
)
{
App
.
vent
.
trigger
(
'
todoList:filter
'
,
(
filter
&&
filter
.
trim
())
||
''
);
var
newFilter
=
filter
&&
filter
.
trim
()
||
'
all
'
;
App
.
request
(
'
filterState
'
).
set
(
'
filter
'
,
newFilter
);
}
}
});
});
...
...
labs/architecture-examples/backbone_marionette/js/TodoMVC.Todos.js
View file @
757e78ae
...
@@ -23,6 +23,18 @@ TodoMVC.module('Todos', function (Todos, App, Backbone) {
...
@@ -23,6 +23,18 @@ TodoMVC.module('Todos', function (Todos, App, Backbone) {
isCompleted
:
function
()
{
isCompleted
:
function
()
{
return
this
.
get
(
'
completed
'
);
return
this
.
get
(
'
completed
'
);
},
matchesFilter
:
function
(
filter
)
{
if
(
filter
==
'
all
'
)
{
return
true
;
}
if
(
filter
==
'
active
'
)
{
return
!
this
.
isCompleted
();
}
return
this
.
isCompleted
();
}
}
});
});
...
...
labs/architecture-examples/backbone_marionette/js/TodoMVC.js
View file @
757e78ae
...
@@ -5,12 +5,22 @@
...
@@ -5,12 +5,22 @@
// and functional testing.
// and functional testing.
window
.
TodoMVC
=
new
Backbone
.
Marionette
.
Application
();
window
.
TodoMVC
=
new
Backbone
.
Marionette
.
Application
();
(
function
()
{
var
filterState
=
new
Backbone
.
Model
({
filter
:
'
all
'
});
TodoMVC
.
reqres
.
setHandler
(
'
filterState
'
,
function
()
{
return
filterState
;
});
})();
TodoMVC
.
addRegions
({
TodoMVC
.
addRegions
({
header
:
'
#header
'
,
header
:
'
#header
'
,
main
:
'
#main
'
,
main
:
'
#main
'
,
footer
:
'
#footer
'
footer
:
'
#footer
'
});
});
TodoMVC
.
on
(
'
initialize:after
'
,
function
()
{
TodoMVC
.
on
(
'
start
'
,
function
()
{
Backbone
.
history
.
start
();
Backbone
.
history
.
start
();
});
});
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