aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/js/autoCompleteTags.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Resources/static/themes/baggy/js/autoCompleteTags.js')
-rwxr-xr-xapp/Resources/static/themes/baggy/js/autoCompleteTags.js35
1 files changed, 17 insertions, 18 deletions
diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
index 90bc982c..edd0a421 100755
--- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js
+++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js
@@ -1,47 +1,46 @@
1jQuery(function($) { 1var $ = global.jquery = require('jquery');
2 2
3 function split( val ) { 3jQuery(function ($) {
4 return val.split( /,\s*/ ); 4 function split(val) {
5 return val.split(/,\s*/);
5 } 6 }
6 function extractLast( term ) { 7 function extractLast(term) {
7 return split( term ).pop(); 8 return split(term).pop();
8 } 9 }
9 10
10 11
11 $("#value").bind("keydown", function(event) { 12 $('#value').bind('keydown', function (event) {
12 if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { 13 if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
13 event.preventDefault(); 14 event.preventDefault();
14 } 15 }
15 }).autocomplete({ 16 }).autocomplete({
16 source : function(request, response) { 17 source: function (request, response) {
17 $.getJSON("./?view=tags", { 18 $.getJSON('./?view=tags', {
18 term : extractLast(request.term), 19 term: extractLast(request.term),
19 //id: $(':hidden#entry_id').val() 20 //id: $(':hidden#entry_id').val()
20 }, response); 21 }, response);
21 }, 22 },
22 search : function() { 23 search: function () {
23 // custom minLength 24 // custom minLength
24 var term = extractLast(this.value); 25 var term = extractLast(this.value);
25 if (term.length < 1) { 26 if (term.length < 1) {
26 return false; 27 return false;
27 } 28 }
28 }, 29 },
29 focus : function() { 30 focus: function () {
30 // prevent value inserted on focus 31 // prevent value inserted on focus
31 return false; 32 return false;
32 }, 33 },
33 select : function(event, ui) { 34 select: function (event, ui) {
34 var terms = split(this.value); 35 var terms = split(this.value);
35 // remove the current input 36 // remove the current input
36 terms.pop(); 37 terms.pop();
37 // add the selected item 38 // add the selected item
38 terms.push(ui.item.value); 39 terms.push(ui.item.value);
39 // add placeholder to get the comma-and-space at the end 40 // add placeholder to get the comma-and-space at the end
40 terms.push(""); 41 terms.push('');
41 this.value = terms.join(", "); 42 this.value = terms.join(', ');
42 return false; 43 return false;
43 } 44 },
44 }); 45 });
45
46
47}); 46});