Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
awesome
  • Loading branch information
yyx990803 committed Aug 4, 2013
1 parent a6b7257 commit fcd9544
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
22 changes: 9 additions & 13 deletions dev.html
Expand Up @@ -29,7 +29,7 @@
</style>
</head>
<body>
<div id="app" class="all" sd-controller="TodoList">
<div id="app" sd-class="filter" sd-controller="TodoList">
<div>
<input placeholder="What needs to be done?" sd-on="change:addTodo">
</div>
Expand All @@ -42,9 +42,9 @@
</ul>
<div id="footer">
Remaining: <span sd-text="remaining"></span><br>
<a class="all" sd-on="click:filter">Show All</a> |
<a class="remaining" sd-on="click:filter">Show Remaining</a> |
<a class="completed" sd-on="click:filter">Show Completed</a>
<a class="all" sd-on="click:setFilter">Show All</a> |
<a class="remaining" sd-on="click:setFilter">Show Remaining</a> |
<a class="completed" sd-on="click:setFilter">Show Completed</a>
</div>
</div>
<script>
Expand All @@ -68,8 +68,9 @@

var Seed = require('seed')

Seed.plant('TodoList', function (scope, seed) {
Seed.controller('TodoList', function (scope, seed) {

scope.filter = 'all'
scope.remaining = scope.todos.reduce(function (count, todo) {
return count + (todo.done ? 0 : 1)
}, 0)
Expand All @@ -95,21 +96,16 @@
scope.remaining += e.seed.scope.done ? -1 : 1
}

scope.filter = function (e) {
var filter = e.el.className
seed.el.className = filter
scope.setFilter = function (e) {
scope.filter = e.el.className
}
})

var now = Date.now()

var app = Seed.sprout({
var app = Seed.bootstrap({
el: '#app',
data: data
})

console.log(Date.now() - now)

</script>
</body>
</html>
8 changes: 7 additions & 1 deletion src/directives.js
Expand Up @@ -13,7 +13,13 @@ module.exports = {
},

class: function (value) {
this.el.classList[value ? 'add' : 'remove'](this.arg)
if (this.arg) {
this.el.classList[value ? 'add' : 'remove'](this.arg)
} else {
this.el.classList.remove(this.lastVal)
this.el.classList.add(value)
this.lastVal = value
}
},

checked: {
Expand Down

0 comments on commit fcd9544

Please sign in to comment.