Skip to content

Commit

Permalink
2.3.1
Browse files Browse the repository at this point in the history
Add colors invert parameter
Apply custom CSS in bootstrap/template mode
  • Loading branch information
conseilgouz committed Feb 14, 2025
1 parent 467219b commit 48e0538
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 24 deletions.
14 changes: 14 additions & 0 deletions cg_template_switcher_changelog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<changelogs>
<changelog>
<element>pkg_cg_template_switcher</element>
<type>package</type>
<version>2.3.1</version>
<note>
<item>Update : 14/02/2025</item>
</note>
<addition>
<item>Add colors invert parameter</item>
</addition>
<fix>
<item>Apply custom CSS in bootstrap/template mode</item>
</fix>
</changelog>
<changelog>
<element>pkg_cg_template_switcher</element>
<type>package</type>
Expand Down
Binary file modified packages/mod_cg_template_switcher_j4.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher.</p>"
CG_XML_DESCRIPTION="<script src='../media/mod_cg_template_switcher/js/admin.js'></script><p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher.</p>"
CG_STYLE_PREVIEW="Preview template ?"
CG_STYLE_PREVIEWDESC="Show or not template preview window ?"
CG_STYLE_AUTO="Auto Switch"
Expand Down Expand Up @@ -33,4 +33,6 @@ CG_NOTE5="Your user custom field 'Change Template's colors' is <span style='colo
CGSWITCHCOLOR="Switch colors on/off"
CG_STYLE_COLOR="Colors"
CG_STYLE_GRAYSCALE="Gray scale ?"
CG_STYLE_GRAYSCALEDESC="Select your grau scale in %. 100% displays your pages in gray. Default value 80% leaves some other colors on your page.
CG_STYLE_GRAYSCALEDESC="Select your grau scale in %. 100% displays your pages in gray. Default value 80% leaves some other colors on your page.
CG_STYLE_INVERT="Invert ?"
CG_STYLE_INVERTDESC="Select desired colors inversion in %. The recommanded value (100%) inverts all colors."
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher.</p>"
CG_XML_DESCRIPTION="<script src='../media/mod_cg_template_switcher/js/admin.js'></script><p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher.</p>"
CG_STYLE_PREVIEW="Pr&eacute;visualisation du template ?"
CG_STYLE_PREVIEWDESC="Activer ou non la Pr&eacute;visualisation du template ?"
CG_STYLE_AUTO="Auto Switch"
Expand Down Expand Up @@ -33,4 +33,6 @@ CG_NOTE5="Le champ utilisateur 'Modifier les couleurs Template' est actuellement
CGSWITCHCOLOR="Modifier les couleurs ou non"
CG_STYLE_COLOR="Couleurs"
CG_STYLE_GRAYSCALE="Nuance de gris ?"
CG_STYLE_GRAYSCALEDESC="Régler la nuance de gris souhaitée en %. La valeur 100% n'affichera vos pages qu'en nuances de gris. La valeur par défaut 80% laisse quelques couleurs passer."
CG_STYLE_GRAYSCALEDESC="Régler la nuance de gris souhaitée en %. La valeur 100% n'affichera vos pages qu'en nuances de gris. La valeur par défaut 80% laisse quelques couleurs passer."
CG_STYLE_INVERT="Inversion ?"
CG_STYLE_INVERTDESC="Régler l'inversion des couleurs souhaitée en %. La valeur recommandée à 100% inverse toutes les couleurs."
55 changes: 55 additions & 0 deletions packages/mod_cg_template_switcher_j4/media/js/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @package CG template switcher Module
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
* @copyright (c) 2025 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*
**/
document.addEventListener("DOMContentLoaded", function(){
// check CG custom classes
fields = document.querySelectorAll('.view-module .clear');
for(var i=0; i< fields.length; i++) {
let field = fields[i];
field.parentNode.parentNode.style.clear = "both";
field.parentNode.parentNode.parentNode.style.clear = "both";
field.parentNode.parentNode.parentNode.parentNode.style.clear = "both";
}
fields = document.querySelectorAll('.view-module .left');
for(var i=0; i< fields.length; i++) {
let field = fields[i];
if (field.type == 'range') {
field.parentNode.parentNode.parentNode.parentNode.style.float = "left";
} else if (field.children && field.children.length > 0 && field.children[0].type == "radio") {
field.parentNode.parentNode.parentNode.style.float = "left";
} else {
field.parentNode.parentNode.style.float = "left";
}
}
fields = document.querySelectorAll('.view-module .right');
for(var i=0; i< fields.length; i++) {
let field = fields[i];
if (field.type == 'range') {
field.parentNode.parentNode.parentNode.parentNode.style.float = "right";
} else if (field.children && field.children.length > 0 && field.children[0].type == "radio") {
field.parentNode.parentNode.parentNode.style.float = "right";
} else {
field.parentNode.parentNode.style.float = "right";
}
}
fields = document.querySelectorAll('.view-module .half');
for(var i=0; i< fields.length; i++) {
let field = fields[i];
if (field.type == 'range') {
field.parentNode.parentNode.parentNode.parentNode.style.width = "50%";
} else if (field.children && field.children.length > 0 && field.children[0].type == "radio") {
field.parentNode.parentNode.parentNode.style.width = "50%";
} else {
field.parentNode.parentNode.style.width = "50%";
}
}
fields = document.querySelectorAll('.view-module .gridauto');
for(var i=0; i< fields.length; i++) {
let field = fields[i];
field.parentNode.parentNode.style.gridColumn = "auto";
}
})
18 changes: 11 additions & 7 deletions packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="module" method="upgrade" client="site">
<name>CG Template Switcher</name>
<author>ConseilGouz</author>
<creationDate>2025-02-10</creationDate>
<creationDate>2025-02-14</creationDate>
<copyright>Copyright (C) 2025 ConseilGouz. All rights reserved</copyright>
<license>https://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv2</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.3.0</version>
<version>2.3.1</version>
<description>CG_XML_DESCRIPTION</description>
<namespace path="src">ConseilGouz\Module\CGTemplateSwitcher</namespace>
<changelogurl>https://raw.githubusercontent.com/conseilgouz/pkg_cg_template_switcher_j4/master/cg_template_switcher_changelog.xml</changelogurl>
Expand Down Expand Up @@ -62,7 +62,7 @@
<option value="true">JYES</option>
<option value="false">JNO</option>
</field>
<field name="oneclick" type="radio" class="btn-group" default="false"
<field name="oneclick" type="radio" class="btn-group half left" default="false"
label="CG_STYLE_ONECLICK" description="CG_STYLE_ONECLICKDESC"
>
<option value="false">JNO</option>
Expand All @@ -71,14 +71,18 @@
<option value="color">CG_STYLE_COLOR</option>
</field>
<field showon="oneclick:color" name="grayscale" type="cgrange" default="80"
class="limits" unit="%"
class="limits clear half left" unit="%"
label="CG_STYLE_GRAYSCALE" description="CG_STYLE_GRAYSCALEDESC"
min="1" max="100" step="1" />
<field showon="oneclick:tmpl" name="onetmpl" type="templatestyle"
<field showon="oneclick:color" name="invert" type="cgrange" default="100"
class="limits half right" unit="%"
label="CG_STYLE_INVERT" description="CG_STYLE_INVERTDESC"
min="1" max="100" step="1" />
<field showon="oneclick:tmpl" name="onetmpl" type="templatestyle" class="half right"
label="CG_STYLE_TMPL" description="CG_STYLE_TMPLDESC"
/>
<field name="cookie_duration" type="text" default="0" label="COOKIE_DURATION" description="COOKIE_DURATIONDESC" size="3" maxlength="3"/>
<field name="user_field" type="sql" class="hidden"
<field name="cookie_duration" type="text" class="clear half" default="0" label="COOKIE_DURATION" description="COOKIE_DURATIONDESC" size="3" maxlength="3"/>
<field name="user_field" type="sql" class="hidden clear"
label="CG_STYLE_USER" description="CG_STYLE_USERDESC"
query="select f.id as id, f.state as value from #__fields f where f.context like 'com_user%' and f.type like 'cgtemplateswitcher' "
key_field="value" value_field="value"
Expand Down
Binary file modified packages/plg_fields_cgtemplateswitcher_j4.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension type="plugin" version="4.0" group="fields" method="upgrade">
<name>plg_fields_cgtemplateswitcher</name>
<author>ConseilGouz</author>
<creationDate>2025-02-10</creationDate>
<creationDate>2025-02-14</creationDate>
<copyright>Copyright (C) 2025 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.3.0</version>
<version>2.3.1</version>
<description>PLG_FIELDS_CGTEMPLATESWITCHER_XML_DESC</description>
<namespace path="src">ConseilGouz\Plugin\Fields\Cgtemplateswitcher</namespace>
<scriptfile>script.php</scriptfile>
Expand Down
Binary file modified packages/plg_fields_cgtscolor_j4.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/plg_fields_cgtscolor_j4/cgtscolor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension type="plugin" version="4.0" group="fields" method="upgrade">
<name>plg_fields_cgtscolor</name>
<author>ConseilGouz</author>
<creationDate>2025-02-10</creationDate>
<creationDate>2025-02-14</creationDate>
<copyright>Copyright (C) 2025 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.3.0</version>
<version>2.3.1</version>
<description>PLG_FIELDS_CGTSCOLOR_XML_DESC</description>
<namespace path="src">ConseilGouz\Plugin\Fields\Cgtscolor</namespace>
<scriptfile>script.php</scriptfile>
Expand Down
Binary file modified packages/plg_system_cgstyle_j4.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/plg_system_cgstyle_j4/cgstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="plugin" group="system" method="upgrade">
<name>plg_system_cgstyle</name>
<author>ConseilGouz</author>
<creationDate>2025-02-10</creationDate>
<creationDate>2025-02-14</creationDate>
<copyright>(C)2025 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.3.0</version>
<version>2.3.1</version>
<description>PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION</description>
<namespace path="src">Conseilgouz\Plugin\System\Cgstyle</namespace>
<files>
Expand Down
12 changes: 7 additions & 5 deletions packages/plg_system_cgstyle_j4/src/Extension/Cgstyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function onBeforeRender(\Joomla\Event\Event $event): void
$cookie = explode(':', $cookieValue);
$default = 80; // init default grayscale value
$gray = 0;
$invert = 100;
$list = $this->getSiteModules();
// get default grayscale from first CG Template Switcher module
foreach ($list as $module) {
Expand All @@ -137,20 +138,21 @@ public function onBeforeRender(\Joomla\Event\Event $event): void
if (isset($tmp_params->grayscale) && $tmp_params->grayscale) {
$default = $tmp_params->grayscale;
}
if (isset($tmp_params->invert) && $tmp_params->invert) {
$invert = $tmp_params->invert;
}
}
$graycss = "";
if (isset($cookie[1])) {
if (is_integer($cookie[1])) {// grayscale in cookie ?
if ((int)$cookie[1]) {// grayscale in cookie ?
$gray = (int)$cookie[1];
$graycss = ".cgcolor {filter: grayscale($gray%) invert(100%)}
.cgcolor img { filter: brightness(1.1) contrast(1.2) invert(100%) grayscale(0) }";
} else {
return;
}
}
if (!$gray) { // empty or null : take default value
$gray = $default;
}
$graycss = ".cgcolor {filter: grayscale($gray%) invert($invert%)}
.cgcolor img { filter: brightness(1.1) contrast(1.2) invert($invert%) grayscale(0) }";
$customcss = $this->params->get('customcss', '');

$customCSS = <<< CSS
Expand Down
4 changes: 2 additions & 2 deletions pkg_cgtemplateswitcher.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.10" method="upgrade">
<name>CG Template Switcher</name>
<creationDate>2025-02-11</creationDate>
<creationDate>2025-02-14</creationDate>
<packagename>cgtemplateswitcher</packagename>
<license>https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<author>ConseilGouz</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.3.0</version>
<version>2.3.1</version>
<url>https://www.conseilgouz.com/</url>
<packager>ConseilGouz</packager>
<description>Package CG Template Switcher</description>
Expand Down

0 comments on commit 48e0538

Please sign in to comment.