@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 37 | 37 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
| 38 | - if ($immediatly) |
|
| 39 | - $this->jquery_code_for_compile[]=$retour; |
|
| 38 | + if ($immediatly) { |
|
| 39 | + $this->jquery_code_for_compile[]=$retour; |
|
| 40 | + } |
|
| 40 | 41 | return $retour; |
| 41 | 42 | } |
| 42 | 43 | |
@@ -44,13 +45,15 @@ discard block |
||
| 44 | 45 | $url=$this->_correctAjaxUrl($url); |
| 45 | 46 | $retour="url='".$url."';\n"; |
| 46 | 47 | $slash="/"; |
| 47 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 48 | - $slash=""; |
|
| 48 | + if(PhalconUtils::endsWith($url, "/")) { |
|
| 49 | + $slash=""; |
|
| 50 | + } |
|
| 49 | 51 | if(JString::isNotNull($attr)){ |
| 50 | - if ($attr=="value") |
|
| 51 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 52 | - else if($attr!=null && $attr!=="") |
|
| 53 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 52 | + if ($attr=="value") { |
|
| 53 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 54 | + } else if($attr!=null && $attr!=="") { |
|
| 55 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 56 | + } |
|
| 54 | 57 | } |
| 55 | 58 | return $retour; |
| 56 | 59 | } |
@@ -72,8 +75,9 @@ discard block |
||
| 72 | 75 | } |
| 73 | 76 | |
| 74 | 77 | protected function _correctAjaxUrl($url) { |
| 75 | - if (PhalconUtils::endsWith($url, "/")) |
|
| 76 | - $url=substr($url, 0, strlen($url)-1); |
|
| 78 | + if (PhalconUtils::endsWith($url, "/")) { |
|
| 79 | + $url=substr($url, 0, strlen($url)-1); |
|
| 80 | + } |
|
| 77 | 81 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 78 | 82 | $url=$this->_di->get("url")->get($url); |
| 79 | 83 | } |
@@ -97,8 +101,9 @@ discard block |
||
| 97 | 101 | $retour.="\t".$jsCallback."\n". |
| 98 | 102 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 99 | 103 | "});\n"; |
| 100 | - if ($immediatly) |
|
| 101 | - $this->jquery_code_for_compile[]=$retour; |
|
| 104 | + if ($immediatly) { |
|
| 105 | + $this->jquery_code_for_compile[]=$retour; |
|
| 106 | + } |
|
| 102 | 107 | return $retour; |
| 103 | 108 | } |
| 104 | 109 | |
@@ -137,7 +142,7 @@ discard block |
||
| 137 | 142 | if($context===null){ |
| 138 | 143 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 139 | 144 | $newElm = "$('#'+newId)"; |
| 140 | - }else{ |
|
| 145 | + } else{ |
|
| 141 | 146 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 142 | 147 | $newElm = $context.".find('#'+newId)"; |
| 143 | 148 | } |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 148 | 153 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 149 | 154 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 150 | - if ($immediatly) |
|
| 151 | - $this->jquery_code_for_compile[]=$retour; |
|
| 155 | + if ($immediatly) { |
|
| 156 | + $this->jquery_code_for_compile[]=$retour; |
|
| 157 | + } |
|
| 152 | 158 | return $retour; |
| 153 | 159 | } |
| 154 | 160 | /** |
@@ -189,8 +195,9 @@ discard block |
||
| 189 | 195 | }});\n"; |
| 190 | 196 | $retour.="$('#".$form."').submit();\n"; |
| 191 | 197 | } |
| 192 | - if ($immediatly) |
|
| 193 | - $this->jquery_code_for_compile[]=$retour; |
|
| 198 | + if ($immediatly) { |
|
| 199 | + $this->jquery_code_for_compile[]=$retour; |
|
| 200 | + } |
|
| 194 | 201 | return $retour; |
| 195 | 202 | } |
| 196 | 203 | |
@@ -9,7 +9,17 @@ discard block |
||
| 9 | 9 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 10 | 10 | |
| 11 | 11 | public abstract function _prep_value($value); |
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @param string $element |
|
| 15 | + * @param string $js |
|
| 16 | + * @param string $event |
|
| 17 | + */ |
|
| 12 | 18 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @param string $retour |
|
| 22 | + */ |
|
| 13 | 23 | protected function addLoading(&$retour, $responseElement) { |
| 14 | 24 | $loading_notifier='<div class="ajax-loader">'; |
| 15 | 25 | if ($this->ajaxLoader=='') { |
@@ -22,13 +32,23 @@ discard block |
||
| 22 | 32 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 23 | 33 | } |
| 24 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $url |
|
| 37 | + */ |
|
| 25 | 38 | public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 26 | 39 | return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
| 27 | 40 | } |
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @param string $url |
|
| 44 | + */ |
|
| 28 | 45 | public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 29 | 46 | return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
| 30 | 47 | } |
| 31 | 48 | |
| 49 | + /** |
|
| 50 | + * @param string $method |
|
| 51 | + */ |
|
| 32 | 52 | protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 33 | 53 | if(JString::isNull($params)){$params="{}";} |
| 34 | 54 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
@@ -45,6 +65,9 @@ discard block |
||
| 45 | 65 | return $retour; |
| 46 | 66 | } |
| 47 | 67 | |
| 68 | + /** |
|
| 69 | + * @param string $attr |
|
| 70 | + */ |
|
| 48 | 71 | protected function _getAjaxUrl($url,$attr){ |
| 49 | 72 | $url=$this->_correctAjaxUrl($url); |
| 50 | 73 | $retour="url='".$url."';\n"; |
@@ -176,6 +199,11 @@ discard block |
||
| 176 | 199 | return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
| 177 | 200 | } |
| 178 | 201 | |
| 202 | + /** |
|
| 203 | + * @param string $url |
|
| 204 | + * @param string $form |
|
| 205 | + * @param string $responseElement |
|
| 206 | + */ |
|
| 179 | 207 | public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 180 | 208 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 181 | 209 | $retour=$this->_getAjaxUrl($url, $attr); |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 10 | 10 | |
| 11 | 11 | public abstract function _prep_value($value); |
| 12 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 12 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 13 | 13 | protected function addLoading(&$retour, $responseElement) { |
| 14 | 14 | $loading_notifier='<div class="ajax-loader">'; |
| 15 | 15 | if ($this->ajaxLoader=='') { |
| 16 | 16 | $loading_notifier.="Loading..."; |
| 17 | - } else { |
|
| 17 | + }else { |
|
| 18 | 18 | $loading_notifier.=$this->ajaxLoader; |
| 19 | 19 | } |
| 20 | 20 | $loading_notifier.='</div>'; |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 26 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 25 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 26 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 27 | 27 | } |
| 28 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 29 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 28 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 29 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 33 | - if(JString::isNull($params)){$params="{}";} |
|
| 32 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 33 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 34 | 34 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 35 | 35 | $retour=$this->_getAjaxUrl($url, $attr); |
| 36 | 36 | $responseElement=$this->_getResponseElement($responseElement); |
| 37 | 37 | $retour.="var self=this;\n"; |
| 38 | - if($hasLoader===true){ |
|
| 38 | + if ($hasLoader===true) { |
|
| 39 | 39 | $this->addLoading($retour, $responseElement); |
| 40 | 40 | } |
| 41 | 41 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -45,22 +45,22 @@ discard block |
||
| 45 | 45 | return $retour; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function _getAjaxUrl($url,$attr){ |
|
| 48 | + protected function _getAjaxUrl($url, $attr) { |
|
| 49 | 49 | $url=$this->_correctAjaxUrl($url); |
| 50 | 50 | $retour="url='".$url."';\n"; |
| 51 | 51 | $slash="/"; |
| 52 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 52 | + if (PhalconUtils::endsWith($url, "/")) |
|
| 53 | 53 | $slash=""; |
| 54 | - if(JString::isNotNull($attr)){ |
|
| 54 | + if (JString::isNotNull($attr)) { |
|
| 55 | 55 | if ($attr=="value") |
| 56 | 56 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 57 | - else if($attr!=null && $attr!=="") |
|
| 57 | + else if ($attr!=null && $attr!=="") |
|
| 58 | 58 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 59 | 59 | } |
| 60 | 60 | return $retour; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 63 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 64 | 64 | $retour=""; |
| 65 | 65 | if ($responseElement!=="") { |
| 66 | 66 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | return $retour; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - protected function _getResponseElement($responseElement){ |
|
| 72 | + protected function _getResponseElement($responseElement) { |
|
| 73 | 73 | if ($responseElement!=="") { |
| 74 | 74 | $responseElement=$this->_prep_value($responseElement); |
| 75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | protected function _correctAjaxUrl($url) { |
| 80 | 80 | if (PhalconUtils::endsWith($url, "/")) |
| 81 | 81 | $url=substr($url, 0, strlen($url)-1); |
| 82 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 82 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 83 | 83 | $url=$this->_di->get("url")->get($url); |
| 84 | 84 | } |
| 85 | 85 | return $url; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param string $jsCallback javascript code to execute after the request |
| 94 | 94 | * @param boolean $immediatly |
| 95 | 95 | */ |
| 96 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 96 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 97 | 97 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 98 | 98 | $retour=$this->_getAjaxUrl($url, $attr); |
| 99 | 99 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param string $url the request address |
| 115 | 115 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 116 | 116 | */ |
| 117 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 117 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 118 | 118 | $preventDefault=true; |
| 119 | 119 | $stopPropagation=true; |
| 120 | 120 | $jsCallback=null; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $params="{}"; |
| 125 | 125 | $immediatly=true; |
| 126 | 126 | extract($parameters); |
| 127 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 127 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | * @param string $context jquery DOM element, array container. |
| 137 | 137 | * @param boolean $immediatly |
| 138 | 138 | */ |
| 139 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 139 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 140 | 140 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 141 | 141 | $retour=$this->_getAjaxUrl($url, $attr); |
| 142 | - if($context===null){ |
|
| 142 | + if ($context===null) { |
|
| 143 | 143 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 144 | - $newElm = "$('#'+newId)"; |
|
| 145 | - }else{ |
|
| 144 | + $newElm="$('#'+newId)"; |
|
| 145 | + }else { |
|
| 146 | 146 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 147 | - $newElm = $context.".find('#'+newId)"; |
|
| 147 | + $newElm=$context.".find('#'+newId)"; |
|
| 148 | 148 | } |
| 149 | 149 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 150 | 150 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"; |
| 151 | - $retour.= $appendTo; |
|
| 151 | + $retour.=$appendTo; |
|
| 152 | 152 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 153 | 153 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 154 | 154 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -163,26 +163,26 @@ discard block |
||
| 163 | 163 | * @param string $url the request address |
| 164 | 164 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 165 | 165 | */ |
| 166 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 166 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 167 | 167 | $preventDefault=true; |
| 168 | 168 | $stopPropagation=true; |
| 169 | 169 | $jsCallback=null; |
| 170 | 170 | $attr="id"; |
| 171 | 171 | $method="get"; |
| 172 | - $context = null; |
|
| 172 | + $context=null; |
|
| 173 | 173 | $params="{}"; |
| 174 | 174 | $immediatly=true; |
| 175 | 175 | extract($parameters); |
| 176 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 176 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 179 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 180 | 180 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 181 | 181 | $retour=$this->_getAjaxUrl($url, $attr); |
| 182 | 182 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 183 | 183 | $responseElement=$this->_getResponseElement($responseElement); |
| 184 | 184 | $retour.="var self=this;\n"; |
| 185 | - if($hasLoader===true){ |
|
| 185 | + if ($hasLoader===true) { |
|
| 186 | 186 | $this->addLoading($retour, $responseElement); |
| 187 | 187 | } |
| 188 | 188 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param string $responseElement |
| 210 | 210 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 211 | 211 | */ |
| 212 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 212 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 213 | 213 | $preventDefault=true; |
| 214 | 214 | $stopPropagation=true; |
| 215 | 215 | $jsCallback=null; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $hasLoader=true; |
| 218 | 218 | $immediatly=true; |
| 219 | 219 | extract($parameters); |
| 220 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 220 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param string $responseElement |
| 231 | 231 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 232 | 232 | */ |
| 233 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 233 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 234 | 234 | $preventDefault=true; |
| 235 | 235 | $stopPropagation=true; |
| 236 | 236 | $jsCallback=null; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $hasLoader=true; |
| 239 | 239 | $immediatly=true; |
| 240 | 240 | extract($parameters); |
| 241 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 241 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param string $responseElement |
| 252 | 252 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 253 | 253 | */ |
| 254 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 254 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 255 | 255 | $preventDefault=true; |
| 256 | 256 | $stopPropagation=true; |
| 257 | 257 | $validation=false; |
@@ -260,6 +260,6 @@ discard block |
||
| 260 | 260 | $hasLoader=true; |
| 261 | 261 | $immediatly=true; |
| 262 | 262 | extract($parameters); |
| 263 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 263 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | \ No newline at end of file |
@@ -13,62 +13,62 @@ discard block |
||
| 13 | 13 | * @author jc |
| 14 | 14 | * @version 1.001 |
| 15 | 15 | */ |
| 16 | -class HtmlForm extends HtmlSemCollection{ |
|
| 16 | +class HtmlForm extends HtmlSemCollection { |
|
| 17 | 17 | |
| 18 | 18 | use FieldsTrait; |
| 19 | 19 | |
| 20 | 20 | protected $_fields; |
| 21 | 21 | |
| 22 | - public function __construct( $identifier, $elements=array()){ |
|
| 23 | - parent::__construct( $identifier, "form", "ui form"); |
|
| 24 | - $this->_states=[State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED]; |
|
| 22 | + public function __construct($identifier, $elements=array()) { |
|
| 23 | + parent::__construct($identifier, "form", "ui form"); |
|
| 24 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
| 25 | 25 | $this->setProperty("name", $this->identifier); |
| 26 | 26 | $this->_fields=array(); |
| 27 | 27 | $this->addItems($elements); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function addHeader($title,$niveau=1,$dividing=true){ |
|
| 31 | - $header=new HtmlHeader("",$niveau,$title); |
|
| 32 | - if($dividing) |
|
| 30 | + public function addHeader($title, $niveau=1, $dividing=true) { |
|
| 31 | + $header=new HtmlHeader("", $niveau, $title); |
|
| 32 | + if ($dividing) |
|
| 33 | 33 | $header->setDividing(); |
| 34 | 34 | return $this->addItem($header); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function addFields($fields=NULL,$label=NULL){ |
|
| 38 | - if(isset($fields)){ |
|
| 39 | - if(!$fields instanceof HtmlFormFields){ |
|
| 40 | - if(\is_array($fields)===false){ |
|
| 41 | - $fields = \func_get_args(); |
|
| 37 | + public function addFields($fields=NULL, $label=NULL) { |
|
| 38 | + if (isset($fields)) { |
|
| 39 | + if (!$fields instanceof HtmlFormFields) { |
|
| 40 | + if (\is_array($fields)===false) { |
|
| 41 | + $fields=\func_get_args(); |
|
| 42 | 42 | $end=\end($fields); |
| 43 | - if(\is_string($end)){ |
|
| 43 | + if (\is_string($end)) { |
|
| 44 | 44 | $label=$end; |
| 45 | 45 | \array_pop($fields); |
| 46 | 46 | }else $label=NULL; |
| 47 | 47 | } |
| 48 | - $this->_fields=\array_merge($this->_fields,$fields); |
|
| 49 | - $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields); |
|
| 48 | + $this->_fields=\array_merge($this->_fields, $fields); |
|
| 49 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
| 50 | 50 | } |
| 51 | - if(isset($label)) |
|
| 52 | - $fields=new HtmlFormField("", $fields,$label); |
|
| 53 | - }else{ |
|
| 51 | + if (isset($label)) |
|
| 52 | + $fields=new HtmlFormField("", $fields, $label); |
|
| 53 | + }else { |
|
| 54 | 54 | $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
| 55 | 55 | } |
| 56 | 56 | $this->addItem($fields); |
| 57 | 57 | return $fields; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function addItem($item){ |
|
| 60 | + public function addItem($item) { |
|
| 61 | 61 | $item=parent::addItem($item); |
| 62 | - if(\is_subclass_of($item, HtmlFormField::class)===true){ |
|
| 62 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
| 63 | 63 | $this->_fields[]=$item; |
| 64 | 64 | } |
| 65 | 65 | return $item; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function getField($index){ |
|
| 69 | - if(\is_string($index)){ |
|
| 68 | + public function getField($index) { |
|
| 69 | + if (\is_string($index)) { |
|
| 70 | 70 | $field=$this->getElementById($index, $this->_fields); |
| 71 | - }else{ |
|
| 71 | + }else { |
|
| 72 | 72 | $field=$this->_fields[$index]; |
| 73 | 73 | } |
| 74 | 74 | return $field; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * automatically divide fields to be equal width |
| 79 | 79 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
| 80 | 80 | */ |
| 81 | - public function setEqualWidth(){ |
|
| 81 | + public function setEqualWidth() { |
|
| 82 | 82 | return $this->addToProperty("class", "equal width"); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param HtmlFormField $field |
| 88 | 88 | * @return \Ajax\common\html\HtmlDoubleElement |
| 89 | 89 | */ |
| 90 | - public function addField($field){ |
|
| 90 | + public function addField($field) { |
|
| 91 | 91 | return $this->addItem($field); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | * @param string $type |
| 100 | 100 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 101 | 101 | */ |
| 102 | - public function addMessage($identifier,$content,$header=NULL,$icon=NULL,$type=NULL){ |
|
| 103 | - $message=new HtmlMessage($identifier,$content); |
|
| 104 | - if(isset($header)) |
|
| 102 | + public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
|
| 103 | + $message=new HtmlMessage($identifier, $content); |
|
| 104 | + if (isset($header)) |
|
| 105 | 105 | $message->addHeader($header); |
| 106 | - if(isset($icon)) |
|
| 106 | + if (isset($icon)) |
|
| 107 | 107 | $message->setIcon($icon); |
| 108 | - if(isset($type)) |
|
| 108 | + if (isset($type)) |
|
| 109 | 109 | $message->setStyle($type); |
| 110 | 110 | return $this->addItem($message); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setLoading(){ |
|
| 113 | + public function setLoading() { |
|
| 114 | 114 | return $this->addToProperty("class", "loading"); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function jsState($state){ |
|
| 118 | - return $this->jsDoJquery("addClass",$state); |
|
| 117 | + public function jsState($state) { |
|
| 118 | + return $this->jsDoJquery("addClass", $state); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | \ No newline at end of file |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function addHeader($title,$niveau=1,$dividing=true){ |
| 31 | 31 | $header=new HtmlHeader("",$niveau,$title); |
| 32 | - if($dividing) |
|
| 33 | - $header->setDividing(); |
|
| 32 | + if($dividing) { |
|
| 33 | + $header->setDividing(); |
|
| 34 | + } |
|
| 34 | 35 | return $this->addItem($header); |
| 35 | 36 | } |
| 36 | 37 | |
@@ -43,14 +44,17 @@ discard block |
||
| 43 | 44 | if(\is_string($end)){ |
| 44 | 45 | $label=$end; |
| 45 | 46 | \array_pop($fields); |
| 46 | - }else $label=NULL; |
|
| 47 | + } else { |
|
| 48 | + $label=NULL; |
|
| 49 | + } |
|
| 47 | 50 | } |
| 48 | 51 | $this->_fields=\array_merge($this->_fields,$fields); |
| 49 | 52 | $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields); |
| 50 | 53 | } |
| 51 | - if(isset($label)) |
|
| 52 | - $fields=new HtmlFormField("", $fields,$label); |
|
| 53 | - }else{ |
|
| 54 | + if(isset($label)) { |
|
| 55 | + $fields=new HtmlFormField("", $fields,$label); |
|
| 56 | + } |
|
| 57 | + } else{ |
|
| 54 | 58 | $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
| 55 | 59 | } |
| 56 | 60 | $this->addItem($fields); |
@@ -68,7 +72,7 @@ discard block |
||
| 68 | 72 | public function getField($index){ |
| 69 | 73 | if(\is_string($index)){ |
| 70 | 74 | $field=$this->getElementById($index, $this->_fields); |
| 71 | - }else{ |
|
| 75 | + } else{ |
|
| 72 | 76 | $field=$this->_fields[$index]; |
| 73 | 77 | } |
| 74 | 78 | return $field; |
@@ -101,12 +105,15 @@ discard block |
||
| 101 | 105 | */ |
| 102 | 106 | public function addMessage($identifier,$content,$header=NULL,$icon=NULL,$type=NULL){ |
| 103 | 107 | $message=new HtmlMessage($identifier,$content); |
| 104 | - if(isset($header)) |
|
| 105 | - $message->addHeader($header); |
|
| 106 | - if(isset($icon)) |
|
| 107 | - $message->setIcon($icon); |
|
| 108 | - if(isset($type)) |
|
| 109 | - $message->setStyle($type); |
|
| 108 | + if(isset($header)) { |
|
| 109 | + $message->addHeader($header); |
|
| 110 | + } |
|
| 111 | + if(isset($icon)) { |
|
| 112 | + $message->setIcon($icon); |
|
| 113 | + } |
|
| 114 | + if(isset($type)) { |
|
| 115 | + $message->setStyle($type); |
|
| 116 | + } |
|
| 110 | 117 | return $this->addItem($message); |
| 111 | 118 | } |
| 112 | 119 | |
@@ -13,8 +13,9 @@ |
||
| 13 | 13 | if(\is_array($value)){ |
| 14 | 14 | $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
| 15 | 15 | return $itemO; |
| 16 | - }else |
|
| 17 | - return new HtmlFormInput($value); |
|
| 16 | + } else { |
|
| 17 | + return new HtmlFormInput($value); |
|
| 18 | + } |
|
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | public function addInputs($inputs,$fieldslabel=null){ |
@@ -9,26 +9,26 @@ discard block |
||
| 9 | 9 | use Ajax\semantic\html\collections\form\HtmlFormCheckbox; |
| 10 | 10 | use Ajax\semantic\html\collections\form\HtmlFormRadio; |
| 11 | 11 | trait FieldsTrait { |
| 12 | - public abstract function addFields($fields=NULL,$label=NULL); |
|
| 12 | + public abstract function addFields($fields=NULL, $label=NULL); |
|
| 13 | 13 | public abstract function addItem($item); |
| 14 | 14 | |
| 15 | - protected function createItem($value){ |
|
| 16 | - if(\is_array($value)){ |
|
| 17 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
| 15 | + protected function createItem($value) { |
|
| 16 | + if (\is_array($value)) { |
|
| 17 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
| 18 | 18 | return $itemO; |
| 19 | 19 | }else |
| 20 | 20 | return new HtmlFormInput($value); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function addInputs($inputs,$fieldslabel=null){ |
|
| 23 | + public function addInputs($inputs, $fieldslabel=null) { |
|
| 24 | 24 | $fields=array(); |
| 25 | - foreach ($inputs as $input){ |
|
| 25 | + foreach ($inputs as $input) { |
|
| 26 | 26 | \extract($input); |
| 27 | - $f=new HtmlFormInput("",""); |
|
| 27 | + $f=new HtmlFormInput("", ""); |
|
| 28 | 28 | $f->fromArray($input); |
| 29 | 29 | $fields[]=$f; |
| 30 | 30 | } |
| 31 | - return $this->addFields($fields,$fieldslabel); |
|
| 31 | + return $this->addFields($fields, $fieldslabel); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -39,23 +39,23 @@ discard block |
||
| 39 | 39 | * @param boolean $multiple |
| 40 | 40 | * @return \Ajax\common\html\HtmlDoubleElement |
| 41 | 41 | */ |
| 42 | - public function addDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false){ |
|
| 43 | - return $this->addItem(new HtmlFormDropdown($identifier,$items,$label,$value,$multiple)); |
|
| 42 | + public function addDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
| 43 | + return $this->addItem(new HtmlFormDropdown($identifier, $items, $label, $value, $multiple)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function addInput($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL){ |
|
| 47 | - return $this->addItem(new HtmlFormInput($identifier,$label,$type,$value,$placeholder)); |
|
| 46 | + public function addInput($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 47 | + return $this->addItem(new HtmlFormInput($identifier, $label, $type, $value, $placeholder)); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function addButton($identifier,$value,$cssStyle=NULL,$onClick=NULL){ |
|
| 51 | - return $this->addItem(new HtmlButton($identifier,$value,$cssStyle,$onClick)); |
|
| 50 | + public function addButton($identifier, $value, $cssStyle=NULL, $onClick=NULL) { |
|
| 51 | + return $this->addItem(new HtmlButton($identifier, $value, $cssStyle, $onClick)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function addCheckbox($identifier, $label=NULL,$value=NULL,$type=NULL){ |
|
| 55 | - return $this->addItem(new HtmlFormCheckbox($identifier,$label,$value,$type)); |
|
| 54 | + public function addCheckbox($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
| 55 | + return $this->addItem(new HtmlFormCheckbox($identifier, $label, $value, $type)); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function addRadio($identifier, $name,$label=NULL,$value=NULL){ |
|
| 59 | - return $this->addItem(new HtmlFormRadio($identifier,$name,$label,$value)); |
|
| 58 | + public function addRadio($identifier, $name, $label=NULL, $value=NULL) { |
|
| 59 | + return $this->addItem(new HtmlFormRadio($identifier, $name, $label, $value)); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | \ No newline at end of file |
@@ -3,11 +3,11 @@ |
||
| 3 | 3 | namespace Ajax\semantic\html\collections\form; |
| 4 | 4 | |
| 5 | 5 | trait TextFieldsTrait { |
| 6 | - public function setPlaceholder($value){ |
|
| 6 | + public function setPlaceholder($value) { |
|
| 7 | 7 | return $this->getField()->setPlaceholder($value); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - public function setValue($value){ |
|
| 10 | + public function setValue($value) { |
|
| 11 | 11 | return $this->getField()->setValue($value); |
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | foreach ($icons as $icon=>$size){ |
| 37 | 37 | $group->addIcon($icon,$size); |
| 38 | 38 | } |
| 39 | - }else{ |
|
| 39 | + } else{ |
|
| 40 | 40 | foreach ($icons as $icon){ |
| 41 | 41 | $group->addIcon($icon); |
| 42 | 42 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param boolean $asIcons |
| 43 | 43 | * @return HtmlButtonGroups |
| 44 | 44 | */ |
| 45 | - public function htmlButtonGroups($identifier,$elements=array(),$asIcons=false){ |
|
| 46 | - return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements,$asIcons)); |
|
| 45 | + public function htmlButtonGroups($identifier, $elements=array(), $asIcons=false) { |
|
| 46 | + return $this->addHtmlComponent(new HtmlButtonGroups($identifier, $elements, $asIcons)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string $content |
| 53 | 53 | * @return HtmlContainer |
| 54 | 54 | */ |
| 55 | - public function htmlContainer($identifier,$content=""){ |
|
| 55 | + public function htmlContainer($identifier, $content="") { |
|
| 56 | 56 | return $this->addHtmlComponent(new HtmlContainer($identifier, $content)); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | * @param string $content |
| 62 | 62 | * @return HtmlDivider |
| 63 | 63 | */ |
| 64 | - public function htmlDivider($identifier,$content="",$tagName="div"){ |
|
| 65 | - return $this->addHtmlComponent(new HtmlDivider($identifier, $content,$tagName)); |
|
| 64 | + public function htmlDivider($identifier, $content="", $tagName="div") { |
|
| 65 | + return $this->addHtmlComponent(new HtmlDivider($identifier, $content, $tagName)); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @param string $type |
| 73 | 73 | * @return HtmlHeader |
| 74 | 74 | */ |
| 75 | - public function htmlHeader($identifier,$niveau=1,$content=NULL,$type="page"){ |
|
| 76 | - return $this->addHtmlComponent(new HtmlHeader($identifier,$niveau,$content,$type)); |
|
| 75 | + public function htmlHeader($identifier, $niveau=1, $content=NULL, $type="page") { |
|
| 76 | + return $this->addHtmlComponent(new HtmlHeader($identifier, $niveau, $content, $type)); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param string $icon |
| 82 | 82 | * @return HtmlIcon |
| 83 | 83 | */ |
| 84 | - public function htmlIcon($identifier,$icon){ |
|
| 84 | + public function htmlIcon($identifier, $icon) { |
|
| 85 | 85 | return $this->addHtmlComponent(new HtmlIcon($identifier, $icon)); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | * @param array $icons |
| 92 | 92 | * @return HtmlIconGroups |
| 93 | 93 | */ |
| 94 | - public function htmlIconGroups($identifier,$size="",$icons=array()){ |
|
| 95 | - $group=new HtmlIconGroups($identifier,$size); |
|
| 96 | - if(JArray::isAssociative($icons)){ |
|
| 97 | - foreach ($icons as $icon=>$size){ |
|
| 98 | - $group->add($icon,$size); |
|
| 94 | + public function htmlIconGroups($identifier, $size="", $icons=array()) { |
|
| 95 | + $group=new HtmlIconGroups($identifier, $size); |
|
| 96 | + if (JArray::isAssociative($icons)) { |
|
| 97 | + foreach ($icons as $icon=>$size) { |
|
| 98 | + $group->add($icon, $size); |
|
| 99 | 99 | } |
| 100 | - }else{ |
|
| 101 | - foreach ($icons as $icon){ |
|
| 100 | + }else { |
|
| 101 | + foreach ($icons as $icon) { |
|
| 102 | 102 | $group->add($icon); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | * @param string $placeholder |
| 114 | 114 | * @return HtmlInput |
| 115 | 115 | */ |
| 116 | - public function htmlInput($identifier,$type="text",$value="",$placeholder=""){ |
|
| 117 | - return $this->addHtmlComponent(new HtmlInput($identifier,$type,$value,$placeholder)); |
|
| 116 | + public function htmlInput($identifier, $type="text", $value="", $placeholder="") { |
|
| 117 | + return $this->addHtmlComponent(new HtmlInput($identifier, $type, $value, $placeholder)); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | * @param string $tagName |
| 124 | 124 | * @return HtmlLabel |
| 125 | 125 | */ |
| 126 | - public function htmlLabel($identifier,$content="",$tagName="div"){ |
|
| 127 | - return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$tagName)); |
|
| 126 | + public function htmlLabel($identifier, $content="", $tagName="div") { |
|
| 127 | + return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $tagName)); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | * @param array $items |
| 134 | 134 | * @return HtmlList |
| 135 | 135 | */ |
| 136 | - public function htmlList($identifier,$items=array()){ |
|
| 137 | - return $this->addHtmlComponent(new HtmlList($identifier,$items)); |
|
| 136 | + public function htmlList($identifier, $items=array()) { |
|
| 137 | + return $this->addHtmlComponent(new HtmlList($identifier, $items)); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @param string $content |
| 144 | 144 | * @return HtmlSegment |
| 145 | 145 | */ |
| 146 | - public function htmlSegment($identifier, $content=""){ |
|
| 147 | - return $this->addHtmlComponent(new HtmlSegment($identifier,$content)); |
|
| 146 | + public function htmlSegment($identifier, $content="") { |
|
| 147 | + return $this->addHtmlComponent(new HtmlSegment($identifier, $content)); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | * @param array $items the segments |
| 154 | 154 | * @return HtmlSegmentGroups |
| 155 | 155 | */ |
| 156 | - public function htmlSegmentGroups($identifier, $items=array()){ |
|
| 157 | - return $this->addHtmlComponent(new HtmlSegmentGroups($identifier,$items)); |
|
| 156 | + public function htmlSegmentGroups($identifier, $items=array()) { |
|
| 157 | + return $this->addHtmlComponent(new HtmlSegmentGroups($identifier, $items)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | * @param RevealType|string $type |
| 165 | 165 | * @param Direction|string $attributeType |
| 166 | 166 | */ |
| 167 | - public function htmlReveal($identifier, $visibleContent,$hiddenContent,$type=RevealType::FADE,$attributeType=NULL){ |
|
| 168 | - return $this->addHtmlComponent(new HtmlReveal($identifier,$visibleContent,$hiddenContent,$type,$attributeType)); |
|
| 167 | + public function htmlReveal($identifier, $visibleContent, $hiddenContent, $type=RevealType::FADE, $attributeType=NULL) { |
|
| 168 | + return $this->addHtmlComponent(new HtmlReveal($identifier, $visibleContent, $hiddenContent, $type, $attributeType)); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function htmlStep($identifier, $steps=array()){ |
|
| 172 | - return $this->addHtmlComponent(new HtmlStep($identifier,$steps)); |
|
| 171 | + public function htmlStep($identifier, $steps=array()) { |
|
| 172 | + return $this->addHtmlComponent(new HtmlStep($identifier, $steps)); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | \ No newline at end of file |
@@ -3,7 +3,16 @@ |
||
| 3 | 3 | namespace Ajax\common\traits; |
| 4 | 4 | |
| 5 | 5 | trait JqueryEventsTrait { |
| 6 | + |
|
| 7 | + /** |
|
| 8 | + * @param string $element |
|
| 9 | + */ |
|
| 6 | 10 | public abstract function _prep_element($element); |
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @param string $element |
|
| 14 | + * @param string $event |
|
| 15 | + */ |
|
| 7 | 16 | public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
| 8 | 17 | |
| 9 | 18 | /** |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | trait JqueryEventsTrait { |
| 6 | 6 | public abstract function _prep_element($element); |
| 7 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 7 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Blur |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
| 48 | 48 | if (!is_array($js)) { |
| 49 | - $js=array ( |
|
| 49 | + $js=array( |
|
| 50 | 50 | $js |
| 51 | 51 | ); |
| 52 | 52 | } |
@@ -21,6 +21,9 @@ discard block |
||
| 21 | 21 | protected $params=array("action"=>"nothing","on"=>"hover"); |
| 22 | 22 | protected $input; |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param string $identifier |
|
| 26 | + */ |
|
| 24 | 27 | public function __construct($identifier, $value="", $items=array()) { |
| 25 | 28 | parent::__construct($identifier, "div"); |
| 26 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
@@ -47,7 +50,7 @@ discard block |
||
| 47 | 50 | /** |
| 48 | 51 | * Insert an item at a position |
| 49 | 52 | * @param mixed $item |
| 50 | - * @param number $position |
|
| 53 | + * @param integer $position |
|
| 51 | 54 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 52 | 55 | */ |
| 53 | 56 | public function insertItem($item,$position=0){ |
@@ -196,6 +199,9 @@ discard block |
||
| 196 | 199 | } |
| 197 | 200 | } |
| 198 | 201 | |
| 202 | + /** |
|
| 203 | + * @param string $action |
|
| 204 | + */ |
|
| 199 | 205 | public function setAction($action){ |
| 200 | 206 | $this->params["action"]=$action; |
| 201 | 207 | } |
@@ -17,31 +17,31 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | protected $mClass="menu"; |
| 19 | 19 | protected $mTagName="div"; |
| 20 | - protected $items=array (); |
|
| 21 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
| 20 | + protected $items=array(); |
|
| 21 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
| 22 | 22 | protected $input; |
| 23 | 23 | |
| 24 | 24 | public function __construct($identifier, $value="", $items=array()) { |
| 25 | 25 | parent::__construct($identifier, "div"); |
| 26 | 26 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
| 27 | 27 | $this->setProperty("class", "ui dropdown"); |
| 28 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
| 28 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
| 29 | 29 | $content->setClass("text"); |
| 30 | 30 | $content->setContent($value); |
| 31 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
| 31 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
| 32 | 32 | $this->content=array($content); |
| 33 | 33 | $this->tagName="div"; |
| 34 | 34 | $this->addItems($items); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 38 | - $itemO=$this->beforeAddItem($item,$value,$image); |
|
| 37 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 38 | + $itemO=$this->beforeAddItem($item, $value, $image); |
|
| 39 | 39 | $this->items[]=$itemO; |
| 40 | 40 | return $itemO; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 44 | - $this->addIconP($icon,$before,$labeled); |
|
| 43 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 44 | + $this->addIconP($icon, $before, $labeled); |
|
| 45 | 45 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
| 46 | 46 | } |
| 47 | 47 | /** |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | * @param number $position |
| 51 | 51 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 52 | 52 | */ |
| 53 | - public function insertItem($item,$position=0){ |
|
| 53 | + public function insertItem($item, $position=0) { |
|
| 54 | 54 | $itemO=$this->beforeAddItem($item); |
| 55 | - $start = array_slice($this->items, 0, $position); |
|
| 56 | - $end = array_slice($this->items, $position); |
|
| 57 | - $start[] = $item; |
|
| 55 | + $start=array_slice($this->items, 0, $position); |
|
| 56 | + $end=array_slice($this->items, $position); |
|
| 57 | + $start[]=$item; |
|
| 58 | 58 | $this->items=array_merge($start, $end); |
| 59 | 59 | return $itemO; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - protected function beforeAddItem($item,$value=NULL,$image=NULL){ |
|
| 62 | + protected function beforeAddItem($item, $value=NULL, $image=NULL) { |
|
| 63 | 63 | $itemO=$item; |
| 64 | - if(!$item instanceof HtmlDropdownItem){ |
|
| 65 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
| 66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 64 | + if (!$item instanceof HtmlDropdownItem) { |
|
| 65 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
| 66 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
| 67 | 67 | $this->addToProperty("class", "vertical"); |
| 68 | 68 | } |
| 69 | 69 | return $itemO; |
@@ -76,76 +76,76 @@ discard block |
||
| 76 | 76 | $this->addItem($function($object)); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function addInput($name){ |
|
| 80 | - if(!isset($name)) |
|
| 79 | + public function addInput($name) { |
|
| 80 | + if (!isset($name)) |
|
| 81 | 81 | $name="input-".$this->identifier; |
| 82 | 82 | $this->setAction("activate"); |
| 83 | - $this->input=new HtmlInput($name,"hidden"); |
|
| 83 | + $this->input=new HtmlInput($name, "hidden"); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function addItems($items){ |
|
| 87 | - if(JArray::isAssociative($items)){ |
|
| 88 | - foreach ($items as $k=>$v){ |
|
| 86 | + public function addItems($items) { |
|
| 87 | + if (JArray::isAssociative($items)) { |
|
| 88 | + foreach ($items as $k=>$v) { |
|
| 89 | 89 | $this->addItem($v)->setData($k); |
| 90 | 90 | } |
| 91 | - }else{ |
|
| 92 | - foreach ($items as $item){ |
|
| 91 | + }else { |
|
| 92 | + foreach ($items as $item) { |
|
| 93 | 93 | $this->addItem($item); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function count(){ |
|
| 98 | + public function count() { |
|
| 99 | 99 | return \sizeof($this->items); |
| 100 | 100 | } |
| 101 | 101 | /** |
| 102 | 102 | * @param boolean $dropdown |
| 103 | 103 | */ |
| 104 | - public function asDropdown($dropdown){ |
|
| 105 | - if($dropdown===false){ |
|
| 104 | + public function asDropdown($dropdown) { |
|
| 105 | + if ($dropdown===false) { |
|
| 106 | 106 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 107 | 107 | $dropdown="menu"; |
| 108 | - }else{ |
|
| 108 | + }else { |
|
| 109 | 109 | $dropdown="dropdown"; |
| 110 | 110 | $this->mClass="menu"; |
| 111 | 111 | } |
| 112 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
| 112 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function setVertical(){ |
|
| 116 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
| 115 | + public function setVertical() { |
|
| 116 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function setSimple(){ |
|
| 120 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
| 119 | + public function setSimple() { |
|
| 120 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function asButton($floating=false){ |
|
| 124 | - if($floating) |
|
| 123 | + public function asButton($floating=false) { |
|
| 124 | + if ($floating) |
|
| 125 | 125 | $this->addToProperty("class", "floating"); |
| 126 | 126 | return $this->addToProperty("class", "button"); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 130 | - if(isset($name)) |
|
| 129 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 130 | + if (isset($name)) |
|
| 131 | 131 | $this->addInput($name); |
| 132 | - if($multiple) |
|
| 132 | + if ($multiple) |
|
| 133 | 133 | $this->addToProperty("class", "multiple"); |
| 134 | 134 | if ($selection) |
| 135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 135 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
| 136 | 136 | return $this; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
| 140 | - $this->asSelect($name,$multiple,$selection); |
|
| 139 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
| 140 | + $this->asSelect($name, $multiple, $selection); |
|
| 141 | 141 | return $this->addToProperty("class", "search"); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setSelect($name=NULL,$multiple=false){ |
|
| 145 | - if(!isset($name)) |
|
| 144 | + public function setSelect($name=NULL, $multiple=false) { |
|
| 145 | + if (!isset($name)) |
|
| 146 | 146 | $name="select-".$this->identifier; |
| 147 | 147 | $this->input=null; |
| 148 | - if($multiple){ |
|
| 148 | + if ($multiple) { |
|
| 149 | 149 | $this->setProperty("multiple", true); |
| 150 | 150 | $this->addToProperty("class", "multiple"); |
| 151 | 151 | } |
@@ -153,32 +153,32 @@ discard block |
||
| 153 | 153 | $this->tagName="select"; |
| 154 | 154 | $this->setProperty("name", $name); |
| 155 | 155 | $this->content=null; |
| 156 | - foreach ($this->items as $item){ |
|
| 156 | + foreach ($this->items as $item) { |
|
| 157 | 157 | $item->asOption(); |
| 158 | 158 | } |
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function asSubmenu($pointing=NULL){ |
|
| 162 | + public function asSubmenu($pointing=NULL) { |
|
| 163 | 163 | $this->setClass("ui dropdown link item"); |
| 164 | - if(isset($pointing)){ |
|
| 164 | + if (isset($pointing)) { |
|
| 165 | 165 | $this->setPointing($pointing); |
| 166 | 166 | } |
| 167 | 167 | return $this; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public function setPointing($value=Direction::NONE){ |
|
| 171 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 170 | + public function setPointing($value=Direction::NONE) { |
|
| 171 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function setValue($value){ |
|
| 175 | - if(isset($this->input)){ |
|
| 174 | + public function setValue($value) { |
|
| 175 | + if (isset($this->input)) { |
|
| 176 | 176 | $this->input->setProperty("value", $value); |
| 177 | - }else{ |
|
| 177 | + }else { |
|
| 178 | 178 | $this->setProperty("value", $value); |
| 179 | 179 | } |
| 180 | 180 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 181 | - if(isset($textElement)) |
|
| 181 | + if (isset($textElement)) |
|
| 182 | 182 | $textElement->setContent($value); |
| 183 | 183 | return $this; |
| 184 | 184 | } |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | * @see BaseHtml::run() |
| 189 | 189 | */ |
| 190 | 190 | public function run(JsUtils $js) { |
| 191 | - if($this->propertyContains("class", "simple")===false){ |
|
| 192 | - if(isset($this->_bsComponent)===false) |
|
| 193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 191 | + if ($this->propertyContains("class", "simple")===false) { |
|
| 192 | + if (isset($this->_bsComponent)===false) |
|
| 193 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
| 194 | 194 | $this->addEventsOnRun($js); |
| 195 | 195 | return $this->_bsComponent; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function setAction($action){ |
|
| 199 | + public function setAction($action) { |
|
| 200 | 200 | $this->_params["action"]=$action; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - public function setFullTextSearch($value){ |
|
| 203 | + public function setFullTextSearch($value) { |
|
| 204 | 204 | $this->_params["fullTextSearch"]=$value; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $itemO=$item; |
| 64 | 64 | if(!$item instanceof HtmlDropdownItem){ |
| 65 | 65 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
| 66 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 66 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
| 67 | 67 | $this->addToProperty("class", "vertical"); |
| 68 | 68 | } |
| 69 | 69 | return $itemO; |
@@ -77,8 +77,9 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function addInput($name){ |
| 80 | - if(!isset($name)) |
|
| 81 | - $name="input-".$this->identifier; |
|
| 80 | + if(!isset($name)) { |
|
| 81 | + $name="input-".$this->identifier; |
|
| 82 | + } |
|
| 82 | 83 | $this->setAction("activate"); |
| 83 | 84 | $this->input=new HtmlInput($name,"hidden"); |
| 84 | 85 | } |
@@ -88,7 +89,7 @@ discard block |
||
| 88 | 89 | foreach ($items as $k=>$v){ |
| 89 | 90 | $this->addItem($v)->setData($k); |
| 90 | 91 | } |
| 91 | - }else{ |
|
| 92 | + } else{ |
|
| 92 | 93 | foreach ($items as $item){ |
| 93 | 94 | $this->addItem($item); |
| 94 | 95 | } |
@@ -105,7 +106,7 @@ discard block |
||
| 105 | 106 | if($dropdown===false){ |
| 106 | 107 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 107 | 108 | $dropdown="menu"; |
| 108 | - }else{ |
|
| 109 | + } else{ |
|
| 109 | 110 | $dropdown="dropdown"; |
| 110 | 111 | $this->mClass="menu"; |
| 111 | 112 | } |
@@ -121,18 +122,22 @@ discard block |
||
| 121 | 122 | } |
| 122 | 123 | |
| 123 | 124 | public function asButton($floating=false){ |
| 124 | - if($floating) |
|
| 125 | - $this->addToProperty("class", "floating"); |
|
| 125 | + if($floating) { |
|
| 126 | + $this->addToProperty("class", "floating"); |
|
| 127 | + } |
|
| 126 | 128 | return $this->addToProperty("class", "button"); |
| 127 | 129 | } |
| 128 | 130 | |
| 129 | 131 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
| 130 | - if(isset($name)) |
|
| 131 | - $this->addInput($name); |
|
| 132 | - if($multiple) |
|
| 133 | - $this->addToProperty("class", "multiple"); |
|
| 134 | - if ($selection) |
|
| 135 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 132 | + if(isset($name)) { |
|
| 133 | + $this->addInput($name); |
|
| 134 | + } |
|
| 135 | + if($multiple) { |
|
| 136 | + $this->addToProperty("class", "multiple"); |
|
| 137 | + } |
|
| 138 | + if ($selection) { |
|
| 139 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 140 | + } |
|
| 136 | 141 | return $this; |
| 137 | 142 | } |
| 138 | 143 | |
@@ -142,8 +147,9 @@ discard block |
||
| 142 | 147 | } |
| 143 | 148 | |
| 144 | 149 | public function setSelect($name=NULL,$multiple=false){ |
| 145 | - if(!isset($name)) |
|
| 146 | - $name="select-".$this->identifier; |
|
| 150 | + if(!isset($name)) { |
|
| 151 | + $name="select-".$this->identifier; |
|
| 152 | + } |
|
| 147 | 153 | $this->input=null; |
| 148 | 154 | if($multiple){ |
| 149 | 155 | $this->setProperty("multiple", true); |
@@ -174,12 +180,13 @@ discard block |
||
| 174 | 180 | public function setValue($value){ |
| 175 | 181 | if(isset($this->input)){ |
| 176 | 182 | $this->input->setProperty("value", $value); |
| 177 | - }else{ |
|
| 183 | + } else{ |
|
| 178 | 184 | $this->setProperty("value", $value); |
| 179 | 185 | } |
| 180 | 186 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 181 | - if(isset($textElement)) |
|
| 182 | - $textElement->setContent($value); |
|
| 187 | + if(isset($textElement)) { |
|
| 188 | + $textElement->setContent($value); |
|
| 189 | + } |
|
| 183 | 190 | return $this; |
| 184 | 191 | } |
| 185 | 192 | |
@@ -189,8 +196,9 @@ discard block |
||
| 189 | 196 | */ |
| 190 | 197 | public function run(JsUtils $js) { |
| 191 | 198 | if($this->propertyContains("class", "simple")===false){ |
| 192 | - if(isset($this->_bsComponent)===false) |
|
| 193 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 199 | + if(isset($this->_bsComponent)===false) { |
|
| 200 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 201 | + } |
|
| 194 | 202 | $this->addEventsOnRun($js); |
| 195 | 203 | return $this->_bsComponent; |
| 196 | 204 | } |
@@ -16,6 +16,9 @@ |
||
| 16 | 16 | |
| 17 | 17 | trait BootstrapComponentsTrait { |
| 18 | 18 | |
| 19 | + /** |
|
| 20 | + * @param string|null $attachTo |
|
| 21 | + */ |
|
| 19 | 22 | public abstract function addComponent(SimpleComponent $component, $attachTo, $params); |
| 20 | 23 | /** |
| 21 | 24 | * |
@@ -11,7 +11,6 @@ |
||
| 11 | 11 | use Ajax\bootstrap\components\Tab; |
| 12 | 12 | use Ajax\bootstrap\components\Carousel; |
| 13 | 13 | use Ajax\bootstrap\components\Collapse; |
| 14 | -use Ajax\Bootstrap; |
|
| 15 | 14 | use Ajax\common\components\SimpleComponent; |
| 16 | 15 | |
| 17 | 16 | trait BootstrapComponentsTrait { |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | $item=$itemO; |
| 58 | 58 | } |
| 59 | 59 | $item=parent::addItem($item); |
| 60 | - if(!$item instanceof HtmlMenu) |
|
| 61 | - $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 62 | - else{ |
|
| 60 | + if(!$item instanceof HtmlMenu) { |
|
| 61 | + $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 62 | + } else{ |
|
| 63 | 63 | $this->setSecondary(); |
| 64 | 64 | } |
| 65 | 65 | return $item; |
@@ -129,8 +129,9 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public function asTab($vertical=false){ |
| 131 | 131 | $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
| 132 | - if($vertical===true) |
|
| 133 | - $this->setVertical(); |
|
| 132 | + if($vertical===true) { |
|
| 133 | + $this->setVertical(); |
|
| 134 | + } |
|
| 134 | 135 | return $this->addToProperty("class", "tabular"); |
| 135 | 136 | } |
| 136 | 137 | |
@@ -156,10 +157,11 @@ discard block |
||
| 156 | 157 | */ |
| 157 | 158 | public function fromDatabaseObject($object, $function) { |
| 158 | 159 | $return=$function($object); |
| 159 | - if(\is_array($return)) |
|
| 160 | - $this->addItems($return); |
|
| 161 | - else |
|
| 162 | - $this->addItem($return); |
|
| 160 | + if(\is_array($return)) { |
|
| 161 | + $this->addItems($return); |
|
| 162 | + } else { |
|
| 163 | + $this->addItem($return); |
|
| 164 | + } |
|
| 163 | 165 | } |
| 164 | 166 | |
| 165 | 167 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * Sets the menu type |
| 33 | 33 | * @param string $type one of text,item |
| 34 | - * @return \Ajax\semantic\html\collections\HtmlMenu |
|
| 34 | + * @return HtmlMenu |
|
| 35 | 35 | */ |
| 36 | 36 | public function setType($type=""){ |
| 37 | 37 | return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
@@ -73,6 +73,7 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * {@inheritDoc} |
| 75 | 75 | * @see \Ajax\common\html\HtmlCollection::insertItem() |
| 76 | + * @param HtmlIcon $item |
|
| 76 | 77 | */ |
| 77 | 78 | public function insertItem($item,$position=0){ |
| 78 | 79 | $item=parent::insertItem($this->getItemToInsert($item),$position); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | class HtmlMenu extends HtmlSemCollection { |
| 25 | 25 | |
| 26 | 26 | public function __construct($identifier, $items=array()) { |
| 27 | - parent::__construct($identifier, "div","ui menu"); |
|
| 27 | + parent::__construct($identifier, "div", "ui menu"); |
|
| 28 | 28 | $this->addItems($items); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -33,30 +33,30 @@ discard block |
||
| 33 | 33 | * @param string $type one of text,item |
| 34 | 34 | * @return \Ajax\semantic\html\collections\HtmlMenu |
| 35 | 35 | */ |
| 36 | - public function setType($type=""){ |
|
| 37 | - return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
|
| 36 | + public function setType($type="") { |
|
| 37 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function setActiveItem($index){ |
|
| 40 | + public function setActiveItem($index) { |
|
| 41 | 41 | $item=$this->getItem($index); |
| 42 | - if($item!==null){ |
|
| 42 | + if ($item!==null) { |
|
| 43 | 43 | $item->addToProperty("class", "active"); |
| 44 | 44 | } |
| 45 | 45 | return $this; |
| 46 | 46 | } |
| 47 | - private function getItemToInsert($item){ |
|
| 48 | - if($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon){ |
|
| 49 | - $itemO=new HtmlSemDoubleElement("item-".$this->identifier,"div",""); |
|
| 47 | + private function getItemToInsert($item) { |
|
| 48 | + if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon) { |
|
| 49 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier, "div", ""); |
|
| 50 | 50 | $itemO->setContent($item); |
| 51 | 51 | $item=$itemO; |
| 52 | 52 | } |
| 53 | 53 | return $item; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - private function afterInsert($item){ |
|
| 57 | - if(!$item instanceof HtmlMenu) |
|
| 58 | - $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 59 | - else{ |
|
| 56 | + private function afterInsert($item) { |
|
| 57 | + if (!$item instanceof HtmlMenu) |
|
| 58 | + $item->addToPropertyCtrl("class", "item", array("item")); |
|
| 59 | + else { |
|
| 60 | 60 | $this->setSecondary(); |
| 61 | 61 | } |
| 62 | 62 | return $item; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * {@inheritDoc} |
| 66 | 66 | * @see \Ajax\common\html\html5\HtmlCollection::addItem() |
| 67 | 67 | */ |
| 68 | - public function addItem($item){ |
|
| 68 | + public function addItem($item) { |
|
| 69 | 69 | $item=parent::addItem($this->getItemToInsert($item)); |
| 70 | 70 | return $this->afterInsert($item); |
| 71 | 71 | } |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | * {@inheritDoc} |
| 75 | 75 | * @see \Ajax\common\html\HtmlCollection::insertItem() |
| 76 | 76 | */ |
| 77 | - public function insertItem($item,$position=0){ |
|
| 78 | - $item=parent::insertItem($this->getItemToInsert($item),$position); |
|
| 77 | + public function insertItem($item, $position=0) { |
|
| 78 | + $item=parent::insertItem($this->getItemToInsert($item), $position); |
|
| 79 | 79 | return $this->afterInsert($item); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function generateMenuAsItem($menu,$header=null){ |
|
| 82 | + public function generateMenuAsItem($menu, $header=null) { |
|
| 83 | 83 | $count=$this->count(); |
| 84 | - $item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count,"div"); |
|
| 85 | - if(isset($header)){ |
|
| 86 | - $headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count,"div","header"); |
|
| 84 | + $item=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "div"); |
|
| 85 | + if (isset($header)) { |
|
| 86 | + $headerItem=new HtmlSemDoubleElement("item-header-".$this->identifier."-".$count, "div", "header"); |
|
| 87 | 87 | $headerItem->setContent($header); |
| 88 | 88 | $item->addContent($headerItem); |
| 89 | 89 | } |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | $item->addContent($menu); |
| 92 | 92 | return $item; |
| 93 | 93 | } |
| 94 | - public function addMenuAsItem($menu,$header=null){ |
|
| 95 | - return $this->addItem($this->generateMenuAsItem($menu,$header)); |
|
| 94 | + public function addMenuAsItem($menu, $header=null) { |
|
| 95 | + return $this->addItem($this->generateMenuAsItem($menu, $header)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function addPopupAsItem($value,$identifier, $content=""){ |
|
| 99 | - $value=new HtmlSemDoubleElement($identifier,"a","browse item",$value); |
|
| 98 | + public function addPopupAsItem($value, $identifier, $content="") { |
|
| 99 | + $value=new HtmlSemDoubleElement($identifier, "a", "browse item", $value); |
|
| 100 | 100 | $value->addContent(new HtmlIcon("", "dropdown")); |
| 101 | 101 | $value=$this->addItem($value); |
| 102 | - $popup=new HtmlPopup($value,"popup-".$this->identifier."-".$this->count(),$content); |
|
| 102 | + $popup=new HtmlPopup($value, "popup-".$this->identifier."-".$this->count(), $content); |
|
| 103 | 103 | $popup->setFlowing()->setPosition("bottom left")->setOn("click"); |
| 104 | - $this->wrap("",$popup); |
|
| 104 | + $this->wrap("", $popup); |
|
| 105 | 105 | return $popup; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function addDropdownAsItem($value,$items=NULL){ |
|
| 108 | + public function addDropdownAsItem($value, $items=NULL) { |
|
| 109 | 109 | $dd=$value; |
| 110 | - if(\is_string($value)){ |
|
| 111 | - $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(),$value,$items); |
|
| 110 | + if (\is_string($value)) { |
|
| 111 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$this->count(), $value, $items); |
|
| 112 | 112 | } |
| 113 | 113 | return $this->addItem($dd); |
| 114 | 114 | } |
@@ -117,51 +117,51 @@ discard block |
||
| 117 | 117 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 118 | 118 | */ |
| 119 | 119 | protected function createItem($value) { |
| 120 | - $itemO=new HtmlLink("item-".\sizeof($this->content),"",$value); |
|
| 120 | + $itemO=new HtmlLink("item-".\sizeof($this->content), "", $value); |
|
| 121 | 121 | return $itemO->setClass("item"); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function setInverted(){ |
|
| 124 | + public function setInverted() { |
|
| 125 | 125 | return $this->addToProperty("class", "inverted"); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function setSecondary(){ |
|
| 128 | + public function setSecondary() { |
|
| 129 | 129 | return $this->addToProperty("class", "secondary"); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function setVertical(){ |
|
| 133 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
| 132 | + public function setVertical() { |
|
| 133 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function setPosition($value="right"){ |
|
| 137 | - return $this->addToPropertyCtrl("class", $value,array("right","left")); |
|
| 136 | + public function setPosition($value="right") { |
|
| 137 | + return $this->addToPropertyCtrl("class", $value, array("right", "left")); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function setPointing($value=Direction::NONE){ |
|
| 141 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 140 | + public function setPointing($value=Direction::NONE) { |
|
| 141 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function asTab($vertical=false){ |
|
| 145 | - $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
|
| 146 | - if($vertical===true) |
|
| 144 | + public function asTab($vertical=false) { |
|
| 145 | + $this->apply(function(HtmlDoubleElement & $item) {$item->setTagName("a"); }); |
|
| 146 | + if ($vertical===true) |
|
| 147 | 147 | $this->setVertical(); |
| 148 | 148 | return $this->addToProperty("class", "tabular"); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function asPagination(){ |
|
| 152 | - $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
|
| 151 | + public function asPagination() { |
|
| 152 | + $this->apply(function(HtmlDoubleElement & $item) {$item->setTagName("a"); }); |
|
| 153 | 153 | return $this->addToProperty("class", "pagination"); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function setFixed(){ |
|
| 156 | + public function setFixed() { |
|
| 157 | 157 | return $this->addToProperty("class", "fixed"); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function setFluid(){ |
|
| 160 | + public function setFluid() { |
|
| 161 | 161 | return $this->addToProperty("class", "fluid"); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function setCompact(){ |
|
| 164 | + public function setCompact() { |
|
| 165 | 165 | return $this->addToProperty("class", "compact"); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function fromDatabaseObject($object, $function) { |
| 172 | 172 | $return=$function($object); |
| 173 | - if(\is_array($return)) |
|
| 173 | + if (\is_array($return)) |
|
| 174 | 174 | $this->addItems($return); |
| 175 | 175 | else |
| 176 | 176 | $this->addItem($return); |
@@ -181,19 +181,19 @@ discard block |
||
| 181 | 181 | * @param int $width |
| 182 | 182 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 183 | 183 | */ |
| 184 | - public function setWidth($width){ |
|
| 185 | - if(\is_int($width)){ |
|
| 184 | + public function setWidth($width) { |
|
| 185 | + if (\is_int($width)) { |
|
| 186 | 186 | $width=Wide::getConstants()["W".$width]; |
| 187 | 187 | } |
| 188 | 188 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 189 | - return $this->addToPropertyCtrl("class", "item",array("item")); |
|
| 189 | + return $this->addToPropertyCtrl("class", "item", array("item")); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function addImage($identifier, $src="", $alt=""){ |
|
| 193 | - return $this->addItem(new HtmlImg($identifier,$src,$alt)); |
|
| 192 | + public function addImage($identifier, $src="", $alt="") { |
|
| 193 | + return $this->addItem(new HtmlImg($identifier, $src, $alt)); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public static function vertical($identifier,$items=array()){ |
|
| 197 | - return (new HtmlMenu($identifier,$items))->setVertical(); |
|
| 196 | + public static function vertical($identifier, $items=array()) { |
|
| 197 | + return (new HtmlMenu($identifier, $items))->setVertical(); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | \ No newline at end of file |