@@ -7,23 +7,23 @@ discard block |
||
| 7 | 7 | class HtmlFormInput extends HtmlFormField { |
| 8 | 8 | use TextFieldsTrait; |
| 9 | 9 | |
| 10 | - const TOGGLE_CLICK = 0; |
|
| 10 | + const TOGGLE_CLICK=0; |
|
| 11 | 11 | |
| 12 | - const TOGGLE_MOUSEDOWN = 1; |
|
| 12 | + const TOGGLE_MOUSEDOWN=1; |
|
| 13 | 13 | |
| 14 | - const TOGGLE_INTERVAL = 2; |
|
| 14 | + const TOGGLE_INTERVAL=2; |
|
| 15 | 15 | |
| 16 | - public function __construct($identifier, $label = NULL, $type = "text", $value = NULL, $placeholder = NULL) { |
|
| 17 | - if (! isset($placeholder) && $type === "text") |
|
| 18 | - $placeholder = $label; |
|
| 19 | - parent::__construct("field-" . $identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
| 20 | - $this->_identifier = $identifier; |
|
| 16 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 17 | + if (!isset($placeholder) && $type==="text") |
|
| 18 | + $placeholder=$label; |
|
| 19 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
| 20 | + $this->_identifier=$identifier; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function getDataField() { |
| 24 | - $field = $this->getField(); |
|
| 24 | + $field=$this->getField(); |
|
| 25 | 25 | if ($field instanceof HtmlInput) |
| 26 | - $field = $field->getDataField(); |
|
| 26 | + $field=$field->getDataField(); |
|
| 27 | 27 | return $field; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param string $keyIcon |
| 34 | 34 | */ |
| 35 | - public function asPassword($keyIcon = 'key') { |
|
| 35 | + public function asPassword($keyIcon='key') { |
|
| 36 | 36 | $this->setInputType('password'); |
| 37 | - if ($keyIcon != '') { |
|
| 37 | + if ($keyIcon!='') { |
|
| 38 | 38 | $this->addIcon($keyIcon); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -49,28 +49,28 @@ discard block |
||
| 49 | 49 | * one of TOGGLE_CLICK, TOGGLE_MOUSEDOWN, TOGGLE_INTERVAL |
| 50 | 50 | * @return mixed|\Ajax\semantic\html\elements\HtmlButton |
| 51 | 51 | */ |
| 52 | - public function addTogglePasswordAction($buttonIcon = 'eye', $keyIcon = 'key', $slashIcon = 'slash', $type = 0) { |
|
| 52 | + public function addTogglePasswordAction($buttonIcon='eye', $keyIcon='key', $slashIcon='slash', $type=0) { |
|
| 53 | 53 | $this->asPassword($keyIcon); |
| 54 | - $action = $this->addAction('see'); |
|
| 54 | + $action=$this->addAction('see'); |
|
| 55 | 55 | $action->asIcon($buttonIcon); |
| 56 | 56 | switch ($type) { |
| 57 | 57 | case self::TOGGLE_CLICK: |
| 58 | - $action->onClick('let th=$(this);' . $this->getJsToggle($slashIcon, '(_,attr)=>(attr=="text")?"password":"text"', 'toggle')); |
|
| 58 | + $action->onClick('let th=$(this);'.$this->getJsToggle($slashIcon, '(_,attr)=>(attr=="text")?"password":"text"', 'toggle')); |
|
| 59 | 59 | break; |
| 60 | 60 | case self::TOGGLE_MOUSEDOWN: |
| 61 | 61 | $action->onClick(''); |
| 62 | - $action->addEvent('mousedown', 'let th=$(this);' . $this->getJsToggle($slashIcon, '"text"', 'add')); |
|
| 63 | - $action->addEvent('mouseup', 'let th=$(this);' . $this->getJsToggle($slashIcon, '"password"', 'remove')); |
|
| 64 | - $action->addEvent('mouseout', 'let th=$(this);' . $this->getJsToggle($slashIcon, '"password"', 'remove')); |
|
| 62 | + $action->addEvent('mousedown', 'let th=$(this);'.$this->getJsToggle($slashIcon, '"text"', 'add')); |
|
| 63 | + $action->addEvent('mouseup', 'let th=$(this);'.$this->getJsToggle($slashIcon, '"password"', 'remove')); |
|
| 64 | + $action->addEvent('mouseout', 'let th=$(this);'.$this->getJsToggle($slashIcon, '"password"', 'remove')); |
|
| 65 | 65 | break; |
| 66 | 66 | case self::TOGGLE_INTERVAL: |
| 67 | - $action->onClick('let th=$(this);' . $this->getJsToggle($slashIcon, '"text"', 'add') . 'setTimeout(function(){ ' . $this->getJsToggle($slashIcon, '"password"', 'remove') . ' }, 5000);'); |
|
| 67 | + $action->onClick('let th=$(this);'.$this->getJsToggle($slashIcon, '"text"', 'add').'setTimeout(function(){ '.$this->getJsToggle($slashIcon, '"password"', 'remove').' }, 5000);'); |
|
| 68 | 68 | break; |
| 69 | 69 | } |
| 70 | 70 | return $action; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | private function getJsToggle($slashIcon, $type, $actionClass) { |
| 74 | - return 'th.find(".icon").' . $actionClass . 'Class("' . $slashIcon . '");th.closest(".field").find("input").attr("type",' . $type . ');'; |
|
| 74 | + return 'th.find(".icon").'.$actionClass.'Class("'.$slashIcon.'");th.closest(".field").find("input").attr("type",'.$type.');'; |
|
| 75 | 75 | } |
| 76 | 76 | } |