noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 215/219: ICheckBox : add attribute to allow t


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 215/219: ICheckBox : add attribute to allow to select checkbox thanks its attribute with the js select_checkbox_attribute
Date: Mon, 18 Dec 2017 13:23:05 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 66d68954db0886ff0b4acfca549fd99192473058
Author: Dany De Bontridder <address@hidden>
Date:   Sat Dec 16 12:27:26 2017 +0100

    ICheckBox : add attribute to allow to select checkbox thanks its attribute
    with the js select_checkbox_attribute
---
 html/js/scripts.js               | 19 +++++++++++++++++++
 include/lib/html_input.class.php | 34 ++++++++++++++++++++++++++++++++++
 include/lib/icheckbox.class.php  |  1 +
 3 files changed, 54 insertions(+)

diff --git a/html/js/scripts.js b/html/js/scripts.js
index 6831dc2..02c4792 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -1033,6 +1033,25 @@ function select_checkbox(form_id)
     }
 }
 /**
+ * select all the checkbox in a given form if the specific attribute 
+ * has the given value
+ * @param form_id id of the form
+ * @param attribute name
+ * @param attribute value
+ */
+function select_checkbox_attribute(form_id,p_attribute_name,p_attribute_value)
+{
+    var form = $(form_id);
+    for (var i = 0; i < form.length; i++)
+    {
+        var e = form.elements[i];
+        if (e.type === 'checkbox' && 
e.getAttribute(p_attribute_name)==p_attribute_value)
+        {
+            e.checked = true;
+        }
+    }
+}
+/**
  * unselect all the checkbox in a given form
  * @param form_id id of the form
  */
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index 18909af..33307ee 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -450,6 +450,24 @@ class HtmlInput
        return $r;
     }
     /**
+     * Anchor Html with javascript
+     address@hidden $action action action to perform (message) without onclick
+     address@hidden $javascript javascript to execute
+     address@hidden $id is the DOM element id 
+     address@hidden $p_class CSS class of the button
+     address@hidden $p_symbole raw symbole to add to the action message
+     */
+    static function 
anchor_action($action,$javascript,$id=NULL,$p_class="button",$p_symbole="")
+    {
+        if ($id==NULL){
+            $id=uniqid("xx");
+        }
+        $r="";
+        $r.='<a  id="'.$id.'" class="'.$p_class.'" 
onclick="'.$javascript.'">'.$p_symbole.h($action).'</a>';
+        return $r;
+
+    }
+    /**
      * button Html with javascript
      address@hidden $action action action to perform (message) without onclick
      address@hidden $javascript javascript to execute
@@ -1025,4 +1043,20 @@ EOF;
             $js=HtmlInput::button_action(_('Nouvel 
événement'),'action_add('.$dossier.')','xx','smallbutton');
             return $js;
         }
+        /**
+         * Insert attribute inside a INPUT TYPE, these attribute can be 
retrieved
+         * in javascript with element.getAttribute or changed with 
element.setAttribute
+         * example insert my_attribute into a checkbox <input type="checkbox" 
"my_attribute"="XX"> 
+         * @return string to insert into the HTML node
+         * 
+         */
+        function get_node_attribute() 
+        {
+            $r="";
+            $nb_attribute=count($this->attribute);
+            for ($i=0;$i < $nb_attribute;$i++) {
+                $r.=sprintf(' %s="%s" ',$this->attribute[$i][0] 
,$this->attribute[$i][1]);
+            }
+            return $r;
+        }
 }
diff --git a/include/lib/icheckbox.class.php b/include/lib/icheckbox.class.php
index ff7195f..13177dc 100644
--- a/include/lib/icheckbox.class.php
+++ b/include/lib/icheckbox.class.php
@@ -36,6 +36,7 @@ class ICheckBox extends HtmlInput
         $check=( $this->selected==true )?"checked":"unchecked";
         $r='<input type="CHECKBOX" id="'.$this->id.'" 
name="'.$this->name.'"'.' value="'.$this->value.'"';
         $r.="  $check";
+        $r.=$this->get_node_attribute();
         $r.=' '.$this->disabled."  ".$this->javascript.'>';
 
         $r=$r." $this->label";



reply via email to

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