3 define([
'jquery',
'elgg',
'jquery.ui.autocomplete.html'],
function ($,
elgg) {
14 this.$ul = $(
'.elgg-user-picker-list',
wrapper);
17 data = this.$wrapper.data();
19 this.
name = data.name ||
'members';
20 this.handler = data.handler ||
'livesearch';
21 this.limit = data.limit || 0;
22 this.minLength = data.minLength || 2;
23 this.isSealed =
false;
26 source:
function(request, response) {
34 elgg.get(
self.handler, {
37 "match_on[]": ($(
'[name=match_on]',
self.$wrapper).attr(
'checked') ?
'friends' :
'users'),
46 minLength:
self.minLength,
48 select:
function(event, ui) {
49 self.addUser(event, ui.item.guid, ui.item.html);
54 results:
function() {}
58 $(
'.elgg-user-picker-remove', this.$wrapper).live(
'click',
function(event) {
59 self.removeUser(event);
65 UserPicker.prototype = {
73 addUser :
function(event, guid,
html) {
75 if (!$(
'li[data-guid="' + guid +
'"]', this.$ul).length) {
76 this.$ul.append(
html);
82 event.preventDefault();
90 removeUser :
function(event) {
91 $(
event.target).closest(
'.elgg-user-picker-list > li').remove();
95 event.preventDefault();
101 enforceLimit :
function() {
103 if ($(
'li[data-guid]', this.$ul).length >= this.limit) {
104 if (!this.isSealed) {
119 this.
$input.prop(
'disabled',
true);
120 this.$wrapper.addClass(
'elgg-state-disabled');
121 this.isSealed =
true;
127 unseal :
function() {
128 this.
$input.prop(
'disabled',
false);
129 this.$wrapper.removeClass(
'elgg-state-disabled');
130 this.isSealed =
false;
137 UserPicker.setup =
function(selector) {
138 elgg.register_hook_handler(
'init',
'system',
function () {
139 $(selector).each(
function () {
141 if (!$(
this).data(
'initialized')) {
142 new UserPicker(
this);
143 $(
this).data(
'initialized', 1);
elgg message elgg state success
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
friends picker main wrapper
define(function(require){var $=require('jquery');var active=false;var SHOW_DELAY=20;$('body').append('< div class="elgg-spinner">< div class="elgg-ajax-loader"></div ></div >');return{start:function(){active=true;setTimeout(function(){if(active){$('body').addClass('elgg-spinner-active');}}, SHOW_DELAY);}, stop:function(){active=false;$('body').removeClass('elgg-spinner-active');}};})