aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-14 23:41:14 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-14 23:41:14 +0000
commit640eec398e8b5493b3d1721f916ea34706e22ddd (patch)
treefd77f645e8308d98cacdb838d88841cc2a745caf /js/lib
parentfd58db640066f31fc064db72575101aca85c1852 (diff)
downloadelgg-640eec398e8b5493b3d1721f916ea34706e22ddd.tar.gz
elgg-640eec398e8b5493b3d1721f916ea34706e22ddd.tar.bz2
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
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/autocomplete.js39
1 files changed, 39 insertions, 0 deletions
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 $("<li/>")
+ .data("item.autocomplete", item)
+ .append(r)
+ .appendTo(ul);
+ };
+};
+
+elgg.register_event_handler('init', 'system', elgg.autocomplete.init); \ No newline at end of file