From 00bd01edae98b2353979ef1dbbdbd6ada0531c4e Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 10 Oct 2021 14:41:13 +0200 Subject: [PATCH] =?UTF-8?q?11.1.00=20r=C3=A9=C3=A9criture=20aper=C3=A7u=20?= =?UTF-8?q?header=20/=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/theme/theme.php | 6 +- core/module/theme/view/header/header.js.php | 71 +++++++++++++++------ 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 4a80be8a..c7039b66 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -451,10 +451,10 @@ class theme extends common { { $this->setData(['theme', 'menu', 'position',str_replace ('site-','body-',$this->getData(['theme','menu','position']))]); } + // Menu accroché à la bannière qui devient cachée if ( $this->getData(['theme','header','position']) == 'hide' && - ( $this->getData(['theme','menu','position']) == 'body-first' || - $this->getData(['theme','menu','position']) == 'site-first') ) - { + in_array( $this->getData(['theme','menu','position']) , ['body-first', 'site-first', 'body-first' , 'site-second']) + ) { $this->setData(['theme', 'menu', 'position','site']); } // Valeurs en sortie diff --git a/core/module/theme/view/header/header.js.php b/core/module/theme/view/header/header.js.php index 93773655..29344f0f 100644 --- a/core/module/theme/view/header/header.js.php +++ b/core/module/theme/view/header/header.js.php @@ -104,35 +104,68 @@ $("input, select").on("change", function() { css += 'header{margin:0}'; } // Position de la bannière - switch($("#themeHeaderPosition").val()) { + var positionNav = getData(['theme', 'menu', 'position'])); ?>; + var positionHeader = $("#themeHeaderPosition").val(); + + switch(positionHeader) { case 'hide': $("header").hide(); + $("nav").show().prependTo("#site"); break; case 'site': - if(getData(['theme', 'menu', 'position']) === 'site-first'); ?>) { - $("header").show().insertAfter("nav"); - } - else { - $("header").show().prependTo("#site"); - // Supprime le margin en trop du menu - if(getData(['theme', 'menu', 'margin'])); ?>) { - css += 'nav{margin:0 20px}'; - } + $("header").show().prependTo("#site"); + // Position du menu + switch (positionNav) { + case "body-first": + $("nav").show().insertAfter("header"); + break; + case "site-first": + $("nav").show().prependTo("#site"); + // Supprime le margin en trop du menu + if(getData(['theme', 'menu', 'margin'])); ?>) { + css += 'nav{margin:0 20px}'; + } + break; + case "body-second": + case "site-second": + $("nav").show().insertAfter("header"); + // Supprime le margin en trop du menu + if(getData(['theme', 'menu', 'margin'])); ?>) { + css += 'nav{margin:0 20px}'; + } + break; } break; case 'body': - if(getData(['theme', 'menu', 'position']) === 'body-first'); ?>) { - $("header").show().insertAfter("nav"); + // Position du menu + switch (positionNav) { + case "top": + $("header").show().insertAfter("nav"); + break; + case "site-first": + case "body-first": + $("header").show().insertAfter("#bar"); + $("nav").show().insertAfter("#bar"); + break; + case "site-second": + case "body-second": + $("header").show().insertAfter("#bar"); + $("nav").show().insertAfter("header"); + break; + } - else { - $("header").show().insertAfter("#bar"); - } - if(getData(['theme', 'menu', 'position']) === 'top'); ?>) { - $("header").show().insertAfter("nav"); - } - break; } + // La bannière est cachée, déplacer le menu dans le site + if (positionHeader === "hide" && + (positionNav === "body-first" || + positionnav === "site-first" || + positionnav === "body-second" || + positionnav === "site-second" + )) { + $("nav").show().prependTo("#site"); + } + // Ajout du css au DOM $("#themePreview").remove(); $("