DYEBench should use TodoMVC to test FlightJS for consistency
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / resources / todomvc / dependency-examples / flight / app / js / ui / stats.js
1 /*global define */
2 'use strict';
3
4 define([
5     'flight/lib/component',
6     './with_filters',
7     'text!app/templates/stats.html',
8     '../utils'
9 ], function (defineComponent, withFilters, statsTmpl, utils) {
10     function stats() {
11         var template = utils.tmpl(statsTmpl);
12
13         this.defaultAttrs({
14             clearCompletedSelector: '#clear-completed'
15         });
16
17         this.render = function (e, data) {
18             var toggle = data.all > 0;
19
20             this.$node.html(template(data));
21             this.$node.toggle(toggle);
22             this.markSelected(data.filter);
23         };
24
25         this.clearCompleted = function () {
26             this.trigger('uiClearRequested');
27         };
28
29         this.after('initialize', function () {
30             this.$node.hide();
31             this.on(document, 'dataStatsCounted', this.render);
32             this.on('click', { 'clearCompletedSelector': this.clearCompleted });
33         });
34     }
35
36     return defineComponent(stats, withFilters);
37 });