1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +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

@ -1817,38 +1817,39 @@ button.sf-dropdown-toggle:focus {
text-align:center;
}
/**** custom select2 ****/
.select2-container .select2-selection {
min-height:30px;
border-color:#ddd;
border-radius:2px;
.select2-container-multi .select2-choices {
border-color: #ddd;
border-radius: 2px;
background-image: none; /* rm the shadow */
}
.select2-container-multi .select2-choices .select2-search-field {
float:none;
}
.select2-container-multi .select2-choices .select2-search-field input {
padding:2px 2px 2px 5px;
font-family:inherit;
font-size:13px;
line-height:0; /* to remove the extra height */
}
.select2-container.select2-container--focus .select2-selection {
border-color: #66afe9;
}
.select2-container .select2-selection .select2-selection__rendered {
padding:0;
}
.select2-container .select2-selection .select2-selection__choice {
.select2-container-multi .select2-choices .select2-search-choice {
border:none;
border-radius:0;
background:#eee;
border-radius:2px;
margin:4px 0 0 5px;
}
.select2-container--default .select2-search--inline .select2-search__field {
padding:0 5px;
box-sizing:content-box;
.select2-container .avatar,
.select2-results .select2-result-label .avatar {
vertical-align:middle;
margin-right:3px;
}
.select2-results__option .avatar {
margin-right:10px;
}
.select2-results__option .text {
.select2-result-label .text {
display:inline-block;
width:calc(100% - 42px);
}
.select2-container .select2-selection__rendered {
line-height:1.5;
.select2-results .select2-result-label .avatar {
margin-right:10px;
}
.select2-result-label .avatar,
.select2-result-label .text {
vertical-align:middle;
}
/**** custom magnificPopup ****/
.mfp-bottom-bar {

View File

@ -341,17 +341,7 @@ function HTMLescape(html){
function userInputOPtionsForSelect2(user_search_url) {
return {
// with 'tags', the user can directly enter, not just select
tags: true,
tokenSeparators: [',', ' '],
createTag: function(params) {
var term = $.trim(params.term);
return {
'id': term,
'text': term
};
},
tags: [],
minimumInputLength: 1, // input at least 1 character
@ -362,10 +352,10 @@ function userInputOPtionsForSelect2(user_search_url) {
cache: true,
data: function (params) {
return {
q: params.term
q: params
};
},
processResults: function(data) {
results: function (data) {
var user_list = [], users = data['users'];
for (var i = 0, len = users.length; i < len; i++) {
user_list.push({ // 'id' & 'text' are required by the plugin
@ -384,19 +374,25 @@ function userInputOPtionsForSelect2(user_search_url) {
},
// format items shown in the drop-down menu
templateResult: function(item) {
formatResult: function(item) {
if (item.avatar_url) {
return '<img src="' + item.avatar_url + '" width="32" height="32" class="avatar vam">' + '<span class="text ellipsis vam">' + HTMLescape(item.name) + '<br />' + HTMLescape(item.id) + '</span>';
return '<img src="' + item.avatar_url + '" width="32" height="32" class="avatar">' + '<span class="text ellipsis">' + HTMLescape(item.name) + '<br />' + HTMLescape(item.id) + '</span>';
} else {
return; // if no match, show nothing
}
},
// format selected item shown in the input
templateSelection: function(item) {
formatSelection: function(item) {
return HTMLescape(item.name || item.id); // if no name, show the email, i.e., when directly input, show the email
},
createSearchChoice: function(term) {
return {
'id': $.trim(term)
};
},
escapeMarkup: function(m) { return m; }
};
}

View File

@ -14,7 +14,6 @@
<link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.min.css" %}"/>
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/jstree_default_theme/style.min.css" />
<link rel="stylesheet" type="text/css" href="{% static "css/magnific-popup.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.min.css" %}" />
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/seahub.css?t=1398068110" />
{% block extra_style %}{% endblock %}
{% if branding_css != '' %}<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}{{ branding_css }}" />{% endif %}
@ -153,44 +152,6 @@ function ajaxErrorHandler(xhr, textStatus, errorThrown) {
var error_msg = prepareAjaxErrorMsg(xhr);
feedback(error_msg, 'error');
}
// i18n for select2
var i18n_select2 = {
errorLoading: function() {
return "{% trans "Loading failed" %}";
},
inputTooLong: function(e) { // not used in seahub
var t = e.input.length - e.maximum,
n = "Please delete " + t + " character";
return t != 1 && (n += "s"), n
},
inputTooShort: function(e) {
/*
var t = e.minimum - e.input.length,
n = "Please enter " + t + " or more characters";
return n
*/
return "{% trans "Please enter 1 or more character" %}";
},
loadingMore: function() { // not used in seahub
return "Loading more results…"
},
maximumSelected: function(e) {
/*
var t = "You can only select " + e.maximum + " item";
return e.maximum != 1 && (t += "s"), t
*/
return "{% trans "You cannot select any more choices" %}";
},
noResults: function() {
//return "No results found"
return "{% trans "No matches" %}";
},
searching: function() {
return "{% trans "Searching..." %}";
}
};
{% if request.user.is_authenticated %}
{% if request.cur_note %}
$('#info-bar .close').on('click', function() {

View File

@ -13,7 +13,7 @@
{% compress css %}
<link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.min.css" %}" />
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/jstree_default_theme/style.min.css" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.min.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/magnific-popup.css" %}" />
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/seahub.css?t=1398068110" />
{% endcompress %}

View File

@ -400,7 +400,7 @@
<input type="text" name="library_name" value="" class="input" id="library-name" /><br />
<label for="library-owner">{% trans "Owner" %}</label>
<span class="tip">{% trans "(If left blank, owner will be admin)" %}</span><br />
<select name="library_owner" id="library-owner"></select><br />
<input type="hidden" name="library_owner" value="" id="library-owner" />
<p class="error hide"></p>
<input type="submit" class="submit" value="{% trans "Submit" %}" />
</form>
@ -614,7 +614,7 @@
<script type="text/template" id="library-transfer-form-tmpl">
<form method="" action="" id="repo-transfer-form">
<h3><%= title %></h3>
<select name="email"></select><br />
<input type="hidden" name="email" /><br />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" />
</form>
@ -685,7 +685,7 @@
<input type="text" name="group_name" value="" class="input" id="group-name" /><br />
<label for="group-owner">{% trans "Owner" %}</label>
<span class="tip">{% trans "(If left blank, owner will be admin)" %}</span><br />
<select name="group_owner" id="group-owner"></select><br />
<input type="hidden" name="group_owner" value="" id="group-owner" />
<p class="error hide"></p>
<input type="submit" class="submit" value="{% trans "Submit" %}" />
</form>
@ -718,7 +718,7 @@
<script type="text/template" id="group-transfer-form-tmpl">
<form method="" action="" id="group-transfer-form">
<h3><%= title %></h3>
<select name="email"></select><br />
<input type="hidden" name="email" /><br />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" />
</form>
@ -787,7 +787,7 @@
<div id="share-tabs" class="nav-con-tabs">
<ul class="nav-con-tabs-nav">
<li class="tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
<li class="tab" id="dir-group-share-tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
<li class="tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
</ul>
<div class="nav-con-tabs-content">
@ -804,7 +804,7 @@
<tbody>
<tr id="add-dir-user-share-item">
<td>
<select name="emails"></select>
<input type="hidden" name="emails" class="w100" />
</td>
<td>
<select name="permission" class="share-permission-select w100">
@ -834,7 +834,7 @@
<tbody>
<tr id="add-dir-group-share-item">
<td>
<select name="groups"></select>
<input type="groups" name="groups" class="w100" />
</td>
<td>
<select name="permission" class="share-permission-select w100">
@ -881,7 +881,7 @@
<form id="add-group-member-form" action="" method="post" class="hide">{% csrf_token %}
<h3 id="dialogTitle">{% trans "Add Member" %}</h3>
<label for="email">{% trans "Email" %}</label><br />
<select name="email" id="email"></select><br />
<input type="text" name="email" value="" id="email" /><br />
<p class="error hide"></p>
<input type="submit" class="submit" value="{% trans "Submit" %}" />
</form>

View File

@ -79,7 +79,7 @@
<script type="text/template" id="add-lib-label-form-tmpl">
<form action="" method="">
<h3 id="dialogTitle">{% trans "Label current state" %}</h3>
<select name="labels"></select>
<input type="hidden" name="labels" class="w100" />
<p class="error hide"></p>
<button type="submit" class="submit">{% trans "Submit" %}</button>
</form>
@ -1092,7 +1092,7 @@
<span class="loading-icon"></span>
<ul class="cur-tags hide ovhd"></ul>
<span class="sf2-icon-edit tags-edit-icon op-icon hide" title="{% trans "Edit" %}"></span>
<select class="tags-input hide"></select>
<input type="hidden" class="w100 hide tags-input" />
<button class="submit tags-submit-btn hide">{% trans "Submit" %}</button>
<p class="error hide"></p>
</td>
@ -1138,7 +1138,7 @@
<span class="loading-icon"></span>
<ul class="cur-tags hide ovhd"></ul>
<span class="sf2-icon-edit tags-edit-icon op-icon hide" title="{% trans "Edit" %}"></span>
<select class="tags-input hide"></select>
<input type="hidden" class="w100 hide tags-input" />
<button class="submit tags-submit-btn hide">{% trans "Submit" %}</button>
<p class="error hide"></p>
</td>
@ -1163,8 +1163,8 @@
<% } %>
<% if (enable_dir_private_share) { %> {# dir private share #}
<li class="tab" id="dir-user-share-tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
<li class="tab" id="dir-group-share-tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
<li class="tab"><a href="#dir-user-share" class="a">{% trans "Share to user" %}</a></li>
<li class="tab"><a href="#dir-group-share" class="a">{% trans "Share to group" %}</a></li>
<% } %>
<% } %>
</ul>
@ -1308,7 +1308,7 @@
<tbody>
<tr id="add-dir-user-share-item">
<td>
<select name="emails"></select>
<input type="hidden" name="emails" class="w100" />
</td>
<td>
<select name="permission" class="share-permission-select w100">
@ -1344,7 +1344,7 @@
<tbody>
<tr id="add-dir-group-share-item">
<td>
<select name="groups"></select>
<select name="groups" class="w100" multiple="multiple"></select>
</td>
<td>
<select name="permission" class="share-permission-select w100">
@ -1685,7 +1685,7 @@
<div id="folder-perm-tabs" class="nav-con-tabs">
<ul class="nav-con-tabs-nav">
<li class="tab"><a href="#user-folder-perm" class="a">{% trans "User Permission" %}</a></li>
<li class="tab" id="group-folder-perm-tab"><a href="#group-folder-perm" class="a">{% trans "Group Permission" %}</a></li>
<li class="tab"><a href="#group-folder-perm" class="a">{% trans "Group Permission" %}</a></li>
</ul>
<div class="nav-con-tabs-content">
<div id="user-folder-perm" class="tabs-panel">
@ -1700,7 +1700,7 @@
<tbody>
<tr id="add-user-folder-perm">
<td>
<select name="email"></select>
<input type="hidden" name="email" class="w100" />
</td>
<td>
<select name="permission" class="folder-perm-select w100">
@ -1726,7 +1726,7 @@
<tbody>
<tr id="add-group-folder-perm">
<td>
<select name="group"></select>
<select name="group" class="w100" multiple="multiple"></select>
</td>
<td>
<select name="permission" class="folder-perm-select w100">
@ -2085,7 +2085,7 @@
<script type="text/template" id="group-transfer-form-tmpl">
<form method="post" action="">
<h3 id="dialogTitle">{% trans "Transfer Group To" %}</h3>
<select name="email"></select><br />
<input type="hidden" name="email" /><br />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" />
</form>
@ -2103,7 +2103,7 @@
<script type="text/template" id="group-manage-members-tmpl">
<h3 id="dialogTitle"><%= title %></h3>
<form method="post" action="" id="add-group-members-form">
<select name="user_name"></select>
<input type="hidden" name="user_name" />
<input type="submit" value="{% trans "Add" %}" class="submit" />
</form>
{% if enable_guest_invitation and user.permissions.can_invite_guest %}
@ -2257,7 +2257,7 @@
<script type="text/template" id="repo-transfer-form-tmpl">
<form method="post" action="" id="repo-transfer-form">
<h3 id="dialogTitle"><%= title %></h3>
<select name="email"></select><br />
<input type="hidden" name="email" /><br />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" />
</form>
@ -2268,7 +2268,7 @@
<div id="repo-folder-perm" class="nav-con-tabs js-tabs">
<ul class="nav-con-tabs-nav">
<li class="tab"><a href="#js-repo-user-folder-perm" class="a">{% trans "User Permission" %}</a></li>
<li class="tab" id="repo-group-folder-perm-tab"><a href="#js-repo-group-folder-perm" class="a">{% trans "Group Permission" %}</a></li>
<li class="tab"><a href="#js-repo-group-folder-perm" class="a">{% trans "Group Permission" %}</a></li>
</ul>
<div class="nav-con-tabs-content">
@ -2285,9 +2285,7 @@
</thead>
<tbody>
<tr>
<td>
<select name="emails"></select>
</td>
<td><input name="emails" type="hidden" class="w100" /></td>
<td>
<div class="pos-rel">
<input type="text" name="folder_path" class="repo-folder-perm-folder-path" />
@ -2332,7 +2330,7 @@
<tbody>
<tr>
<td>
<select name="groups"></select>
<select name="groups" class="w100" multiple="multiple"></select>
</td>
<td>
<div class="pos-rel">

View File

@ -6,6 +6,8 @@
{% block sub_title %}{% trans "History" %} - {% endblock %}
{% block extra_style %}
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.custom.css" %}" />
<style type="text/css">
.go-back { top:-3px; }
</style>
@ -105,7 +107,7 @@
{% if show_label and user_perm == 'rw' %}
<form id="label-edit-form" action="" class="hide">
<h3 id="dialogTitle">{% trans "Edit labels" %}</h3>
<select name="labels"></select><br />
<input type="hidden" name="labels" /><br />
<p class="error hide"></p>
<button type="submit" class="submit">{% trans "Submit" %}</button>
</form>
@ -114,7 +116,7 @@
{% endblock %}
{% block extra_script %}
<script type="text/javascript" src="{% static "scripts/lib/select2.min.js" %}"></script>
<script type="text/javascript" src="{% static "scripts/lib/select2-3.5.2.js" %}"></script>
<script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %}
$('.view-snapshot').each(function() {
@ -129,20 +131,19 @@ $('.label-edit-icon').on('click', function() {
var label = $(item).text();
s2_tags.push({
'id': label,
'text': label,
'selected': true
'text': label
});
});
var $form = $('#label-edit-form');
$form.data('tr', $tr).modal({focus: false});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
$('[name="labels"]').select2({
language: i18n_select2,
multiple: true,
width: '280px',
tags: s2_tags
});
$('[name="labels"]')
.select2({
width: '280px',
tags: []
})
.select2('data', s2_tags);
});
$('#label-edit-form').on('submit', function() {
var $form = $(this);
@ -150,7 +151,7 @@ $('#label-edit-form').on('submit', function() {
var $error = $('.error', $form);
var $submit = $('[type="submit"]', $form);
var $tr = $form.data('tr');
var tags = $input.val();
var tags = $input.select2('val');
disable($submit);
$.ajax({

View File

@ -2,8 +2,9 @@
<form id="repo-transfer-form" method="" action="" class="hide">{% csrf_token %}
<h3>{% trans "Transfer Library"%}</h3>
<p class="detail">{% trans "Transfer %(lib_name)s to:"%}</p>
<select name="email"></select><br />
<input type="hidden" name="email" /><br />
<input type="hidden" name="repo_id" value="" />
<p class="error hide"></p>
<input type="submit" value="{% trans "Submit" %}" class="submit" />
<button class="simplemodal-close">{% trans "Cancel" %}</button>
</form>

View File

@ -7,18 +7,21 @@ $('.repo-transfer-btn').on('click', function(){
repo_name = btn_ct.attr('data-name'),
form = $('#repo-transfer-form');
form.modal({focus: false});
form.modal({appendTo:'#main'});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
var detail = $('.detail', form);
detail.html(detail.html().replace('%(lib_name)s', '<span class="op-target">' + HTMLescape(repo_name) + '</span>'));
$('[name="email"]', form).select2($.extend({
language: i18n_select2,
multiple: true, // to keep the same UI with the others
width: '268px',
maximumSelectionLength: 1,
placeholder: "{% trans "Search user or enter email and press Enter" %}"
maximumSelectionSize: 1,
placeholder: "{% trans "Search user or enter email and press Enter" %}",
formatInputTooShort: "{% trans "Please enter 1 or more character" %}",
formatNoMatches: "{% trans "No matches" %}",
formatSearching: "{% trans "Searching..." %}",
formatAjaxError: "{% trans "Loading failed" %}",
formatSelectionTooBig: "{% trans "You cannot select any more choices" %}"
}, userInputOPtionsForSelect2('{% url 'search-user' %}')));
$('input[name="repo_id"]', form).val(repo_id);
@ -30,17 +33,17 @@ $('#repo-transfer-form').on('submit', function() {
var form = $(this),
form_id = form.attr('id'),
repo_id = $('[name="repo_id"]', form).val(),
email = $('[name="email"]', form).val(); // []
email = $.trim(form.children('[name="email"]').val());
var $tr = form.data('tr');
if (!email.length) {
if (!email) {
return false;
}
$.ajax({
url: '{{SITE_ROOT}}api/v2.1/admin/libraries/' + encodeURIComponent(repo_id) + '/',
data: {'owner': email},
type: 'PUT',
data: {'owner': email[0]},
cache: false,
beforeSend: prepareCSRFToken,
dataType: 'json',

View File

@ -2,6 +2,11 @@
{% load i18n seahub_tags %}
{% load staticfiles %}
{% block extra_style %}
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.custom.css" %}" />
{% endblock %}
{% block right_panel %}
<div class="tabnav">
<ul class="tabnav-tabs">
@ -16,7 +21,7 @@
<form id="add-member-form" action="" method="" class="hide">
<h3>{% trans "Add Members" %}</h3>
<label>{% trans "Email" %}</label><br />
<select name="emails"></select><br />
<input type="hidden" name="emails" /><br />
<p class="error hide"></p>
<button type="submit" class="submit">{% trans "Submit" %}</button>
</form>
@ -66,7 +71,7 @@
{% endblock %}
{% block extra_script %}{{ block.super }}
<script type="text/javascript" src= "{% static "scripts/lib/select2.min.js" %}"></script>
<script type="text/javascript" src= "{% static "scripts/lib/select2-3.5.2.js" %}"></script>
<script type="text/javascript">
addConfirmTo($('.js-toggle-admin'), {
@ -134,17 +139,19 @@ $('#add-member-btn').on('click', function(){
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
$('[name="emails"]', $form).select2($.extend({
language: i18n_select2,
multiple: true,
width: '280px',
placeholder: "{% trans "Search users or enter emails and press Enter" %}"
placeholder: "{% trans "Search user or enter email and press Enter" %}",
formatInputTooShort: "{% trans "Please enter 1 or more character" %}",
formatNoMatches: "{% trans "No matches" %}",
formatSearching: "{% trans "Searching..." %}",
formatAjaxError: "{% trans "Loading failed" %}"
}, userInputOPtionsForSelect2('{% url 'search-user' %}')));
});
$('#add-member-form').on('submit', function(){
var $form = $(this);
var $error = $('.error', $form);
var $submit = $('[type="submit"]', $form);
var emails = $('[name="emails"]', $form).val();
var emails = $('[name="emails"]', $form).select2('val');
if (!emails.length) {
$error.html("{% trans "It is required." %}").show();

View File

@ -13,7 +13,7 @@
{% compress css %}
<link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.min.css" %}"/>
<link rel="stylesheet" type="text/css" href="{% static "css/select2.min.css" %}"/>
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}"/>
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/seahub.css?t=1398068110" />
<link rel="stylesheet" type="text/css" href="{% static "css/magnific-popup.css" %}" />
{% endcompress %}

View File

@ -1,6 +1,13 @@
{% extends "sysadmin/base.html" %}
{% load i18n avatar_tags seahub_tags staticfiles %}
{% block extra_style %}
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.custom.css" %}" />
{% endblock %}
{% block right_panel %}
<p class="path-bar">
@ -329,7 +336,7 @@
{% block extra_script %}
<script type="text/javascript" src="{% static "scripts/lib/jquery-ui.min.js" %}"></script> {# for tabs #}
<script type="text/javascript" src="{% static "scripts/lib/select2.min.js" %}"></script>
<script type="text/javascript" src="{% static "scripts/lib/select2-3.5.2.js" %}"></script>
<script type="text/javascript">
$('#tabs').tabs({cookie:{expires:1}});

View File

@ -0,0 +1,704 @@
/*
Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
*/
.select2-container {
margin: 0;
position: relative;
display: inline-block;
/* inline-block for ie7 */
zoom: 1;
*display: inline;
vertical-align: middle;
}
.select2-container,
.select2-drop,
.select2-search,
.select2-search input {
/*
Force border-box so that % widths fit the parent
container without overlap because of margin/padding.
More Info : http://www.quirksmode.org/css/box.html
*/
-webkit-box-sizing: border-box; /* webkit */
-moz-box-sizing: border-box; /* firefox */
box-sizing: border-box; /* css3 */
}
.select2-container .select2-choice {
display: block;
height: 26px;
padding: 0 0 0 8px;
overflow: hidden;
position: relative;
border: 1px solid #aaa;
white-space: nowrap;
line-height: 26px;
color: #444;
text-decoration: none;
border-radius: 4px;
background-clip: padding-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #fff;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
background-image: linear-gradient(to top, #eee 0%, #fff 50%);
}
html[dir="rtl"] .select2-container .select2-choice {
padding: 0 8px 0 0;
}
.select2-container.select2-drop-above .select2-choice {
border-bottom-color: #aaa;
border-radius: 0 0 4px 4px;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
background-image: linear-gradient(to bottom, #eee 0%, #fff 90%);
}
.select2-container.select2-allowclear .select2-choice .select2-chosen {
margin-right: 42px;
}
.select2-container .select2-choice > .select2-chosen {
margin-right: 26px;
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
float: none;
width: auto;
}
html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
margin-left: 26px;
margin-right: 0;
}
.select2-container .select2-choice abbr {
display: none;
width: 12px;
height: 12px;
position: absolute;
right: 24px;
top: 8px;
font-size: 1px;
text-decoration: none;
border: 0;
background: url('select2.png') right top no-repeat;
cursor: pointer;
outline: 0;
}
.select2-container.select2-allowclear .select2-choice abbr {
display: inline-block;
}
.select2-container .select2-choice abbr:hover {
background-position: right -11px;
cursor: pointer;
}
.select2-drop-mask {
border: 0;
margin: 0;
padding: 0;
position: fixed;
left: 0;
top: 0;
min-height: 100%;
min-width: 100%;
height: auto;
width: auto;
opacity: 0;
z-index: 9998;
/* styles required for IE to work */
background-color: #fff;
filter: alpha(opacity=0);
}
.select2-drop {
width: 100%;
margin-top: -1px;
position: absolute;
z-index: 9999;
top: 100%;
background: #fff;
color: #000;
border: 1px solid #aaa;
border-top: 0;
border-radius: 0 0 4px 4px;
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
}
.select2-drop.select2-drop-above {
margin-top: 1px;
border-top: 1px solid #aaa;
border-bottom: 0;
border-radius: 4px 4px 0 0;
-webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
}
.select2-drop-active {
border: 1px solid #5897fb;
border-top: none;
}
.select2-drop.select2-drop-above.select2-drop-active {
border-top: 1px solid #5897fb;
}
.select2-drop-auto-width {
border-top: 1px solid #aaa;
width: auto;
}
.select2-drop-auto-width .select2-search {
padding-top: 4px;
}
.select2-container .select2-choice .select2-arrow {
display: inline-block;
width: 18px;
height: 100%;
position: absolute;
right: 0;
top: 0;
border-left: 1px solid #aaa;
border-radius: 0 4px 4px 0;
background-clip: padding-box;
background: #ccc;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
}
html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
left: 0;
right: auto;
border-left: none;
border-right: 1px solid #aaa;
border-radius: 4px 0 0 4px;
}
.select2-container .select2-choice .select2-arrow b {
display: block;
width: 100%;
height: 100%;
background: url('select2.png') no-repeat 0 1px;
}
html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
background-position: 2px 1px;
}
.select2-search {
display: inline-block;
width: 100%;
min-height: 26px;
margin: 0;
padding-left: 4px;
padding-right: 4px;
position: relative;
z-index: 10000;
white-space: nowrap;
}
.select2-search input {
width: 100%;
height: auto !important;
min-height: 26px;
padding: 4px 20px 4px 5px;
margin: 0;
outline: 0;
font-family: sans-serif;
font-size: 1em;
border: 1px solid #aaa;
border-radius: 0;
-webkit-box-shadow: none;
box-shadow: none;
background: #fff url('select2.png') no-repeat 100% -22px;
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
html[dir="rtl"] .select2-search input {
padding: 4px 5px 4px 20px;
background: #fff url('select2.png') no-repeat -37px -22px;
background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
.select2-drop.select2-drop-above .select2-search input {
margin-top: 4px;
}
.select2-search input.select2-active {
background: #fff url('select2-spinner.gif') no-repeat 100%;
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
}
.select2-container-active .select2-choice,
.select2-container-active .select2-choices {
border: 1px solid #5897fb;
outline: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.select2-dropdown-open .select2-choice {
border-bottom-color: transparent;
-webkit-box-shadow: 0 1px 0 #fff inset;
box-shadow: 0 1px 0 #fff inset;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
background-color: #eee;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
background-image: linear-gradient(to top, #fff 0%, #eee 50%);
}
.select2-dropdown-open.select2-drop-above .select2-choice,
.select2-dropdown-open.select2-drop-above .select2-choices {
border: 1px solid #5897fb;
border-top-color: transparent;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
background-image: linear-gradient(to bottom, #fff 0%, #eee 50%);
}
.select2-dropdown-open .select2-choice .select2-arrow {
background: transparent;
border-left: none;
filter: none;
}
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
border-right: none;
}
.select2-dropdown-open .select2-choice .select2-arrow b {
background-position: -18px 1px;
}
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
background-position: -16px 1px;
}
.select2-hidden-accessible {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/* results */
.select2-results {
max-height: 200px;
padding: 0 0 0 4px;
margin: 4px 4px 4px 0;
position: relative;
overflow-x: hidden;
overflow-y: auto;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html[dir="rtl"] .select2-results {
padding: 0 4px 0 0;
margin: 4px 0 4px 4px;
}
.select2-results ul.select2-result-sub {
margin: 0;
padding-left: 0;
}
.select2-results li {
list-style: none;
display: list-item;
background-image: none;
}
.select2-results li.select2-result-with-children > .select2-result-label {
font-weight: bold;
}
.select2-results .select2-result-label {
padding: 3px 7px 4px;
margin: 0;
cursor: pointer;
min-height: 1em;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.select2-results-dept-1 .select2-result-label { padding-left: 20px }
.select2-results-dept-2 .select2-result-label { padding-left: 40px }
.select2-results-dept-3 .select2-result-label { padding-left: 60px }
.select2-results-dept-4 .select2-result-label { padding-left: 80px }
.select2-results-dept-5 .select2-result-label { padding-left: 100px }
.select2-results-dept-6 .select2-result-label { padding-left: 110px }
.select2-results-dept-7 .select2-result-label { padding-left: 120px }
.select2-results .select2-highlighted {
background: #3875d7;
color: #fff;
}
.select2-results li em {
background: #feffde;
font-style: normal;
}
.select2-results .select2-highlighted em {
background: transparent;
}
.select2-results .select2-highlighted ul {
background: #fff;
color: #000;
}
.select2-results .select2-no-results,
.select2-results .select2-searching,
.select2-results .select2-ajax-error,
.select2-results .select2-selection-limit {
background: #f4f4f4;
display: list-item;
padding-left: 5px;
}
/*
disabled look for disabled choices in the results dropdown
*/
.select2-results .select2-disabled.select2-highlighted {
color: #666;
background: #f4f4f4;
display: list-item;
cursor: default;
}
.select2-results .select2-disabled {
background: #f4f4f4;
display: list-item;
cursor: default;
}
.select2-results .select2-selected {
display: none;
}
.select2-more-results.select2-active {
background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
}
.select2-results .select2-ajax-error {
background: rgba(255, 50, 50, .2);
}
.select2-more-results {
background: #f4f4f4;
display: list-item;
}
/* disabled styles */
.select2-container.select2-container-disabled .select2-choice {
background-color: #f4f4f4;
background-image: none;
border: 1px solid #ddd;
cursor: default;
}
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
background-color: #f4f4f4;
background-image: none;
border-left: 0;
}
.select2-container.select2-container-disabled .select2-choice abbr {
display: none;
}
/* multiselect */
.select2-container-multi .select2-choices {
height: auto !important;
height: 1%;
margin: 0;
padding: 0 5px 0 0;
position: relative;
border: 1px solid #aaa;
cursor: text;
overflow: hidden;
background-color: #fff;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
background-image: linear-gradient(to bottom, #eee 1%, #fff 15%);
}
html[dir="rtl"] .select2-container-multi .select2-choices {
padding: 0 0 0 5px;
}
.select2-locked {
padding: 3px 5px 3px 5px !important;
}
.select2-container-multi .select2-choices {
min-height: 26px;
}
.select2-container-multi.select2-container-active .select2-choices {
border: 1px solid #5897fb;
outline: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.select2-container-multi .select2-choices li {
float: left;
list-style: none;
}
html[dir="rtl"] .select2-container-multi .select2-choices li
{
float: right;
}
.select2-container-multi .select2-choices .select2-search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.select2-container-multi .select2-choices .select2-search-field input {
padding: 5px;
margin: 1px 0;
font-family: sans-serif;
font-size: 100%;
color: #666;
outline: 0;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
background: transparent !important;
}
.select2-container-multi .select2-choices .select2-search-field input.select2-active {
background: #fff url('select2-spinner.gif') no-repeat 100% !important;
}
.select2-default {
color: #999 !important;
}
.select2-container-multi .select2-choices .select2-search-choice {
padding: 3px 5px 3px 18px;
margin: 3px 0 3px 5px;
position: relative;
line-height: 13px;
color: #333;
cursor: default;
border: 1px solid #aaaaaa;
border-radius: 3px;
-webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
background-clip: padding-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #e4e4e4;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
}
html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
{
margin: 3px 5px 3px 0;
padding: 3px 18px 3px 5px;
}
.select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
cursor: default;
}
.select2-container-multi .select2-choices .select2-search-choice-focus {
background: #d4d4d4;
}
.select2-search-choice-close {
display: block;
width: 12px;
height: 13px;
position: absolute;
right: 3px;
top: 4px;
font-size: 1px;
outline: none;
background: url('select2.png') right top no-repeat;
}
html[dir="rtl"] .select2-search-choice-close {
right: auto;
left: 3px;
}
.select2-container-multi .select2-search-choice-close {
left: 3px;
}
html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
left: auto;
right: 2px;
}
.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
background-position: right -11px;
}
.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
background-position: right -11px;
}
/* disabled styles */
.select2-container-multi.select2-container-disabled .select2-choices {
background-color: #f4f4f4;
background-image: none;
border: 1px solid #ddd;
cursor: default;
}
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
padding: 3px 5px 3px 5px;
border: 1px solid #ddd;
background-image: none;
background-color: #f4f4f4;
}
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
background: none;
}
/* end multiselect */
.select2-result-selectable .select2-match,
.select2-result-unselectable .select2-match {
text-decoration: underline;
}
.select2-offscreen, .select2-offscreen:focus {
clip: rect(0 0 0 0) !important;
width: 1px !important;
height: 1px !important;
border: 0 !important;
margin: 0 !important;
padding: 0 !important;
overflow: hidden !important;
position: absolute !important;
outline: 0 !important;
left: 0px !important;
top: 0px !important;
}
.select2-display-none {
display: none;
}
.select2-measure-scrollbar {
position: absolute;
top: -10000px;
left: -10000px;
width: 100px;
height: 100px;
overflow: scroll;
}
/* Retina-ize icons */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
.select2-search input,
.select2-search-choice-close,
.select2-container .select2-choice abbr,
.select2-container .select2-choice .select2-arrow b {
background-image: url('select2x2.png') !important;
background-repeat: no-repeat !important;
background-size: 60px 40px !important;
}
.select2-search input {
background-position: 100% -21px !important;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,14 @@
/* custom select2 */
.select2-container-multi .select2-choices {
border-color: #ddd;
border-radius: 2px;
background-image: none; /* rm the shadow */
}
.select2-container-multi .select2-choices .select2-search-field input {
padding:2px 2px 2px 5px;
}
.select2-container-multi .select2-choices .select2-search-choice {
border:none;
border-radius:0;
background:#eee;
}

File diff suppressed because one or more lines are too long

BIN
static/css/select2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

BIN
static/css/select2x2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

View File

@ -98,9 +98,21 @@ define([
if (collection.perm_type == 'user') {
$('[name="emails"]', $panel).select2($.extend(
Common.contactInputOptionsForSelect2(), {
'width': '100%'
}));
Common.contactInputOptionsForSelect2(), {
placeholder: gettext("Search user or enter email and press Enter") // to override 'placeholder' returned by `Common.conta...`
}));
} else {
var groups = app.pageOptions.joined_groups_exclude_address_book || [];
var g_opts = '';
for (var i = 0, len = groups.length; i < len; i++) {
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
}
$('[name="groups"]', $panel).html(g_opts).select2({
placeholder: gettext("Select a group"),
maximumSelectionSize: 1,
formatSelectionTooBig: gettext("You can only select 1 item"),
escapeMarkup: function(m) { return m; }
});
}
// show existing items
@ -135,8 +147,6 @@ define([
},
events: {
'click #repo-group-folder-perm-tab': 'clickGroupPermTab',
'click .js-add-folder': 'showFolderSelectForm',
'click .js-folder-select-submit': 'addFolder',
'click .js-folder-select-cancel': 'cancelFolderSelect',
@ -145,25 +155,6 @@ define([
'click .js-group-perm-add-submit': 'addPerm'
},
clickGroupPermTab: function() {
var groups = app.pageOptions.joined_groups_exclude_address_book || [];
var group_list = [];
for (var i = 0, len = groups.length; i < len; i++) {
group_list.push({
id: groups[i].id,
text: groups[i].name
});
}
$('[name="groups"]', this.$groupPermPanel).select2({
language: Common.i18nForSelect2(),
width: '100%',
multiple: true,
data: group_list,
placeholder: gettext("Select groups"),
escapeMarkup: function(m) { return m; }
});
},
showFolderSelectForm: function(e) {
var $icon = $(e.currentTarget);
var $permContent = $icon.closest('.js-folder-perm-content').slideUp();
@ -225,36 +216,29 @@ define([
if ($submit.hasClass('js-user-perm-add-submit')) {
for_user = true;
$panel = this.$userPermPanel;
$email_or_group = $('[name="emails"]', $panel);
url = Common.getUrl({name: 'repo_user_folder_perm', repo_id: this.repo_id});
url = Common.getUrl({
name: 'repo_user_folder_perm',
repo_id: this.repo_id
});
var emails = $email_or_group.val(); // []
if (!emails.length) {
var $email_or_group = $('[name="emails"]', $panel);
var email = $email_or_group.val();
if (!email) {
return false;
}
post_data = {'user_email': emails};
post_data = {'user_email': email.split(',')};
} else {
for_user = false;
$panel = this.$groupPermPanel;
$email_or_group = $('[name="groups"]', $panel);
url = Common.getUrl({name: 'repo_group_folder_perm', repo_id: this.repo_id});
url = Common.getUrl({
name: 'repo_group_folder_perm',
repo_id: this.repo_id
});
var groups = $email_or_group.val();
if (!groups.length) {
var $email_or_group = $('[name="groups"]', $panel);
var group_val = $email_or_group.val().join(',');
if (!group_val) {
return false;
}
post_data = {'group_id': groups};
post_data = {'group_id': group_val.split(',')};
}
var $path = $('[name="folder_path"]', $panel);
@ -266,10 +250,7 @@ define([
return false;
}
$.extend(post_data, {
'folder_path': path,
'permission': perm
});
$.extend(post_data, {'folder_path': path, 'permission': perm});
var $error = $('.error', $panel);
Common.disableButton($submit);
@ -286,16 +267,12 @@ define([
$(data.success).each(function(index, item) {
var encoded_path = Common.encodePath(item.folder_path);
var perm_item = new ItemView({
item_data: $.extend(item, {
'for_user': for_user,
'show_folder_path': true,
'encoded_path': encoded_path
})
item_data: $.extend(item, {'for_user': for_user, 'show_folder_path': true, 'encoded_path': encoded_path})
});
$path.closest('tr').after(perm_item.el);
$('[name="folder_path"]', $panel).closest('tr').after(perm_item.el);
});
$email_or_group.val(null).trigger('change');
$email_or_group.select2('val', '');
$path.val('');
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);

View File

@ -70,8 +70,7 @@ define([
str += '<li class="cur-tag fleft">' + Common.HTMLescape(tags[i].name) + '</li>';
s2_tags.push({
'id': tags[i].name,
'text': tags[i].name,
'selected': true
'text': tags[i].name
});
}
this.s2_tags = s2_tags;
@ -84,19 +83,18 @@ define([
this.$('.cur-tags, .tags-edit-icon').hide();
this.$('.tags-submit-btn').show();
var $input = this.$('.tags-input');
// Select2 has been initialized
if ($input.hasClass("select2-hidden-accessible")) {
this.$('.select2-container').show();
$input.val(this.s2_tags2).trigger('change'); // s2_tags2
var $input = this.$('input.tags-input');
var $s2_container = this.$('.tags-input.select2-container');
if ($s2_container.length) {
$input.select2('data', this.s2_tags);
$s2_container.show();
} else {
$input.show()
.select2({
language: Common.i18nForSelect2(),
width: '100%',
multiple: true,
tags: this.s2_tags
});
tags: [],
formatNoMatches: gettext("No matches")
})
.select2('data', this.s2_tags);
}
return false;
},
@ -104,7 +102,7 @@ define([
submitTags: function() {
var _this = this;
var $input = this.$('.tags-input');
var tags = $input.val();
var tags = $input.select2('val');
var $submit = this.$('.tags-submit-btn');
var $error = this.$('.tags-container .error');
var error_msg;
@ -141,14 +139,15 @@ define([
var s2_tags = [];
for (var i = 0, len = tags.length; i < len; i++) {
str += '<li class="cur-tag fleft">' + Common.HTMLescape(tags[i].name) + '</li>';
s2_tags.push(tags[i].name);
s2_tags.push({
'id': tags[i].name,
'text': tags[i].name
});
}
_this.s2_tags2 = s2_tags; // s2_tags2
_this.s2_tags = s2_tags;
$input.hide();
_this.$('.tags-input').hide();
$submit.hide();
_this.$('.select2-container').hide();
_this.$('.cur-tags').html(str).show();
_this.$('.tags-edit-icon').show();
},

View File

@ -120,37 +120,18 @@ define([
'group_id': this.group_id
});
}
$('[name="email"]', this.$add_user_perm).select2($.extend({
'width': '100%'
}, Common.contactInputOptionsForSelect2({'url': url})));
},
events: {
'click #group-folder-perm-tab': 'clickGroupFolderPermTab',
'click #add-user-folder-perm .submit': 'addFolderPerm',
'click #add-group-folder-perm .submit': 'addFolderPerm'
},
clickGroupFolderPermTab: function() {
var _this = this;
$('[name="email"]', this.$add_user_perm).select2(
Common.contactInputOptionsForSelect2({'url': url}));
// use select2 to 'group' input in 'add group perm'
var groups;
var prepareGroupSelector = function(groups) {
var group_list = [];
var g_opts = '';
for (var i = 0, len = groups.length; i < len; i++) {
group_list.push({
id: groups[i].id,
text: groups[i].name
});
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
}
$('[name="group"]', _this.$add_group_perm).select2({
language: Common.i18nForSelect2(),
width: '100%',
multiple: true,
$('[name="group"]', _this.$add_group_perm).html(g_opts).select2({
placeholder: gettext("Select groups"),
data: group_list,
escapeMarkup: function(m) { return m; }
});
};
@ -178,12 +159,16 @@ define([
}
},
events: {
'click #add-user-folder-perm .submit': 'addFolderPerm',
'click #add-group-folder-perm .submit': 'addFolderPerm'
},
addFolderPerm: function(e) {
var $form, $input, $error, url, perm, post_data, extended_data;
var $form, $error, url, post_data, extended_data;
if ($(e.currentTarget).closest('tr').attr('id') == 'add-user-folder-perm') {
$form = this.$add_user_perm;
$input = $('[name="email"]', $form);
$error = $('#user-folder-perm .error');
url = Common.getUrl({
@ -192,17 +177,17 @@ define([
'repo_user_folder_perm',
repo_id: this.repo_id
});
var emails_group_ids_input = $('[name="email"]', $form),
emails = emails_group_ids_input.val(),
perm = $('[name="permission"]', $form).val();
var emails = $input.val(); // []
perm = $('[name="permission"]', $form).val();
if (!emails.length || !perm) {
if (!emails || !perm) {
return false;
}
post_data = {
'folder_path': this.path,
'user_email': emails,
'user_email': emails.split(','),
'permission': perm
};
@ -213,7 +198,6 @@ define([
} else {
$form = this.$add_group_perm;
$input = $('[name="group"]', $form);
$error = $('#group-folder-perm .error');
url = Common.getUrl({
@ -223,16 +207,17 @@ define([
repo_id: this.repo_id
});
var group_ids = $input.val();
perm = $('[name="permission"]', $form).val();
var emails_group_ids_input = $('[name="group"]', $form),
group_ids = emails_group_ids_input.val().join(','),
perm = $('[name="permission"]', $form).val();
if (!group_ids.length || !perm) {
if (!group_ids || !perm) {
return false;
}
post_data = {
'folder_path': this.path,
'group_id': group_ids,
'group_id': group_ids.split(','),
'permission': perm
};
@ -262,7 +247,7 @@ define([
$form.closest('tr').after(perm_item.el);
});
$input.val(null).trigger('change');
emails_group_ids_input.select2("val", "");
$error.addClass('hide');
}
if (data.failed.length > 0) {

View File

@ -130,7 +130,7 @@ define([
validate: true,
prepend: true,
success: function() {
$input.val(null).trigger('change');
$input.select2('val', '');
},
error: function(collection, response, options) {
var error_msg = Common.prepareAjaxErrorMsg(response);
@ -148,7 +148,7 @@ define([
beforeSend: Common.prepareCSRFToken,
data: {'emails': input_val},
success: function(data) { // data: {success, failed}
$input.val(null).trigger('change');
$input.select2('val', '');
if (data.success.length > 0) {
_this.collection.add(data.success, {prepend: true});

View File

@ -146,13 +146,14 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '268px',
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.groupView.group.owner) {
@ -170,7 +171,7 @@ define([
dataType: 'json',
beforeSend: Common.prepareCSRFToken,
data: {
'owner': email[0]
'owner': email
},
success: function(data) {
_this.groupView.group = data;

View File

@ -243,13 +243,14 @@ define([
$('[name="email"]', $form).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '280px',
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')) {
@ -267,7 +268,7 @@ define([
dataType: 'json',
beforeSend: Common.prepareCSRFToken,
data: {
'owner': email[0]
'owner': email
},
success: function() {
$.modal.close();
@ -387,12 +388,7 @@ define([
});
}
$('#simplemodal-data').html($form);
$('[name="labels"]', $form).select2({
language: Common.i18nForSelect2(),
width: '100%',
multiple: true,
tags: s2_data
});
$('[name="labels"]', $form).select2({tags: s2_data});
},
error: function(xhr) {
var error_msg = Common.prepareAjaxErrorMsg(xhr);
@ -402,11 +398,11 @@ define([
$form.on('submit', function() {
var $input = $('[name="labels"]', $form);
var labels = $input.val();
var labels = $input.select2('val');
var $error = $('.error', $form);
var $submit = $('[type="submit"]', $form);
if (!labels.length) {
if (labels.length == 0) {
$error.html(gettext("It is required.")).show();
return false;
}

View File

@ -53,7 +53,7 @@ define([
}).modal({focus:false});
}
this.$("#share-tabs").tabs({});
this.$("#share-tabs").tabs();
if (!this.repo_encrypted && app.pageOptions.can_generate_share_link) {
this.downloadLinkPanelInit();
@ -106,9 +106,6 @@ define([
},
events: {
'click #dir-user-share-tab': 'clickUserShareTab',
'click #dir-group-share-tab': 'clickGroupShareTab',
'click [type="checkbox"]': 'clickCheckbox',
'click .shared-link': 'clickToSelect',
@ -140,40 +137,6 @@ define([
'click #add-dir-group-share-item .submit': 'dirGroupShare'
},
// To make select2 input get the right width
clickUserShareTab: function() {
var $add_item = $('#add-dir-user-share-item');
$('[name="emails"]', $add_item).select2($.extend({
'width': '100%'
}, Common.contactInputOptionsForSelect2()));
},
clickGroupShareTab: function() {
var $add_item = $('#add-dir-group-share-item');
var prepareGroupsSelector = function(groups) {
var group_list = [];
for (var i = 0, len = groups.length; i < len; i++) {
group_list.push({
id: groups[i].id,
text: groups[i].name
});
}
$('[name="groups"]', $add_item).select2({
language: Common.i18nForSelect2(),
width: '100%',
multiple: true,
placeholder: gettext("Select groups"),
data: group_list,
escapeMarkup: function(m) { return m; }
});
};
if (this.parent_group_id) { // group owned repo
this.prepareAvailableGroupsForGroupOwnedRepo({'callback': prepareGroupsSelector});
} else {
this.prepareAvailableGroups({'callback': prepareGroupsSelector});
}
},
clickCheckbox: function(e) {
var $el = $(e.currentTarget);
// for link options such as 'password', 'expire'
@ -676,6 +639,9 @@ define([
});
$add_item.after(new_item.el);
});
$('[name="emails"]', $add_item).select2($.extend({
//width: '292px' // the container will copy class 'w100' from the original element to get width
},Common.contactInputOptionsForSelect2()));
$table.removeClass('hide');
},
error: function(xhr, textStatus, errorThrown) {
@ -818,7 +784,23 @@ define([
});
$add_item.after(new_item.el);
});
$table.removeClass('hide');
var prepareGroupsSelector = function(groups) {
var g_opts = '';
for (var i = 0, len = groups.length; i < len; i++) {
g_opts += '<option value="' + groups[i].id + '" data-index="' + i + '">' + groups[i].name + '</option>';
}
$('[name="groups"]', $add_item).html(g_opts).select2({
placeholder: gettext("Select groups"),
escapeMarkup: function(m) { return m; }
});
$table.removeClass('hide');
};
if (_this.parent_group_id) { // group owned repo
_this.prepareAvailableGroupsForGroupOwnedRepo({'callback': prepareGroupsSelector});
} else {
_this.prepareAvailableGroups({'callback': prepareGroupsSelector});
}
},
error: function(xhr, textStatus, errorThrown) {
var err_msg = Common.prepareAjaxErrorMsg(xhr);
@ -840,9 +822,9 @@ define([
var $panel = $('#dir-user-share');
var $form = this.$('#add-dir-user-share-item'); // pseudo form
var $emails_input = $('[name="emails"]', $form),
emails = $emails_input.val(); // []
if (!emails.length) {
var emails_input = $('[name="emails"]', $form),
emails = emails_input.val(); // string
if (!emails) {
return false;
}
@ -864,7 +846,7 @@ define([
data = {
'permission': perm,
'path': path,
'username': emails
'username': emails.split(',')
};
} else {
url = Common.getUrl({
@ -874,7 +856,7 @@ define([
method = 'PUT';
data = {
'share_type': 'user',
'username': emails,
'username': emails.split(','),
'permission': perm
};
}
@ -898,7 +880,7 @@ define([
});
$add_item.after(new_item.el);
});
$emails_input.val(null).trigger('change'); // clear the selected items
emails_input.select2("val", "");
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');
@ -928,9 +910,9 @@ define([
var $form = this.$('#add-dir-group-share-item'); // pseudo form
var $groups_input = $('[name="groups"]', $form),
groups = $groups_input.val(); // [] or [group.id]
groups = $groups_input.val(); // null or [group.id]
if (!groups.length) {
if (!groups) {
return false;
}
@ -985,7 +967,7 @@ define([
});
$add_item.after(new_item.el);
});
$groups_input.val(null).trigger('change'); // clear the selected items
$groups_input.select2("val", "");
$('option', $perm).prop('selected', false);
$('[value="rw"]', $perm).prop('selected', true);
$error.addClass('hide');

View File

@ -43,7 +43,7 @@ require.config({
'js.cookie': 'lib/js.cookie',
simplemodal: 'lib/jquery.simplemodal', // TODO: it uses deprecated methods in jquery 3
jstree: 'lib/jstree.min', // TODO: it uses deprecated methods in jquery 3
select2: 'lib/select2.min',
select2: 'lib/select2-3.5.2', // TODO
moment: 'lib/moment-with-locales.min',
marked: 'lib/marked.min',
@ -659,44 +659,6 @@ define([
}
},
i18nForSelect2: function() {
return {
errorLoading: function() {
return gettext("Loading failed");
},
inputTooLong: function(e) { // not used in seahub
var t = e.input.length - e.maximum,
n = "Please delete " + t + " character";
return t != 1 && (n += "s"), n
},
inputTooShort: function(e) {
/*
var t = e.minimum - e.input.length,
n = "Please enter " + t + " or more characters";
return n
*/
return gettext("Please enter 1 or more character");
},
loadingMore: function() { // not used in seahub
return "Loading more results…"
},
maximumSelected: function(e) {
/*
var t = "You can only select " + e.maximum + " item";
return e.maximum != 1 && (t += "s"), t
*/
return gettext("You cannot select any more choices");
},
noResults: function() {
//return "No results found"
return gettext("No matches");
},
searching: function() {
return gettext("Searching...");
}
};
},
contactInputOptionsForSelect2: function(options) {
var _this = this;
@ -708,24 +670,19 @@ define([
}
return {
language: _this.i18nForSelect2(),
multiple: true,
placeholder: gettext("Search users or enter emails and press Enter"),
// with 'tags', the user can directly enter, not just select
tags: true,
tokenSeparators: [',', ' '],
createTag: function(params) {
var term = $.trim(params.term);
return {
'id': term,
'text': term
};
},
// tags need `<input type="hidden" />`, not `<select>`
tags: [],
minimumInputLength: 1, // input at least 1 character
formatInputTooShort: gettext("Please enter 1 or more character"),
formatNoMatches: gettext("No matches"),
formatSearching: gettext("Searching..."),
formatAjaxError: gettext("Loading failed"),
ajax: {
url: url,
dataType: 'json',
@ -733,10 +690,10 @@ define([
cache: true,
data: function(params) {
return {
q: params.term
q: params
};
},
processResults: function(data) {
results: function(data) {
var user_list = [], users = data['users'] || data;
for (var i = 0, len = users.length; i < len; i++) {
@ -758,19 +715,25 @@ define([
},
// format items shown in the drop-down menu
templateResult: function(item) {
formatResult: function(item) {
if (item.avatar_url) {
return '<img src="' + item.avatar_url + '" width="32" height="32" class="avatar vam"><span class="text ellipsis vam">' + _this.HTMLescape(item.name) + '<br />' + _this.HTMLescape(item.contact_email) + '</span>';
return '<img src="' + item.avatar_url + '" width="32" height="32" class="avatar"><span class="text ellipsis">' + _this.HTMLescape(item.name) + '<br />' + _this.HTMLescape(item.contact_email) + '</span>';
} else {
return; // if no match, show nothing
}
},
// format selected item shown in the input
templateSelection: function(item) {
formatSelection: function(item) {
return _this.HTMLescape(item.name || item.id); // if no name, show the email, i.e., when directly input, show the email
},
createSearchChoice: function(term) {
return {
'id': $.trim(term)
};
},
escapeMarkup: function(m) { return m; }
}
},
@ -778,13 +741,19 @@ define([
groupInputOptionsForSelect2: function() {
var _this = this;
return {
language: _this.i18nForSelect2(),
multiple: true,
placeholder: gettext("Search groups"),
// with 'tags', the user can directly enter, not just select
// tags need `<input type="hidden" />`, not `<select>`
tags: [],
minimumInputLength: 1, // input at least 1 character
formatInputTooShort: gettext("Please enter 1 or more character"),
formatNoMatches: gettext("No matches"),
formatSearching: gettext("Searching..."),
formatAjaxError: gettext("Loading failed"),
ajax: {
url: _this.getUrl({name: 'search_group'}),
dataType: 'json',
@ -792,10 +761,10 @@ define([
cache: true,
data: function(params) {
return {
q: params.term
q: params
};
},
processResults: function(data) {
results: function(data) {
var group_list = [], groups = data;
for (var i = 0, len = groups.length; i < len; i++) {
@ -813,7 +782,7 @@ define([
},
// format items shown in the drop-down menu
templateResult: function(item) {
formatResult: function(item) {
if (item.name) {
return '<span class="text ellipsis">' + _this.HTMLescape(item.name) + '</span>';
} else {
@ -822,7 +791,7 @@ define([
},
// format selected item shown in the input
templateSelection: function(item) {
formatSelection: function(item) {
return _this.HTMLescape(item.name);
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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;