blob: 1635d8a2abf3b4e16c57be3643d6a827f6e633b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import _ from 'underscore';
import Marionette from 'backbone.marionette';
import './templates';
export default Marionette.ItemView.extend({
template: Templates['api-documentation-search'],
ui: {
input: '.search-box-input'
},
events: {
'keyup @ui.input': 'onChange',
'search @ui.input': 'onChange'
},
initialize: function () {
this.query = '';
this.debouncedFilter = _.debounce(this.filter, 250);
},
onChange: function () {
var query = this.ui.input.val();
if (query === this.query) {
return;
}
this.query = this.ui.input.val();
this.debouncedFilter(query);
},
filter: function (query) {
this.options.state.set({ query: query });
}
});
|