Parcourir la source

#2150 make password field showable

RomanL il y a 6 ans
Parent
commit
27d0c1f27a

+ 18 - 1
inc/js/jquery.webForms.js

@@ -114,7 +114,24 @@
                 $(".bx-form-select-labels").select2ToTree();
             }
         });
-        
+
+        if (!$(".bx-form-input-wrapper-password").hasClass("bx-inited")) {
+            $(".bx-form-input-wrapper-password A").on("click", function () {
+                var oIcon = $(this).find("I");
+                var oFld = $(this).parents(".bx-form-input-wrapper-password").find("INPUT");
+                console.log(oFld.prop("type"))
+                if (oIcon.hasClass("eye")) {
+                    oIcon.removeClass("eye").addClass("eye-slash");
+                    oFld.attr("type", "text");
+                }
+                else {
+                    oIcon.addClass("eye").removeClass("eye-slash");
+                    oFld.attr("type", "password");
+                }
+            });
+            $(".bx-form-input-wrapper-password").addClass("bx-inited");
+        }
+           
         $("input", this).each(function() {
         	var oInput = $(this);
 

+ 11 - 0
template/css/forms.css

@@ -187,6 +187,17 @@
     -o-transition: all 0.2s linear;
     transition: all 0.2s linear;
 }
+.bx-form-input-wrapper-password{
+	display: flex;
+	align-items: baseline;
+	justify-content: space-between
+}
+.bx-form-input-wrapper-password > div:first-child{
+    width: calc(100% - 2rem);
+}
+.bx-form-input-wrapper-password > div:last-child{
+	width:1.5rem;
+}
 
 .bx-form-input-select_multiple,
 .bx-form-input-radio_set,

+ 6 - 0
template/form_field_password.html

@@ -0,0 +1,6 @@
+<div>
+	__input__
+</div>
+<div>
+	<a href="javascript:"><i class="sys-icon briefcase eye"></i></a>
+</div>

+ 9 - 1
template/scripts/BxBaseFormView.php

@@ -725,12 +725,15 @@ BLAH;
             case 'checkbox':
             case 'radio':
             case 'image':
-            case 'password':
             case 'slider':
             case 'doublerange':
             case 'hidden':
                 $sInput = $this->genInputStandard($aInput);
             break;
+            
+            case 'password':
+            	$sInput = $this->genInputPassword($aInput);
+            	break;
 
             case 'file':
             	$sInput = $this->genInputFile($aInput);
@@ -1519,6 +1522,11 @@ BLAH;
 
         return $this->oTemplate->parseHtmlByName('form_field_location.html', $aVars);
     }
+    
+    function genInputPassword(&$aInput)
+    {
+        return $this->oTemplate->parseHtmlByName('form_field_password.html', array('input' => $this->genInputStandard($aInput)));
+    }
 
     public function setLocationVal ($aInput, $sIndex, $sVal)
     {