DYEBench should use TodoMVC to test FlightJS for consistency
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / resources / todomvc / dependency-examples / flight / app / js / ui / new_item.js
1 /*global define */
2 'use strict';
3
4 define([
5     'flight/lib/component'
6 ], function (defineComponent) {
7     function newItem() {
8         var ENTER_KEY = 13;
9
10         this.createOnEnter = function (e) {
11             if (e.which !== ENTER_KEY ||
12                 !this.$node.val().trim()) {
13                 return;
14             }
15
16             this.trigger('uiAddRequested', {
17                 title: this.$node.val().trim()
18             });
19
20             this.$node.val('');
21         };
22
23         this.after('initialize', function () {
24             this.on('keydown', this.createOnEnter);
25         });
26     }
27
28     return defineComponent(newItem);
29 });