diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-10-03 09:09:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-03 09:09:45 +0200 |
commit | ab809de18415a9ce3bbc95d3a0a1af6c50a41c4f (patch) | |
tree | bee406df7af4b6e024764e153d8844dfe69aeda1 /app/Resources/static/themes/baggy/js/autoCompleteTags.js | |
parent | dfbbf0e18ad585e318c2609e46963e4b9fd198ef (diff) | |
parent | 49f25d6ee820619a15851b12a33667d707e4edf7 (diff) | |
download | wallabag-ab809de18415a9ce3bbc95d3a0a1af6c50a41c4f.tar.gz wallabag-ab809de18415a9ce3bbc95d3a0a1af6c50a41c4f.tar.zst wallabag-ab809de18415a9ce3bbc95d3a0a1af6c50a41c4f.zip |
Merge pull request #2314 from wallabag/assets
Assets work
Diffstat (limited to 'app/Resources/static/themes/baggy/js/autoCompleteTags.js')
-rwxr-xr-x | app/Resources/static/themes/baggy/js/autoCompleteTags.js | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js index edd0a421..f287ebfa 100755 --- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js | |||
@@ -1,46 +1,8 @@ | |||
1 | var $ = global.jquery = require('jquery'); | 1 | function split(val) { |
2 | return val.split(/,\s*/); | ||
3 | } | ||
4 | function extractLast(term) { | ||
5 | return split(term).pop(); | ||
6 | } | ||
2 | 7 | ||
3 | jQuery(function ($) { | 8 | export { split, extractLast }; |
4 | function split(val) { | ||
5 | return val.split(/,\s*/); | ||
6 | } | ||
7 | function extractLast(term) { | ||
8 | return split(term).pop(); | ||
9 | } | ||
10 | |||
11 | |||
12 | $('#value').bind('keydown', function (event) { | ||
13 | if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) { | ||
14 | event.preventDefault(); | ||
15 | } | ||
16 | }).autocomplete({ | ||
17 | source: function (request, response) { | ||
18 | $.getJSON('./?view=tags', { | ||
19 | term: extractLast(request.term), | ||
20 | //id: $(':hidden#entry_id').val() | ||
21 | }, response); | ||
22 | }, | ||
23 | search: function () { | ||
24 | // custom minLength | ||
25 | var term = extractLast(this.value); | ||
26 | if (term.length < 1) { | ||
27 | return false; | ||
28 | } | ||
29 | }, | ||
30 | focus: function () { | ||
31 | // prevent value inserted on focus | ||
32 | return false; | ||
33 | }, | ||
34 | select: function (event, ui) { | ||
35 | var terms = split(this.value); | ||
36 | // remove the current input | ||
37 | terms.pop(); | ||
38 | // add the selected item | ||
39 | terms.push(ui.item.value); | ||
40 | // add placeholder to get the comma-and-space at the end | ||
41 | terms.push(''); | ||
42 | this.value = terms.join(', '); | ||
43 | return false; | ||
44 | }, | ||
45 | }); | ||
46 | }); | ||