noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 13/17: Improve Output_Html : row , tab and ac


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 13/17: Improve Output_Html : row , tab and accordean
Date: Mon, 31 Oct 2022 12:53:39 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 3ad1602b92abfa2bb34f4db76ca58a41a3bba3ed
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Oct 30 18:37:41 2022 +0100

    Improve Output_Html : row , tab and accordean
---
 include/lib/output_html_tab.class.php | 51 +++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/include/lib/output_html_tab.class.php 
b/include/lib/output_html_tab.class.php
index 1eff7f605..89ff75cde 100644
--- a/include/lib/output_html_tab.class.php
+++ b/include/lib/output_html_tab.class.php
@@ -166,23 +166,28 @@ class Output_Html_Tab
     }
 
     /**
-     * set the mode , possible values are row or tabs
-     * @param mixed $mode
+     * @brief set the mode , possible values : row , tabs or accordeon
+     * @param string $mode possible values : row , tabs or accordeon
      */
     public function set_mode($mode)
     {
-        if ($mode != "row" && $mode != "tab") {
+        if (! in_array($mode,['tab','row','accordeon'] )) {
             throw new Exception(_("OUTPUTHTML070 Mode invalide"));
         }
         $this->mode = $mode;
         if ($mode == "row") {
             $this->set_class_tab_selected("tab_row_selected");
             $this->set_class_tab("tab_row");
-        }
-        if ( $mode == "tab") {
+
+        }elseif  ( $mode == "tab") {
             $this->set_class_tab_selected("tabs_selected");
             $this->set_class_tab("tabs");
 
+        }elseif ($mode == "accordeon") {
+            $this->set_class_tab_selected("");
+            $this->set_class_tab("tab_row");
+        } else {
+            throw new \Exception("OH186.unknow mode [$mode]");
         }
         return $this;
     }
@@ -244,9 +249,15 @@ class Output_Html_Tab
     {
         $r="";
         $nb=count($this->a_tabs);
+        $mode=$this->get_mode();
+        if ($mode=="accordeon") {
+            $r .= \Icon_Action::toggle_hide(uniqid(), sprintf("div%s", 
$p_not_hidden));
+
+            return $r;
+        }
         for ($i =0 ; $i < $nb;$i++)
         {
-            if ($this->get_mode()=="tab") {
+            if ($mode=="tab") {
 
                 if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) {
                     $r .= 
sprintf("$('div%s').hide();",$this->a_tabs[$i]->get_id() );
@@ -256,7 +267,7 @@ class Output_Html_Tab
                     $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden 
,$this->class_tab_selected);
 
                 }
-            } elseif ($this->get_mode()=="row") {
+            } elseif ($mode=="row") {
                 if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) {
                     $r .= sprintf("Effect.BlindUp('div%s',{duration : 
0.7});",$this->a_tabs[$i]->get_id() );
                     $r .= 
sprintf("$('tab%s').className='%s';",$this->a_tabs[$i]->get_id(),$this->class_tab
 );
@@ -265,6 +276,8 @@ class Output_Html_Tab
                     $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden 
,$this->class_tab_selected);
 
                 }
+            }   else {
+                throw new \Exception("OH283.unknow mode [$mode]");
             }
         }
         return $r;
@@ -294,6 +307,7 @@ class Output_Html_Tab
         }
         printf('<div class="%s">',$this->class_div);
         printf ( '<ul class="%s">',$this->class_tab_main);
+        $mode=$this->get_mode();
         for ($i=0; $i<$nb; $i++)
         {
             printf ('<li id="tab%s" class="%s">',
@@ -326,33 +340,39 @@ class Output_Html_Tab
                     echo '</a>';
                     break;
                 case 'static':
-                    // show one , hide other
+                    // show one , hide other except for accordeon
                     $script=$this->build_js($this->a_tabs[$i]->get_id());
-                    printf('<a class="%s" onclick="%s">', 
$this->class_anchor,$script);
+                    if  ($mode != 'accordeon')  {
+                        printf('<a class="%s" onclick="%s">', 
$this->class_anchor,$script);
+                    } else {
+                        print $script;
+                    }
+
                     printf ('<span class="title_%s"> %s </span>',
                         $this->get_class_tab(),
                         $this->a_tabs[$i]->get_title()
                         );
 
                     echo '</a>';
-                    
+                    $script=$this->build_js($this->a_tabs[$i]->get_id());
+
                     break;
                 default:
                     throw new Exception('OUTPUTHTMLTAB01');
                     break;
             }
-            if ( $this->get_mode()=="row") {
+            if ( $mode =="row" || $mode == "accordeon") {
                 $this->print_comment($i);
             }
             echo '</li>';
-            if ( $this->get_mode()=="row") {
+            if ( $mode =="row" || $mode == "accordeon") {
                 $this->print_div($i);
             }
         }
         echo '</ul>';
         echo '</div>';
         
-        if ( $this->get_mode()=="tab" ) {
+        if ( $mode=="tab" ) {
             for ($i=0;$i<$nb;$i++)
             {
                 $this->print_div($i);
@@ -363,10 +383,13 @@ class Output_Html_Tab
     private function print_div($p_index)
     {
         $class="";
-        if ( $this->get_mode() == "row") {
+        if ( $this->get_mode() == "row" ) {
             $class="tab_row";
+        } elseif ( $this->get_mode() == 'accordeon') {
+            $class="";
         }
 
+
         printf('<div id="div%s" style="display:none;clear:both" class="%s">',
                             $this->a_tabs[$p_index]->get_id(),
                             $class);



reply via email to

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