ZwiiCMS/core/module/theme/view/site/site.js.php

106 lines
5.6 KiB
PHP
Raw Normal View History

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
* @link http://zwiicms.com/
*/
2020-03-16 10:20:25 +01:00
/*
* Chargement de l'aperçu
*/
$( document ).ready(function() {
// Import des polices de caractères
var titleFont = $("#themeTitleFont").val();
var textFont = $("#themeTextFont").val();
2020-03-16 15:25:31 +01:00
2020-03-16 10:20:25 +01:00
var css = "@import url('https://fonts.googleapis.com/css?family=" + titleFont + "|" + textFont + "');";
var colors = core.colorVariants($("#themeButtonBackgroundColor").val());
2020-03-16 15:25:31 +01:00
// Texte
css += "p.preview{color:" + $("#themeTextTextColor").val() + ";font-family:'" + textFont.replace(/\+/g, " ") + "',sans-serif}";
// Titres
2020-03-16 10:20:25 +01:00
css += "h1.preview,h3.preview{color:" + $("#themeTitleTextColor").val() + ";font-family:'" + titleFont.replace(/\+/g, " ") + "',sans-serif;font-weight:" + $("#themeTitleFontWeight").val() + ";text-transform:" + $("#themeTitleTextTransform").val() + "}";
2020-03-16 15:25:31 +01:00
// Fond
css += "div.preview{background-color:" + $("#themeSiteBackgroundColor").val() + ";}";
2020-03-16 10:20:25 +01:00
// Couleurs des liens
colors = core.colorVariants($("#themeLinkTextColor").val());
css += "a.preview{color:" + colors.normal + "}";
css += "a.preview:hover{color:" + colors.darken + "}";
// Paramètrage du DOM
$("#themePreview").remove();
$("<style>")
.attr("type", "text/css")
.attr("id", "themePreview")
.text(css)
.appendTo("head");
});
2018-04-02 08:29:19 +02:00
/**
* Aperçu en direct
*/
$("input, select").on("change", function() {
// Import des polices de caractères
var titleFont = $("#themeTitleFont").val();
var textFont = $("#themeTextFont").val();
var css = "@import url('https://fonts.googleapis.com/css?family=" + titleFont + "|" + textFont + "');";
// Couleurs des boutons
var colors = core.colorVariants($("#themeButtonBackgroundColor").val());
css += ".speechBubble,.button,.button:hover,button[type='submit'],.pagination a,.pagination a:hover,input[type='checkbox']:checked + label:before,.helpContent{background-color:" + colors.normal + ";color:" + colors.text + "}";
css += ".helpButton span{color:" + colors.normal + "}";
2020-03-15 20:53:13 +01:00
//css += "input[type='text']:hover,input[type='password']:hover,.inputFile:hover,select:hover,textarea:hover{border-color:" + colors.normal + "}";
2018-04-02 08:29:19 +02:00
css += ".speechBubble:before{border-color:" + colors.normal + " transparent transparent transparent}";
css += ".button:hover,button[type='submit']:hover,.pagination a:hover,input[type='checkbox']:not(:active):checked:hover + label:before,input[type='checkbox']:active + label:before{background-color:" + colors.darken + "}";
css += ".helpButton span:hover{color:" + colors.darken + "}";
css += ".button:active,button[type='submit']:active,.pagination a:active{background-color:" + colors.veryDarken + "}";
2019-05-13 21:40:20 +02:00
if ($("#themeSiteWidth").val() === "750px") {
css += ".button, button{font-size:0.8em;}";
} else {
css += ".button, button{font-size:1em;}";
}
2018-04-02 08:29:19 +02:00
// Couleurs des liens
colors = core.colorVariants($("#themeLinkTextColor").val());
2020-03-15 20:53:13 +01:00
//css += "a{color:" + colors.normal + "}";
//css += "a:hover{color:" + colors.darken + "}";
2020-03-16 10:20:25 +01:00
css += "a.preview{color:" + colors.normal + "}";
css += "a.preview:hover{color:" + colors.darken + "}";
2018-04-02 08:29:19 +02:00
// Couleur, polices, épaisseur et capitalisation de caractères des titres
2020-03-15 20:53:13 +01:00
//css += "h1,h2,h3,h4,h5,h6{color:" + $("#themeTitleTextColor").val() + ";font-family:'" + titleFont.replace(/\+/g, " ") + "',sans-serif;font-weight:" + $("#themeTitleFontWeight").val() + ";text-transform:" + $("#themeTitleTextTransform").val() + "}";
2020-03-16 10:20:25 +01:00
css += "h1.preview,h3.preview{color:" + $("#themeTitleTextColor").val() + ";font-family:'" + titleFont.replace(/\+/g, " ") + "',sans-serif;font-weight:" + $("#themeTitleFontWeight").val() + ";text-transform:" + $("#themeTitleTextTransform").val() + "}";
2018-04-02 08:29:19 +02:00
// Police de caractères
2020-03-16 15:25:31 +01:00
//css += "body{font-family:'" + textFont.replace(/\+/g, " ") + "',sans-serif}";
// Police + couleur
css += "p.preview{color:" + $("#themeTextTextColor").val() + ";font-family:'" + textFont.replace(/\+/g, " ") + "',sans-serif}";
2018-04-02 08:29:19 +02:00
// Taille du texte
2020-03-16 15:25:31 +01:00
//css += "body,.row > div{font-size:" + $("#themeTextFontSize").val() + "}";
2018-04-02 08:29:19 +02:00
// Couleur du texte
2020-03-15 20:53:13 +01:00
//css += "body,.block h4,input[type='email'],input[type='text'],input[type='password'],.inputFile,select,textarea,.inputFile,.button.buttonGrey,.button.buttonGrey:hover{color:" + $("#themeTextTextColor").val() + "}";
2020-03-16 10:20:25 +01:00
css += "p.preview{color:" + $("#themeTextTextColor").val() + "}";
2018-04-02 08:29:19 +02:00
// Largeur du site
css += ".container{max-width:" + $("#themeSiteWidth").val() + "}";
2019-05-27 10:26:11 +02:00
if ($("#themeSiteWidth").val() === "100%") {
2019-05-27 11:09:18 +02:00
css += "#site{margin:0 auto;} body{margin:0 auto;} #bar{margin:0 auto;} body > header{margin:0 auto;} body > nav {margin: 0 auto;} body > footer {margin:0 auto;}";
2019-05-27 10:47:32 +02:00
} else {
2019-05-27 11:09:18 +02:00
css += "#site{margin:20px auto !important;} body{margin:0px 10px;} #bar{margin: 0 -10px;} body > header{margin: 0 -10px;} body > nav {margin: 0 -10px;} body > footer {margin: 0 -10px;} ";
2019-05-27 10:47:32 +02:00
2019-05-27 10:26:11 +02:00
}
2018-04-02 08:29:19 +02:00
// Couleur du site, arrondi sur les coins du site et ombre sur les bords du site
2020-03-15 20:53:13 +01:00
//css += "#site{background-color:" + $("#themeSiteBackgroundColor").val() + ";border-radius:" + $("#themeSiteRadius").val() + ";box-shadow:" + $("#themeSiteShadow").val() + " #212223}";
css += "#site{border-radius:" + $("#themeSiteRadius").val() + ";box-shadow:" + $("#themeSiteShadow").val() + " #212223}";
2020-03-16 10:20:25 +01:00
css += "div.preview{background-color:" + $("#themeSiteBackgroundColor").val() + ";}";
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");
});