X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FResources%2Fviews%2Fthemes%2Fbaggy%2Fpublic%2Fjs%2FautoCompleteTags.js;fp=src%2FWallabag%2FCoreBundle%2FResources%2Fviews%2Fthemes%2Fbaggy%2Fpublic%2Fjs%2FautoCompleteTags.js;h=90bc982c2080ed61fe42e92b7707dd1f70d3231c;hb=89ee994f772554b035e8033ee49c389f0f7786ba;hp=0000000000000000000000000000000000000000;hpb=a78d6afeaafb372cb5d620db7361b8ad98f070dc;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js new file mode 100755 index 00000000..90bc982c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js @@ -0,0 +1,47 @@ +jQuery(function($) { + + function split( val ) { + return val.split( /,\s*/ ); + } + function extractLast( term ) { + return split( term ).pop(); + } + + + $("#value").bind("keydown", function(event) { + if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { + event.preventDefault(); + } + }).autocomplete({ + source : function(request, response) { + $.getJSON("./?view=tags", { + term : extractLast(request.term), + //id: $(':hidden#entry_id').val() + }, response); + }, + search : function() { + // custom minLength + var term = extractLast(this.value); + if (term.length < 1) { + return false; + } + }, + focus : function() { + // prevent value inserted on focus + return false; + }, + select : function(event, ui) { + var terms = split(this.value); + // remove the current input + terms.pop(); + // add the selected item + terms.push(ui.item.value); + // add placeholder to get the comma-and-space at the end + terms.push(""); + this.value = terms.join(", "); + return false; + } + }); + + +});