todomvc: switch to new ui library
This commit is contained in:
parent
4acb32813e
commit
d316449538
|
@ -1,5 +1,4 @@
|
||||||
var DOM = Syndicate.DOM.DOM;
|
|
||||||
var jQueryEvent = Syndicate.JQuery.jQueryEvent;
|
|
||||||
|
|
||||||
assertion type todo(id, task, completed, assignee);
|
assertion type todo(id, task, completed, assignee);
|
||||||
message type deleteTodo(id);
|
message type deleteTodo(id);
|
||||||
|
@ -8,23 +7,23 @@ var nextId = 0;
|
||||||
function addTodo(task) {
|
function addTodo(task) {
|
||||||
actor {
|
actor {
|
||||||
this.id = nextId++;
|
this.id = nextId++;
|
||||||
this.domNode = new DomNode();
|
this.ui = new Syndicate.UI.Anchor();
|
||||||
this.task = task;
|
this.task = task;
|
||||||
this.completed = false;
|
this.completed = false;
|
||||||
this.assignee = null;
|
this.assignee = null;
|
||||||
react {
|
react {
|
||||||
assert todo(this.id, this.task, this.completed, this.assignee);
|
assert todo(this.id, this.task, this.completed, this.assignee);
|
||||||
assert DOM('#todo-list', this.cls,
|
assert this.ui.html('#todo-list',
|
||||||
Mustache.render($('#todo-list-item-template').html(), {
|
Mustache.render($('#todo-list-item-template').html(), {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
checked: this.completed ? "checked" : "",
|
checked: this.completed ? "checked" : "",
|
||||||
task: this.task
|
task: this.task
|
||||||
}));
|
}));
|
||||||
on message jQueryEvent('.'+this.cls+' > .toggle', 'click', $e) {
|
on message this.ui.event('.toggle', 'click', $e) {
|
||||||
console.log('toggle clicked');
|
console.log('toggle clicked');
|
||||||
this.completed = e.target.value;
|
this.completed = e.target.value;
|
||||||
}
|
}
|
||||||
on message jQueryEvent('.'+this.cls+' > .destroy', 'click', _) {
|
on message this.ui.event('.destroy', 'click', _) {
|
||||||
console.log('destroy clicked');
|
console.log('destroy clicked');
|
||||||
:: deleteTodo(this.id);
|
:: deleteTodo(this.id);
|
||||||
}
|
}
|
||||||
|
@ -36,8 +35,7 @@ function addTodo(task) {
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
ground dataspace G {
|
ground dataspace G {
|
||||||
Syndicate.JQuery.spawnJQueryDriver();
|
Syndicate.UI.spawnUIDriver();
|
||||||
Syndicate.DOM.spawnDOMDriver();
|
|
||||||
|
|
||||||
addTodo('Buy milk');
|
addTodo('Buy milk');
|
||||||
addTodo('Buy bread');
|
addTodo('Buy bread');
|
||||||
|
|
Loading…
Reference in New Issue