OO-ize DOM builder, improve performance (part 1), add benchmarking suite

This commit is contained in:
impinball 2015-12-15 07:07:50 -05:00
parent c202c04631
commit a7b2294c11
22 changed files with 1953 additions and 813 deletions

View file

@ -0,0 +1,40 @@
/* global m */
(function (app) {
"use strict"
var filter = {
view: function (_, ctrl, expected, name, href) {
return m("li", [
m("a", {
href: href,
config: m.route,
class: ctrl.filter() === expected ? "selected" : ""
}, name)
])
}
}
app.footer = {
view: function (_, ctrl) {
var amountCompleted = ctrl.amountCompleted()
var amountActive = ctrl.list.length - amountCompleted
return m("footer#footer", [
m("span#todo-count", [
m("strong", amountActive), " item" +
(amountActive !== 1 ? "s" : "") + " left"
]),
m("ul#filters", [
m(filter, ctrl, "", "All", "/"),
m(filter, ctrl, "active", "Active", "/active"),
m(filter, ctrl, "completed", "Completed", "/completed")
]),
ctrl.amountCompleted() ? m("button#clear-completed", {
onclick: function () {
ctrl.clearCompleted()
}
}, "Clear completed") : null
])
}
}
})(this.app || (this.app = {}))