From c6a14d6c6a04eeee2c126ea20ec0e9ee23489ef3 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 13 Oct 2011 21:31:27 -0400 Subject: displaying users that have been selected and added remove capability --- js/lib/userpicker.js | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'js/lib') diff --git a/js/lib/userpicker.js b/js/lib/userpicker.js index 780fa47c6..ece5a6951 100644 --- a/js/lib/userpicker.js +++ b/js/lib/userpicker.js @@ -24,7 +24,9 @@ elgg.userpicker.init = function() { select: elgg.userpicker.addUser }) }); -}; + + $('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser); +} /** * elgg.userpicker.userList is defined in the input/userpicker view @@ -35,24 +37,42 @@ elgg.userpicker.addUser = function(event, ui) { // 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-entries'); + var users = $(this).siblings('.elgg-user-picker-list'); var li = ''; + li += elgg.userpicker.renderUser(info); $('
  • ').html(li).appendTo(users); } $(this).val(''); event.preventDefault(); -}; +} + +elgg.userpicker.removeUser = function(event) { + $(this).closest('.elgg-user-picker-list > li').remove(); + event.preventDefault(); +} -elgg.userpicker.removeUser = function(link, guid) { - $(link).closest('.elgg-user-picker-entries > li').remove(); -}; +/** + * The html in this method has to remain sync'ed with input/userpicker + */ +elgg.userpicker.renderUser = function(info) { + + var deleteLink = "X"; + + var html = "
    "; + html += "
    " + info.icon + "
    "; + html += "
    " + deleteLink + "
    "; + html += "
    " + info.name + "
    "; + html += "