3 define([
'jquery',
'elgg'],
function ($,
elgg) {
15 this.$ul = $(
'.elgg-user-picker-list',
wrapper);
18 data = this.$wrapper.data();
20 this.name = data.name ||
'members';
21 this.handler = data.handler ||
'livesearch';
22 this.limit = data.limit || 0;
23 this.minLength = data.minLength || 2;
24 this.isSealed =
false;
27 source:
function(request, response) {
35 elgg.get(
self.handler, {
38 "match_on[]": ($(
'[name=match_on]',
self.$wrapper).attr(
'checked') ?
'friends' :
'users'),
47 minLength:
self.minLength,
49 select:
function(event, ui) {
50 self.addUser(event, ui.item.guid, ui.item.html);
55 results:
function() {}
59 $(
'.elgg-user-picker-remove', this.$wrapper).live(
'click',
function(event) {
60 self.removeUser(event);
66 UserPicker.prototype = {
74 addUser :
function(event, guid,
html) {
76 if (!$(
'li[data-guid="' + guid +
'"]', this.$ul).length) {
77 this.$ul.append(
html);
83 event.preventDefault();
91 removeUser :
function(event) {
92 $(
event.target).closest(
'.elgg-user-picker-list > li').remove();
96 event.preventDefault();
102 enforceLimit :
function() {
104 if ($(
'li[data-guid]', this.$ul).length >= this.limit) {
105 if (!this.isSealed) {
120 this.
$input.prop(
'disabled',
true);
121 this.$wrapper.addClass(
'elgg-state-disabled');
122 this.isSealed =
true;
128 unseal :
function() {
129 this.
$input.prop(
'disabled',
false);
130 this.$wrapper.removeClass(
'elgg-state-disabled');
131 this.isSealed =
false;
138 UserPicker.setup =
function(selector) {
139 elgg.register_hook_handler(
'init',
'system',
function () {
140 $(selector).each(
function () {
142 if (!$(
this).data(
'initialized')) {
143 new UserPicker(
this);
144 $(
this).data(
'initialized', 1);
elgg message elgg state success
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
friends picker main wrapper