diff --git a/media/css/seahub.css b/media/css/seahub.css
index 681c7ea478..5653046487 100644
--- a/media/css/seahub.css
+++ b/media/css/seahub.css
@@ -1728,39 +1728,38 @@ button.sf-dropdown-toggle:focus {
text-align:center;
}
/**** 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 {
- float:none;
-}
-.select2-container-multi .select2-choices .select2-search-field input {
- padding:2px 2px 2px 5px;
- font-family:inherit;
+.select2-container .select2-selection {
+ min-height:30px;
+ border-color:#ddd;
+ border-radius:2px;
font-size:13px;
+ line-height:0; /* to remove the extra height */
}
-.select2-container-multi .select2-choices .select2-search-choice {
+.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 {
border:none;
- border-radius:0;
background:#eee;
+ border-radius:2px;
+ margin:4px 0 0 5px;
}
-.select2-container .avatar,
-.select2-results .select2-result-label .avatar {
- vertical-align:middle;
- margin-right:3px;
+.select2-container--default .select2-search--inline .select2-search__field {
+ padding:0 5px;
+ box-sizing:content-box;
}
-.select2-result-label .text {
+.select2-results__option .avatar {
+ margin-right:10px;
+}
+.select2-results__option .text {
display:inline-block;
width:calc(100% - 42px);
}
-.select2-results .select2-result-label .avatar {
- margin-right:10px;
-}
-.select2-result-label .avatar,
-.select2-result-label .text {
- vertical-align:middle;
+.select2-container .select2-selection__rendered {
+ line-height:1.5;
}
/**** custom magnificPopup ****/
.mfp-bottom-bar {
diff --git a/media/js/base.js b/media/js/base.js
index d240ea823d..9d4cebba49 100644
--- a/media/js/base.js
+++ b/media/js/base.js
@@ -341,7 +341,17 @@ function HTMLescape(html){
function userInputOPtionsForSelect2(user_search_url) {
return {
- tags: [],
+
+ // 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
+ };
+ },
minimumInputLength: 1, // input at least 1 character
@@ -352,10 +362,10 @@ function userInputOPtionsForSelect2(user_search_url) {
cache: true,
data: function (params) {
return {
- q: params
+ q: params.term
};
},
- results: function (data) {
+ processResults: 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
@@ -374,25 +384,19 @@ function userInputOPtionsForSelect2(user_search_url) {
},
// format items shown in the drop-down menu
- formatResult: function(item) {
+ templateResult: function(item) {
if (item.avatar_url) {
- return '' + '' + HTMLescape(item.name) + '
' + HTMLescape(item.id) + '';
+ return '' + '' + HTMLescape(item.name) + '
' + HTMLescape(item.id) + '';
} else {
return; // if no match, show nothing
}
},
// format selected item shown in the input
- formatSelection: function(item) {
+ templateSelection: 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; }
};
}
diff --git a/seahub/templates/base.html b/seahub/templates/base.html
index 07c7568e05..27ed22768c 100644
--- a/seahub/templates/base.html
+++ b/seahub/templates/base.html
@@ -14,6 +14,7 @@
+
{% block extra_style %}{% endblock %}
{% if branding_css != '' %}{% endif %}
@@ -143,6 +144,44 @@ function ajaxErrorHandler(xhr, textStatus, errorThrown) {
feedback("{% trans "Failed. Please check the network." %}", '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() {
diff --git a/seahub/templates/base_for_backbone.html b/seahub/templates/base_for_backbone.html
index f0f4d4bffa..5118bdb727 100644
--- a/seahub/templates/base_for_backbone.html
+++ b/seahub/templates/base_for_backbone.html
@@ -13,7 +13,7 @@
{% compress css %}
-
+
{% endcompress %}
diff --git a/seahub/templates/js/sysadmin-templates.html b/seahub/templates/js/sysadmin-templates.html
index 84f907ae12..6f7cf6a13a 100644
--- a/seahub/templates/js/sysadmin-templates.html
+++ b/seahub/templates/js/sysadmin-templates.html
@@ -400,7 +400,7 @@
{% trans "(If left blank, owner will be admin)" %}
-
+