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
e624af75
Commit
e624af75
authored
Jan 12, 2013
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #395 from ssarj/backbone-tidy-up
backbone examples: minor style updates.
parents
6c2eb0d9
8b95665f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
37 deletions
+37
-37
architecture-examples/backbone/js/views/app.js
architecture-examples/backbone/js/views/app.js
+6
-6
architecture-examples/backbone/js/views/todos.js
architecture-examples/backbone/js/views/todos.js
+7
-7
dependency-examples/backbone_require/js/views/app.js
dependency-examples/backbone_require/js/views/app.js
+6
-6
dependency-examples/backbone_require/js/views/todos.js
dependency-examples/backbone_require/js/views/todos.js
+7
-7
labs/architecture-examples/backbone.xmpp/index.html
labs/architecture-examples/backbone.xmpp/index.html
+1
-1
labs/architecture-examples/backbone.xmpp/js/views/app.js
labs/architecture-examples/backbone.xmpp/js/views/app.js
+4
-4
labs/architecture-examples/backbone.xmpp/js/views/todos.js
labs/architecture-examples/backbone.xmpp/js/views/todos.js
+6
-6
No files found.
architecture-examples/backbone/js/views/app.js
View file @
e624af75
...
...
@@ -27,8 +27,8 @@ $(function( $ ) {
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize
:
function
()
{
this
.
input
=
this
.
$
(
'
#new-todo
'
);
this
.
allCheckbox
=
this
.
$
(
'
#toggle-all
'
)[
0
];
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
...
...
@@ -81,18 +81,18 @@ $(function( $ ) {
app
.
Todos
.
each
(
this
.
addOne
,
this
);
},
filterOne
:
function
(
todo
)
{
filterOne
:
function
(
todo
)
{
todo
.
trigger
(
'
visible
'
);
},
filterAll
:
function
()
{
filterAll
:
function
()
{
app
.
Todos
.
each
(
this
.
filterOne
,
this
);
},
// Generate the attributes for a new Todo item.
newAttributes
:
function
()
{
return
{
title
:
this
.
input
.
val
().
trim
(),
title
:
this
.
$
input
.
val
().
trim
(),
order
:
app
.
Todos
.
nextOrder
(),
completed
:
false
};
...
...
@@ -101,12 +101,12 @@ $(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
.
input
.
val
().
trim
()
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
input
.
val
().
trim
()
)
{
return
;
}
app
.
Todos
.
create
(
this
.
newAttributes
()
);
this
.
input
.
val
(
''
);
this
.
$
input
.
val
(
''
);
},
// Clear all completed todo items, destroying their models.
...
...
architecture-examples/backbone/js/views/todos.js
View file @
e624af75
...
...
@@ -17,7 +17,7 @@ $(function() {
// The DOM events specific to an item.
events
:
{
'
click .toggle
'
:
'
toggle
c
ompleted
'
,
'
click .toggle
'
:
'
toggle
C
ompleted
'
,
'
dblclick label
'
:
'
edit
'
,
'
click .destroy
'
:
'
clear
'
,
'
keypress .edit
'
:
'
updateOnEnter
'
,
...
...
@@ -39,15 +39,15 @@ $(function() {
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
this
.
toggleVisible
();
this
.
input
=
this
.
$
(
'
.edit
'
);
this
.
$
input
=
this
.
$
(
'
.edit
'
);
return
this
;
},
toggleVisible
:
function
()
{
toggleVisible
:
function
()
{
this
.
$el
.
toggleClass
(
'
hidden
'
,
this
.
isHidden
());
},
isHidden
:
function
()
{
isHidden
:
function
()
{
var
isCompleted
=
this
.
model
.
get
(
'
completed
'
);
return
(
// hidden cases only
(
!
isCompleted
&&
app
.
TodoFilter
===
'
completed
'
)
...
...
@@ -56,19 +56,19 @@ $(function() {
},
// Toggle the `"completed"` state of the model.
toggle
c
ompleted
:
function
()
{
toggle
C
ompleted
:
function
()
{
this
.
model
.
toggle
();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
input
.
focus
();
this
.
$
input
.
focus
();
},
// Close the `"editing"` mode, saving changes to the todo.
close
:
function
()
{
var
value
=
this
.
input
.
val
().
trim
();
var
value
=
this
.
$
input
.
val
().
trim
();
if
(
value
)
{
this
.
model
.
save
({
title
:
value
});
...
...
dependency-examples/backbone_require/js/views/app.js
View file @
e624af75
...
...
@@ -28,8 +28,8 @@ define([
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize
:
function
()
{
this
.
input
=
this
.
$
(
'
#new-todo
'
);
this
.
allCheckbox
=
this
.
$
(
'
#toggle-all
'
)[
0
];
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
...
...
@@ -82,18 +82,18 @@ define([
Todos
.
each
(
this
.
addOne
,
this
);
},
filterOne
:
function
(
todo
)
{
filterOne
:
function
(
todo
)
{
todo
.
trigger
(
"
visible
"
);
},
filterAll
:
function
()
{
filterAll
:
function
()
{
Todos
.
each
(
this
.
filterOne
,
this
);
},
// Generate the attributes for a new Todo item.
newAttributes
:
function
()
{
return
{
title
:
this
.
input
.
val
().
trim
(),
title
:
this
.
$
input
.
val
().
trim
(),
order
:
Todos
.
nextOrder
(),
completed
:
false
};
...
...
@@ -102,12 +102,12 @@ define([
// If you hit return in the main input field, create new **Todo** model,
// persisting it to *localStorage*.
createOnEnter
:
function
(
e
)
{
if
(
e
.
which
!==
Common
.
ENTER_KEY
||
!
this
.
input
.
val
().
trim
()
)
{
if
(
e
.
which
!==
Common
.
ENTER_KEY
||
!
this
.
$
input
.
val
().
trim
()
)
{
return
;
}
Todos
.
create
(
this
.
newAttributes
()
);
this
.
input
.
val
(
''
);
this
.
$
input
.
val
(
''
);
},
// Clear all completed todo items, destroying their models.
...
...
dependency-examples/backbone_require/js/views/todos.js
View file @
e624af75
...
...
@@ -14,7 +14,7 @@ define([
// The DOM events specific to an item.
events
:
{
'
click .toggle
'
:
'
toggle
c
ompleted
'
,
'
click .toggle
'
:
'
toggle
C
ompleted
'
,
'
dblclick label
'
:
'
edit
'
,
'
click .destroy
'
:
'
clear
'
,
'
keypress .edit
'
:
'
updateOnEnter
'
,
...
...
@@ -36,15 +36,15 @@ define([
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
this
.
toggleVisible
();
this
.
input
=
this
.
$
(
'
.edit
'
);
this
.
$
input
=
this
.
$
(
'
.edit
'
);
return
this
;
},
toggleVisible
:
function
()
{
toggleVisible
:
function
()
{
this
.
$el
.
toggleClass
(
'
hidden
'
,
this
.
isHidden
());
},
isHidden
:
function
()
{
isHidden
:
function
()
{
var
isCompleted
=
this
.
model
.
get
(
'
completed
'
);
return
(
// hidden cases only
(
!
isCompleted
&&
Common
.
TodoFilter
===
'
completed
'
)
...
...
@@ -53,19 +53,19 @@ define([
},
// Toggle the `"completed"` state of the model.
toggle
c
ompleted
:
function
()
{
toggle
C
ompleted
:
function
()
{
this
.
model
.
toggle
();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
input
.
focus
();
this
.
$
input
.
focus
();
},
// Close the `"editing"` mode, saving changes to the todo.
close
:
function
()
{
var
value
=
this
.
input
.
val
().
trim
();
var
value
=
this
.
$
input
.
val
().
trim
();
if
(
value
){
this
.
model
.
save
({
title
:
value
});
...
...
labs/architecture-examples/backbone.xmpp/index.html
View file @
e624af75
...
...
@@ -58,7 +58,7 @@
<script
src=
"../../../assets/base.js"
></script>
<script
src=
"../../../assets/jquery.min.js"
></script>
<script
src=
"../../../assets/lodash.min.js"
></script>
<script
src=
"../../../architecture-examples/backbone/js/lib/backbone
-min
.js"
></script>
<script
src=
"../../../architecture-examples/backbone/js/lib/backbone.js"
></script>
<script
src=
"js/lib/strophe.js"
></script>
<script
src=
"js/lib/strophe.forms.js"
></script>
<script
src=
"js/lib/strophe.pubsub.js"
></script>
...
...
labs/architecture-examples/backbone.xmpp/js/views/app.js
View file @
e624af75
...
...
@@ -27,7 +27,6 @@ $(function( $ ) {
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize
:
function
()
{
this
.
input
=
this
.
$
(
'
#new-todo
'
);
this
.
allCheckbox
=
this
.
$
(
'
#toggle-all
'
)[
0
];
window
.
app
.
Todos
.
on
(
'
add
'
,
this
.
addAll
,
this
);
...
...
@@ -35,6 +34,7 @@ $(function( $ ) {
window
.
app
.
Todos
.
on
(
'
change:completed
'
,
this
.
addAll
,
this
);
window
.
app
.
Todos
.
on
(
'
all
'
,
this
.
render
,
this
);
this
.
$input
=
this
.
$
(
'
#new-todo
'
);
this
.
$footer
=
this
.
$
(
'
#footer
'
);
this
.
$main
=
this
.
$
(
'
#main
'
);
...
...
@@ -95,7 +95,7 @@ $(function( $ ) {
// Generate the attributes for a new Todo item.
newAttributes
:
function
()
{
return
{
title
:
this
.
input
.
val
().
trim
(),
title
:
this
.
$
input
.
val
().
trim
(),
order
:
app
.
Todos
.
nextOrder
(),
completed
:
false
};
...
...
@@ -104,12 +104,12 @@ $(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
.
input
.
val
().
trim
()
)
{
if
(
e
.
which
!==
ENTER_KEY
||
!
this
.
$
input
.
val
().
trim
()
)
{
return
;
}
app
.
Todos
.
create
(
this
.
newAttributes
(),
{
wait
:
true
}
);
this
.
input
.
val
(
''
);
this
.
$
input
.
val
(
''
);
},
// Clear all completed todo items, destroying their models.
...
...
labs/architecture-examples/backbone.xmpp/js/views/todos.js
View file @
e624af75
...
...
@@ -17,7 +17,7 @@ $(function() {
// The DOM events specific to an item.
events
:
{
'
click .toggle
'
:
'
toggle
c
ompleted
'
,
'
click .toggle
'
:
'
toggle
C
ompleted
'
,
'
dblclick label
'
:
'
edit
'
,
'
click .destroy
'
:
'
clear
'
,
'
keypress .edit
'
:
'
updateOnEnter
'
,
...
...
@@ -33,7 +33,7 @@ $(function() {
this
.
model
.
collection
.
on
(
'
remove
'
,
this
.
remoteRemove
,
this
);
},
remoteRemove
:
function
(
model
)
{
remoteRemove
:
function
(
model
)
{
if
(
model
.
id
===
this
.
model
.
id
)
{
this
.
remove
();
}
...
...
@@ -44,24 +44,24 @@ $(function() {
this
.
$el
.
html
(
this
.
template
(
this
.
model
.
toJSON
()
)
);
this
.
$el
.
toggleClass
(
'
completed
'
,
this
.
model
.
get
(
'
completed
'
)
);
this
.
input
=
this
.
$
(
'
.edit
'
);
this
.
$
input
=
this
.
$
(
'
.edit
'
);
return
this
;
},
// Toggle the `"completed"` state of the model.
toggle
c
ompleted
:
function
()
{
toggle
C
ompleted
:
function
()
{
this
.
model
.
toggle
();
},
// Switch this view into `"editing"` mode, displaying the input field.
edit
:
function
()
{
this
.
$el
.
addClass
(
'
editing
'
);
this
.
input
.
focus
();
this
.
$
input
.
focus
();
},
// Close the `"editing"` mode, saving changes to the todo.
close
:
function
()
{
var
value
=
this
.
input
.
val
().
trim
();
var
value
=
this
.
$
input
.
val
().
trim
();
if
(
value
)
{
this
.
model
.
save
({
title
:
value
});
...
...
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