mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 07:01:12 +00:00
[folder perm, share] contacts input: improvement
This commit is contained in:
@@ -405,43 +405,12 @@ define([
|
||||
},
|
||||
|
||||
filePrivateSharePanelInit: function() {
|
||||
var loading_tip = this.$('.loading-tip');
|
||||
var form = this.$('#file-private-share-form');
|
||||
loading_tip.show();
|
||||
|
||||
$('[name="emails"]', form).select2({
|
||||
placeholder: gettext("Enter emails or select contacts"),
|
||||
width: '400px',
|
||||
// with 'tags', the user can directly enter, not just select
|
||||
// tags need `<input type="hidden" />`, not `<select>`
|
||||
tags: function () {
|
||||
var contacts = app.pageOptions.contacts || [];
|
||||
var contact_list = [];
|
||||
for (var i = 0, len = contacts.length; i < len; i++) {
|
||||
contact_list.push({ // 'id' & 'text' are required by the plugin
|
||||
"id": contacts[i].email,
|
||||
"text": contacts[i].name + contacts[i].email, // for search. both name & email can be searched.
|
||||
"avatar": contacts[i].avatar,
|
||||
"name": contacts[i].name
|
||||
});
|
||||
}
|
||||
return contact_list;
|
||||
},
|
||||
formatResult: function(item) { // format items shown in the drop-down menu
|
||||
if (item.avatar) {
|
||||
return item.avatar + '<span class="text">' + item.name + '<br />' + item.id + '</span>';
|
||||
} else {
|
||||
return; // if no match, show nothing
|
||||
}
|
||||
},
|
||||
formatSelection: function(item) { // format selected item shown in the input
|
||||
return item.name || item.id; // if no name, show the email, i.e., when directly input, show the email
|
||||
},
|
||||
tokenSeparators: [',', ' '],
|
||||
escapeMarkup: function(m) { return m; }
|
||||
});
|
||||
$('[name="emails"]', form).select2($.extend({
|
||||
width: '400px'
|
||||
},Common.contactInputOptionsForSelect2));
|
||||
|
||||
loading_tip.hide();
|
||||
form.removeClass('hide');
|
||||
},
|
||||
|
||||
@@ -485,40 +454,11 @@ define([
|
||||
|
||||
dirPrivateSharePanelInit: function() {
|
||||
// no 'share to all'
|
||||
var loading_tip = this.$('.loading-tip');
|
||||
var form = this.$('#dir-private-share-form');
|
||||
loading_tip.show();
|
||||
|
||||
var contacts = app.pageOptions.contacts || [];
|
||||
$('[name="emails"]', form).select2({
|
||||
placeholder: gettext("Select contacts or input"),
|
||||
width: '400px',
|
||||
tags: function () {
|
||||
var contacts = app.pageOptions.contacts || [];
|
||||
var contact_list = [];
|
||||
for (var i = 0, len = contacts.length; i < len; i++) {
|
||||
contact_list.push({ // 'id' & 'text' are required by the plugin
|
||||
"id": contacts[i].email,
|
||||
"text": contacts[i].name + contacts[i].email, // for search. both name & email can be searched.
|
||||
"avatar": contacts[i].avatar,
|
||||
"name": contacts[i].name
|
||||
});
|
||||
}
|
||||
return contact_list;
|
||||
},
|
||||
formatResult: function(item) { // format items shown in the drop-down menu
|
||||
if (item.avatar) {
|
||||
return item.avatar + '<span class="text">' + item.name + '<br />' + item.id + '</span>';
|
||||
} else {
|
||||
return; // if no match, show nothing
|
||||
}
|
||||
},
|
||||
formatSelection: function(item) { // format selected item shown in the input
|
||||
return item.name || item.id; // if no name, show the email, i.e., when directly input, show the email
|
||||
},
|
||||
tokenSeparators: [',', ' '],
|
||||
escapeMarkup: function(m) { return m; }
|
||||
});
|
||||
$('[name="emails"]', form).select2($.extend({
|
||||
width: '400px'
|
||||
},Common.contactInputOptionsForSelect2));
|
||||
|
||||
var groups = app.pageOptions.groups || [];
|
||||
var g_opts = '';
|
||||
@@ -531,7 +471,6 @@ define([
|
||||
escapeMarkup: function(m) { return m; }
|
||||
});
|
||||
|
||||
loading_tip.hide();
|
||||
form.removeClass('hide');
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user