Bug lang select with theme open

This commit is contained in:
Fred Tempez 2023-02-18 22:30:00 +01:00
parent 32f70918b7
commit 2f88ac9a7e
2 changed files with 89 additions and 65 deletions

View File

@ -16,8 +16,8 @@ var core = {};
/** /**
* Crée un message d'alerte * Crée un message d'alerte
*/ */
core.alert = function(text) { core.alert = function (text) {
var lightbox = lity(function($) { var lightbox = lity(function ($) {
return $("<div>") return $("<div>")
.addClass("lightbox") .addClass("lightbox")
.append( .append(
@ -28,14 +28,14 @@ core.alert = function(text) {
$("<a>") $("<a>")
.addClass("button") .addClass("button")
.text("Ok") .text("Ok")
.on("click", function() { .on("click", function () {
lightbox.close(); lightbox.close();
}) })
) )
) )
}(jQuery)); }(jQuery));
// Validation de la lightbox avec le bouton entrée // Validation de la lightbox avec le bouton entrée
$(document).on("keyup", function(event) { $(document).on("keyup", function (event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
lightbox.close(); lightbox.close();
} }
@ -46,7 +46,7 @@ core.alert = function(text) {
/** /**
* Génère des variations d'une couleur * Génère des variations d'une couleur
*/ */
core.colorVariants = function(rgba) { core.colorVariants = function (rgba) {
rgba = rgba.match(/\(+(.*)\)/); rgba = rgba.match(/\(+(.*)\)/);
rgba = rgba[1].split(", "); rgba = rgba[1].split(", ");
return { return {
@ -60,8 +60,8 @@ core.colorVariants = function(rgba) {
/** /**
* Crée un message de confirmation * Crée un message de confirmation
*/ */
core.confirm = function(text, yesCallback, noCallback) { core.confirm = function (text, yesCallback, noCallback) {
var lightbox = lity(function($) { var lightbox = lity(function ($) {
return $("<div>") return $("<div>")
.addClass("lightbox") .addClass("lightbox")
.append( .append(
@ -72,7 +72,7 @@ core.confirm = function(text, yesCallback, noCallback) {
$("<a>") $("<a>")
.addClass("button grey") .addClass("button grey")
.text("<?php echo helper::translate('Non');?>") .text("<?php echo helper::translate('Non');?>")
.on("click", function() { .on("click", function () {
lightbox.options('button', true); lightbox.options('button', true);
lightbox.close(); lightbox.close();
if (typeof noCallback !== "undefined") { if (typeof noCallback !== "undefined") {
@ -82,7 +82,7 @@ core.confirm = function(text, yesCallback, noCallback) {
$("<a>") $("<a>")
.addClass("button") .addClass("button")
.text("<?php echo helper::translate('Oui');?>") .text("<?php echo helper::translate('Oui');?>")
.on("click", function() { .on("click", function () {
lightbox.options('button', true); lightbox.options('button', true);
lightbox.close(); lightbox.close();
if (typeof yesCallback !== "undefined") { if (typeof yesCallback !== "undefined") {
@ -94,7 +94,7 @@ core.confirm = function(text, yesCallback, noCallback) {
}(jQuery)); }(jQuery));
// Callback lors d'un clic sur le fond et sur la croix de fermeture // Callback lors d'un clic sur le fond et sur la croix de fermeture
lightbox.options('button', false); lightbox.options('button', false);
$(document).on('lity:close', function(event, instance) { $(document).on('lity:close', function (event, instance) {
if ( if (
instance.options('button') === false && instance.options('button') === false &&
typeof noCallback !== "undefined" typeof noCallback !== "undefined"
@ -103,7 +103,7 @@ core.confirm = function(text, yesCallback, noCallback) {
} }
}); });
// Validation de la lightbox avec le bouton entrée // Validation de la lightbox avec le bouton entrée
$(document).on("keyup", function(event) { $(document).on("keyup", function (event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
lightbox.close(); lightbox.close();
if (typeof yesCallback !== "undefined") { if (typeof yesCallback !== "undefined") {
@ -117,7 +117,7 @@ core.confirm = function(text, yesCallback, noCallback) {
/** /**
* Scripts à exécuter en dernier * Scripts à exécuter en dernier
*/ */
core.end = function() { core.end = function () {
/** /**
* Modifications non enregistrées du formulaire * Modifications non enregistrées du formulaire
*/ */
@ -127,24 +127,24 @@ core.end = function() {
// - Les champs avec data-no-dirty // - Les champs avec data-no-dirty
var inputsDOM = formDOM.find("input:not([data-no-dirty]), select:not([data-no-dirty]), textarea:not(.editorWysiwyg):not([data-no-dirty])"); var inputsDOM = formDOM.find("input:not([data-no-dirty]), select:not([data-no-dirty]), textarea:not(.editorWysiwyg):not([data-no-dirty])");
var inputSerialize = inputsDOM.serialize(); var inputSerialize = inputsDOM.serialize();
$(window).on("beforeunload", function() { $(window).on("beforeunload", function () {
if (inputsDOM.serialize() !== inputSerialize) { if (inputsDOM.serialize() !== inputSerialize) {
message = "<?php echo helper::translate('Les modifications que vous avez apportées ne seront peut-être pas enregistrées.');?>"; message = "<?php echo helper::translate('Les modifications que vous avez apportées ne seront peut-être pas enregistrées.');?>";
return message; return message;
} }
}); });
formDOM.submit(function() { formDOM.submit(function () {
$(window).off("beforeunload"); $(window).off("beforeunload");
}); });
}; };
$(function() { $(function () {
core.end(); core.end();
}); });
/** /**
* Ajoute une notice * Ajoute une notice
*/ */
core.noticeAdd = function(id, notice) { core.noticeAdd = function (id, notice) {
$("#" + id + "Notice").text(notice).removeClass("displayNone"); $("#" + id + "Notice").text(notice).removeClass("displayNone");
$("#" + id).addClass("notice"); $("#" + id).addClass("notice");
}; };
@ -152,7 +152,7 @@ core.noticeAdd = function(id, notice) {
/** /**
* Supprime une notice * Supprime une notice
*/ */
core.noticeRemove = function(id) { core.noticeRemove = function (id) {
$("#" + id + "Notice").text("").addClass("displayNone"); $("#" + id + "Notice").text("").addClass("displayNone");
$("#" + id).removeClass("notice"); $("#" + id).removeClass("notice");
}; };
@ -160,18 +160,20 @@ core.noticeRemove = function(id) {
/** /**
* Scripts à exécuter en premier * Scripts à exécuter en premier
*/ */
core.start = function() { core.start = function () {
/** /**
* Remonter en haut au clic sur le bouton * Remonter en haut au clic sur le bouton
*/ */
var backToTopDOM = $("#backToTop"); var backToTopDOM = $("#backToTop");
backToTopDOM.on("click", function() { backToTopDOM.on("click", function () {
$("body, html").animate({ scrollTop: 0 }, "400"); $("body, html").animate({
scrollTop: 0
}, "400");
}); });
/** /**
* Affiche / Cache le bouton pour remonter en haut * Affiche / Cache le bouton pour remonter en haut
*/ */
$(window).on("scroll", function() { $(window).on("scroll", function () {
if ($(this).scrollTop() > 200) { if ($(this).scrollTop() > 200) {
backToTopDOM.fadeIn(); backToTopDOM.fadeIn();
} else { } else {
@ -183,15 +185,15 @@ core.start = function() {
*/ */
var notificationTimer; var notificationTimer;
$("#notification") $("#notification")
.on("mouseenter", function() { .on("mouseenter", function () {
clearTimeout(notificationTimer); clearTimeout(notificationTimer);
$("#notificationProgress") $("#notificationProgress")
.stop() .stop()
.width("100%"); .width("100%");
}) })
.on("mouseleave", function() { .on("mouseleave", function () {
// Disparition de la notification // Disparition de la notification
notificationTimer = setTimeout(function() { notificationTimer = setTimeout(function () {
$("#notification").fadeOut(); $("#notification").fadeOut();
}, 3000); }, 3000);
// Barre de progression // Barre de progression
@ -200,7 +202,7 @@ core.start = function() {
}, 3000, "linear"); }, 3000, "linear");
}) })
.trigger("mouseleave"); .trigger("mouseleave");
$("#notificationClose").on("click", function() { $("#notificationClose").on("click", function () {
clearTimeout(notificationTimer); clearTimeout(notificationTimer);
$("#notification").fadeOut(); $("#notification").fadeOut();
$("#notificationProgress").stop(); $("#notificationProgress").stop();
@ -209,7 +211,7 @@ core.start = function() {
/** /**
* Traitement du formulaire cookies * Traitement du formulaire cookies
*/ */
$("#cookieForm").submit(function(event) { $("#cookieForm").submit(function (event) {
// Variables des cookies // Variables des cookies
var getUrl = window.location; var getUrl = window.location;
@ -226,7 +228,7 @@ core.start = function() {
/** /**
* Fermeture de la popup des cookies * Fermeture de la popup des cookies
*/ */
$("#cookieConsent .cookieClose").on("click", function() { $("#cookieConsent .cookieClose").on("click", function () {
$('#cookieConsent').addClass("displayNone"); $('#cookieConsent').addClass("displayNone");
}); });
@ -234,7 +236,7 @@ core.start = function() {
* Commande de gestion des cookies dans le footer * Commande de gestion des cookies dans le footer
*/ */
$("#footerLinkCookie").on("click", function() { $("#footerLinkCookie").on("click", function () {
$("#cookieConsent").removeClass("displayNone"); $("#cookieConsent").removeClass("displayNone");
}); });
@ -242,10 +244,10 @@ core.start = function() {
* Affiche / Cache le menu en mode responsive * Affiche / Cache le menu en mode responsive
*/ */
var menuDOM = $("#menu"); var menuDOM = $("#menu");
$("#toggle").on("click", function() { $("#toggle").on("click", function () {
menuDOM.slideToggle(); menuDOM.slideToggle();
}); });
$(window).on("resize", function() { $(window).on("resize", function () {
if ($(window).width() > 768) { if ($(window).width() > 768) {
menuDOM.css("display", ""); menuDOM.css("display", "");
} }
@ -254,22 +256,34 @@ core.start = function() {
/** /**
* Sélection d'une langue du site * Sélection d'une langue du site
*/ */
$("select#barSelectLanguage").on("change", function() { $("select#barSelectLanguage").on("change", function () {
var langUrl = $(this).val(); // La langue courante ne déclenche pas de chargement
// Récupère la langue sélectionnée dans l'élément 6 d'un tableau var langSelected = $(this).val();
var lang = langUrl.split("/"); var langSelected = langSelected.split("/");
// Lit le cookie de langue // Lit le cookie de langue
var langCookie = getCookie('ZWII_CONTENT'); var langCookie = getCookie('ZWII_CONTENT');
// Découpe l'URL pour exclure le changement de page avec le thème
var url = window.location;
var currentUrl = url.href.split("/");
// Change si différent, corrige le problème avec le thème et le rechargement de la langue. // Change si différent, corrige le problème avec le thème et le rechargement de la langue.
if (lang[6] !== langCookie) { if (( currentUrl !== "?theme" ||
$(location).attr("href", langUrl); currentUrl !== "theme") &&
langSelected[6] !== langCookie
) {
//$(location).attr("href", langUrl);
var select = document.getElementById("barSelectLanguage");
var selectedOption = select.options[select.selectedIndex];
if (selectedOption.value !== "") {
window.location = selectedOption.value;
}
} }
}); });
/** /**
* Choix de page dans la barre de membre * Choix de page dans la barre de membre
*/ */
$("#barSelectPage").on("change", function() { $("#barSelectPage").on("change", function () {
var pageUrl = $(this).val(); var pageUrl = $(this).val();
if (pageUrl) { if (pageUrl) {
$(location).attr("href", pageUrl); $(location).attr("href", pageUrl);
@ -280,7 +294,7 @@ core.start = function() {
* Champs d'upload de fichiers * Champs d'upload de fichiers
*/ */
// Mise à jour de l'affichage des champs d'upload // Mise à jour de l'affichage des champs d'upload
$(".inputFileHidden").on("change", function() { $(".inputFileHidden").on("change", function () {
var inputFileHiddenDOM = $(this); var inputFileHiddenDOM = $(this);
var fileName = inputFileHiddenDOM.val(); var fileName = inputFileHiddenDOM.val();
if (fileName === "") { if (fileName === "") {
@ -293,31 +307,31 @@ core.start = function() {
inputFileHiddenDOM.parent().find(".inputFileLabel").text(fileName); inputFileHiddenDOM.parent().find(".inputFileLabel").text(fileName);
}).trigger("change"); }).trigger("change");
// Suppression du fichier contenu dans le champ // Suppression du fichier contenu dans le champ
$(".inputFileDelete").on("click", function() { $(".inputFileDelete").on("click", function () {
$(this).parents(".inputWrapper").find(".inputFileHidden").val("").trigger("change"); $(this).parents(".inputWrapper").find(".inputFileHidden").val("").trigger("change");
}); });
// Suppression de la date contenu dans le champ // Suppression de la date contenu dans le champ
$(".inputDateDelete").on("click", function() { $(".inputDateDelete").on("click", function () {
$(this).parents(".inputWrapper").find(".datepicker").val("").trigger("change"); $(this).parents(".inputWrapper").find(".datepicker").val("").trigger("change");
}); });
// Confirmation de mise à jour // Confirmation de mise à jour
$("#barUpdate").on("click", function() { $("#barUpdate").on("click", function () {
message = "<?php echo helper::translate('Mettre à jour') . ' ?';?>"; message = "<?php echo helper::translate('Mettre à jour') . ' ?';?>";
return core.confirm(message, function() { return core.confirm(message, function () {
$(location).attr("href", $("#barUpdate").attr("href")); $(location).attr("href", $("#barUpdate").attr("href"));
}); });
}); });
// Confirmation de déconnexion // Confirmation de déconnexion
$("#barLogout").on("click", function() { $("#barLogout").on("click", function () {
message = "<?php echo helper::translate('Se déconnecter') . '?';?>"; message = "<?php echo helper::translate('Se déconnecter') . '?';?>";
return core.confirm(message, function() { return core.confirm(message, function () {
$(location).attr("href", $("#barLogout").attr("href")); $(location).attr("href", $("#barLogout").attr("href"));
}); });
}); });
/** /**
* Bloque la multi-soumission des boutons * Bloque la multi-soumission des boutons
*/ */
$("form").on("submit", function() { $("form").on("submit", function () {
$(this).find(".uniqueSubmission") $(this).find(".uniqueSubmission")
.addClass("disabled") .addClass("disabled")
.prop("disabled", true) .prop("disabled", true)
@ -329,7 +343,7 @@ core.start = function() {
/** /**
* Check adresse email * Check adresse email
*/ */
$("[type=email]").on("change", function() { $("[type=email]").on("change", function () {
var _this = $(this); var _this = $(this);
var pattern = /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)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
if (pattern.test(_this.val())) { if (pattern.test(_this.val())) {
@ -345,7 +359,7 @@ core.start = function() {
*/ */
var elementDOM = $("iframe, video, embed, object"); var elementDOM = $("iframe, video, embed, object");
// Calcul du ratio et suppression de la hauteur / largeur des iframes // Calcul du ratio et suppression de la hauteur / largeur des iframes
elementDOM.each(function() { elementDOM.each(function () {
var _this = $(this); var _this = $(this);
_this _this
.data("ratio", _this.height() / _this.width()) .data("ratio", _this.height() / _this.width())
@ -353,11 +367,13 @@ core.start = function() {
.removeAttr("width height"); .removeAttr("width height");
}); });
// Prend la largeur du parent et détermine la hauteur à l'aide du ratio lors du resize de la fenêtre // Prend la largeur du parent et détermine la hauteur à l'aide du ratio lors du resize de la fenêtre
$(window).on("resize", function() { $(window).on("resize", function () {
elementDOM.each(function() { elementDOM.each(function () {
var _this = $(this); var _this = $(this);
var width = _this.parent().first().width(); var width = _this.parent().first().width();
if (width > _this.data("maxwidth")) { width = _this.data("maxwidth"); } if (width > _this.data("maxwidth")) {
width = _this.data("maxwidth");
}
_this _this
.width(width) .width(width)
.height(width * _this.data("ratio")); .height(width * _this.data("ratio"));
@ -367,7 +383,7 @@ core.start = function() {
/* /*
* Header responsive * Header responsive
*/ */
$(window).on("resize", function() { $(window).on("resize", function () {
var responsive = "<?php echo $this->getdata(['theme','header','imageContainer']);?>"; var responsive = "<?php echo $this->getdata(['theme','header','imageContainer']);?>";
if (responsive === "cover" || responsive === "contain") { if (responsive === "cover" || responsive === "contain") {
var widthpx = "<?php echo $this->getdata(['theme','site','width']);?>"; var widthpx = "<?php echo $this->getdata(['theme','site','width']);?>";
@ -391,10 +407,10 @@ core.start();
/** /**
* Confirmation de suppression * Confirmation de suppression
*/ */
$("#pageDelete").on("click", function() { $("#pageDelete").on("click", function () {
var _this = $(this); var _this = $(this);
message = "<?php echo helper::translate('Confirmez-vous la suppression de cette page ?');?>"; message = "<?php echo helper::translate('Confirmez-vous la suppression de cette page ?');?>";
return core.confirm(message, function() { return core.confirm(message, function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
}); });
@ -403,7 +419,7 @@ $("#pageDelete").on("click", function() {
/** /**
* Calcul de la luminance relative d'une couleur * Calcul de la luminance relative d'une couleur
*/ */
core.relativeLuminanceW3C = function(rgba) { core.relativeLuminanceW3C = function (rgba) {
// Conversion en sRGB // Conversion en sRGB
var RsRGB = rgba[0] / 255; var RsRGB = rgba[0] / 255;
var GsRGB = rgba[1] / 255; var GsRGB = rgba[1] / 255;
@ -447,17 +463,25 @@ function capitalizeFirstLetter(string) {
} }
$(document).ready(function() { $(document).ready(function () {
/** /**
* Affiche le sous-menu quand il est sticky * Affiche le sous-menu quand il est sticky
*/ */
$("nav").mouseenter(function() { $("nav").mouseenter(function () {
$("#navfixedlogout .navSub").css({ 'pointer-events': 'auto' }); $("#navfixedlogout .navSub").css({
$("#navfixedconnected .navSub").css({ 'pointer-events': 'auto' }); 'pointer-events': 'auto'
});
$("#navfixedconnected .navSub").css({
'pointer-events': 'auto'
});
}); });
$("nav").mouseleave(function() { $("nav").mouseleave(function () {
$("#navfixedlogout .navSub").css({ 'pointer-events': 'none' }); $("#navfixedlogout .navSub").css({
$("#navfixedconnected .navSub").css({ 'pointer-events': 'none' }); 'pointer-events': 'none'
});
$("#navfixedconnected .navSub").css({
'pointer-events': 'none'
});
}); });
/** /**
@ -468,7 +492,7 @@ $(document).ready(function() {
/** /**
* Effet accordéon * Effet accordéon
*/ */
$('.accordion').each(function(e) { $('.accordion').each(function (e) {
// on stocke l'accordéon dans une variable locale // on stocke l'accordéon dans une variable locale
var accordion = $(this); var accordion = $(this);
// on récupère la valeur data-speed si elle existe // on récupère la valeur data-speed si elle existe
@ -493,7 +517,7 @@ $(document).ready(function() {
open(accordion.find('.active:first'), 0); open(accordion.find('.active:first'), 0);
// au clic sur un titre... // au clic sur un titre...
accordion.on('click', '.accordion-title', function(ev) { accordion.on('click', '.accordion-title', function (ev) {
ev.preventDefault(); ev.preventDefault();
// Masquer l'élément déjà actif // Masquer l'élément déjà actif
if ($(this).closest('.accordion-item').hasClass('active')) { if ($(this).closest('.accordion-item').hasClass('active')) {
@ -508,7 +532,7 @@ $(document).ready(function() {
/** /**
* Icône du Menu Burger * Icône du Menu Burger
*/ */
$("#toggle").click(function() { $("#toggle").click(function () {
var changeIcon = $('#toggle').children("span"); var changeIcon = $('#toggle').children("span");
if ($(changeIcon).hasClass('zwiico-menu')) { if ($(changeIcon).hasClass('zwiico-menu')) {
$(changeIcon).removeClass('zwiico-menu').addClass('zwiico-cancel'); $(changeIcon).removeClass('zwiico-menu').addClass('zwiico-cancel');

View File

@ -2118,7 +2118,7 @@ class common
} }
} }
if ($c > 1) { if ($c > 1) {
$leftItems .= '<li><select id="barSelectLanguage">'; $leftItems .= '<li><select id="barSelectLanguage" >';
$leftItems .= $leftItem; $leftItems .= $leftItem;
$leftItems .= '</select></li>'; $leftItems .= '</select></li>';
} }