X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FAutocomplete%2FAutocomplete.js;h=2b031cc3132aa0d4878a123e718437099dac367a;hb=8454b1fbadc00fcf8c87d19bd7615a5be00fde09;hp=c3f022702ac0fb107e11a29d67ec859df3be6306;hpb=e25d4683c8999a215f3f8e91e280ff52b8dd2499;p=quix0rs-gnu-social.git diff --git a/plugins/Autocomplete/Autocomplete.js b/plugins/Autocomplete/Autocomplete.js index c3f022702a..2b031cc313 100644 --- a/plugins/Autocomplete/Autocomplete.js +++ b/plugins/Autocomplete/Autocomplete.js @@ -1,4 +1,15 @@ -$(document).ready(function(){ +(function(SN, $) { + +var origInit = SN.Init.NoticeFormSetup; +SN.Init.NoticeFormSetup = function(form) { + origInit(form); + + // Only attach to traditional-style forms + var textarea = form.find('.notice_data-text:first'); + if (textarea.length == 0) { + return; + } + function fullName(row) { if (typeof row.fullname == "string" && row.fullname != '') { return row.nickname + ' (' + row.fullname + ')'; @@ -6,7 +17,9 @@ $(document).ready(function(){ return row.nickname; } } - $('#notice_data-text').autocomplete($('address .url')[0].href+'main/autocomplete/suggest', { + + var apiUrl = $('#autocomplete-api').attr('data-url'); + textarea.autocomplete(apiUrl, { multiple: true, multipleSeparator: " ", minChars: 1, @@ -35,4 +48,6 @@ $(document).ready(function(){ } } }); -}); +}; + +})(SN, jQuery);