From 845591bce64a1b62a54c41dc70cecfcef2f1a49d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Tue, 25 Aug 2015 11:52:10 +0300 Subject: [PATCH] Autocomplete base --- js/autocomplete.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 js/autocomplete.js diff --git a/js/autocomplete.js b/js/autocomplete.js new file mode 100644 index 00000000..2f5eb280 --- /dev/null +++ b/js/autocomplete.js @@ -0,0 +1,21 @@ +$(function () { + $(".channel-textarea-inner textarea").ready(function () { + var availableTags = [ + "Kappa", + "4Head"]; + + $("#tags").on("keydown", function () { + var newY = $(this).textareaHelper('caretPos').top + (parseInt($(this).css('font-size'), 10) * 1.5); + var newX = $(this).textareaHelper('caretPos').left; + var posString = "left+" + newX + "px top+" + newY + "px"; + $(this).autocomplete("option", "position", { + my: "left top", + at: posString + }); + }); + + $(".channel-textarea-inner textarea").autocomplete({ + source: availableTags + }); + }); +}); \ No newline at end of file