@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Ajax\service; |
| 3 | 3 | class JQueryAjaxEffect { |
| 4 | - public static function none($responseElement,$jqueryDone="html"){ |
|
| 4 | + public static function none($responseElement, $jqueryDone="html") { |
|
| 5 | 5 | return "\t$({$responseElement}).{$jqueryDone}( data );\n"; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | - public static function fade($responseElement,$jqueryDone="html"){ |
|
| 8 | + public static function fade($responseElement, $jqueryDone="html") { |
|
| 9 | 9 | return "\t$({$responseElement}).hide().{$jqueryDone}( data ).fadeIn();\n"; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - public static function slide($responseElement,$jqueryDone="html"){ |
|
| 12 | + public static function slide($responseElement, $jqueryDone="html") { |
|
| 13 | 13 | return "\t$({$responseElement}).hide().{$jqueryDone}( data ).slideDown();\n"; |
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -6,28 +6,28 @@ discard block |
||
| 6 | 6 | use Ajax\service\AjaxCall; |
| 7 | 7 | use Ajax\JsUtils; |
| 8 | 8 | |
| 9 | -trait FormTrait{ |
|
| 9 | +trait FormTrait { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @return HtmlForm |
| 13 | 13 | */ |
| 14 | 14 | abstract protected function getForm(); |
| 15 | 15 | |
| 16 | - protected function addCompoValidation($compo,$field){ |
|
| 16 | + protected function addCompoValidation($compo, $field) { |
|
| 17 | 17 | $validation=$field->getValidation(); |
| 18 | - if(isset($validation)){ |
|
| 18 | + if (isset($validation)) { |
|
| 19 | 19 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
| 20 | 20 | $compo->addFieldValidation($validation); |
| 21 | 21 | } |
| 22 | 22 | return $compo; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
| 25 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
| 26 | 26 | $form=$this->getForm(); |
| 27 | 27 | $params=$form->getValidationParams(); |
| 28 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
| 28 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
| 29 | 29 | $compilation=$params["_ajaxSubmit"]->compile($js); |
| 30 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
| 30 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
| 31 | 31 | $this->onSuccess($compilation); |
| 32 | 32 | $form->removeValidationParam("_ajaxSubmit"); |
| 33 | 33 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | return $this->getForm()->addToProperty("class", "loading"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function setAttached($value=true){ |
|
| 43 | + public function setAttached($value=true) { |
|
| 44 | 44 | $form=$this->getForm(); |
| 45 | - if($value) |
|
| 46 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 45 | + if ($value) |
|
| 46 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 47 | 47 | return $form; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function addErrorMessage(){ |
|
| 50 | + public function addErrorMessage() { |
|
| 51 | 51 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -62,38 +62,38 @@ discard block |
||
| 62 | 62 | * @param string $responseElement |
| 63 | 63 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 64 | 64 | */ |
| 65 | - public function submitOn($event,$identifier,$url,$responseElement){ |
|
| 65 | + public function submitOn($event, $identifier, $url, $responseElement) { |
|
| 66 | 66 | $form=$this->getForm(); |
| 67 | 67 | $elem=$form->getElementById($identifier, $form->getContent()); |
| 68 | - if(isset($elem)){ |
|
| 69 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement); |
|
| 68 | + if (isset($elem)) { |
|
| 69 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement); |
|
| 70 | 70 | } |
| 71 | 71 | return $form; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function submitOnClick($identifier,$url,$responseElement){ |
|
| 74 | + public function submitOnClick($identifier, $url, $responseElement) { |
|
| 75 | 75 | return $this->submitOn("click", $identifier, $url, $responseElement); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
| 79 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 80 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement); |
|
| 78 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
| 79 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 80 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
| 83 | + protected function _buttonAsSubmit(&$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
| 84 | 84 | $form=$this->getForm(); |
| 85 | - if(isset($url) && isset($responseElement)){ |
|
| 85 | + if (isset($url) && isset($responseElement)) { |
|
| 86 | 86 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');"); |
| 87 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
| 88 | - if(\is_array($parameters)) |
|
| 89 | - $params=\array_merge($params,$parameters); |
|
| 87 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
| 88 | + if (\is_array($parameters)) |
|
| 89 | + $params=\array_merge($params, $parameters); |
|
| 90 | 90 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
| 91 | 91 | } |
| 92 | 92 | return $button; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
| 96 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
| 95 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
| 96 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
| 97 | 97 | $bt->setProperty("type", "reset"); |
| 98 | 98 | return $bt; |
| 99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param string $jsCode |
| 104 | 104 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 105 | 105 | */ |
| 106 | - public function onValid($jsCode){ |
|
| 106 | + public function onValid($jsCode) { |
|
| 107 | 107 | $form=$this->getForm(); |
| 108 | 108 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
| 109 | 109 | return $form; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param string $jsCode can use event and fields parameters |
| 115 | 115 | * @return HtmlForm |
| 116 | 116 | */ |
| 117 | - public function onSuccess($jsCode){ |
|
| 117 | + public function onSuccess($jsCode) { |
|
| 118 | 118 | $form=$this->getForm(); |
| 119 | 119 | $form->addValidationParam("onSuccess", "%function(event,fields){console.log(fields);".$jsCode."}%"); |
| 120 | 120 | return $form; |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function setAttached($value=true){ |
| 44 | 44 | $form=$this->getForm(); |
| 45 | - if($value) |
|
| 46 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 45 | + if($value) { |
|
| 46 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 47 | + } |
|
| 47 | 48 | return $form; |
| 48 | 49 | } |
| 49 | 50 | |
@@ -85,8 +86,9 @@ discard block |
||
| 85 | 86 | if(isset($url) && isset($responseElement)){ |
| 86 | 87 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');"); |
| 87 | 88 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
| 88 | - if(\is_array($parameters)) |
|
| 89 | - $params=\array_merge($params,$parameters); |
|
| 89 | + if(\is_array($parameters)) { |
|
| 90 | + $params=\array_merge($params,$parameters); |
|
| 91 | + } |
|
| 90 | 92 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
| 91 | 93 | } |
| 92 | 94 | return $button; |
@@ -9,22 +9,22 @@ discard block |
||
| 9 | 9 | class FormInstanceViewer extends InstanceViewer { |
| 10 | 10 | protected $separators; |
| 11 | 11 | |
| 12 | - public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
| 13 | - parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
| 12 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 13 | + parent::__construct($identifier, $instance=NULL, $captions=NULL); |
|
| 14 | 14 | $this->separators=[-1]; |
| 15 | - $this->defaultValueFunction=function($name,$value,$index){ |
|
| 15 | + $this->defaultValueFunction=function($name, $value, $index) { |
|
| 16 | 16 | $caption=$this->getCaption($index); |
| 17 | - $input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
| 17 | + $input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value); |
|
| 18 | 18 | $input->setName($name); |
| 19 | 19 | return $input; |
| 20 | 20 | }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - protected function _beforeAddProperty($index,&$field){ |
|
| 24 | - if(JString::endswith($field, "\n")===true){ |
|
| 23 | + protected function _beforeAddProperty($index, &$field) { |
|
| 24 | + if (JString::endswith($field, "\n")===true) { |
|
| 25 | 25 | $this->addSeparatorAfter($index); |
| 26 | 26 | } |
| 27 | - if($index>1 && JString::startswith($field, "\n")===true){ |
|
| 27 | + if ($index>1 && JString::startswith($field, "\n")===true) { |
|
| 28 | 28 | $this->addSeparatorAfter($index-1); |
| 29 | 29 | } |
| 30 | 30 | $field=\str_replace("\n", "", $field); |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - public function addSeparatorAfter($fieldNum){ |
|
| 36 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 35 | + public function addSeparatorAfter($fieldNum) { |
|
| 36 | + if (\array_search($fieldNum, $this->separators)===false) |
|
| 37 | 37 | $this->separators[]=$fieldNum; |
| 38 | 38 | return $this; |
| 39 | 39 | } |
@@ -33,8 +33,9 @@ |
||
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | public function addSeparatorAfter($fieldNum){ |
| 36 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 37 | - $this->separators[]=$fieldNum; |
|
| 36 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
| 37 | + $this->separators[]=$fieldNum; |
|
| 38 | + } |
|
| 38 | 39 | return $this; |
| 39 | 40 | } |
| 40 | 41 | |