aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-10-13 21:31:27 -0400
committercash <cash.costello@gmail.com>2011-10-13 21:31:27 -0400
commitc6a14d6c6a04eeee2c126ea20ec0e9ee23489ef3 (patch)
tree6808e6674d64e7b0997271c347bd605a81e4b843 /js
parent7e23a3bd6382190084f136ed5aeb6b910ae00eee (diff)
downloadelgg-c6a14d6c6a04eeee2c126ea20ec0e9ee23489ef3.tar.gz
elgg-c6a14d6c6a04eeee2c126ea20ec0e9ee23489ef3.tar.bz2
displaying users that have been selected and added remove capability
Diffstat (limited to 'js')
-rw-r--r--js/lib/userpicker.js40
1 files changed, 30 insertions, 10 deletions
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 = '<input type="hidden" name="members[]" value="' + info.guid + '" />';
+ li += elgg.userpicker.renderUser(info);
$('<li>').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 = "<a href='#' class='elgg-userpicker-remove'>X</a>";
+
+ var html = "<div class='elgg-image-block'>";
+ html += "<div class='elgg-image'>" + info.icon + "</div>";
+ html += "<div class='elgg-image-alt'>" + deleteLink + "</div>";
+ html += "<div class='elgg-body'>" + info.name + "</div>";
+ html += "</div";
+
+ return html;
+}
-elgg.userpicker.getSearchParams = function(e) {
- if (e.element.siblings('[name=match_on]').attr('checked')) {
- return {'match_on[]': 'friends', 'term' : e.term};
+elgg.userpicker.getSearchParams = function(obj) {
+ if (obj.element.siblings('[name=match_on]').attr('checked')) {
+ return {'match_on[]': 'friends', 'term' : obj.term};
} else {
- return {'match_on[]': 'users', 'term' : e.term};
+ return {'match_on[]': 'users', 'term' : obj.term};
}
}