noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 09/13: New Icon_Action for hidding or showing


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 09/13: New Icon_Action for hidding or showing a DIV
Date: Sun, 16 Oct 2022 17:26:14 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit b382455dd0a1dc59f2d2885ff69dc049ff91972f
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Oct 16 23:10:31 2022 +0200

    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='<span id="'.uniqid().'" class="smallicon icon"  
style="background-color:yellow" 
onclick="document.getElementById(\''.$p_domid.'\').show()">&#xf0f6;</span>';
         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('<i id="%s" onclick="%s" class="smallicon icon   
icon-down-open-2" style="margin-left:5px"></i>',
+            $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";
 <p>
     Increase INPUT TEXT Element
     <input type="text" id="text_element" size="20"><?php echo 
Icon_Action::longer("text_element",50)?>
-</p>
\ No newline at end of file
+</p>
+<p>
+    <?php echo \Icon_Action::toggle_hide(uniqid(),"example_div")?>
+    <div id="example_div" style="display:none">
+    Ceci est caché
+</div>
+</div>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]