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
480cf298
Commit
480cf298
authored
Feb 01, 2015
by
Pascal Hartig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Foam: Various style fixes
parent
1655b316
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
examples/foam/Todo.js
examples/foam/Todo.js
+25
-25
No files found.
examples/foam/Todo.js
View file @
480cf298
...
...
@@ -8,7 +8,7 @@
name
:
'
TodoDAO
'
,
extendsModel
:
'
ProxyDAO
'
,
methods
:
{
put
:
function
(
issue
,
s
)
{
put
:
function
(
issue
,
s
)
{
// If the user tried to put an empty text, remove the entry instead.
if
(
!
issue
.
text
)
{
this
.
remove
(
issue
.
id
,
{
remove
:
s
&&
s
.
put
});
...
...
@@ -26,23 +26,23 @@
{
name
:
'
completed
'
,
model_
:
'
BooleanProperty
'
},
{
name
:
'
text
'
,
preSet
:
function
(
_
,
text
)
{
return
text
.
trim
();
}
}
],
templates
:
[
function
toDetailHTML
()
{
/*
templates
:
[
function
toDetailHTML
()
{
/*
<li id="%%id">
<div class="view">
$$completed{className: 'toggle'}
$$text{mode: 'read-only', tagName: 'label'}
<button class="destroy" id="<%= this.on('click', function() { this.parent.dao.remove(this.data); }) %>"></button>
<button class="destroy" id="<%= this.on('click', function
() { this.parent.dao.remove(this.data); }) %>"></button>
</div>
$$text{className: 'edit'}
</li>
<%
var toEdit = function() { DOM.setClass(this.$, 'editing'); this.textView.focus(); }.bind(this);
var toDisplay = function() { DOM.setClass(this.$, 'editing', false); }.bind(this);
var toEdit = function
() { DOM.setClass(this.$, 'editing'); this.textView.focus(); }.bind(this);
var toDisplay = function
() { DOM.setClass(this.$, 'editing', false); }.bind(this);
this.on('dblclick', toEdit, this.id);
this.on('blur', toDisplay, this.textView.id);
this.textView.subscribe(this.textView.ESCAPE, toDisplay);
this.setClass('completed', function() { return this.data.completed; }.bind(this), this.id);
%> */
}
]
this.setClass('completed', function
() { return this.data.completed; }.bind(this), this.id);
%> */
}]
});
// Needed to massage the HTML to fit TodoMVC spec; it works without this.
...
...
@@ -50,10 +50,10 @@
name
:
'
TodoFilterView
'
,
extendsModel
:
'
ChoiceListView
'
,
methods
:
{
choiceToHTML
:
function
(
id
,
choice
)
{
choiceToHTML
:
function
(
id
,
choice
)
{
var
self
=
this
;
this
.
setClass
(
'
selected
'
,
function
()
{
return
self
.
label
===
choice
[
1
];
},
id
);
return
'
<li><a id="
'
+
id
+
'
" class="choice
">
'
+
choice
[
1
]
+
'
</a></li>
'
;
this
.
setClass
(
'
selected
'
,
function
()
{
return
self
.
label
===
choice
[
1
];
},
id
);
return
'
<li><a id="
'
+
id
+
'
" class="choice" href="
">
'
+
choice
[
1
]
+
'
</a></li>
'
;
}
}
});
...
...
@@ -63,7 +63,7 @@
properties
:
[
{
name
:
'
input
'
,
setter
:
function
(
text
)
{
setter
:
function
(
text
)
{
// This is a fake property that adds the todo when its value gets saved.
if
(
!
text
)
{
return
;
}
this
.
dao
.
put
(
Todo
.
create
({
text
:
text
}));
...
...
@@ -72,32 +72,32 @@
view
:
{
factory_
:
'
TextFieldView
'
,
placeholder
:
'
What needs to be done?
'
}
},
{
name
:
'
dao
'
},
{
name
:
'
filteredDAO
'
,
model_
:
'
DAOProperty
'
,
view
:
'
DAOListView
'
},
{
name
:
'
filteredDAO
'
,
model_
:
'
DAOProperty
'
,
view
:
'
DAOListView
'
},
{
name
:
'
completedCount
'
,
model_
:
'
IntProperty
'
},
{
name
:
'
activeCount
'
,
model_
:
'
IntProperty
'
,
postSet
:
function
(
_
,
c
)
{
this
.
toggle
=
!
c
;
}},
{
name
:
'
toggle
'
,
model_
:
'
BooleanProperty
'
,
postSet
:
function
(
_
,
n
)
{
{
name
:
'
activeCount
'
,
model_
:
'
IntProperty
'
,
postSet
:
function
(
_
,
c
)
{
this
.
toggle
=
!
c
;
}},
{
name
:
'
toggle
'
,
model_
:
'
BooleanProperty
'
,
postSet
:
function
(
_
,
n
)
{
if
(
n
===
(
this
.
activeCount
>
0
))
{
this
.
dao
.
update
(
SET
(
Todo
.
COMPLETED
,
n
));
}
}},
{
name
:
'
query
'
,
postSet
:
function
(
_
,
q
)
{
this
.
filteredDAO
=
this
.
dao
.
where
(
q
);
},
postSet
:
function
(
_
,
q
)
{
this
.
filteredDAO
=
this
.
dao
.
where
(
q
);
},
defaultValue
:
TRUE
,
view
:
{
factory_
:
'
TodoFilterView
'
,
choices
:
[
[
TRUE
,
'
All
'
],
[
NOT
(
Todo
.
COMPLETED
),
'
Active
'
],
[
Todo
.
COMPLETED
,
'
Completed
'
]
]
}
view
:
{
factory_
:
'
TodoFilterView
'
,
choices
:
[
[
TRUE
,
'
All
'
],
[
NOT
(
Todo
.
COMPLETED
),
'
Active
'
],
[
Todo
.
COMPLETED
,
'
Completed
'
]
]
}
}
],
actions
:
[
{
name
:
'
clear
'
,
labelFn
:
function
()
{
return
'
Clear completed (
'
+
this
.
completedCount
+
'
)
'
;
},
isEnabled
:
function
()
{
return
this
.
completedCount
;
},
action
:
function
()
{
this
.
dao
.
where
(
Todo
.
COMPLETED
).
removeAll
();
}
labelFn
:
function
()
{
return
'
Clear completed (
'
+
this
.
completedCount
+
'
)
'
;
},
isEnabled
:
function
()
{
return
this
.
completedCount
;
},
action
:
function
()
{
this
.
dao
.
where
(
Todo
.
COMPLETED
).
removeAll
();
}
}
],
listeners
:
[
{
name
:
'
onDAOUpdate
'
,
isFramed
:
true
,
code
:
function
()
{
code
:
function
()
{
this
.
dao
.
select
(
GROUP_BY
(
Todo
.
COMPLETED
,
COUNT
()))(
function
(
q
)
{
this
.
completedCount
=
q
.
groups
[
true
];
this
.
activeCount
=
q
.
groups
[
false
];
...
...
@@ -106,7 +106,7 @@
}
],
methods
:
{
init
:
function
()
{
init
:
function
()
{
this
.
SUPER
();
this
.
filteredDAO
=
this
.
dao
=
TodoDAO
.
create
({
delegate
:
EasyDAO
.
create
({
model
:
Todo
,
seqNo
:
true
,
daoType
:
'
StorageDAO
'
,
name
:
'
todos-foam
'
})
});
...
...
@@ -141,18 +141,18 @@
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<%
var f = function() { return this.completedCount + this.activeCount == 0; }.bind(this.data);
var f = function
() { return this.completedCount + this.activeCount == 0; }.bind(this.data);
this.setClass('hidden', f, 'main');
this.setClass('hidden', f, 'footer');
Events.relate(this.X.memento, this.queryView.label$,
function(memento) {
function
(memento) {
var s = memento && memento.substring(1);
var t = s ? s.capitalize() : 'All';
console.log('memento->label', memento, s, t);
return t;
},
function(label) { var s = '/' + label.toLowerCase(); console.log('label->memento', label, s); return s; });
this.addInitializer(function() {
function
(label) { var s = '/' + label.toLowerCase(); console.log('label->memento', label, s); return s; });
this.addInitializer(function
() {
$('new-todo').focus();
});
%>
...
...
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