noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 192/219: Select_box : add a new type of value


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 192/219: Select_box : add a new type of value and fix a problem with the position of the div
Date: Mon, 18 Dec 2017 13:23:01 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit beaa17e66dd2a9076c8ed2930daa1a08d062ee67
Author: Dany De Bontridder <address@hidden>
Date:   Sun Dec 10 13:54:59 2017 +0100

    Select_box : add a new type of value and fix a problem with the position
    of the div
---
 include/lib/select_box.class.php | 41 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/include/lib/select_box.class.php b/include/lib/select_box.class.php
index 6a66898..430e28b 100644
--- a/include/lib/select_box.class.php
+++ b/include/lib/select_box.class.php
@@ -46,17 +46,28 @@ class Select_Box
 
     function input()
     {
+        // Show when click
         $javascript=sprintf('$("%s_bt").onclick=function() {
        try {
            var newDiv=$("select_box%s");
-              var pos=$("%s_bt").cumulativeOffset();
-           
newDiv.setStyle({display:"block",position:"absolute",top:pos.top+25+"px",left:pos.left+5+"px"});
+          var pos=$("%s_bt").cumulativeOffset();
+           
newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"});
 
        } catch(e) {
             alert(e.message);
        }
-}
-', $this->id, $this->id, $this->id, $this->id);
+       }
+        ', $this->id, $this->id, $this->id, $this->id);
+        
+        // Hide when out of the zone
+        $javascript.=sprintf('$("select_box%s").onmouseleave=function() {
+       try {
+           var newDiv=$("select_box%s");
+           newDiv.setStyle({display:"none"});
+       } catch(e) {
+            alert(e.message);
+       }
+       }',$this->id,$this->id);
 
         // display the button
         printf('<input type="button" id="%s_bt" value="%s &#x25BE;">',
@@ -68,7 +79,7 @@ class Select_Box
 
 
         // Print the list of possible options
-        echo "<ul>";
+        printf('<ul id="%s_list">',$this->id);
         for ($i=0; $i<count($this->item); $i++)
         {
             if ($this->item[$i]['type']=="url")
@@ -87,6 +98,15 @@ class Select_Box
                 printf('<li><a href="javascript:void(0)" 
onclick="%s">%s</a></li>',
                         $this->item[$i]['javascript'], 
$this->item[$i]['label']);
             }
+            else if ($this->item[$i]['type']=="input") {
+                $ok=new IButton("ok");
+                $ok->value=$this->item[$i]['label'];
+                $ok->javascript=$this->item[$i]['input']->javascript;
+                printf('<li> %s %s</li>',
+                        $this->item[$i]['input']->input(),
+                        $ok->input()
+                        );
+            }
         }
 
         echo "</ul>";
@@ -123,5 +143,16 @@ class Select_Box
         $this->item[$this->cnt]['type']='value';
         $this->cnt++;
     }
+    function add_input($p_label,HtmlInput $p_element) {
+        /* $this->item[$this->cnt]['label']=$p_element->label;
+        $this->item[$this->cnt]['value']=$p_element->value;
+        $this->item[$this->cnt]['javascript']=$p_element->javascript;
+         * 
+         */
+        $this->item[$this->cnt]['label']=$p_label;
+        $this->item[$this->cnt]['input']=clone $p_element;
+        $this->item[$this->cnt]['type']='input';
+        $this->cnt++;
+    }
 
 }



reply via email to

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