From 640eec398e8b5493b3d1721f916ea34706e22ddd Mon Sep 17 00:00:00 2001 From: ewinslow Date: Mon, 14 Feb 2011 23:41:14 +0000 Subject: Refs #2102: Replaced input/autocomplete with jQuery UI autocomplete (untested) git-svn-id: http://code.elgg.org/elgg/trunk@8240 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/autocomplete.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js/lib/autocomplete.js (limited to 'js/lib') diff --git a/js/lib/autocomplete.js b/js/lib/autocomplete.js new file mode 100644 index 000000000..eb59f51aa --- /dev/null +++ b/js/lib/autocomplete.js @@ -0,0 +1,39 @@ +/** + * + */ +elgg.provide('elgg.autocomplete'); + +elgg.autocomplete.init = function() { + $('.elgg-input-autocomplete').autocomplete({ + source: elgg.autocomplete.url, //gets set by input/autocomplete + minLength: 1, + select: function(event, ui) { + var item = ui.item; + $(this).val(item.name); + + var hidden = $(this).next(); + hidden.val(item.guid); + } + }) + + //@todo This seems convoluted + .data("autocomplete")._renderItem = function(ul, item) { + switch (item.type) { + case 'user': + case 'group': + r = item.icon + item.name + ' - ' + item.desc; + break; + + default: + r = item.name + ' - ' + item.desc; + break; + } + + return $("
  • ") + .data("item.autocomplete", item) + .append(r) + .appendTo(ul); + }; +}; + +elgg.register_event_handler('init', 'system', elgg.autocomplete.init); \ No newline at end of file -- cgit v1.2.3