From b382455dd0a1dc59f2d2885ff69dc049ff91972f Mon Sep 17 00:00:00 2001
From: sparkyx
Date: Sun, 16 Oct 2022 23:10:31 +0200
Subject: [PATCH] New Icon_Action for hidding or showing a DIV
---
html/js/noalyss_script.js | 20 ++++++++++++++++----
include/lib/icon_action.class.php | 15 +++++++++++++++
scenario/icon_actionTest.php | 8 +++++++-
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js
index 60b186f52..8840550ab 100644
--- a/html/js/noalyss_script.js
+++ b/html/js/noalyss_script.js
@@ -369,22 +369,34 @@ function format_date(p_object)
*@brief check if the object is hidden or show and perform the opposite,
* show the hidden obj or hide the shown one
*@param name of the object
+ * @param button id of the button
+ * @param rotate : if true with rotate the object of p_button otherwise
*/
-function toggleHideShow(p_obj, p_button)
+function toggleHideShow(p_obj, p_button,rotate)
{
var stat = g(p_obj).style.display;
- var str = g(p_button).value;
+ var str = g(p_button).value??"";
if (stat === 'none')
{
- show(p_obj);
+ $(p_obj).show()
str = str.replace(/Afficher/, content[62]);
g(p_button).value = str;
} else
{
- hide(p_obj);
+ $(p_obj).hide();
str = str.replace(/Cacher/, content[63]);
g(p_button).value = str;
}
+ if ( ! rotate ) return;
+ if ( stat == "none") {
+ g(p_button).addClassName ("icon-up-open-1")
+ g(p_button).removeClassName(" icon-down-open-2")
+ } else {
+ g(p_button).removeClassName("icon-up-open-1")
+ g(p_button).addClassName(" icon-down-open-2")
+
+ }
+
}
/**
*@brief open popup with the search windows
diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php
index 65a3485ee..ef6d0d7c0 100644
--- a/include/lib/icon_action.class.php
+++ b/include/lib/icon_action.class.php
@@ -471,4 +471,19 @@ class Icon_Action
$r='';
return $r;
}
+
+ /**
+ * @brief hide or display an element, to be used for an accordon
+ * @param $p_id ip of the icon
+ * @param $p_id_to_hide element to hide or show
+ * @return HTML string
+ */
+ static function toggle_hide($p_id,$p_id_to_hide)
+ {
+ $javascript=sprintf("toggleHideShow('%s','%s',true)",$p_id_to_hide,$p_id);
+ $r=sprintf('',
+ $p_id,$javascript
+ );
+ return $r;
+ }
}
diff --git a/scenario/icon_actionTest.php b/scenario/icon_actionTest.php
index f35ea25a9..551f5d590 100644
--- a/scenario/icon_actionTest.php
+++ b/scenario/icon_actionTest.php
@@ -111,4 +111,10 @@ include_once NOALYSS_INCLUDE."/lib/icon_action.class.php";