-
Notifications
You must be signed in to change notification settings - Fork 6
/
autocomplete.js
50 lines (42 loc) · 1.2 KB
/
autocomplete.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
AutoForm.addInputType('autocomplete-input', {
template: 'afAutocompleteInput'
});
AutoForm.addInputType('autocomplete-textarea', {
template: 'afAutocompleteTextarea'
});
Template.__copy__('afAutocompleteInput_bootstrap3',
'afAutocompleteInput');
Template.__copy__('afAutocompleteTextarea_bootstrap3',
'afAutocompleteTextarea');
helpers = {
attsWithValue: function (atts, value) {
if (value) {
atts.value = value;
}
return atts;
},
bootstrapAtts: function (atts) {
atts['class'] = _.isString(atts['class'])
? atts['class'] + ' form-control'
: 'form-control';
return atts;
},
bootstrapAttsWithValue: function (atts, value) {
return helpers.attsWithValue(helpers.bootstrapAtts(atts), value);
}
};
Template.afAutocompleteInput.helpers({
atts: function () {
return helpers.attsWithValue(this.atts, this.value);
}
});
Template.afAutocompleteInput_bootstrap3.helpers({
atts: function () {
return helpers.bootstrapAttsWithValue(this.atts, this.value);
}
});
Template.afAutocompleteTextarea_bootstrap3.helpers({
atts: function () {
return helpers.bootstrapAtts(this.atts);
}
});