Améliorations menu et menu burger

This commit is contained in:
Deltacms 2023-06-19 18:02:31 +02:00
parent ae1cec427c
commit 9706ac64e4
3 changed files with 104 additions and 112 deletions

View File

@ -598,15 +598,12 @@ $(document).ready(function(){
});
<?php } ?>
/* Affichage / masquage des items du sous-menu
* après appui sur l'icône plus / minus
* substitution des icônes down, plus, minus
/* En petit écran, affichage / masquage des items du sous-menu
* ou signalisation que la page est désactivée par ouverture du sous-menu
*/
$(window).on("resize", function() {
if($(window).width() < 800) {
$("nav #menu ul li span").click(function() {
// id de la page parent
var parentId = $(this).parents().attr("id");
function displaySubPages( parentId ){
var select = "ul#_"+parentId+".navSub";
var select2 = 'nav #menu ul li #' + parentId + ' span.iconSubExistSmallScreen';
if( $(select).css("z-index") === "-1" ) {
@ -621,6 +618,16 @@ $(document).ready(function(){
$(select).css("position","absolute");
$(select2).removeClass('zwiico-minus').addClass('zwiico-plus');
}
}
$("nav #menu ul li span").click(function() {
// id de la page parent
var parentId = $(this).parents().attr("id");
displaySubPages( parentId);
});
$("nav #menu a.disabled-link").click(function() {
// id de la page parent
var parentId = $(this).parents().parents().attr("id");
displaySubPages( parentId);
});
}
}).trigger("resize");
@ -634,15 +641,4 @@ $(document).ready(function(){
<?php } ?>
}
/* Signalisation qu'une page est désactivée en petit écran
* pour la page ou la sous-page cliquée
*/
if($(window).width() < 800) {
$("nav #menu a.disabled-link").click(function() {
var parentIdSubPage = $(this).parents("ul").attr("id");
var parentIdPage = $(this).parents().parents().attr("id");
$("nav #menu ul li ul li #"+parentIdSubPage+" .linkDisabledSmallScreen").css("display","inline");
$("nav #menu ul li #"+parentIdPage+" .linkDisabledSmallScreen").css("display","inline");
});
}
});

View File

@ -1767,6 +1767,8 @@ class common {
</div>
<div id="menu" <?php echo $menuClass; ?> > <?php
// Groupe du client connecté (1, 2, 3, 4) ou non connecté (0)
$groupUser = $this->getUser('group') === false ? 0 : $this->getUser('group');
// Met en forme les items du menu
$itemsLeft = '';
$currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
@ -1778,8 +1780,7 @@ class common {
// Propriétés de l'item
$active = ($parentPageId === $currentPageId OR in_array($currentPageId, $childrenPageIds)) ? 'active ' : '';
$targetBlank = $this->getData(['page', $parentPageId, 'targetBlank']) ? ' target="_blank"' : '';
// Cas où les pages enfants enfant sont toutes masquées dans le menu
// ne pas afficher de symbole lorsqu'il n'y a rien à afficher
// Cas où les pages enfants enfant sont toutes desactivées dans le menu, ne pas afficher de symbole lorsqu'il n'y a rien à afficher et que le client est < éditeur
$totalChild = 0;
$disableChild = 0;
foreach($childrenPageIds as $childKey) {
@ -1788,119 +1789,118 @@ class common {
}
$iconSubExistLargeScreen='';
$iconSubExistSmallScreen='';
if($childrenPageIds && $disableChild !== $totalChild && $this->getdata(['page',$parentPageId,'hideMenuChildren']) === false) {
if($childrenPageIds && ( $disableChild !== $totalChild || $groupUser >= 2 ) && $this->getdata(['page',$parentPageId,'hideMenuChildren']) === false) {
$iconSubExistLargeScreen= '<span class="zwiico-down iconSubExistLargeScreen" style="font-size:1em"><!----></span>';
$iconSubExistSmallScreen= '<span class="zwiico-plus zwiico-margin-left iconSubExistSmallScreen" style="font-size:1em"><!----></span>';
}
// Mise en page de l'item
$itemsLeft .= '<li>';
$pageDesactived = false;
if ( ( $this->getData(['page',$parentPageId,'disable']) === true AND $this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD'))
OR ( $this->getData(['page',$parentPageId,'disable']) === true AND $this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')AND $this->getUser('group') < self::GROUP_EDITOR ))
{
$pageUrl = ($this->getData(['locale', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0);
$itemsLeft .= '<div id="'.$parentPageId.'" class="box" style="display:flex; align-items:center;"><div><a class="A ' . $active . $parentPageId . ' disabled-link">';
$pageDesactived = true;
} else {
$pageUrl = ($this->getData(['locale', 'homePageId']) === $parentPageId) ? helper::baseUrl(false) : helper::baseUrl() . $parentPageId;
$itemsLeft .= '<div id="'.$parentPageId.'" class="box '.$active.'" style="display:flex; align-items:center;"><div><a class="B ' . $active . $parentPageId . '" href="' . $pageUrl . '"' . $targetBlank . '>';
}
$fileLogo = './site/file/source/'. $this->getData(['page', $parentPageId, 'iconUrl']);
switch ($this->getData(['page', $parentPageId, 'typeMenu'])) {
case '' :
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'text' :
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'icon' :
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. $fileLogo.'" style="height:'.$heightLogo.'px; width:auto;">';
} else {
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
case 'icontitle' :
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'titlshortTitlee']).'" src="'. $fileLogo.'" style="height:'.$heightLogo.'px; width:auto;" data-tippy-content="';
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']).'">';
} else {
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
}
$fileIcon = './site/file/source/icones/disabledPage.gif';
if( file_exists($fileIcon) && $pageDesactived) $itemsLeft .='<span class="linkDisabledSmallScreen" style="font-size:1em"><img src="'. $fileIcon .'" style="height:15px; width:auto;" alt=""></span>';
$itemsLeft .= $iconSubExistLargeScreen;
$itemsLeft .= '</a>';
$itemsLeft .= '</div>';
$itemsLeft .= $iconSubExistSmallScreen;
$itemsLeft .= '</div>';
if ($this->getdata(['page',$parentPageId,'hideMenuChildren']) === true ||
empty($childrenPageIds)) {
// Si la page est désactivée et sans sous-page active et client < éditeur => elle n'est pas affichée
if ( $this->getData(['page',$parentPageId,'disable']) && (empty($childrenPageIds) || $disableChild === $totalChild) && $groupUser < 2){
continue;
}
$itemsLeft .= '<ul id="_'.$parentPageId.'" class="navSub">';
foreach($childrenPageIds as $childKey) {
// Propriétés de l'item
$active = ($childKey === $currentPageId) ? 'active ' : '';
$targetBlank = $this->getData(['page', $childKey, 'targetBlank']) ? ' target="_blank"' : '';
// Mise en page du sous-item
} else {
// Mise en page de l'item
$itemsLeft .= '<li>';
$pageDesactived = false;
if ( ( $this->getData(['page',$childKey,'disable']) === true
AND $this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD')
) OR (
$this->getData(['page',$childKey,'disable']) === true
AND $this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')
AND $this->getUser('group') < self::GROUP_EDITOR
)
){
/*if ( ( $this->getData(['page',$parentPageId,'disable']) === true AND $this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD'))
OR ( $this->getData(['page',$parentPageId,'disable']) === true AND $this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')AND $this->getUser('group') < self::GROUP_EDITOR ))
{*/
if ( $this->getData(['page',$parentPageId,'disable']) === true && $groupUser < 2 ){
$pageUrl = ($this->getData(['locale', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0);
$itemsLeft .= '<a class="disabled-link">';
$itemsLeft .= '<div id="'.$parentPageId.'" class="box" style="display:flex; align-items:center;"><div><a class="A ' . $active . $parentPageId . ' disabled-link">';
$pageDesactived = true;
} else {
$pageUrl = ($this->getData(['locale', 'homePageId']) === $childKey) ? helper::baseUrl(false) : helper::baseUrl() . $childKey;
$itemsLeft .= '<a class="' . $active . $parentPageId . '" href="' . $pageUrl . '"' . $targetBlank . '>';
$pageUrl = ($this->getData(['locale', 'homePageId']) === $parentPageId) ? helper::baseUrl(false) : helper::baseUrl() . $parentPageId;
$itemsLeft .= '<div id="'.$parentPageId.'" class="box '.$active.'" style="display:flex; align-items:center;"><div><a class="B ' . $active . $parentPageId . '" href="' . $pageUrl . '"' . $targetBlank . '>';
}
switch ($this->getData(['page', $childKey, 'typeMenu'])) {
$fileLogo = './site/file/source/'. $this->getData(['page', $parentPageId, 'iconUrl']);
switch ($this->getData(['page', $parentPageId, 'typeMenu'])) {
case '' :
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'text' :
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'icon' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;">';
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. $fileLogo.'" style="height:'.$heightLogo.'px; width:auto;">';
} else {
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
case 'icontitle' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;" data-tippy-content="';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']).'">';
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'titlshortTitlee']).'" src="'. $fileLogo.'" style="height:'.$heightLogo.'px; width:auto;" data-tippy-content="';
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']).'">';
} else {
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
}
break;
case 'icontext' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;">';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
} else {
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
}
$itemsLeft .= $iconSubExistLargeScreen;
$itemsLeft .= '</a>';
$itemsLeft .= '</div>';
$itemsLeft .= $iconSubExistSmallScreen;
$itemsLeft .= '</div>';
if ($this->getdata(['page',$parentPageId,'hideMenuChildren']) === true ||
empty($childrenPageIds)) {
continue;
}
$fileIcon = './site/file/source/icones/disabledPage.gif';
if( file_exists($fileIcon) && $pageDesactived) $itemsLeft .='<span class="linkDisabledSmallScreen" style="font-size:1em"><img src="'. $fileIcon .'" style="height:15px; width:auto;" alt=""></span>';
$itemsLeft .= '</a></li>';
$itemsLeft .= '<ul id="_'.$parentPageId.'" class="navSub">';
foreach($childrenPageIds as $childKey) {
// Propriétés de l'item
$active = ($childKey === $currentPageId) ? 'active ' : '';
$targetBlank = $this->getData(['page', $childKey, 'targetBlank']) ? ' target="_blank"' : '';
//Si la sous-page est désactivée et que le client est < éditeur on ne l'affiche pas
if( $this->getData(['page',$childKey,'disable']) === true && $groupUser < 2 ){
continue;
} else {
// Mise en page du sous-item
$itemsLeft .= '<li>';
$pageDesactived = false;
if ( $this->getData(['page',$childKey,'disable']) === true && $groupUser < 2 ){
$pageUrl = ($this->getData(['locale', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0);
$itemsLeft .= '<a class="disabled-link">';
$pageDesactived = true;
} else {
$pageUrl = ($this->getData(['locale', 'homePageId']) === $childKey) ? helper::baseUrl(false) : helper::baseUrl() . $childKey;
$itemsLeft .= '<a class="' . $active . $parentPageId . '" href="' . $pageUrl . '"' . $targetBlank . '>';
}
switch ($this->getData(['page', $childKey, 'typeMenu'])) {
case '' :
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
break;
case 'text' :
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
break;
case 'icon' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;">';
} else {
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
case 'icontitle' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;" data-tippy-content="';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']).'">';
} else {
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
}
break;
case 'icontext' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$itemsLeft .= '<img alt="'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src="'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" style="height:'.$heightLogo.'px; width:auto;">';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
} else {
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
}
break;
}
$itemsLeft .= '</a></li>';
}
}
$itemsLeft .= '</ul>';
}
$itemsLeft .= '</ul>';
}
// Lien de connexion
$itemsRight = '';

View File

@ -46,9 +46,6 @@
nav .iconSubExistSmallScreen{
display:none;
}
nav .linkDisabledSmallScreen{
display:none;
}
/* Corps */
section {
padding: 20px;
@ -194,9 +191,8 @@
nav .iconSubExistSmallScreen{
display:inline;
}
nav .linkDisabledSmallScreen{
display:none;
margin-left:20px;
nav a.disabled-link{
font-style:italic;
}
/*bandeau flex*/
nav #toggle {