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
1abd9579
Commit
1abd9579
authored
Jul 25, 2015
by
Arthur Verschaeve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Thorax-lumbar: fix JSCS errors
parent
334e9f61
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
158 additions
and
158 deletions
+158
-158
examples/thorax_lumbar/public/base.js
examples/thorax_lumbar/public/base.js
+3
-3
examples/thorax_lumbar/public/todomvc.js
examples/thorax_lumbar/public/todomvc.js
+79
-79
examples/thorax_lumbar/src/js/app.js
examples/thorax_lumbar/src/js/app.js
+6
-6
examples/thorax_lumbar/src/js/collections/todos.js
examples/thorax_lumbar/src/js/collections/todos.js
+3
-3
examples/thorax_lumbar/src/js/init.js
examples/thorax_lumbar/src/js/init.js
+3
-3
examples/thorax_lumbar/src/js/models/todo.js
examples/thorax_lumbar/src/js/models/todo.js
+2
-2
examples/thorax_lumbar/src/js/routers/todomvc.js
examples/thorax_lumbar/src/js/routers/todomvc.js
+2
-2
examples/thorax_lumbar/src/js/views/app.js
examples/thorax_lumbar/src/js/views/app.js
+9
-9
examples/thorax_lumbar/src/js/views/stats.js
examples/thorax_lumbar/src/js/views/stats.js
+41
-41
examples/thorax_lumbar/src/js/views/todo-item.js
examples/thorax_lumbar/src/js/views/todo-item.js
+10
-10
No files found.
examples/thorax_lumbar/public/base.js
View file @
1abd9579
...
...
@@ -17281,7 +17281,7 @@ Thorax.templatePathPrefix = 'src/templates/';
var
app
=
window
.
app
=
module
.
exports
;
$
(
function
()
{
$
(
function
()
{
app
.
initBackboneLoader
();
Backbone
.
history
.
start
();
});
...
...
examples/thorax_lumbar/public/todomvc.js
View file @
1abd9579
...
...
@@ -7,7 +7,7 @@ Application['todomvc'] = (function() {
/* router : todomvc */
module
.
name
=
"
todomvc
"
;
module
.
routes
=
{
""
:
"
setFilter
"
,
"
:filter
"
:
"
setFilter
"
};
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Model
...
...
@@ -24,7 +24,7 @@ module.routes = {"":"setFilter",":filter":"setFilter"};
},
// Toggle the `completed` state of this todo item.
toggle
:
function
()
{
toggle
:
function
()
{
this
.
save
({
completed
:
!
this
.
get
(
'
completed
'
)
});
...
...
@@ -46,7 +46,7 @@ module.routes = {"":"setFilter",":filter":"setFilter"};
}());
;;
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Collection
...
...
@@ -91,7 +91,7 @@ module.routes = {"":"setFilter",":filter":"setFilter"};
}());
;;
$
(
function
()
{
$
(
function
()
{
'
use strict
'
;
// Todo Item View
...
...
@@ -116,27 +116,27 @@ $(function() {
// The "rendered" event is triggered by Thorax each time render()
// is called and the result of the template has been appended
// to the View's $el
rendered
:
function
()
{
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
rendered
:
function
()
{
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
}
},
// Toggle the `"completed"` state of the model.
toggleCompleted
:
function
()
{
toggleCompleted
:
function
()
{
this
.
model
.
toggle
();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
$
(
'
.edit
'
).
focus
();
},
// Close the `"editing"` mode, saving changes to the todo.
close
:
function
()
{
close
:
function
()
{
var
value
=
this
.
$
(
'
.edit
'
).
val
().
trim
();
if
(
value
)
{
if
(
value
)
{
this
.
model
.
save
({
title
:
value
});
}
else
{
this
.
clear
();
...
...
@@ -146,14 +146,14 @@ $(function() {
},
// If you hit `enter`, we're through editing the item.
updateOnEnter
:
function
(
e
)
{
if
(
e
.
which
===
ENTER_KEY
)
{
updateOnEnter
:
function
(
e
)
{
if
(
e
.
which
===
ENTER_KEY
)
{
this
.
close
();
}
},
// Remove the item, destroy the model from *localStorage* and delete its view.
clear
:
function
()
{
clear
:
function
()
{
this
.
model
.
destroy
();
}
});
...
...
@@ -171,18 +171,18 @@ Thorax.templates['src/templates/stats'] = Handlebars.compile('<span id=\"todo-co
rendered
:
'
highlightFilter
'
},
initialize
:
function
()
{
initialize
:
function
()
{
// Whenever the Todos collection changes re-render the stats
// render() needs to be called with no arguments, otherwise calling
// it with arguments will insert the arguments as content
this
.
listenTo
(
window
.
app
.
Todos
,
'
all
'
,
_
.
debounce
(
function
()
{
this
.
listenTo
(
window
.
app
.
Todos
,
'
all
'
,
_
.
debounce
(
function
()
{
this
.
render
();
}));
},
// Clear all completed todo items, destroying their models.
clearCompleted
:
function
()
{
_
.
each
(
window
.
app
.
Todos
.
completed
(),
function
(
todo
)
{
clearCompleted
:
function
()
{
_
.
each
(
window
.
app
.
Todos
.
completed
(),
function
(
todo
)
{
todo
.
destroy
();
});
...
...
@@ -192,7 +192,7 @@ Thorax.templates['src/templates/stats'] = Handlebars.compile('<span id=\"todo-co
// Each time the stats view is rendered this function will
// be called to generate the context / scope that the template
// will be called with. "context" defaults to "return this"
context
:
function
()
{
context
:
function
()
{
var
remaining
=
window
.
app
.
Todos
.
remaining
().
length
;
return
{
itemText
:
remaining
===
1
?
'
item
'
:
'
items
'
,
...
...
@@ -202,16 +202,16 @@ Thorax.templates['src/templates/stats'] = Handlebars.compile('<span id=\"todo-co
},
// Highlight which filter will appear to be active
highlightFilter
:
function
()
{
highlightFilter
:
function
()
{
this
.
$
(
'
#filters li a
'
)
.
removeClass
(
'
selected
'
)
.
filter
(
'
[href="#/
'
+
(
window
.
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
filter
(
'
[href="#/
'
+
(
window
.
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
addClass
(
'
selected
'
);
}
});
;;
Thorax
.
templates
[
'
src/templates/app
'
]
=
Handlebars
.
compile
(
'
<section id=
\
"todoapp
\
">
\n
<header id=
\
"header
\
">
\n
<h1>todos</h1>
\n
<input id=
\
"new-todo
\
" placeholder=
\
"What needs to be done?
\
" autofocus>
\n
</header>
\n
{{^empty collection}}
\n
<section id=
\
"main
\
">
\n
<input id=
\
"toggle-all
\
" type=
\
"checkbox
\
">
\n
<label for=
\
"toggle-all
\
">Mark all as complete</label>
\n
{{#collection item-view=
\
"todo-item
\
" tag=
\
"ul
\
" id=
\
"todo-list
\
"}}
\n
<div class=
\
"view
\
">
\n
<input class=
\
"toggle
\
" type=
\
"checkbox
\
" {{#if completed}}checked=
\
"checked
\
"{{/if}}>
\n
<label>{{title}}</label>
\n
<button class=
\
"destroy
\
"></button>
\n
</div>
\n
<input class=
\
"edit
\
" value=
\
"{{title}}
\
">
\n
{{/collection}}
\n
</section>
\n
{{view
\
"stats
\
" tag=
\
"footer
\
" id=
\
"footer
\
"}}
\n
{{/empty}}
\n
</section>
\n
<div id=
\
"info
\
">
\n
<p>Double-click to edit a todo</p>
\n
<p>Written by <a href=
\
"https://github.com/addyosmani
\
">Addy Osmani</a> & <a href=
\
"https://github.com/eastridge
\
">Ryan Eastridge</a></p>
\n
<p>Part of <a href=
\
"http://todomvc.com
\
">TodoMVC</a></p>
\n
</div>
\n
'
);
$
(
function
(
$
)
{
Thorax
.
templates
[
'
src/templates/app
'
]
=
Handlebars
.
compile
(
'
<section id=
\
"todoapp
\
">
\n
<header id=
\
"header
\
">
\n
<h1>todos</h1>
\n
<input id=
\
"new-todo
\
" placeholder=
\
"What needs to be done?
\
" autofocus>
\n
</header>
\n
{{^empty collection}}
\n
<section id=
\
"main
\
">
\n
<input id=
\
"toggle-all
\
" type=
\
"checkbox
\
">
\n
<label for=
\
"toggle-all
\
">Mark all as complete</label>
\n
{{#collection item-view=
\
"todo-item
\
" tag=
\
"ul
\
" id=
\
"todo-list
\
"}}
\n
<div class=
\
"view
\
">
\n
<input class=
\
"toggle
\
" type=
\
"checkbox
\
" {{#if completed}}checked=
\
"checked
\
"{{/if}}>
\n
<label>{{title}}</label>
\n
<button class=
\
"destroy
\
"></button>
\n
</div>
\n
<input class=
\
"edit
\
" value=
\
"{{title}}
\
">
\n
{{/collection}}
\n
</section>
\n
{{view
\
"stats
\
" tag=
\
"footer
\
" id=
\
"footer
\
"}}
\n
{{/empty}}
\n
</section>
\n
<div id=
\
"info
\
">
\n
<p>Double-click to edit a todo</p>
\n
<p>Written by <a href=
\
"https://github.com/addyosmani
\
">Addy Osmani</a> & <a href=
\
"https://github.com/eastridge
\
">Ryan Eastridge</a></p>
\n
<p>Part of <a href=
\
"http://todomvc.com
\
">TodoMVC</a></p>
\n
</div>
\n
'
);
$
(
function
(
$
)
{
'
use strict
'
;
// The Application
...
...
@@ -236,7 +236,7 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
rendered
:
'
toggleToggleAllButton
'
},
toggleToggleAllButton
:
function
()
{
toggleToggleAllButton
:
function
()
{
var
toggleInput
=
this
.
$
(
'
#toggle-all
'
)[
0
];
if
(
toggleInput
)
{
toggleInput
.
checked
=
!
this
.
collection
.
remaining
().
length
;
...
...
@@ -245,12 +245,12 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
// When this function is specified, items will only be shown
// when this function returns true
itemFilter
:
function
(
model
)
{
itemFilter
:
function
(
model
)
{
return
model
.
isVisible
();
},
// Generate the attributes for a new Todo item.
newAttributes
:
function
()
{
newAttributes
:
function
()
{
return
{
title
:
this
.
$
(
'
#new-todo
'
).
val
().
trim
(),
order
:
this
.
collection
.
nextOrder
(),
...
...
@@ -260,18 +260,18 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter
:
function
(
e
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
(
'
#new-todo
'
).
val
().
trim
()
)
{
createOnEnter
:
function
(
e
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
(
'
#new-todo
'
).
val
().
trim
()
)
{
return
;
}
this
.
collection
.
create
(
this
.
newAttributes
()
);
this
.
collection
.
create
(
this
.
newAttributes
()
);
this
.
$
(
'
#new-todo
'
).
val
(
''
);
},
toggleAllComplete
:
function
()
{
toggleAllComplete
:
function
()
{
var
completed
=
this
.
$
(
'
#toggle-all
'
)[
0
].
checked
;
this
.
collection
.
each
(
function
(
todo
)
{
this
.
collection
.
each
(
function
(
todo
)
{
todo
.
save
({
completed
:
completed
});
...
...
@@ -281,7 +281,7 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
});
;;
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Router
...
...
@@ -293,7 +293,7 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
name
:
module
.
name
,
routes
:
module
.
routes
,
setFilter
:
function
(
param
)
{
setFilter
:
function
(
param
)
{
// Set the current filter to be used
window
.
app
.
TodoFilter
=
param
?
param
.
trim
().
replace
(
/^
\/
/
,
''
)
:
''
;
// Thorax listens for a `filter` event which will
...
...
@@ -307,9 +307,9 @@ Thorax.templates['src/templates/app'] = Handlebars.compile('<section id=\"todoap
;;
var
ENTER_KEY
=
13
;
$
(
function
()
{
$
(
function
()
{
// Kick things off by creating the **App**.
var
view
=
new
Thorax
.
Views
[
'
app
'
]
({
var
view
=
new
Thorax
.
Views
.
app
({
collection
:
window
.
app
.
Todos
});
view
.
appendTo
(
'
body
'
);
...
...
examples/thorax_lumbar/src/js/app.js
View file @
1abd9579
var
ENTER_KEY
=
13
;
$
(
function
()
{
$
(
function
()
{
// Kick things off by creating the **App**.
var
view
=
new
Thorax
.
Views
[
'
app
'
]
({
var
view
=
new
Thorax
.
Views
.
app
({
collection
:
window
.
app
.
Todos
});
view
.
appendTo
(
'
body
'
);
...
...
examples/thorax_lumbar/src/js/collections/todos.js
View file @
1abd9579
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Collection
...
...
examples/thorax_lumbar/src/js/init.js
View file @
1abd9579
...
...
@@ -3,7 +3,7 @@ Thorax.templatePathPrefix = 'src/templates/';
var
app
=
window
.
app
=
module
.
exports
;
$
(
function
()
{
$
(
function
()
{
app
.
initBackboneLoader
();
Backbone
.
history
.
start
();
});
examples/thorax_lumbar/src/js/models/todo.js
View file @
1abd9579
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Model
...
...
@@ -15,7 +15,7 @@
},
// Toggle the `completed` state of this todo item.
toggle
:
function
()
{
toggle
:
function
()
{
this
.
save
({
completed
:
!
this
.
get
(
'
completed
'
)
});
...
...
examples/thorax_lumbar/src/js/routers/todomvc.js
View file @
1abd9579
(
function
()
{
(
function
()
{
'
use strict
'
;
// Todo Router
...
...
@@ -10,7 +10,7 @@
name
:
module
.
name
,
routes
:
module
.
routes
,
setFilter
:
function
(
param
)
{
setFilter
:
function
(
param
)
{
// Set the current filter to be used
window
.
app
.
TodoFilter
=
param
?
param
.
trim
().
replace
(
/^
\/
/
,
''
)
:
''
;
// Thorax listens for a `filter` event which will
...
...
examples/thorax_lumbar/src/js/views/app.js
View file @
1abd9579
$
(
function
(
$
)
{
$
(
function
(
$
)
{
'
use strict
'
;
// The Application
...
...
@@ -23,7 +23,7 @@ $(function( $ ) {
rendered
:
'
toggleToggleAllButton
'
},
toggleToggleAllButton
:
function
()
{
toggleToggleAllButton
:
function
()
{
var
toggleInput
=
this
.
$
(
'
#toggle-all
'
)[
0
];
if
(
toggleInput
)
{
toggleInput
.
checked
=
!
this
.
collection
.
remaining
().
length
;
...
...
@@ -32,12 +32,12 @@ $(function( $ ) {
// When this function is specified, items will only be shown
// when this function returns true
itemFilter
:
function
(
model
)
{
itemFilter
:
function
(
model
)
{
return
model
.
isVisible
();
},
// Generate the attributes for a new Todo item.
newAttributes
:
function
()
{
newAttributes
:
function
()
{
return
{
title
:
this
.
$
(
'
#new-todo
'
).
val
().
trim
(),
order
:
this
.
collection
.
nextOrder
(),
...
...
@@ -47,18 +47,18 @@ $(function( $ ) {
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter
:
function
(
e
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
(
'
#new-todo
'
).
val
().
trim
()
)
{
createOnEnter
:
function
(
e
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
(
'
#new-todo
'
).
val
().
trim
()
)
{
return
;
}
this
.
collection
.
create
(
this
.
newAttributes
()
);
this
.
collection
.
create
(
this
.
newAttributes
()
);
this
.
$
(
'
#new-todo
'
).
val
(
''
);
},
toggleAllComplete
:
function
()
{
toggleAllComplete
:
function
()
{
var
completed
=
this
.
$
(
'
#toggle-all
'
)[
0
].
checked
;
this
.
collection
.
each
(
function
(
todo
)
{
this
.
collection
.
each
(
function
(
todo
)
{
todo
.
save
({
completed
:
completed
});
...
...
examples/thorax_lumbar/src/js/views/stats.js
View file @
1abd9579
...
...
@@ -9,18 +9,18 @@ Thorax.View.extend({
rendered
:
'
highlightFilter
'
},
initialize
:
function
()
{
initialize
:
function
()
{
// Whenever the Todos collection changes re-render the stats
// render() needs to be called with no arguments, otherwise calling
// it with arguments will insert the arguments as content
this
.
listenTo
(
window
.
app
.
Todos
,
'
all
'
,
_
.
debounce
(
function
()
{
this
.
listenTo
(
window
.
app
.
Todos
,
'
all
'
,
_
.
debounce
(
function
()
{
this
.
render
();
}));
},
// Clear all completed todo items, destroying their models.
clearCompleted
:
function
()
{
_
.
each
(
window
.
app
.
Todos
.
completed
(),
function
(
todo
)
{
clearCompleted
:
function
()
{
_
.
each
(
window
.
app
.
Todos
.
completed
(),
function
(
todo
)
{
todo
.
destroy
();
});
...
...
@@ -30,7 +30,7 @@ Thorax.View.extend({
// Each time the stats view is rendered this function will
// be called to generate the context / scope that the template
// will be called with. "context" defaults to "return this"
context
:
function
()
{
context
:
function
()
{
var
remaining
=
window
.
app
.
Todos
.
remaining
().
length
;
return
{
itemText
:
remaining
===
1
?
'
item
'
:
'
items
'
,
...
...
@@ -40,10 +40,10 @@ Thorax.View.extend({
},
// Highlight which filter will appear to be active
highlightFilter
:
function
()
{
highlightFilter
:
function
()
{
this
.
$
(
'
#filters li a
'
)
.
removeClass
(
'
selected
'
)
.
filter
(
'
[href="#/
'
+
(
window
.
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
filter
(
'
[href="#/
'
+
(
window
.
app
.
TodoFilter
||
''
)
+
'
"]
'
)
.
addClass
(
'
selected
'
);
}
});
examples/thorax_lumbar/src/js/views/todo-item.js
View file @
1abd9579
$
(
function
()
{
$
(
function
()
{
'
use strict
'
;
// Todo Item View
...
...
@@ -23,27 +23,27 @@ $(function() {
// The "rendered" event is triggered by Thorax each time render()
// is called and the result of the template has been appended
// to the View's $el
rendered
:
function
()
{
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
rendered
:
function
()
{
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
}
},
// Toggle the `"completed"` state of the model.
toggleCompleted
:
function
()
{
toggleCompleted
:
function
()
{
this
.
model
.
toggle
();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
$
(
'
.edit
'
).
focus
();
},
// Close the `"editing"` mode, saving changes to the todo.
close
:
function
()
{
close
:
function
()
{
var
value
=
this
.
$
(
'
.edit
'
).
val
().
trim
();
if
(
value
)
{
if
(
value
)
{
this
.
model
.
save
({
title
:
value
});
}
else
{
this
.
clear
();
...
...
@@ -53,14 +53,14 @@ $(function() {
},
// If you hit `enter`, we're through editing the item.
updateOnEnter
:
function
(
e
)
{
if
(
e
.
which
===
ENTER_KEY
)
{
updateOnEnter
:
function
(
e
)
{
if
(
e
.
which
===
ENTER_KEY
)
{
this
.
close
();
}
},
// Remove the item, destroy the model from *localStorage* and delete its view.
clear
:
function
()
{
clear
:
function
()
{
this
.
model
.
destroy
();
}
});
...
...
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