6 require(
'jquery.ui.autocomplete.html');
18 this.$ul = $(
'.elgg-user-picker-list',
wrapper);
21 data = this.$wrapper.data();
23 this.
name = data.name ||
'members';
24 this.handler = data.handler ||
'livesearch';
25 this.limit = data.limit || 0;
26 this.minLength = data.minLength || 2;
27 this.isSealed =
false;
30 source:
function(request, response) {
38 elgg.get(
self.handler, {
41 "match_on[]": ($(
'[name=match_on]',
self.$wrapper).prop(
'checked') ?
'friends' :
'users'),
50 minLength:
self.minLength,
52 select:
function(event, ui) {
53 self.addUser(event, ui.item.guid, ui.item.html);
58 results:
function() {}
62 this.$wrapper.on(
'click',
'.elgg-user-picker-remove',
function(event) {
63 self.removeUser(event);
69 UserPicker.prototype = {
77 addUser :
function(event, guid,
html) {
79 if (!$(
'li[data-guid="' + guid +
'"]', this.$ul).length) {
80 this.$ul.append(
html);
86 event.preventDefault();
94 removeUser :
function(event) {
95 $(
event.target).closest(
'.elgg-user-picker-list > li').remove();
99 event.preventDefault();
105 enforceLimit :
function() {
107 if ($(
'li[data-guid]', this.$ul).length >= this.limit) {
108 if (!this.isSealed) {
123 this.
$input.prop(
'disabled',
true);
124 this.$wrapper.addClass(
'elgg-state-disabled');
125 this.isSealed =
true;
131 unseal :
function() {
132 this.
$input.prop(
'disabled',
false);
133 this.$wrapper.removeClass(
'elgg-state-disabled');
134 this.isSealed =
false;
141 UserPicker.setup =
function(selector) {
142 elgg.register_hook_handler(
'init',
'system',
function () {
143 $(selector).each(
function () {
145 if (!$(
this).data(
'initialized')) {
146 new UserPicker(
this);
147 $(
this).data(
'initialized', 1);
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
friends picker main wrapper
elgg require
Throw an error if the required package isn't present.
elgg message elgg state success
define(function(require){var $=require('jquery');$(document).on('change', '#elgg-river-selector', function(){var url=window.location.href;if(window.location.search.length){url=url.substring(0, url.indexOf('?'));}url+= '?'+$(this).val();window.location.href=url;});})
Initiates page reload when river selector value changes core/river/filter.