Implement email autocomplete for link share

This commit is contained in:
Vincent Petry 2015-09-14 18:34:56 +02:00
parent 62ff78787a
commit 1933bcfa92
1 changed files with 27 additions and 0 deletions

View File

@ -248,6 +248,33 @@
}
});
var $emailField = this.$el.find('#email');
if (isLinkShare && $emailField.length !== 0) {
$emailField.autocomplete({
minLength: 1,
source: function (search, response) {
$.get(
OC.generateUrl('core/ajax/share.php'), {
fetch: 'getShareWithEmail',
search: search.term
}, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
}
});
},
select: function( event, item ) {
$emailField.val(item.item.email);
return false;
}
})
.data("ui-autocomplete")._renderItem = function( ul, item ) {
return $('<li>')
.append('<a>' + escapeHTML(item.displayname) + "<br>" + escapeHTML(item.email) + '</a>' )
.appendTo( ul );
};
}
this.delegateEvents();
return this;