2018-04-02 08:29:19 +02:00
|
|
|
/**
|
|
|
|
* This file is part of Zwii.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* @license GNU General Public License, version 3
|
2019-05-13 20:37:50 +02:00
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
2021-12-18 10:25:33 +01:00
|
|
|
* @copyright Copyright (C) 2018-2022, Frédéric Tempez
|
2020-09-01 20:48:40 +02:00
|
|
|
* @link http://zwiicms.fr/
|
2018-04-02 08:29:19 +02:00
|
|
|
*/
|
|
|
|
|
2021-03-22 18:51:40 +01:00
|
|
|
$(document).ready(function(){
|
2019-11-11 19:12:19 +01:00
|
|
|
$("header").css("line-height", "");
|
|
|
|
$("header").css("height", "");
|
|
|
|
});
|
2019-11-10 20:55:30 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
/**
|
|
|
|
* Aperçu en direct
|
|
|
|
*/
|
2019-11-10 20:55:30 +01:00
|
|
|
$("input, select").on("change", function() {
|
2021-11-11 15:54:57 +01:00
|
|
|
|
|
|
|
var css = "";
|
2019-11-10 20:12:41 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
// Contenu perso
|
|
|
|
if ($("#themeHeaderFeature").val() == "feature") {
|
2021-11-15 09:01:08 +01:00
|
|
|
|
2021-11-30 14:03:58 +01:00
|
|
|
css = "header{min-height: " + $("#themeHeaderHeight").val() + ";height:" + $("#themeHeaderHeight").val() + "; overflow:hidden; background-position:top; background-repeat: no-repeat; line-height:1.15; background-color:unset; background-image:unset; text-align:unset;}";
|
2021-11-12 11:44:40 +01:00
|
|
|
|
2021-11-11 16:25:43 +01:00
|
|
|
$("#featureContent").appendTo("header").show();
|
2021-11-09 22:31:31 +01:00
|
|
|
$("#themeHeaderTitle").hide();
|
2021-11-11 16:25:43 +01:00
|
|
|
|
2021-11-12 11:44:40 +01:00
|
|
|
// Modifier le texte du sélecteur de hauteur
|
|
|
|
$("#themeHeaderHeight option:eq(0)").text("Hauteur du contenu personnalisé");
|
2021-11-16 14:37:50 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
2021-11-16 14:37:50 +01:00
|
|
|
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
// Couleurs, image, alignement et hauteur de la bannière
|
|
|
|
if ($("#themeHeaderFeature").val() == "wallpaper") {
|
2019-11-10 20:12:41 +01:00
|
|
|
|
2021-11-11 16:25:43 +01:00
|
|
|
// Masque le contenu perso
|
|
|
|
$("#featureContent").hide();
|
2021-11-09 22:31:31 +01:00
|
|
|
// Récupérer la taille de l'image
|
|
|
|
var tmpImg = new Image();
|
|
|
|
tmpImg.onload = function() {
|
|
|
|
// Informations affichées
|
2022-01-31 18:49:03 +01:00
|
|
|
$("#themeHeaderImageHeight").val(tmpImg.height + " px");
|
|
|
|
$("#themeHeaderImageWidth").val(tmpImg.width + " px");
|
|
|
|
$("#themeHeaderImageRatio").val(tmpImg.width / tmpImg.height);
|
2021-11-09 22:31:31 +01:00
|
|
|
|
|
|
|
// Limiter la hauteur à 600 px
|
|
|
|
if (tmpImg.height > 600) {
|
|
|
|
tmpImgHeight = 600;
|
|
|
|
} else {
|
|
|
|
tmpImgHeight = tmpImg.height;
|
2021-03-22 18:51:40 +01:00
|
|
|
}
|
2019-11-11 19:12:19 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
//Modifier la dropdown liste si une image n'est pas sélectionnée
|
|
|
|
if ($("#themeHeaderImage").val() !== "" ) {
|
|
|
|
// Une image est ajoutée ou changée
|
|
|
|
if ($("#themeHeaderHeight option").length === 5) {
|
|
|
|
// Pas d'image précédemment on ajoute l'option
|
|
|
|
$("#themeHeaderHeight ").prepend('<option selected="selected" value="0"> Hauteur de l\'image sélectionnée </option>');
|
|
|
|
}
|
|
|
|
// Modifier la valeur
|
|
|
|
$("#themeHeaderHeight option:eq(0)").val(tmpImgHeight + "px");
|
|
|
|
// Modifier l'option
|
|
|
|
$("#themeHeaderHeight option:eq(0)").html("Hauteur de l\'image sélectionnée (" + tmpImgHeight + "px)");
|
|
|
|
}
|
|
|
|
};
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
if ($("#themeHeaderImage").val() === "" &&
|
|
|
|
$("#themeHeaderHeight option").length === 6 ) {
|
|
|
|
$("#themeHeaderHeight option:eq(0)").remove();
|
2021-11-09 18:46:38 +01:00
|
|
|
}
|
2019-05-13 21:01:37 +02:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
tmpImg.src= "<?php echo helper::baseUrl(false); ?>" + "site/file/source/" + $("#themeHeaderImage").val();
|
|
|
|
|
|
|
|
// Import des polices de caractères
|
2022-02-04 16:26:39 +01:00
|
|
|
var headerFont = $("#themeHeaderFont :selected").val();
|
|
|
|
var headerFontText = $("#themeHeaderFont :selected").text();
|
|
|
|
var css = "@import url('http://fonts.cdnfonts.com/css/" + headerFont + "');";
|
2021-11-09 22:31:31 +01:00
|
|
|
|
2021-11-21 16:11:40 +01:00
|
|
|
css += "header{text-align:" + $("#themeHeaderTextAlign").val() + ";";
|
2021-11-09 22:31:31 +01:00
|
|
|
if ($("#themeHeaderImage").val()) {
|
|
|
|
// Une image est sélectionnée
|
|
|
|
css += "background-image:url('<?php echo helper::baseUrl(false); ?>site/file/source/" + $("#themeHeaderImage").val() + "');background-repeat:" + $("#themeHeaderImageRepeat").val() + ";background-position:" + $("#themeHeaderImagePosition").val() + ";";
|
|
|
|
css += "background-size:" + $("#themeHeaderImageContainer").val() + ";";
|
|
|
|
// Pas d'image sélectionnée
|
|
|
|
} else {
|
|
|
|
// Désactiver l'option responsive
|
|
|
|
css += "background-image:none;";
|
|
|
|
}
|
|
|
|
css += "line-height:" + $("#themeHeaderHeight").val() + ";height:" + $("#themeHeaderHeight").val() + "}";
|
|
|
|
|
2021-03-22 18:51:40 +01:00
|
|
|
|
2021-12-05 16:34:14 +01:00
|
|
|
// Taille, couleur, épaisseur et capitalisation du titre de la bannière
|
2022-02-04 16:26:39 +01:00
|
|
|
css += "header span{font-family:'" + headerFontText + "',sans-serif;font-weight:" + $("#themeHeaderFontWeight").val() + ";font-size:" + $("#themeHeaderFontSize").val() + ";text-transform:" + $("#themeHeaderTextTransform").val() + ";color:" + $("#themeHeaderTextColor").val() + "}";
|
2021-12-05 16:34:14 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
// Cache le titre de la bannière
|
|
|
|
if($("#themeHeaderTextHide").is(":checked")) {
|
2021-11-11 16:25:43 +01:00
|
|
|
$("#themeHeaderTitle").hide();
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
else {
|
2021-11-11 16:25:43 +01:00
|
|
|
$("#themeHeaderTitle").show();
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
2021-11-09 18:38:37 +01:00
|
|
|
|
2021-11-21 16:11:40 +01:00
|
|
|
// Couleur du fond
|
|
|
|
css += "header{background-color:" + $("#themeHeaderBackgroundColor").val() + ";}";
|
|
|
|
|
2021-11-16 14:37:50 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Position de la bannière
|
2021-10-10 14:41:13 +02:00
|
|
|
var positionNav = <?php echo json_encode($this->getData(['theme', 'menu', 'position'])); ?>;
|
|
|
|
var positionHeader = $("#themeHeaderPosition").val();
|
|
|
|
|
|
|
|
switch(positionHeader) {
|
2018-04-02 08:29:19 +02:00
|
|
|
case 'hide':
|
|
|
|
$("header").hide();
|
2021-10-10 14:41:13 +02:00
|
|
|
$("nav").show().prependTo("#site");
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
case 'site':
|
2021-10-10 14:41:13 +02:00
|
|
|
$("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(<?php echo json_encode($this->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(<?php echo json_encode($this->getData(['theme', 'menu', 'margin'])); ?>) {
|
|
|
|
css += 'nav{margin:0 20px}';
|
|
|
|
}
|
|
|
|
break;
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'body':
|
2021-10-10 14:41:13 +02:00
|
|
|
// 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;
|
|
|
|
|
2019-01-22 13:46:35 +01:00
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
2019-02-26 13:46:25 +01:00
|
|
|
|
2021-11-16 14:37:50 +01:00
|
|
|
// Marge dans le site
|
|
|
|
if( $("#themeHeaderMargin").is(":checked") &&
|
|
|
|
$("#themeHeaderPosition").val() === "site"
|
2021-12-06 12:23:39 +01:00
|
|
|
) {
|
2021-11-16 14:37:50 +01:00
|
|
|
css += 'header{margin:20px 20px 0 20px !important;}';
|
2021-12-06 12:23:39 +01:00
|
|
|
/*} else {
|
2021-11-16 14:37:50 +01:00
|
|
|
css += 'header{margin:0 !important;}';*/
|
|
|
|
}
|
|
|
|
|
2021-11-11 16:25:43 +01:00
|
|
|
// Largeur du header
|
2021-11-15 09:01:08 +01:00
|
|
|
switch ($("#themeHeaderWide").val()) {
|
2021-11-11 16:25:43 +01:00
|
|
|
case "container":
|
|
|
|
$("header").addClass("container");
|
|
|
|
break;
|
2021-11-12 10:59:09 +01:00
|
|
|
case "none":
|
2021-11-11 16:25:43 +01:00
|
|
|
$("header").removeClass("container");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-10-10 14:41:13 +02:00
|
|
|
// La bannière est cachée, déplacer le menu dans le site
|
|
|
|
if (positionHeader === "hide" &&
|
|
|
|
(positionNav === "body-first" ||
|
2021-10-24 10:52:24 +02:00
|
|
|
positionNav === "site-first" ||
|
|
|
|
positionNav === "body-second" ||
|
|
|
|
positionNav === "site-second"
|
2021-10-10 14:41:13 +02:00
|
|
|
)) {
|
|
|
|
$("nav").show().prependTo("#site");
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
2021-10-10 14:41:13 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Ajout du css au DOM
|
|
|
|
$("#themePreview").remove();
|
|
|
|
$("<style>")
|
|
|
|
.attr("type", "text/css")
|
|
|
|
.attr("id", "themePreview")
|
|
|
|
.text(css)
|
|
|
|
.appendTo("head");
|
2019-05-09 22:51:30 +02:00
|
|
|
}).trigger("change");
|
2019-02-26 13:46:25 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
// Affiche / Cache les options de l'image du fond
|
|
|
|
$("#themeHeaderImage").on("change", function() {
|
|
|
|
if($(this).val()) {
|
|
|
|
$("#themeHeaderImageOptions").slideDown();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#themeHeaderImageOptions").slideUp(function() {
|
|
|
|
$("#themeHeaderTextHide").prop("checked", false).trigger("change");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).trigger("change");
|
|
|
|
|
|
|
|
// Affiche / Cache les options de la position
|
|
|
|
$("#themeHeaderPosition").on("change", function() {
|
|
|
|
if($(this).val() === 'site') {
|
2021-11-11 16:29:20 +01:00
|
|
|
$("#themeHeaderContainerWrapper").slideUp();
|
2021-11-09 22:31:31 +01:00
|
|
|
$("#themeHeaderPositionOptions").slideDown();
|
2021-11-15 22:23:21 +01:00
|
|
|
$("#themeHeaderWideWrapper").slideUp();
|
2021-11-16 12:23:26 +01:00
|
|
|
$("#themeHeaderMarginWrapper").slideDown();
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
2021-11-15 22:23:21 +01:00
|
|
|
else if ($(this).val() === 'hide') {
|
|
|
|
$("#themeHeaderContainerWrapper").slideUp();
|
|
|
|
$("#themeHeaderWideWrapper").slideUp();
|
2021-11-16 12:23:26 +01:00
|
|
|
$("#themeHeaderMarginWrapper").slideUp();
|
2021-11-16 14:37:50 +01:00
|
|
|
$("#themeHeaderMargin").prop("checked", false);
|
2021-11-09 22:31:31 +01:00
|
|
|
$("#themeHeaderPositionOptions").slideUp(function() {
|
|
|
|
$("#themeHeaderMargin").prop("checked", false).trigger("change");
|
|
|
|
});
|
2021-11-15 22:23:21 +01:00
|
|
|
} else {
|
|
|
|
$("#themeHeaderWideWrapper").slideDown();
|
2021-11-16 12:23:26 +01:00
|
|
|
$("#themeHeaderMarginWrapper").slideUp();
|
2021-11-16 14:37:50 +01:00
|
|
|
$("#themeHeaderMargin").prop("checked", false);
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
|
|
|
}).trigger("change");
|
|
|
|
|
2021-11-15 22:23:21 +01:00
|
|
|
|
2021-11-09 22:31:31 +01:00
|
|
|
|
|
|
|
// Affiche / Cache l'option bannière masquée en écran réduit
|
|
|
|
$("#themeHeaderPosition").on("change", function() {
|
|
|
|
if($(this).val() === 'hide') {
|
|
|
|
$("#themeHeaderSmallDisplay").slideUp();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#themeHeaderSmallDisplay").slideDown();
|
|
|
|
}
|
|
|
|
}).trigger("change");
|
|
|
|
|
|
|
|
// Affiche les blocs selon le type bannière
|
|
|
|
$("#themeHeaderFeature").on("change", function() {
|
|
|
|
if($(this).val() === 'wallpaper') {
|
|
|
|
$(".wallpaperContainer").show();
|
|
|
|
$(".featureContainer").hide();
|
2021-11-21 16:11:40 +01:00
|
|
|
$("#themeHeaderTextColorWrapper").show();
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
|
|
|
if($(this).val() === 'feature') {
|
|
|
|
$(".featureContainer").show();
|
|
|
|
$(".wallpaperContainer").hide();
|
2021-11-21 16:11:40 +01:00
|
|
|
$("#themeHeaderTextColorWrapper").hide();
|
2021-11-09 22:31:31 +01:00
|
|
|
}
|
2021-11-18 17:07:57 +01:00
|
|
|
}).trigger("change");
|