1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-11 03:41:12 +00:00

[select2] upgraded it to v4.0

This commit is contained in:
llj
2018-07-26 18:28:17 +08:00
parent d9fbe44381
commit 62c3519e85
35 changed files with 428 additions and 4568 deletions

View File

@@ -49,10 +49,20 @@ define([
},
events: {
'click #dir-group-share-tab': 'clickDirGroupShareTab',
'click #add-dir-user-share-item .submit': 'dirUserShare',
'click #add-dir-group-share-item .submit': 'dirGroupShare'
},
clickDirGroupShareTab: function() {
var $dir_group_share_panel = this.$('#dir-group-share');
$('[name="groups"]', $dir_group_share_panel).select2($.extend({
'width': '100%'
}, Common.groupInputOptionsForSelect2()));
},
dirUserSharePanelInit: function() {
var $dir_user_share_panel = this.$('#dir-user-share');
@@ -61,7 +71,7 @@ define([
var repo_id = this.repo_id;
$('[name="emails"]', $dir_user_share_panel).select2($.extend({
//width: '292px' // the container will copy class 'w100' from the original element to get width
width: '100%'
}, Common.contactInputOptionsForSelect2()));
Common.ajaxGet({
@@ -98,10 +108,6 @@ define([
var $add_item = this.$('#add-dir-group-share-item');
var repo_id = this.repo_id;
$('[name="groups"]', $dir_group_share_panel).select2($.extend({
//width: '292px' // the container will copy class 'w100' from the original element to get width
}, Common.groupInputOptionsForSelect2()));
Common.ajaxGet({
'get_url': Common.getUrl({name: 'admin_shares'}),
'data': {
@@ -133,12 +139,12 @@ define([
var $user_share_item = this.$('#add-dir-user-share-item');
var $emails_input = $('[name="emails"]', $user_share_item),
emails = $emails_input.val(); // string
emails = $emails_input.val(); // []
var $perm = $('[name="permission"]', $user_share_item),
perm = $perm.val();
if (!emails || !perm) {
if (!emails.length || !perm) {
return false;
}
@@ -156,7 +162,7 @@ define([
data: {
'repo_id': repo_id,
'share_type': 'user',
'share_to': emails.split(','),
'share_to': emails,
'permission': perm
},
success: function(data) {
@@ -174,7 +180,7 @@ define([
});
$user_share_item.after(new_item.el);
});
$emails_input.select2("val", "");
$emails_input.val(null).trigger('change');
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');
@@ -206,12 +212,12 @@ define([
var $group_share_item= this.$('#add-dir-group-share-item');
var $groups_input = $('[name="groups"]', $group_share_item),
groups = $groups_input.val(); // string
groups = $groups_input.val(); // []
var $perm = $('[name="permission"]', $group_share_item),
perm = $perm.val();
if (!groups || !perm) {
if (!groups.length || !perm) {
return false;
}
@@ -230,7 +236,7 @@ define([
data: {
'repo_id': repo_id,
'share_type': 'group',
'share_to': groups.split(','),
'share_to': groups,
'permission': perm
},
success: function(data) {
@@ -248,7 +254,7 @@ define([
});
$group_share_item.after(new_item.el);
});
$groups_input.select2("val", "");
$groups_input.val(null).trigger('change');
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');
@@ -275,7 +281,6 @@ define([
}
});
}
});
return SharePopupView;