]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - app/Resources/static/themes/baggy/js/autoCompleteTags.js
1 var $ = global
.jquery
= require('jquery');
5 return val
.split(/,\s*/);
7 function extractLast(term
) {
8 return split(term
).pop();
12 $('#value').bind('keydown', function (event
) {
13 if (event
.keyCode
=== $.ui
.keyCode
.TAB
&& $(this).data('ui-autocomplete').menu
.active
) {
14 event
.preventDefault();
17 source: function (request
, response
) {
18 $.getJSON('./?view=tags', {
19 term: extractLast(request
.term
),
20 //id: $(':hidden#entry_id').val()
25 var term
= extractLast(this.value
);
26 if (term
.length
< 1) {
31 // prevent value inserted on focus
34 select: function (event
, ui
) {
35 var terms
= split(this.value
);
36 // remove the current input
38 // add the selected item
39 terms
.push(ui
.item
.value
);
40 // add placeholder to get the comma-and-space at the end
42 this.value
= terms
.join(', ');