UNPKG

663 BJavaScriptView Raw
1import { bindAll } from 'underscore';
2import Backbone from 'backbone';
3import globalize from './internal/globalize';
4
5var 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
24globalize('QueryInput', QueryInput);
25
26export default QueryInput;