aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/lib/userpicker.js24
-rw-r--r--views/default/input/autocomplete.php2
-rw-r--r--views/default/input/userpicker.php2
3 files changed, 11 insertions, 17 deletions
diff --git a/js/lib/userpicker.js b/js/lib/userpicker.js
index d978b9c82..2b3d78d6b 100644
--- a/js/lib/userpicker.js
+++ b/js/lib/userpicker.js
@@ -1,12 +1,16 @@
+elgg.provide('elgg.userpicker');
+
elgg.userpicker.init = function() {
// binding autocomplete.
// doing this as an each so we can past this to functions.
$('.elgg-input-user-picker').each(function() {
- var params = elgg.userpicker.getSearchParams(this);
+ var _this = this;
$(this).autocomplete({
source: function(request, response) {
+ var params = elgg.userpicker.getSearchParams(this);
+
elgg.get('pg/livesearch', {
data: params,
dataType: 'json',
@@ -14,7 +18,7 @@ elgg.userpicker.init = function() {
response(data);
}
});
- }
+ },
minLength: 2,
select: elgg.userpicker.addUser
})
@@ -22,16 +26,6 @@ elgg.userpicker.init = function() {
//@todo This seems convoluted
.data("autocomplete")._renderItem = elgg.userpicker.formatItem;
});
-
-
- // changing friends vs all users.
- $('.elgg-user-picker [name=match_on]').live('click', function() {
- // update the extra params for the autocomplete.
- var e = $(this).closest('.elgg-user-picker').find('.elgg-input-user-picker');
- var params = elgg.userpicker.getSearchParams(e);
- e.setOptions({extraParams: params});
- e.flushCache();
- });
};
elgg.userpicker.formatItem = function(ul, item) {
@@ -73,11 +67,11 @@ elgg.userpicker.addUser = function(event, ui) {
$(this).val('');
}
-}
+};
-function elgg.userpicker.removeUser(link, guid) {
+elgg.userpicker.removeUser = function(link, guid) {
$(link).closest('.elgg-user-picker-entries > li').remove();
-}
+};
elgg.userpicker.getSearchParams = function(e) {
if ($(e).closest('.elgg-user-picker').find('[name=match_on]').attr('checked')) {
diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php
index d0b12c31d..1093de2d3 100644
--- a/views/default/input/autocomplete.php
+++ b/views/default/input/autocomplete.php
@@ -29,7 +29,7 @@ $ac_url_params = http_build_query(array(
unset($vars['match_on']);
unset($vars['match_owner']);
-elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'footer');
+elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'head');
?>
diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php
index 18c71a7f3..980af2684 100644
--- a/views/default/input/userpicker.php
+++ b/views/default/input/userpicker.php
@@ -18,7 +18,7 @@
*
*/
-elgg_register_js('js/lib/userpicker.js', 'userpicker', 'footer');
+elgg_register_js('js/lib/userpicker.js', 'userpicker', 'head');
function user_picker_add_user($user_id) {
$user = get_entity($user_id);