2018-04-02 08:29:19 +02:00
/**
2021-02-17 13:51:12 +01:00
* This file is part of Zwii .
2018-04-02 08:29:19 +02:00
* For full copyright and license information , please see the LICENSE
* file that was distributed with this source code .
*
* @ author Rémi Jean < remi . jean @ outlook . com >
* @ copyright Copyright ( C ) 2008 - 2018 , Rémi Jean
2021-02-17 13:49:58 +01:00
* @ author Frédéric Tempez < frederic . tempez @ outlook . com >
2024-01-14 19:31:28 +01:00
* @ copyright Copyright ( C ) 2018 - 2024 , Frédéric Tempez
2022-12-29 17:02:20 +01:00
* @ license CC Attribution - NonCommercial - NoDerivatives 4.0 International
2020-09-01 20:48:40 +02:00
* @ link http :// zwiicms . fr /
2018-04-02 08:29:19 +02:00
*/
2020-03-09 17:05:39 +01:00
$ ( document ) . ready ( function (){
// Menu fixe à afficher
if ( $ ( " #themeMenuPosition " ) . val () === 'top' ) {
2020-06-18 13:21:47 +02:00
$ ( " #themeMenuPositionFixed " ) . slideDown ();
2020-03-09 17:05:39 +01:00
}
else {
$ ( " #themeMenuPositionFixed " ) . slideUp ( function () {
$ ( " #themeMenuFixed " ) . prop ( " checked " , false ) . trigger ( " change " );
});
}
// Option de menu à afficher
if ( $ ( " #themeMenuPosition " ) . val () === 'site-first' || $ ( this ) . val () === 'site-second' ) {
2020-06-18 13:21:47 +02:00
$ ( " #themeMenuPositionOptions " ) . slideDown ();
2020-03-09 17:05:39 +01:00
}
else {
$ ( " #themeMenuPositionOptions " ) . slideUp ( function () {
$ ( " #themeMenuMargin " ) . prop ( " checked " , false ) . trigger ( " change " );
});
}
});
2018-04-02 08:29:19 +02:00
/**
* Aperçu en direct
*/
$ ( " input, select " ) . on ( " change " , function () {
2018-12-09 00:52:05 +01:00
// Import des polices de caractères
2022-02-04 16:26:39 +01:00
var menuFont = $ ( " #themeMenuFont :selected " ) . val ();
var menuFontText = $ ( " #themeMenuFont :selected " ) . text ();
2022-02-17 15:23:18 +01:00
var css = " @import url('https://fonts.cdnfonts.com/css/ " + menuFont + " '); " ;
2018-04-02 08:29:19 +02:00
var colors = core . colorVariants ( $ ( " #themeMenuBackgroundColor " ) . val ());
2020-06-18 13:21:47 +02:00
// Couleurs du menu
2020-11-01 20:19:02 +01:00
css += " nav,nav.navLevel1 a { background-color: " + colors . normal + " } " ;
2018-04-02 08:29:19 +02:00
css += " nav a,#toggle span,nav a:hover { color: " + $ ( " #themeMenuTextColor " ) . val () + " } " ;
css += " nav a:hover { background-color: " + colors . darken + " } " ;
2019-11-29 15:31:37 +01:00
if ( $ ( " #themeMenuActiveColorAuto " ) . is ( ':checked' )) {
2020-05-15 18:31:01 +02:00
css += " nav a:hover { background-color: " + colors . veryDarken + " ;color: " + $ ( '#themeMenuActiveTextColor' ) . val () + " ;} " ;
2019-11-29 15:31:37 +01:00
} else {
2020-05-15 18:31:01 +02:00
css += " nav a:hover { background-color: " + $ ( " #themeMenuActiveColor " ) . val () + " ;color: " + $ ( '#themeMenuActiveTextColor' ) . val () + " ;} " ;
2020-06-18 13:21:47 +02:00
}
2020-11-01 20:19:02 +01:00
// sous menu
var colors = core . colorVariants ( $ ( " #themeMenuBackgroundColorSub " ) . val ());
css += 'nav .navSub a{background-color:' + colors . normal + '}' ;
2018-04-02 08:29:19 +02:00
// Taille, hauteur, épaisseur et capitalisation de caractères du menu
2022-02-04 16:26:39 +01:00
css += " #toggle span,#menu a { padding: " + $ ( " #themeMenuHeight " ) . val () + " ;font-family:' " + menuFontText + " ',sans-serif;font-weight: " + $ ( " #themeMenuFontWeight " ) . val () + " ;font-size: " + $ ( " #themeMenuFontSize " ) . val () + " ;text-transform: " + $ ( " #themeMenuTextTransform " ) . val () + " } " ;
2018-04-02 08:29:19 +02:00
// Alignement du menu
2020-11-01 08:51:23 +01:00
css += " #menu { text-align: " + $ ( " #themeMenuTextAlign " ) . val () + " } " ;
2018-04-02 08:29:19 +02:00
// Marge
if ( $ ( " #themeMenuMargin " ) . is ( " :checked " )) {
if (
< ? php echo json_encode ( $this -> getData ([ 'theme' , 'menu' , 'position' ]) === 'site-first' ); ?>
2020-03-12 09:35:18 +01:00
|| < ? php echo json_encode ( $this -> getData ([ 'theme' , 'menu' , 'position' ]) === 'site-second' ); ?>
2018-04-02 08:29:19 +02:00
) {
2020-03-09 17:05:39 +01:00
css += 'nav{padding: 10px 10px 0 10px}' ;
2018-04-02 08:29:19 +02:00
}
else {
2020-03-09 17:05:39 +01:00
css += 'nav{padding:0 10px;}' ;
2018-04-02 08:29:19 +02:00
}
}
else {
2020-03-09 17:05:39 +01:00
css += 'nav{margin:0;}' ;
2018-04-02 08:29:19 +02:00
}
2020-03-12 09:35:18 +01:00
if (
< ? php echo json_encode ( $this -> getData ([ 'theme' , 'menu' , 'position' ]) === 'top' ); ?>
) {
css += 'nav{padding:0 10px;}' ;
}
2021-10-25 09:11:58 +02:00
2018-04-02 08:29:19 +02:00
// Position du menu
switch ( $ ( " #themeMenuPosition " ) . val ()) {
case 'hide' :
$ ( " nav " ) . hide ();
break ;
case 'site-first' :
$ ( " nav " ) . show () . prependTo ( " #site " );
break ;
case 'site-second' :
if ( < ? php echo json_encode ( $this -> getData ([ 'theme' , 'header' , 'position' ]) === 'site' ); ?> ) {
$ ( " nav " ) . show () . insertAfter ( " header " );
}
else {
$ ( " nav " ) . show () . prependTo ( " #site " );
}
break ;
case 'body-first' :
$ ( " nav " ) . show () . insertAfter ( " #bar " );
2019-01-22 09:04:05 +01:00
$ ( " #menu " ) . removeClass ( 'container-large' );
2020-03-09 17:05:39 +01:00
$ ( " nav " ) . removeAttr ( 'id' );
2019-01-22 09:04:05 +01:00
$ ( " #menu " ) . addClass ( 'container' );
2020-06-18 13:21:47 +02:00
break ;
2018-04-02 08:29:19 +02:00
case 'body-second' :
if ( < ? php echo json_encode ( $this -> getData ([ 'theme' , 'header' , 'position' ]) === 'body' ); ?> ) {
$ ( " nav " ) . show () . insertAfter ( " header " );
}
else {
$ ( " nav " ) . show () . insertAfter ( " #bar " );
}
2020-03-09 17:05:39 +01:00
$ ( " nav " ) . removeAttr ( 'id' );
2018-04-02 08:29:19 +02:00
break ;
2019-01-22 13:46:35 +01:00
case 'top' :
$ ( " nav " ) . show () . insertAfter ( " #bar " );
$ ( " #menu " ) . removeClass ( 'container' );
$ ( " #menu " ) . addClass ( 'container-large' );
2020-03-09 17:05:39 +01:00
$ ( " nav " ) . attr ( 'id' , '#navfixedconnected' );
2019-03-12 09:30:22 +01:00
break ;
case 'site' :
$ ( " nav " ) . show () . prependTo ( " #site " );
2020-06-18 13:21:47 +02:00
break ;
2018-04-02 08:29:19 +02:00
}
2021-11-12 12:59:58 +01:00
// Largeur étendue
2021-11-15 09:01:08 +01:00
if ( $ ( " #themeMenuWide " ) . val () === 'none' ) {
2021-11-12 12:59:58 +01:00
$ ( " #menu " ) . removeClass ();
} else {
$ ( " #menu " ) . addClass ( " container " );
}
2021-03-22 17:18:46 +01:00
// Ajout du css au DOM
$ ( " #themePreview " ) . remove ();
$ ( " <style> " )
. attr ( " type " , " text/css " )
. attr ( " id " , " themePreview " )
. text ( css )
. appendTo ( " head " );
2018-04-02 08:29:19 +02:00
});
2019-11-29 15:31:37 +01:00
//
2018-04-02 08:29:19 +02:00
// Lien de connexion (addClass() et removeClass() au lieu de hide() et show() car ils ne conservent pas le display-inline: block; de #themeMenuLoginLink)
$ ( " #themeMenuLoginLink " ) . on ( " change " , function () {
if ( $ ( this ) . is ( " :checked " )) {
$ ( " #menuLoginLink " ) . removeClass ( 'displayNone' );
}
else {
$ ( " #menuLoginLink " ) . addClass ( 'displayNone' );
}
}) . trigger ( " change " );
2019-11-29 15:31:37 +01:00
2018-04-02 08:29:19 +02:00
// Affiche / Cache les options de la position
$ ( " #themeMenuPosition " ) . on ( " change " , function () {
if ( $ ( this ) . val () === 'site-first' || $ ( this ) . val () === 'site-second' ) {
2020-06-18 13:21:47 +02:00
$ ( " #themeMenuPositionOptions " ) . slideDown ();
2018-04-02 08:29:19 +02:00
}
else {
$ ( " #themeMenuPositionOptions " ) . slideUp ( function () {
$ ( " #themeMenuMargin " ) . prop ( " checked " , false ) . trigger ( " change " );
});
}
2019-01-24 14:26:54 +01:00
}) . trigger ( " change " );
2019-11-29 15:31:37 +01:00
2019-01-24 14:26:54 +01:00
// Affiche / Cache les options du menu fixe
$ ( " #themeMenuPosition " ) . on ( " change " , function () {
if ( $ ( this ) . val () === 'top' ) {
2020-06-18 13:21:47 +02:00
$ ( " #themeMenuPositionFixed " ) . slideDown ();
2019-01-24 14:26:54 +01:00
}
else {
$ ( " #themeMenuPositionFixed " ) . slideUp ( function () {
$ ( " #themeMenuFixed " ) . prop ( " checked " , false ) . trigger ( " change " );
});
}
2019-06-27 12:01:16 +02:00
}) . trigger ( " change " );
2019-11-29 15:31:37 +01:00
// Affiche la sélection de couleur auto
$ ( " #themeMenuActiveColorAuto " ) . on ( " change " , function () {
if ( $ ( this ) . is ( ':checked' ) ) {
$ ( " #themeMenuActiveColorWrapper " ) . slideUp ();
2020-06-18 13:21:47 +02:00
} else {
2019-11-29 15:31:37 +01:00
$ ( " #themeMenuActiveColorWrapper " ) . slideDown ();
}
2021-10-25 09:11:58 +02:00
}) . trigger ( " change " );
// Affiche / Cache la sélection du logo pour le menu burger
$ ( " #themeMenuBurgerContent " ) . on ( " change " , function () {
if ( $ ( this ) . val () === 'logo' ) {
2021-10-25 12:52:12 +02:00
$ ( " #themeMenuBurgerLogoId " ) . slideDown ();
2021-10-25 09:11:58 +02:00
}
else {
2021-10-25 12:52:12 +02:00
$ ( " #themeMenuBurgerLogoId " ) . slideUp ();
2021-10-25 09:11:58 +02:00
}
}) . trigger ( " select " );