Commit c0dc356d authored by Geoffroy ARNOUD's avatar Geoffroy ARNOUD

Managed logos and css #K7

parent 1feda93e
......@@ -13,7 +13,7 @@
<?php
if ($useSelect2) {
echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />'.PHP_EOL;
echo '<link rel="stylesheet" href="'. $_SERVER['SCRIPT_NAME'] .'/select2.css" type="text/css" >'.PHP_EOL;
echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>'.PHP_EOL;
echo '<script type="text/javascript" src="'.$javascriptURL .'/select2Functions.js"></script>'.PHP_EOL;
} elseif ($useImprovedDropDownList) {
......@@ -98,8 +98,8 @@
},
placeholder: "<?php echo getLocalString('select_idp') ?>",
allowClear: true,
// templateResult: formatList,
// templateSelection: formatRepoSelection,
templateResult: formatList,
templateSelection: formatSelection,
escapeMarkup: function (text) { return text; }
});
......
......@@ -7,6 +7,7 @@
<p class="promptMessage"><?php echo getLocalString('permanent_cookie'); ?></p>
<p><?php echo getLocalString('select_idp'); ?></p>
<div style="text-align: center">
<select name="user_idp" id="userIdPSelection" class="userIdPSelection" tabindex="0">
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
......
......@@ -56,7 +56,7 @@ final class IdpObject
}
// languages
if (isset($value{"Name"})) {
// Asume it's a language
// Assume it's a language
$this->names{$key} = $value{"Name"};
}
}
......@@ -124,7 +124,6 @@ final class IdpRepository
array_filter(
$this->idpObjects,
function ($value) use ($query) {
// FIXME : ne pas comparer les accents
return (
fnmatch("*".removeAccents($query)."*", removeAccents($value->name), FNM_CASEFOLD)
|| fnmatch("*".removeAccents($query)."*", removeAccents($value->text), FNM_CASEFOLD)
......
......@@ -410,7 +410,7 @@ function printCSS($file)
{
global $imageURL;
if ($file != 'ImprovedDropDown.css') {
if ($file != 'ImprovedDropDown.css' && $file != 'select2.css') {
$file= 'styles.css';
}
......
......@@ -462,6 +462,12 @@ if (
printCSS('ImprovedDropDown.css');
exit;
} elseif (isRequestType('select2.css')) {
header('Content-Type: text/css');
printCSS('select2.css');
exit;
} elseif (isRequestType('snippet.html')) {
......
This diff is collapsed.
......@@ -4,32 +4,32 @@
* Inspired from https://select2.org/data-sources/ajax
*/
/*
* Format for list items
*/
function formatList (repo) {
if (repo.loading) {
return repo.text;
function formatList(idp) {
if (idp.loading) {
return idp.text;
}
console.log(repo);
var markup = "<div class='select2-result-repository clearfix'>" +
"<div class='select2-result-repository__avatar'><img src='" + repo.owner.avatar_url + "' /></div>" +
"<div class='select2-result-repository__meta'>" +
"<div class='select2-result-repository__title'>" + repo.full_name + "</div>";
if (repo.description) {
markup += "<div class='select2-result-repository__description'>" + repo.description + "</div>";
var img = "";
if (idp.logo !== null) {
// Logo present
if (idp.logo.toLowerCase().indexOf('data:image') !== 0) {
// TODO : gérer le cas où on ne veut pas fetcher les logos distants
// remote logo
img = "<img src='" + idp.logo + "' />";
} else {
// local logo
img = "<img src='" + idp.logo + "' />";
}
} else {
img = "&nbsp;";
}
markup += "<div class='select2-result-repository__statistics'>" +
"<div class='select2-result-repository__forks'><i class='fa fa-flash'></i> " + repo.forks_count + " Forks</div>" +
"<div class='select2-result-repository__stargazers'><i class='fa fa-star'></i> " + repo.stargazers_count + " Stars</div>" +
"<div class='select2-result-repository__watchers'><i class='fa fa-eye'></i> " + repo.watchers_count + " Watchers</div>" +
"</div>" +
"</div></div>";
var markup = "<div class='select2-result-repository clearfix'>" +
"<div class='select2-result-repository__logo'>" + img + "</div>" +
"<div class='select2-result-repository__title'>" + idp.text + "</div></div>";
return markup;
}
......@@ -37,6 +37,6 @@ function formatList (repo) {
/*
* Format for selected element
*/
function formatRepoSelection (repo) {
return repo.full_name || repo.text;
function formatSelection(idp) {
return idp.text;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment