mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
#gzip #extract-inline-js enable gzip in nginx + move ~730 lines of inline JS to 15 external files
This commit is contained in:
@@ -642,50 +642,4 @@ if ($filesMode === 'add'): ?>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
var unit = document.getElementById('duration_unit');
|
||||
var hidden = document.getElementById('duration_value');
|
||||
var intWrap = document.getElementById('duration-value-integer');
|
||||
var intInput = document.getElementById('duration_value_int');
|
||||
var intLabel = document.getElementById('duration-value-label');
|
||||
var timeWrap = document.getElementById('duration-value-time');
|
||||
var hInput = document.getElementById('duration_h');
|
||||
var mInput = document.getElementById('duration_m');
|
||||
var sInput = document.getElementById('duration_s');
|
||||
|
||||
var LABELS = { pages: 'Nombre :', mo: 'Taille :', 'durée': 'Durée :' };
|
||||
if (!unit || !hidden) return;
|
||||
|
||||
function updateHidden() {
|
||||
if (unit.value === 'durée') {
|
||||
var h = parseInt(hInput.value, 10) || 0;
|
||||
var m = parseInt(mInput.value, 10) || 0;
|
||||
var s = parseInt(sInput.value, 10) || 0;
|
||||
var total = h + m / 60 + s / 3600;
|
||||
hidden.value = total > 0 ? total.toFixed(6) : '';
|
||||
} else {
|
||||
hidden.value = intInput.value;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleFields() {
|
||||
if (unit.value === 'durée') {
|
||||
intWrap.style.display = 'none';
|
||||
timeWrap.style.display = '';
|
||||
} else {
|
||||
timeWrap.style.display = 'none';
|
||||
intWrap.style.display = '';
|
||||
if (intLabel) intLabel.textContent = LABELS[unit.value] || 'Valeur :';
|
||||
}
|
||||
updateHidden();
|
||||
}
|
||||
|
||||
unit.addEventListener('change', toggleFields);
|
||||
if (intInput) intInput.addEventListener('input', updateHidden);
|
||||
if (hInput) hInput.addEventListener('input', updateHidden);
|
||||
if (mInput) mInput.addEventListener('input', updateHidden);
|
||||
if (sInput) sInput.addEventListener('input', updateHidden);
|
||||
toggleFields();
|
||||
})();
|
||||
</script>
|
||||
<script src="<?= App::assetV('/assets/js/app/form-duration-toggle.js') ?>"></script>
|
||||
|
||||
@@ -63,7 +63,7 @@ if ($addMode) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
<fieldset>
|
||||
<fieldset data-admin-mode="<?= $adminMode ? '1' : '0' ?>">
|
||||
<legend>Composition du jury</legend>
|
||||
|
||||
<!-- Promoteur·ice(s) interne -->
|
||||
@@ -141,36 +141,6 @@ if ($addMode) {
|
||||
+ Ajouter un·e promoteur·ice ULB
|
||||
</button>
|
||||
</fieldset>
|
||||
<?php if ($promoteurUlbConditional): ?>
|
||||
<script>
|
||||
(function() {
|
||||
try {
|
||||
var finalitySelect = document.querySelector('select[name="finality"]');
|
||||
var ulbRow = document.getElementById('jury-promoteur-ulb-row');
|
||||
if (!finalitySelect || !ulbRow) return;
|
||||
var ulbAsterisk = document.getElementById('jury-ulb-asterisk');
|
||||
function isApprofondiSelected() {
|
||||
var opt = finalitySelect.options[finalitySelect.selectedIndex];
|
||||
if (!opt) return false;
|
||||
return (opt.textContent || opt.text || '').toLowerCase().includes('approfondi');
|
||||
}
|
||||
function toggleUlb() {
|
||||
var show = isApprofondiSelected();
|
||||
ulbRow.style.display = show ? '' : 'none';
|
||||
if (ulbAsterisk) ulbAsterisk.style.display = show ? '' : 'none';
|
||||
var inputs = ulbRow.querySelectorAll('input[name="jury_promoteur_ulb_name[]"]');
|
||||
inputs.forEach(function(inp, idx) {
|
||||
inp.required = <?= $adminMode ? 'false' : 'show && idx === 0' ?>;
|
||||
inp.disabled = !show;
|
||||
if (!show) inp.value = '';
|
||||
});
|
||||
}
|
||||
finalitySelect.addEventListener('change', toggleUlb);
|
||||
toggleUlb();
|
||||
} catch(e) { console.error('jury ULB toggle:', e); }
|
||||
})();
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Lecteur·ice(s) interne -->
|
||||
@@ -235,21 +205,4 @@ if ($addMode) {
|
||||
|
||||
</fieldset>
|
||||
|
||||
<script>
|
||||
function addJuryRow(listId, inputName, roleLabel) {
|
||||
var list = document.getElementById(listId);
|
||||
if (!list) return;
|
||||
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
|
||||
var div = document.createElement('div');
|
||||
div.className = 'admin-jury-entry';
|
||||
div.innerHTML = '<input type="text" name="' + inputName + '" placeholder="Nom" autocomplete="off"'
|
||||
+ ' aria-label="' + roleLabel + ' ' + n + ' \u2014 nom">'
|
||||
+ '<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"'
|
||||
+ ' onclick="removeJuryRow(this)" aria-label="Supprimer">'
|
||||
+ '<span aria-hidden="true">\u2715</span></button>';
|
||||
list.appendChild(div);
|
||||
}
|
||||
function removeJuryRow(btn) {
|
||||
btn.closest('.admin-jury-entry').remove();
|
||||
}
|
||||
</script>
|
||||
<script src="<?= App::assetV('/assets/js/app/form-jury-fields.js') ?>"></script>
|
||||
|
||||
@@ -31,7 +31,7 @@ $maxLanguages = $maxLanguages ?? 10;
|
||||
$required = $required ?? false;
|
||||
$langCount = count($selectedLanguages);
|
||||
?>
|
||||
<div id="<?= htmlspecialchars($id) ?>-search-container" data-pill-search data-pill-name="<?= htmlspecialchars($name) ?>" data-pill-max="<?= (int)$maxLanguages ?>" data-pill-min="0" data-pill-required="0" data-pill-role="lang">
|
||||
<div id="<?= htmlspecialchars($id) ?>-search-container" data-pill-search data-pill-name="<?= htmlspecialchars($name) ?>" data-pill-max="<?= (int)$maxLanguages ?>" data-pill-min="0" data-pill-required="0" data-pill-role="lang" data-search-container-id="<?= htmlspecialchars($id . '-search-container') ?>">
|
||||
<span class="admin-row-label"><?= htmlspecialchars($label) ?><span id="language-autre-required"><?= $required ? ' <span class="asterisk">*</span>' : '' ?></span></span>
|
||||
<div class="tag-search-wrapper">
|
||||
<?php if ($hint): ?>
|
||||
@@ -80,24 +80,6 @@ $langCount = count($selectedLanguages);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Language-specific: toggle checkbox-list asterisk based on pills presence
|
||||
(function () {
|
||||
var container = document.getElementById(<?= json_encode($id . '-search-container') ?>);
|
||||
if (!container) return;
|
||||
var pills = container.querySelector('.tag-search-pills');
|
||||
if (!pills) return;
|
||||
function check() {
|
||||
var asteriskEl = document.getElementById('languages-required-asterisk');
|
||||
if (!asteriskEl) return;
|
||||
var n = pills.querySelectorAll('.tag-pill').length;
|
||||
var checkboxes = document.querySelectorAll('#languages-fieldset input[type="checkbox"]:checked');
|
||||
asteriskEl.innerHTML = (n === 0 && checkboxes.length === 0) ? ' <span class="asterisk">*</span>' : '';
|
||||
}
|
||||
var observer = new MutationObserver(check);
|
||||
observer.observe(pills, { childList: true });
|
||||
check();
|
||||
})();
|
||||
</script>
|
||||
<script src="<?= App::assetV('/assets/js/app/form-language-asterisk.js') ?>"></script>
|
||||
<?php
|
||||
unset($name, $label, $placeholder, $hint, $hxPost, $selectedLanguages, $id, $maxLanguages, $langCount, $required);
|
||||
|
||||
Reference in New Issue
Block a user