1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Revert "[select2] upgraded it to v4.0"

This reverts commit 62c3519e85.
This commit is contained in:
lian
2018-08-03 16:08:29 +08:00
parent 20cb4ce86f
commit ee8e4135ea
35 changed files with 4567 additions and 428 deletions

View File

@@ -155,15 +155,17 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '280px'
width: '275px',
containerCss: {'margin-bottom': '5px'},
placeholder: gettext("Search users or enter emails and press Enter")
}));
$form.submit(function() {
var emails = $('[name="email"]', $form).val();
var emails = $.trim($('[name="email"]', $form).val());
var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form);
if (!emails.length) {
if (!emails) {
$error.html(gettext("It is required.")).show();
return false;
}
@@ -178,7 +180,7 @@ define([
}),
type: 'POST',
dataType: 'json',
data: {'email': emails},
data: {'email': emails.split(',')},
traditional: true,
beforeSend: Common.prepareCSRFToken,
success: function(data) {

View File

@@ -36,16 +36,18 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '280px'
width: '275px',
containerCss: {'margin-bottom': '5px'},
placeholder: gettext("Search users or enter emails and press Enter")
}));
$form.on('submit', function() {
var group_id = _this.groupMemberCollection.group_id;
var emails = $('[name="email"]', $form).val();
var emails = $.trim($('[name="email"]', $form).val());
var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form);
if (!emails.length) {
if (!emails) {
$error.html(gettext("It is required.")).show();
return false;
}
@@ -62,7 +64,7 @@ define([
dataType: 'json',
beforeSend: Common.prepareCSRFToken,
traditional: true,
data: {'email': emails},
data: {'email': emails.split(',')},
success: function(data) {
if (data.success.length > 0) {
_this.groupMemberCollection.add(data.success, {prepend: true});

View File

@@ -70,15 +70,16 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '300px',
maximumSelectionLength: 1,
placeholder: gettext("Search user or enter email and press Enter")
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.on('submit', function() {
var email = $('[name="email"]', $(this)).val(); // []
var email = $.trim($('[name="email"]', $(this)).val());
var $submitBtn = $('[type="submit"]', $(this));
if (!email.length) {
if (!email) {
return false;
}
if (email == cur_owner) {
@@ -92,7 +93,7 @@ define([
dataType: 'json',
beforeSend: Common.prepareCSRFToken,
data: {
'new_owner': email[0]
'new_owner': email
},
success: function() {
$.modal.close();

View File

@@ -58,18 +58,20 @@ define([
_this = this;
$form.modal();
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
$('#simplemodal-container').css({'height':'auto'});
$('[name="group_owner"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '100%',
maximumSelectionLength: 1,
placeholder: gettext("Search user or enter email and press Enter")
width: '268px',
containerCss: {'margin-bottom': '5px'},
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.on('submit', function() {
var group_name = $.trim($('[name="group_name"]', $form).val());
var group_owner = $('[name="group_owner"]', $form).val();
var group_owner = $.trim($('[name="group_owner"]', $form).val());
var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form);
@@ -81,10 +83,7 @@ define([
$error.hide();
Common.disableButton($submitBtn);
groups.create({
'group_name': group_name,
'group_owner': group_owner[0]
}, {
groups.create({'group_name': group_name, 'group_owner': group_owner}, {
prepend: true,
wait: true,
success: function() {

View File

@@ -103,19 +103,19 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '300px',
maximumSelectionLength: 1,
placeholder: gettext("Search user or enter email and press Enter")
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.on('submit', function() {
var email = $('[name="email"]', $(this)).val(); // []
if (!email.length) {
var email = $.trim($('[name="email"]', $(this)).val());
if (!email) {
return false;
}
if (email == _this.model.get('owner')) {
return false;
}
email = email[0];
var url = Common.getUrl({'name': 'admin-library','repo_id': _this.model.get('id')});
var $submitBtn = $('[type="submit"]', $(this));

View File

@@ -52,14 +52,16 @@ define([
$('[name="library_owner"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '100%',
maximumSelectionLength: 1,
placeholder: gettext("Search user or enter email and press Enter")
width: '268px',
containerCss: {'margin-bottom': '5px'},
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));
$form.on('submit', function() {
var library_name = $.trim($('[name="library_name"]', $form).val());
var library_owner = $('[name="library_owner"]', $form).val();
var library_owner = $.trim($('[name="library_owner"]', $form).val());
var $error = $('.error', $form);
var $submitBtn = $('[type="submit"]', $form);
@@ -71,10 +73,7 @@ define([
$error.hide();
Common.disableButton($submitBtn);
repos.create({
'name': library_name,
'owner': library_owner[0]
}, {
repos.create({'name': library_name, 'owner': library_owner}, {
prepend: true,
wait: true,
success: function() {

View File

@@ -49,20 +49,10 @@ 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');
@@ -71,7 +61,7 @@ define([
var repo_id = this.repo_id;
$('[name="emails"]', $dir_user_share_panel).select2($.extend({
width: '100%'
//width: '292px' // the container will copy class 'w100' from the original element to get width
}, Common.contactInputOptionsForSelect2()));
Common.ajaxGet({
@@ -108,6 +98,10 @@ 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': {
@@ -139,12 +133,12 @@ define([
var $user_share_item = this.$('#add-dir-user-share-item');
var $emails_input = $('[name="emails"]', $user_share_item),
emails = $emails_input.val(); // []
emails = $emails_input.val(); // string
var $perm = $('[name="permission"]', $user_share_item),
perm = $perm.val();
if (!emails.length || !perm) {
if (!emails || !perm) {
return false;
}
@@ -162,7 +156,7 @@ define([
data: {
'repo_id': repo_id,
'share_type': 'user',
'share_to': emails,
'share_to': emails.split(','),
'permission': perm
},
success: function(data) {
@@ -180,7 +174,7 @@ define([
});
$user_share_item.after(new_item.el);
});
$emails_input.val(null).trigger('change');
$emails_input.select2("val", "");
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');
@@ -207,12 +201,12 @@ define([
var $group_share_item= this.$('#add-dir-group-share-item');
var $groups_input = $('[name="groups"]', $group_share_item),
groups = $groups_input.val(); // []
groups = $groups_input.val(); // string
var $perm = $('[name="permission"]', $group_share_item),
perm = $perm.val();
if (!groups.length || !perm) {
if (!groups || !perm) {
return false;
}
@@ -231,7 +225,7 @@ define([
data: {
'repo_id': repo_id,
'share_type': 'group',
'share_to': groups,
'share_to': groups.split(','),
'permission': perm
},
success: function(data) {
@@ -249,7 +243,7 @@ define([
});
$group_share_item.after(new_item.el);
});
$groups_input.val(null).trigger('change');
$groups_input.select2("val", "");
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');
@@ -271,6 +265,7 @@ define([
}
});
}
});
return SharePopupView;