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
52f2a8a1
Commit
52f2a8a1
authored
Sep 22, 2012
by
Ryan Eastridge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
always use window.app
parent
e67022dd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
24 deletions
+17
-24
labs/architecture-examples/thorax/index.html
labs/architecture-examples/thorax/index.html
+3
-0
labs/architecture-examples/thorax/js/collections/todos.js
labs/architecture-examples/thorax/js/collections/todos.js
+2
-4
labs/architecture-examples/thorax/js/models/todo.js
labs/architecture-examples/thorax/js/models/todo.js
+4
-6
labs/architecture-examples/thorax/js/routers/router.js
labs/architecture-examples/thorax/js/routers/router.js
+1
-3
labs/architecture-examples/thorax/js/views/app.js
labs/architecture-examples/thorax/js/views/app.js
+4
-6
labs/architecture-examples/thorax/js/views/stats.js
labs/architecture-examples/thorax/js/views/stats.js
+3
-3
labs/architecture-examples/thorax/js/views/todo-item.js
labs/architecture-examples/thorax/js/views/todo-item.js
+0
-2
No files found.
labs/architecture-examples/thorax/index.html
View file @
52f2a8a1
...
...
@@ -68,6 +68,9 @@
app
:
Handlebars
.
compile
(
$
(
'
script[data-template-name="app"]
'
).
html
()),
stats
:
Handlebars
.
compile
(
$
(
'
script[data-template-name="stats"]
'
).
html
())
};
//initialize the app object
window
.
app
=
{};
</script>
<script
src=
"js/models/todo.js"
></script>
<script
src=
"js/collections/todos.js"
></script>
...
...
labs/architecture-examples/thorax/js/collections/todos.js
View file @
52f2a8a1
var
app
=
app
||
{};
(
function
()
{
'
use strict
'
;
...
...
@@ -11,7 +9,7 @@ var app = app || {};
var
TodoList
=
Backbone
.
Collection
.
extend
({
// Reference to this collection's model.
model
:
app
.
Todo
,
model
:
window
.
app
.
Todo
,
// Save all of the todo items under the `"todos"` namespace.
localStorage
:
new
Store
(
'
todos-backbone
'
),
...
...
@@ -44,6 +42,6 @@ var app = app || {};
});
// Create our global collection of **Todos**.
app
.
Todos
=
new
TodoList
();
window
.
app
.
Todos
=
new
TodoList
();
}());
labs/architecture-examples/thorax/js/models/todo.js
View file @
52f2a8a1
var
app
=
app
||
{};
(
function
()
{
'
use strict
'
;
...
...
@@ -7,7 +5,7 @@ var app = app || {};
// ----------
// Our basic **Todo** model has `title`, `order`, and `completed` attributes.
app
.
Todo
=
Backbone
.
Model
.
extend
({
window
.
app
.
Todo
=
Backbone
.
Model
.
extend
({
// Default attributes for the todo
// and ensure that each todo created has `title` and `completed` keys.
...
...
@@ -25,11 +23,11 @@ var app = app || {};
isVisible
:
function
()
{
var
isCompleted
=
this
.
get
(
'
completed
'
);
if
(
app
.
TodoFilter
===
''
)
{
if
(
window
.
app
.
TodoFilter
===
''
)
{
return
true
;
}
else
if
(
app
.
TodoFilter
===
'
completed
'
)
{
}
else
if
(
window
.
app
.
TodoFilter
===
'
completed
'
)
{
return
isCompleted
;
}
else
if
(
app
.
TodoFilter
===
'
active
'
)
{
}
else
if
(
window
.
app
.
TodoFilter
===
'
active
'
)
{
return
!
isCompleted
;
}
}
...
...
labs/architecture-examples/thorax/js/routers/router.js
View file @
52f2a8a1
var
app
=
app
||
{};
(
function
()
{
'
use strict
'
;
// Todo Router
// ----------
app
.
TodoRouter
=
new
(
Thorax
.
Router
.
extend
({
window
.
app
.
TodoRouter
=
new
(
Thorax
.
Router
.
extend
({
routes
:
{
''
:
'
setFilter
'
,
'
:filter
'
:
'
setFilter
'
...
...
labs/architecture-examples/thorax/js/views/app.js
View file @
52f2a8a1
var
app
=
app
||
{};
$
(
function
(
$
)
{
'
use strict
'
;
...
...
@@ -30,7 +28,7 @@ $(function( $ ) {
// global Todos collection available to the template.
// Load any preexisting todos that might be saved in *localStorage*.
initialize
:
function
()
{
this
.
todosCollection
=
app
.
Todos
;
this
.
todosCollection
=
window
.
app
.
Todos
;
this
.
todosCollection
.
fetch
();
this
.
render
();
},
...
...
@@ -50,7 +48,7 @@ $(function( $ ) {
newAttributes
:
function
()
{
return
{
title
:
this
.
$
(
'
#new-todo
'
).
val
().
trim
(),
order
:
app
.
Todos
.
nextOrder
(),
order
:
window
.
app
.
Todos
.
nextOrder
(),
completed
:
false
};
},
...
...
@@ -62,14 +60,14 @@ $(function( $ ) {
return
;
}
app
.
Todos
.
create
(
this
.
newAttributes
()
);
window
.
app
.
Todos
.
create
(
this
.
newAttributes
()
);
this
.
$
(
'
#new-todo
'
).
val
(
''
);
},
toggleAllComplete
:
function
()
{
var
completed
=
this
.
$
(
'
#toggle-all
'
)[
0
].
checked
;
app
.
Todos
.
each
(
function
(
todo
)
{
window
.
app
.
Todos
.
each
(
function
(
todo
)
{
todo
.
save
({
'
completed
'
:
completed
});
...
...
labs/architecture-examples/thorax/js/views/stats.js
View file @
52f2a8a1
...
...
@@ -31,10 +31,10 @@ Thorax.View.extend({
// be called to generate the context / scope that the template
// will be called with. "context" defaults to "return this"
context
:
function
()
{
var
remaining
=
app
.
Todos
.
remaining
().
length
;
var
remaining
=
window
.
app
.
Todos
.
remaining
().
length
;
return
{
itemText
:
remaining
===
1
?
'
item
'
:
'
items
'
,
completed
:
app
.
Todos
.
completed
().
length
,
completed
:
window
.
app
.
Todos
.
completed
().
length
,
remaining
:
remaining
};
},
...
...
@@ -43,7 +43,7 @@ Thorax.View.extend({
highlightFilter
:
function
()
{
this
.
$
(
'
#filters li a
'
)
.
removeClass
(
'
selected
'
)
.
filter
(
'
[href="#/
'
+
(
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
filter
(
'
[href="#/
'
+
(
window
.
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
addClass
(
'
selected
'
);
}
});
\ No newline at end of file
labs/architecture-examples/thorax/js/views/todo-item.js
View file @
52f2a8a1
var
app
=
app
||
{};
$
(
function
()
{
'
use strict
'
;
...
...
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