elgg.provide('elgg.userpicker'); /** * Userpicker initialization * * The userpicker is an autocomplete library for selecting multiple users or * friends. It works in concert with the view input/userpicker. * * @return void */ elgg.userpicker.init = function() { // binding autocomplete. // doing this as an each so we can pass this to functions. $('.elgg-input-user-picker').each(function() { $(this).autocomplete({ source: function(request, response) { var params = elgg.userpicker.getSearchParams(this); elgg.get('livesearch', { data: params, dataType: 'json', success: function(data) { response(data); } }); }, minLength: 2, html: "html", select: elgg.userpicker.addUser }) }); $('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser); } /** * Adds a user to the select user list * * elgg.userpicker.userList is defined in the input/userpicker view * * @param {Object} event * @param {Object} ui The object returned by the autocomplete endpoint * @return void */ elgg.userpicker.addUser = function(event, ui) { var info = ui.item; // do not allow users to be added multiple times if (!(info.guid in elgg.userpicker.userList)) { elgg.userpicker.userList[info.guid] = true; var users = $(this).siblings('.elgg-user-picker-list'); var li = ''; li += elgg.userpicker.viewUser(info); $('