Fix something I think
This commit is contained in:
parent
e58b8c2aad
commit
b120322732
|
@ -124,6 +124,7 @@
|
|||
]
|
||||
})
|
||||
|
||||
function initUserSelect(data) {
|
||||
$('#users').select2({
|
||||
ajax: {
|
||||
url: '/admin/users.json',
|
||||
|
@ -143,52 +144,43 @@
|
|||
|
||||
cache: true,
|
||||
},
|
||||
data: data,
|
||||
minimumInputLength: 2,
|
||||
templateResult: function (data) {
|
||||
if (data.loading) return escapeHtml(data.text);
|
||||
if (data.loading) return data.text;
|
||||
const $container = $(
|
||||
"<div class='select2-result-repository clearfix' style='display:flex;'>" +
|
||||
"<div class='select2-result-repository__avatar' style='display:flex;align-items:center;'><img class='img-circle img-bordered-s' src='" + data.avatarUrl + "?s=40' /></div>" +
|
||||
"<div class='select2-result-repository__meta' style='margin-left:10px'>" +
|
||||
"<div class='select2-result-repository__username' style='font-size:16px;'></div>" +
|
||||
"<div class='select2-result-repository__email' style='font-size=13px;'></div>" +
|
||||
"<div class='select2-result-users clearfix' style='display:flex;'>" +
|
||||
"<div class='select2-result-users__avatar' style='display:flex;align-items:center;'><img class='img-circle img-bordered-s' src='" + data.avatarUrl + "?s=40' /></div>" +
|
||||
"<div class='select2-result-users__meta' style='margin-left:10px'>" +
|
||||
"<div class='select2-result-users__username' style='font-size:16px;'></div>" +
|
||||
"<div class='select2-result-users__email' style='font-size=13px;'></div>" +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
$container.find(".select2-result-repository__username").text(data.name);
|
||||
$container.find(".select2-result-repository__email").text(data.email);
|
||||
$container.find(".select2-result-users__username").text(data.name);
|
||||
$container.find(".select2-result-users__email").text(data.email);
|
||||
|
||||
return $container;
|
||||
{{-- return $('<div class="user-block"> \
|
||||
<img class="img-circle img-bordered-xs" src="' + escapeHtml(data.avatarUrl) + '?s=120" alt="User Image"> \
|
||||
<span class="username"> \
|
||||
<a href="#">' + escapeHtml(data.name) +'</a> \
|
||||
</span> \
|
||||
<span class="description"><strong>' + escapeHtml(data.email) + '</strong></span> \
|
||||
</div>'); --}}
|
||||
},
|
||||
templateSelection: function (data) {
|
||||
return $('<div> \
|
||||
$container = $('<div> \
|
||||
<span> \
|
||||
<img class="img-rounded img-bordered-xs" src="' + escapeHtml(data.avatarUrl) + '?s=120" style="height:24px;margin-top:-4px;" alt="User Image"> \
|
||||
</span> \
|
||||
<span style="padding-left:10px;padding-right:10px;"> \
|
||||
' + escapeHtml(data.name) +' \
|
||||
<img class="img-rounded img-bordered-xs" src="' + data.avatarUrl + '?s=120" style="height:24px;margin-top:-4px;" alt="User Image"> \
|
||||
</span> \
|
||||
<span class="select2-selection-users__username" style="padding-left:10px;padding-right:10px;"></span> \
|
||||
</div>');
|
||||
$container.find(".select2-selection-users__username").text(data.name);
|
||||
return $container;
|
||||
}
|
||||
})
|
||||
}
|
||||
initUserSelect()
|
||||
})
|
||||
|
||||
function toggleClass(id, className) {
|
||||
document.getElementById(id).classList.toggle(className)
|
||||
}
|
||||
function escapeHtml(str) {
|
||||
var div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(str));
|
||||
return div.innerHTML;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue