aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/js/autoCompleteTags.js
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-06-23 09:25:01 +0200
committerGitHub <noreply@github.com>2016-06-23 09:25:01 +0200
commit49e2854d5c15bbce3f24f91da34450e8f209295b (patch)
treef5aa95445549cc151e86f144b40464eecee28cf7 /app/Resources/static/themes/baggy/js/autoCompleteTags.js
parent4eaaa27bb5b9a5725b26471a39548d764fc9cd0a (diff)
parent496cfdc0172fd55cb555f74b64704c8f50c71b77 (diff)
downloadwallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.tar.gz
wallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.tar.zst
wallabag-49e2854d5c15bbce3f24f91da34450e8f209295b.zip
Merge pull request #2142 from wallabag/v2-use-npm
Manage assets through npm
Diffstat (limited to 'app/Resources/static/themes/baggy/js/autoCompleteTags.js')
-rwxr-xr-xapp/Resources/static/themes/baggy/js/autoCompleteTags.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
new file mode 100755
index 00000000..edd0a421
--- /dev/null
+++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
@@ -0,0 +1,46 @@
1var $ = global.jquery = require('jquery');
2
3jQuery(function ($) {
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});