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
4965102c
Commit
4965102c
authored
Feb 20, 2013
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dermis: jshint style
parent
ccad8ec9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
46 deletions
+66
-46
labs/architecture-examples/dermis/js/app.js
labs/architecture-examples/dermis/js/app.js
+16
-13
labs/architecture-examples/dermis/js/models/Todo.js
labs/architecture-examples/dermis/js/models/Todo.js
+11
-8
labs/architecture-examples/dermis/js/models/Todos.js
labs/architecture-examples/dermis/js/models/Todos.js
+24
-17
labs/architecture-examples/dermis/js/storage.js
labs/architecture-examples/dermis/js/storage.js
+15
-8
No files found.
labs/architecture-examples/dermis/js/app.js
View file @
4965102c
(
function
(
window
)
{
/*global $ dermis require*/
(
function
()
{
'
use strict
'
;
dermis
.
route
(
'
/
'
);
dermis
.
route
(
'
/active
'
);
dermis
.
route
(
'
/completed
'
);
require
([
'
js/models/Todo
'
,
'
js/models/Todos
'
,
'
js/storage
'
],
function
(
Todo
,
Todos
,
storage
)
{
require
([
'
js/models/Todo
'
,
'
js/models/Todos
'
,
'
js/storage
'
],
function
(
Todo
,
Todos
,
storage
)
{
//Bind Todos to DOM
Todos
.
bind
(
$
(
'
#content
'
));
$
(
'
#content
'
).
on
(
'
dblclick
'
,
'
.view > label
'
,
function
()
{
$
(
'
#content
'
).
on
(
'
dblclick
'
,
'
.view > label
'
,
function
()
{
$
(
this
).
parent
().
siblings
(
'
input
'
).
focus
();
});
//Load previous todos
var
todos
=
storage
.
load
(
'
todos-dermis
'
);
if
(
todos
)
{
todos
.
forEach
(
function
(
todo
)
{
Todos
.
push
(
Todo
.
create
({
collection
:
Todos
})
if
(
todos
)
{
todos
.
forEach
(
function
(
todo
)
{
Todos
.
push
(
Todo
.
create
({
collection
:
Todos
})
.
set
(
todo
)
.
set
({
editable
:
false
}));
.
set
({
editable
:
false
}));
});
}
//Save when todos modified
var
save
=
function
()
{
var
save
=
function
()
{
storage
.
save
(
'
todos-dermis
'
,
Todos
.
serialize
());
};
Todos
.
on
(
'
change
'
,
save
).
on
(
'
change:child
'
,
save
);
Todos
.
on
(
'
change
'
,
save
).
on
(
'
change:child
'
,
save
);
//Add todo when box submitted
var
box
=
$
(
'
#new-todo
'
);
box
.
change
(
function
()
{
box
.
change
(
function
()
{
var
title
=
box
.
val
().
trim
();
if
(
title
.
length
===
0
)
return
;
Todos
.
push
(
Todo
.
create
({
collection
:
Todos
})
if
(
title
.
length
===
0
)
{
return
;
}
Todos
.
push
(
Todo
.
create
({
collection
:
Todos
})
.
set
({
title
:
title
,
completed
:
false
,
...
...
@@ -43,4 +46,4 @@
box
.
val
(
''
);
});
});
})(
window
);
\ No newline at end of file
})();
labs/architecture-examples/dermis/js/models/Todo.js
View file @
4965102c
define
(
function
(){
/*global define dermis window*/
define
(
function
()
{
'
use strict
'
;
var
Todo
=
dermis
.
model
({
setEditable
:
function
()
{
setEditable
:
function
()
{
this
.
set
(
'
editable
'
,
true
);
},
save
:
function
()
{
save
:
function
()
{
this
.
set
(
'
editable
'
,
false
);
var
title
=
this
.
get
(
'
title
'
).
trim
();
if
(
title
.
length
===
0
)
{
if
(
title
.
length
===
0
)
{
var
todo
=
this
;
setTimeout
(
function
()
{
window
.
setTimeout
(
function
()
{
todo
.
destroy
();
},
1
);
}
},
destroy
:
function
()
{
destroy
:
function
()
{
this
.
collection
.
remove
(
this
);
},
serialize
:
function
()
{
serialize
:
function
()
{
return
{
title
:
this
.
get
(
'
title
'
),
completed
:
this
.
get
(
'
completed
'
)
...
...
labs/architecture-examples/dermis/js/models/Todos.js
View file @
4965102c
define
(
function
(
Todo
){
/*global define dermis*/
define
(
function
()
{
'
use strict
'
;
var
Todos
=
dermis
.
collection
({
toggle
:
function
()
{
toggle
:
function
()
{
var
toggled
=
this
.
allCompleted
();
this
.
emit
(
'
change:toggle
'
);
this
.
all
().
forEach
(
function
(
todo
)
{
this
.
all
().
forEach
(
function
(
todo
)
{
todo
.
set
(
'
completed
'
,
!
toggled
);
});
},
clear
:
function
()
{
this
.
completed
().
forEach
(
function
(
todo
)
{
clear
:
function
()
{
this
.
completed
().
forEach
(
function
(
todo
)
{
todo
.
destroy
();
});
},
// These can all be implemented as rivets formatters
allCompleted
:
function
()
{
allCompleted
:
function
()
{
return
this
.
completed
().
length
===
this
.
all
().
length
;
},
todos
:
function
()
{
todos
:
function
()
{
return
this
[
this
.
get
(
'
mode
'
)]();
},
all
:
function
()
{
all
:
function
()
{
return
this
.
get
(
'
items
'
);
},
completed
:
function
()
{
completed
:
function
()
{
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
){
if
(
todo
.
get
(
'
completed
'
))
out
.
push
(
todo
);
this
.
all
().
forEach
(
function
(
todo
)
{
if
(
todo
.
get
(
'
completed
'
))
{
out
.
push
(
todo
);
}
});
return
out
;
},
active
:
function
()
{
active
:
function
()
{
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
){
if
(
!
todo
.
get
(
'
completed
'
))
out
.
push
(
todo
);
this
.
all
().
forEach
(
function
(
todo
)
{
if
(
!
todo
.
get
(
'
completed
'
))
{
out
.
push
(
todo
);
}
});
return
out
;
},
serialize
:
function
()
{
serialize
:
function
()
{
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
)
{
this
.
all
().
forEach
(
function
(
todo
)
{
out
.
push
(
todo
.
serialize
());
});
return
out
;
...
...
labs/architecture-examples/dermis/js/storage.js
View file @
4965102c
define
(
function
(){
/*global define window*/
define
(
function
()
{
'
use strict
'
;
var
mod
=
{
load
:
function
(
key
){
if
(
!
'
localStorage
'
in
window
)
return
;
load
:
function
(
key
)
{
if
(
window
.
localStorage
===
undefined
)
{
return
;
}
var
d
=
window
.
localStorage
[
key
];
if
(
d
){
if
(
d
)
{
return
JSON
.
parse
(
d
);
}
else
{
return
;
}
},
save
:
function
(
key
,
data
){
if
(
!
'
localStorage
'
in
window
)
return
;
save
:
function
(
key
,
data
)
{
if
(
window
.
localStorage
===
undefined
)
{
return
;
}
window
.
localStorage
[
key
]
=
JSON
.
stringify
(
data
);
}
};
...
...
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