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>
|
2020-01-21 09:14:04 +01:00
|
|
|
* @copyright Copyright (C) 2018-2020, Frédéric Tempez
|
2018-04-02 08:29:19 +02:00
|
|
|
* @link http://zwiicms.com/
|
|
|
|
*/
|
|
|
|
|
2019-11-11 19:12:19 +01:00
|
|
|
$(document).ready(function(){
|
|
|
|
$("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() {
|
2019-11-10 20:12:41 +01:00
|
|
|
|
2019-11-10 20:55:30 +01:00
|
|
|
// Récupérer la taille de l'image
|
2019-11-10 20:12:41 +01:00
|
|
|
|
2019-11-10 20:55:30 +01:00
|
|
|
var tmpImg = new Image();
|
|
|
|
|
|
|
|
tmpImg.onload = function() {
|
2019-11-10 20:12:41 +01:00
|
|
|
// Informations affichées
|
|
|
|
$("#themeHeaderImageHeight").html(tmpImg.height + "px");
|
|
|
|
$("#themeHeaderImageWidth").html(tmpImg.width + "px");
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2019-11-10 20:12:41 +01:00
|
|
|
// Limiter la hauteur à 600 px
|
|
|
|
if (tmpImg.height > 600) {
|
|
|
|
tmpImgHeight = 600;
|
|
|
|
} else {
|
|
|
|
tmpImgHeight = tmpImg.height;
|
|
|
|
}
|
|
|
|
|
2019-11-11 19:12:19 +01:00
|
|
|
//Modifier la dropdown liste si une image n'est pas sélectionnée
|
|
|
|
if ($("#themeHeaderImage").val() !== "" ) {
|
2019-11-10 20:55:30 +01:00
|
|
|
// Une image est ajoutée ou changée
|
2019-11-11 19:12:19 +01:00
|
|
|
if ($("#themeHeaderHeight option").length === 5) {
|
|
|
|
// Pas d'image précédemment on ajoute l'option
|
2019-11-10 20:55:30 +01:00
|
|
|
$("#themeHeaderHeight ").prepend('<option selected="selected" value="0"> Hauteur de l\'image sélectionnée </option>');
|
2019-11-11 19:12:19 +01:00
|
|
|
}
|
2019-11-10 20:55:30 +01:00
|
|
|
// Modifier la valeur
|
|
|
|
$("#themeHeaderHeight option:eq(0)").val(tmpImgHeight + "px");
|
|
|
|
// Modifier l'option
|
2019-11-11 19:12:19 +01:00
|
|
|
$("#themeHeaderHeight option:eq(0)").html("Hauteur de l\'image sélectionnée (" + tmpImgHeight + "px)");
|
2019-11-10 20:55:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-11 19:12:19 +01:00
|
|
|
if ($("#themeHeaderImage").val() === "" &&
|
|
|
|
$("#themeHeaderHeight option").length === 6 ) {
|
|
|
|
$("#themeHeaderHeight option:eq(0)").remove();
|
|
|
|
}
|
|
|
|
|
2019-11-10 20:55:30 +01:00
|
|
|
tmpImg.src= "<?php echo helper::baseUrl(false); ?>" + "site/file/source/" + $("#themeHeaderImage").val();
|
2019-05-12 09:03:50 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Import des polices de caractères
|
|
|
|
var headerFont = $("#themeHeaderFont").val();
|
|
|
|
var css = "@import url('https://fonts.googleapis.com/css?family=" + headerFont + "');";
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Couleurs, image, alignement et hauteur de la bannière
|
2019-05-11 23:31:37 +02:00
|
|
|
css += "header{background-color:" + $("#themeHeaderBackgroundColor").val() + ";text-align:" + $("#themeHeaderTextAlign").val() + ";";
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2019-11-09 15:36:14 +01:00
|
|
|
if ($("#themeHeaderImage").val()) {
|
2019-05-13 20:37:50 +02:00
|
|
|
// Une image est sélectionnée
|
2019-11-09 15:36:14 +01:00
|
|
|
css += "background-image:url('<?php echo helper::baseUrl(false); ?>site/file/source/" + $("#themeHeaderImage").val() + "');background-repeat:" + $("#themeHeaderImageRepeat").val() + ";background-position:" + $("#themeHeaderImagePosition").val() + ";";
|
2019-05-12 09:03:50 +02:00
|
|
|
css += "background-size:" + $("#themeHeaderImageContainer").val() + ";";
|
2019-05-13 20:37:50 +02:00
|
|
|
// Pas d'image sélectionnée
|
|
|
|
} else {
|
|
|
|
// Désactiver l'option responsive
|
2019-05-13 21:01:37 +02:00
|
|
|
css += "background-image:none;";
|
2019-05-13 20:37:50 +02:00
|
|
|
}
|
2019-11-10 20:12:41 +01:00
|
|
|
|
|
|
|
css += "line-height:" + $("#themeHeaderHeight").val() + ";height:" + $("#themeHeaderHeight").val() + "}";
|
|
|
|
|
2019-05-13 21:01:37 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Taille, couleur, épaisseur et capitalisation du titre de la bannière
|
|
|
|
css += "header span{color:" + $("#themeHeaderTextColor").val() + ";font-family:'" + headerFont.replace(/\+/g, " ") + "',sans-serif;font-weight:" + $("#themeHeaderFontWeight").val() + ";font-size:" + $("#themeHeaderFontSize").val() + ";text-transform:" + $("#themeHeaderTextTransform").val() + "}";
|
|
|
|
// Cache le titre de la bannière
|
2019-11-09 15:36:14 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
if($("#themeHeaderTextHide").is(":checked")) {
|
2019-11-09 15:36:14 +01:00
|
|
|
$("header #themeHeaderTitle").hide();
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-11-09 15:36:14 +01:00
|
|
|
$("header #themeHeaderTitle").show();
|
2018-04-02 08:29:19 +02:00
|
|
|
}
|
2019-11-09 15:36:14 +01:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Marge
|
|
|
|
if($("#themeHeaderMargin").is(":checked")) {
|
|
|
|
if(<?php echo json_encode($this->getData(['theme', 'menu', 'position']) === 'site-first'); ?>) {
|
|
|
|
css += 'header{margin:0 20px}';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
css += 'header{margin:20px 20px 0 20px}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
css += 'header{margin:0}';
|
|
|
|
}
|
|
|
|
// Position de la bannière
|
|
|
|
switch($("#themeHeaderPosition").val()) {
|
|
|
|
case 'hide':
|
|
|
|
$("header").hide();
|
|
|
|
break;
|
|
|
|
case 'site':
|
|
|
|
if(<?php echo json_encode($this->getData(['theme', 'menu', 'position']) === 'site-first'); ?>) {
|
|
|
|
$("header").show().insertAfter("nav");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("header").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':
|
|
|
|
if(<?php echo json_encode($this->getData(['theme', 'menu', 'position']) === 'body-first'); ?>) {
|
|
|
|
$("header").show().insertAfter("nav");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("header").show().insertAfter("#bar");
|
|
|
|
}
|
2019-01-22 13:46:35 +01:00
|
|
|
if(<?php echo json_encode($this->getData(['theme', 'menu', 'position']) === 'top'); ?>) {
|
|
|
|
$("header").show().insertAfter("nav");
|
|
|
|
}
|
2018-04-02 08:29:19 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-02-26 13:46:25 +01: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
|
|
|
|
|
|
|
|
2019-05-09 22:51:30 +02:00
|
|
|
|
2018-04-02 08:29:19 +02: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");
|
2019-05-11 23:31:37 +02:00
|
|
|
|
2018-04-02 08:29:19 +02:00
|
|
|
// Affiche / Cache les options de la position
|
|
|
|
$("#themeHeaderPosition").on("change", function() {
|
|
|
|
if($(this).val() === 'site') {
|
|
|
|
$("#themeHeaderPositionOptions").slideDown();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#themeHeaderPositionOptions").slideUp(function() {
|
|
|
|
$("#themeHeaderMargin").prop("checked", false).trigger("change");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).trigger("change");
|
|
|
|
|
|
|
|
// Affiche / Cache les options de la bannière cliquable si pas masquée
|
|
|
|
$("#themeHeaderPosition").on("change", function() {
|
|
|
|
if($(this).val() === 'hide') {
|
|
|
|
$("#themeHeaderShow").slideUp(function() {
|
|
|
|
$("#themeHeaderlinkHome").prop("checked", false).trigger("change");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#themeHeaderShow").slideDown();
|
|
|
|
}
|
|
|
|
}).trigger("change");
|
|
|
|
|
|
|
|
|