/** * 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 * @copyright Copyright (C) 2008-2018, Rémi Jean * @license GNU General Public License, version 3 * @link http://zwiicms.com/ */ // Récupérer les dimensions de l'image et les place dans des champs cachés $("#themeHeaderImage").on("change", function() { if($(this).val() !== '') { var tmpImg = new Image(); var url = "" + "site/file/source/" + $("#themeHeaderImage").val(); tmpImg.src= url; $(tmpImg).on('load',function(){ $("#themeHeaderImageWidth").val(tmpImg.width); $("#themeHeaderImageHeight").val(tmpImg.height); }); } else { $("#themeHeaderImageWidth").val(0); $("#themeHeaderImageHeight").val(0); } console.log ("imagesize"); }).trigger("change"); /** * Aperçu en direct */ $("input, select").on("change", function() { var themeHeaderHeight = $("#themeHeaderHeight").val(); var widthSize = $("#themeHeaderImageWidth").val(); var heightSize = $("#themeHeaderImageHeight").val(); var themeHeaderImage = $("#themeHeaderImage").val(); // Import des polices de caractères var headerFont = $("#themeHeaderFont").val(); var css = "@import url('https://fonts.googleapis.com/css?family=" + headerFont + "');"; // Couleurs, image, alignement et hauteur de la bannière css += "header{background-color:" + $("#themeHeaderBackgroundColor").val() + ";text-align:" + $("#themeHeaderTextAlign").val() + ";"; // Hauteur proportionnelle // Une imge est sélectionnée if(themeHeaderImage) { css += "background-image:url('site/file/source/" + themeHeaderImage + "');background-repeat:" + $("#themeHeaderImageRepeat").val() + ";background-position:" + $("#themeHeaderImagePosition").val() + ";"; // Adaptation de la bannière css += "background-size:" + $("#themeHeaderImageContainer").val() + ";"; // Position responsive if (themeHeaderHeight === "none" ) { css += "height: 0; padding-top:" + (heightSize / widthSize ) * 100 + "%;"; console.log(widthSize + "-" + heightSize + ' ' + themeHeaderImage ); //console.log(css); } else { css += "line-height:" + $("#themeHeaderHeight").val() + ";height:" + themeHeaderHeight + ";"; } }else { css += "background-image:none;"; // Forcer la sélection 150px $("#themeHeaderHeight option:eq(2)").prop("selected", true); } css += "}"; // 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 if($("#themeHeaderTextHide").is(":checked")) { $("header .container").hide(); } else { $("header .container").show(); } // Marge if($("#themeHeaderMargin").is(":checked")) { if(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(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}'; } } break; case 'body': if(getData(['theme', 'menu', 'position']) === 'body-first'); ?>) { $("header").show().insertAfter("nav"); } else { $("header").show().insertAfter("#bar"); } if(getData(['theme', 'menu', 'position']) === 'top'); ?>) { $("header").show().insertAfter("nav"); } break; } // Ajout du css au DOM $("#themePreview").remove(); $("