1 | import { bindAll } from 'underscore';
|
2 | import Backbone from 'backbone';
|
3 | import globalize from './internal/globalize';
|
4 |
|
5 | var QueryInput = Backbone.View.extend({
|
6 | initialize: function () {
|
7 | bindAll(this, 'changed', 'val');
|
8 | this._lastValue = this.val();
|
9 | this.$el.bind('keyup focus', this.changed);
|
10 | },
|
11 |
|
12 | val: function () {
|
13 | return this.$el.val.apply(this.$el, arguments);
|
14 | },
|
15 |
|
16 | changed: function () {
|
17 | if (this._lastValue !== this.val()) {
|
18 | this.trigger('change', this.val());
|
19 | this._lastValue = this.val();
|
20 | }
|
21 | }
|
22 | });
|
23 |
|
24 | globalize('QueryInput', QueryInput);
|
25 |
|
26 | export default QueryInput;
|