]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - themes/_global/js/autoCompleteTags.js
implement #1122
[github/wallabag/wallabag.git] / themes / _global / js / autoCompleteTags.js
index 90bc982c2080ed61fe42e92b7707dd1f70d3231c..986e71d15a22d236609b047b64ad0e7b1e1b1aa8 100755 (executable)
@@ -43,5 +43,19 @@ jQuery(function($) {
     }
   });
 
+  $('.suggestedtag').click(function(){
+    var input = $("#value");
+    var value = input.val();
+    var tag = $(this).text();
+    var terms = value.split(','); // tags into the <input>
+    if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added
+      value += tag + ",";
+      input.val(value);
+    }
+    input.focus();
+    input[0].selectionStart = input[0].selectionEnd = input.val().length;
+
+  });
+
 
 });