From 4697bd581f77eb9788526fe4e3016ba67a0633a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Thu, 19 May 2022 18:26:04 +0200 Subject: [PATCH] =?UTF-8?q?Modules=20Persistance=20tab=20s=C3=A9lection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/plugin/view/index/index.js.php | 66 ++++++++++++++++++---- core/module/plugin/view/index/index.php | 10 ++-- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/core/module/plugin/view/index/index.js.php b/core/module/plugin/view/index/index.js.php index 060d7e18..a82e2447 100644 --- a/core/module/plugin/view/index/index.js.php +++ b/core/module/plugin/view/index/index.js.php @@ -11,6 +11,22 @@ * @link http://zwiicms.fr/ */ + + $(document).ready(function () { + var configLayout = getCookie("pluginLayout"); + if (configLayout == null) { + configLayout = "module"; + setCookie("pluginLayout", "module"); + } + $("#moduleContainer").hide(); + $("#dataContainer").hide(); + $("#" + configLayout + "Container").show(); + $("#config" + capitalizeFirstLetter(configLayout) + "Button").addClass("activeButton"); + + }); + + + /** * Confirmation de suppression */ @@ -33,18 +49,48 @@ $(".moduleDelete").on("click", function() { // Sélecteur de fonctions -$("#configManageModuleButton").on("click", function () { +$("#configModuleButton").on("click", function () { console.log("clic"); - $("#manageDatas").hide(); - $("#manageModules").show(); - $("#configManageModuleButton").addClass("activeButton"); - $("#configManageDatasButton").removeClass("activeButton"); + $("#dataContainer").hide(); + $("#moduleContainer").show(); + $("#configModuleButton").addClass("activeButton"); + $("#configDataButton").removeClass("activeButton"); setCookie("pluginLayout", "module"); }); -$("#configManageDatasButton").on("click", function () { - $("#manageModules").hide(); - $("#manageDatas").show(); - $("#configManageModuleButton").removeClass("activeButton"); - $("#configManageDatasButton").addClass("activeButton"); +$("#configDataButton").on("click", function () { + $("#moduleContainer").hide(); + $("#dataContainer").show(); + $("#configModuleButton").removeClass("activeButton"); + $("#configDataButton").addClass("activeButton"); setCookie("pluginLayout", "data"); }); + + + + +// Fonctions +function setCookie(name, value, days) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax"; +} + +function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); + } + return null; +} + +// Define function to capitalize the first letter of a string +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} diff --git a/core/module/plugin/view/index/index.php b/core/module/plugin/view/index/index.php index 0c33f68d..ca894a5b 100644 --- a/core/module/plugin/view/index/index.php +++ b/core/module/plugin/view/index/index.php @@ -31,16 +31,16 @@
- 'Modules installés', - 'class' => ' buttonTab activeButton' + 'class' => ' buttonTab' ]); ?> - 'Données des modules', 'class' => 'buttonTab' ]); ?>
-
+
@@ -64,7 +64,7 @@
-
+