@@ -7,29 +7,29 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | $this->_identifier=$identifier; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setItems($items){ |
|
| 15 | + public function setItems($items) { |
|
| 16 | 16 | return $this->getField()->setItems($items); |
| 17 | 17 | } |
| 18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 19 | - return $this->getField()->addItem($item,$value,$image); |
|
| 18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 19 | + return $this->getField()->addItem($item, $value, $image); |
|
| 20 | 20 | } |
| 21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){ |
|
| 22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
| 21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) { |
|
| 22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @return HtmlDropdown |
| 27 | 27 | */ |
| 28 | - public function getDataField(){ |
|
| 28 | + public function getDataField() { |
|
| 29 | 29 | return $this->getField()->getInput(); |
| 30 | 30 | } |
| 31 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 32 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
| 31 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 32 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param boolean $floating |
| 38 | 38 | * @return HtmlDropdown |
| 39 | 39 | */ |
| 40 | - public function asButton($floating=false){ |
|
| 40 | + public function asButton($floating=false) { |
|
| 41 | 41 | $field=$this->content["field"]; |
| 42 | 42 | $label=$this->content["label"]; |
| 43 | 43 | $field->addContent($label); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @version 1.001 |
| 16 | 16 | */ |
| 17 | 17 | class HtmlMessage extends HtmlSemDoubleElement { |
| 18 | - use AttachedTrait,HasTimeoutTrait; |
|
| 18 | + use AttachedTrait, HasTimeoutTrait; |
|
| 19 | 19 | protected $icon; |
| 20 | 20 | protected $close; |
| 21 | 21 | |
@@ -32,39 +32,39 @@ discard block |
||
| 32 | 32 | * @param string|HtmlSemDoubleElement $header |
| 33 | 33 | * @return \Ajax\semantic\html\collections\HtmlMessage |
| 34 | 34 | */ |
| 35 | - public function addHeader($header){ |
|
| 35 | + public function addHeader($header) { |
|
| 36 | 36 | $headerO=$header; |
| 37 | - if(\is_string($header)){ |
|
| 38 | - $headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div"); |
|
| 37 | + if (\is_string($header)) { |
|
| 38 | + $headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div"); |
|
| 39 | 39 | $headerO->setClass("header"); |
| 40 | 40 | $headerO->setContent($header); |
| 41 | 41 | } |
| 42 | - return $this->addContent($headerO,true); |
|
| 42 | + return $this->addContent($headerO, true); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function setHeader($header){ |
|
| 45 | + public function setHeader($header) { |
|
| 46 | 46 | return $this->addHeader($header); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function setIcon($icon){ |
|
| 49 | + public function setIcon($icon) { |
|
| 50 | 50 | $this->addToProperty("class", "icon"); |
| 51 | - $this->wrapContent("<div class='content'>","</div>"); |
|
| 52 | - if(\is_string($icon)){ |
|
| 51 | + $this->wrapContent("<div class='content'>", "</div>"); |
|
| 52 | + if (\is_string($icon)) { |
|
| 53 | 53 | $this->icon=new HtmlIcon("icon-".$this->identifier, $icon); |
| 54 | - }else{ |
|
| 54 | + } else { |
|
| 55 | 55 | $this->icon=$icon; |
| 56 | 56 | } |
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function addLoader($loaderIcon="notched circle"){ |
|
| 60 | + public function addLoader($loaderIcon="notched circle") { |
|
| 61 | 61 | $this->setIcon($loaderIcon); |
| 62 | 62 | $this->icon->addToIcon("loading"); |
| 63 | 63 | return $this; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function setDismissable($dismiss=true){ |
|
| 67 | - if($dismiss===true) |
|
| 66 | + public function setDismissable($dismiss=true) { |
|
| 67 | + if ($dismiss===true) |
|
| 68 | 68 | $this->close=new HtmlIcon("close-".$this->identifier, "close"); |
| 69 | 69 | else |
| 70 | 70 | $this->close=NULL; |
@@ -75,43 +75,43 @@ discard block |
||
| 75 | 75 | * {@inheritDoc} |
| 76 | 76 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 77 | 77 | */ |
| 78 | - public function run(JsUtils $js){ |
|
| 79 | - if(!isset($this->_bsComponent)){ |
|
| 80 | - if(isset($this->close)){ |
|
| 78 | + public function run(JsUtils $js) { |
|
| 79 | + if (!isset($this->_bsComponent)) { |
|
| 80 | + if (isset($this->close)) { |
|
| 81 | 81 | $js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})"); |
| 82 | 82 | } |
| 83 | - if(isset($this->_timeout)){ |
|
| 84 | - $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true); |
|
| 83 | + if (isset($this->_timeout)) { |
|
| 84 | + $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | return parent::run($js); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function setState($visible=true){ |
|
| 91 | - $visible=($visible===true)?"visible":"hidden"; |
|
| 92 | - return $this->addToPropertyCtrl("class", $visible, array("visible","hidden")); |
|
| 90 | + public function setState($visible=true) { |
|
| 91 | + $visible=($visible===true) ? "visible" : "hidden"; |
|
| 92 | + return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden")); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function setVariation($value="floating"){ |
|
| 96 | - return $this->addToPropertyCtrl("class", $value, array("floating","compact")); |
|
| 95 | + public function setVariation($value="floating") { |
|
| 96 | + return $this->addToPropertyCtrl("class", $value, array("floating", "compact")); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function setStyle($style){ |
|
| 99 | + public function setStyle($style) { |
|
| 100 | 100 | return $this->addToPropertyCtrl("class", $style, Style::getConstants()); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function setError(){ |
|
| 103 | + public function setError() { |
|
| 104 | 104 | return $this->setStyle("error"); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function setWarning(){ |
|
| 107 | + public function setWarning() { |
|
| 108 | 108 | return $this->setStyle("warning"); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function setMessage($message){ |
|
| 112 | - if(\is_array($this->content)){ |
|
| 111 | + public function setMessage($message) { |
|
| 112 | + if (\is_array($this->content)) { |
|
| 113 | 113 | $this->content[\sizeof($this->content)-1]=$message; |
| 114 | - }else |
|
| 114 | + } else |
|
| 115 | 115 | $this->setContent($message); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n"; |
| 7 | 7 | public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n"; |
| 8 | 8 | |
| 9 | - public static function containsCode($expression){ |
|
| 10 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
| 9 | + public static function containsCode($expression) { |
|
| 10 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | return $value; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function prep_jquery_selector($value){ |
|
| 47 | - if(JString::startswith($value, '$(')===false){ |
|
| 46 | + public static function prep_jquery_selector($value) { |
|
| 47 | + if (JString::startswith($value, '$(')===false) { |
|
| 48 | 48 | return '$('.$value.')'; |
| 49 | 49 | } |
| 50 | 50 | return $value; |
@@ -3,26 +3,26 @@ |
||
| 3 | 3 | use Ajax\semantic\html\base\constants\Transition; |
| 4 | 4 | |
| 5 | 5 | class AjaxTransition { |
| 6 | - public static function none($responseElement,$jqueryDone="html"){ |
|
| 6 | + public static function none($responseElement, $jqueryDone="html") { |
|
| 7 | 7 | return $responseElement.".".$jqueryDone."( data )"; |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - public static function jqFade($responseElement,$jqueryDone="html"){ |
|
| 10 | + public static function jqFade($responseElement, $jqueryDone="html") { |
|
| 11 | 11 | return $responseElement.".hide().{$jqueryDone}( data ).fadeIn()"; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function jqSlide($responseElement,$jqueryDone="html"){ |
|
| 14 | + public static function jqSlide($responseElement, $jqueryDone="html") { |
|
| 15 | 15 | return $responseElement.".hide().{$jqueryDone}( data ).slideDown()"; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public static function random($responseElement,$jqueryDone="html"){ |
|
| 18 | + public static function random($responseElement, $jqueryDone="html") { |
|
| 19 | 19 | $transitions=Transition::getConstantValues(); |
| 20 | - $transition=$transitions[\rand(0,\sizeof($transitions)-1)]; |
|
| 21 | - return self::__callStatic($transition, [$responseElement,$jqueryDone]); |
|
| 20 | + $transition=$transitions[\rand(0, \sizeof($transitions)-1)]; |
|
| 21 | + return self::__callStatic($transition, [$responseElement, $jqueryDone]); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public static function __callStatic($name, $arguments){ |
|
| 25 | - if(\sizeof($arguments)==2){ |
|
| 24 | + public static function __callStatic($name, $arguments) { |
|
| 25 | + if (\sizeof($arguments)==2) { |
|
| 26 | 26 | $responseElement=$arguments[0]; |
| 27 | 27 | $jqueryDone=$arguments[1]; |
| 28 | 28 | $name=JString::camelCaseToSeparated($name); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class HtmlForm extends HtmlSemCollection { |
| 22 | 22 | |
| 23 | - use FieldsTrait,FormTrait; |
|
| 23 | + use FieldsTrait, FormTrait; |
|
| 24 | 24 | /** |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function __construct($identifier, $elements=array()) { |
| 35 | 35 | parent::__construct($identifier, "form", "ui form"); |
| 36 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
| 36 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
| 37 | 37 | $this->setProperty("name", $this->identifier); |
| 38 | - $this->_fields=array (); |
|
| 38 | + $this->_fields=array(); |
|
| 39 | 39 | $this->addItems($elements); |
| 40 | 40 | $this->_validationParams=[]; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - protected function getForm(){ |
|
| 43 | + protected function getForm() { |
|
| 44 | 44 | return $this; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * @param string $caption |
| 63 | 63 | * @return HtmlForm |
| 64 | 64 | */ |
| 65 | - public function addDivider($caption=NULL){ |
|
| 66 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
| 65 | + public function addDivider($caption=NULL) { |
|
| 66 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | $label=NULL; |
| 86 | 86 | } |
| 87 | 87 | $this->_fields=\array_merge($this->_fields, $fields); |
| 88 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
| 88 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
| 89 | 89 | } |
| 90 | - if (isset($label)){ |
|
| 91 | - $fields->wrap("<div class='field'><label>{$label}</label>","</div>"); |
|
| 90 | + if (isset($label)) { |
|
| 91 | + $fields->wrap("<div class='field'><label>{$label}</label>", "</div>"); |
|
| 92 | 92 | } |
| 93 | 93 | } else { |
| 94 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
| 94 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
| 95 | 95 | } |
| 96 | 96 | $this->addItem($fields); |
| 97 | 97 | return $fields; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function addItem($item) { |
| 101 | 101 | $item=parent::addItem($item); |
| 102 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
| 102 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
| 103 | 103 | $this->_fields[]=$item; |
| 104 | 104 | } |
| 105 | 105 | return $item; |
@@ -157,39 +157,39 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | |
| 159 | 159 | |
| 160 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 161 | - if(\sizeof($this->_validationParams)>0) |
|
| 160 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 161 | + if (\sizeof($this->_validationParams)>0) |
|
| 162 | 162 | $this->setProperty("novalidate", ""); |
| 163 | - return parent::compile($js,$view); |
|
| 163 | + return parent::compile($js, $view); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | public function run(JsUtils $js) { |
| 167 | - if(isset($js)){ |
|
| 167 | + if (isset($js)) { |
|
| 168 | 168 | $compo=$js->semantic()->form("#".$this->identifier); |
| 169 | - }else{ |
|
| 169 | + } else { |
|
| 170 | 170 | $compo=new Form(); |
| 171 | 171 | $compo->attach("#".$this->identifier); |
| 172 | 172 | } |
| 173 | - foreach ($this->_fields as $field){ |
|
| 174 | - if($field instanceof HtmlFormField){ |
|
| 173 | + foreach ($this->_fields as $field) { |
|
| 174 | + if ($field instanceof HtmlFormField) { |
|
| 175 | 175 | $compo=$this->addCompoValidation($compo, $field); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | - foreach ($this->content as $field){ |
|
| 179 | - if($field instanceof HtmlFormFields){ |
|
| 178 | + foreach ($this->content as $field) { |
|
| 179 | + if ($field instanceof HtmlFormFields) { |
|
| 180 | 180 | $items=$field->getItems(); |
| 181 | - foreach ($items as $_field){ |
|
| 182 | - if($_field instanceof HtmlFormField) |
|
| 181 | + foreach ($items as $_field) { |
|
| 182 | + if ($_field instanceof HtmlFormField) |
|
| 183 | 183 | $compo=$this->addCompoValidation($compo, $_field); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | - $this->_runValidationParams($compo,$js); |
|
| 187 | + $this->_runValidationParams($compo, $js); |
|
| 188 | 188 | return $this->_bsComponent; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function addValidationParam($paramName,$paramValue,$before="",$after=""){ |
|
| 192 | - $this->addBehavior($this->_validationParams, $paramName, $paramValue,$before,$after); |
|
| 191 | + public function addValidationParam($paramName, $paramValue, $before="", $after="") { |
|
| 192 | + $this->addBehavior($this->_validationParams, $paramName, $paramValue, $before, $after); |
|
| 193 | 193 | return $this; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | return $this->_validationParams; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function removeValidationParam($param){ |
|
| 205 | + public function removeValidationParam($param) { |
|
| 206 | 206 | unset($this->_validationParams[$param]); |
| 207 | 207 | return $this; |
| 208 | 208 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.001 |
| 8 | 8 | * Generates a JSON field validator |
| 9 | 9 | */ |
| 10 | -class FieldValidation implements \JsonSerializable{ |
|
| 10 | +class FieldValidation implements \JsonSerializable { |
|
| 11 | 11 | /** |
| 12 | 12 | * @var string |
| 13 | 13 | */ |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | protected $optional; |
| 26 | 26 | |
| 27 | - public function __construct($identifier){ |
|
| 27 | + public function __construct($identifier) { |
|
| 28 | 28 | $this->identifier=$identifier; |
| 29 | 29 | $this->rules=[]; |
| 30 | 30 | } |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | * @param string $value |
| 49 | 49 | * @return Rule |
| 50 | 50 | */ |
| 51 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
| 52 | - if($type instanceof Rule) |
|
| 51 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 52 | + if ($type instanceof Rule) |
|
| 53 | 53 | $rule=$type; |
| 54 | - else if(\is_array($type)){ |
|
| 54 | + else if (\is_array($type)) { |
|
| 55 | 55 | $value=JArray::getValue($type, "value", 2); |
| 56 | 56 | $prompt=JArray::getValue($type, "prompt", 1); |
| 57 | 57 | $type=JArray::getValue($type, "type", 0); |
| 58 | - $rule=new Rule($type,$prompt,$value); |
|
| 59 | - }else |
|
| 60 | - $rule=new Rule($type,$prompt,$value); |
|
| 58 | + $rule=new Rule($type, $prompt, $value); |
|
| 59 | + } else |
|
| 60 | + $rule=new Rule($type, $prompt, $value); |
|
| 61 | 61 | $this->rules[]=$rule; |
| 62 | 62 | return $rule; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function jsonSerialize(){ |
|
| 66 | - return ["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
| 65 | + public function jsonSerialize() { |
|
| 66 | + return ["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function setDepends($depends) { |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * @param string $action one of "select","auto","activate","combo","nothing","hide" |
| 18 | 18 | * @return \Ajax\semantic\components\Dropdown |
| 19 | 19 | */ |
| 20 | - public function setAction($action){ |
|
| 21 | - return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide")); |
|
| 20 | + public function setAction($action) { |
|
| 21 | + return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide")); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * @param string $event Event used to trigger dropdown (Hover, Click, Custom Event) |
| 27 | 27 | * @return \Ajax\semantic\components\Dropdown |
| 28 | 28 | */ |
| 29 | - public function setOn($event){ |
|
| 29 | + public function setOn($event) { |
|
| 30 | 30 | return $this->setParam("on", $event); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function setFullTextSearch($value){ |
|
| 33 | + public function setFullTextSearch($value) { |
|
| 34 | 34 | return $this->setParam("fullTextSearch", $value); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function setShowOnFocus($value){ |
|
| 37 | + public function setShowOnFocus($value) { |
|
| 38 | 38 | return $this->setParam("showOnFocus", $value); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -15,44 +15,44 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | abstract class HtmlCollection extends HtmlDoubleElement { |
| 17 | 17 | |
| 18 | - public function __construct($identifier,$tagName="div"){ |
|
| 19 | - parent::__construct($identifier,$tagName); |
|
| 18 | + public function __construct($identifier, $tagName="div") { |
|
| 19 | + parent::__construct($identifier, $tagName); |
|
| 20 | 20 | $this->content=array(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function addItems($items){ |
|
| 24 | - if(JArray::isAssociative($items)){ |
|
| 25 | - foreach ($items as $k=>$v){ |
|
| 26 | - $this->addItem([$k,$v]); |
|
| 23 | + public function addItems($items) { |
|
| 24 | + if (JArray::isAssociative($items)) { |
|
| 25 | + foreach ($items as $k=>$v) { |
|
| 26 | + $this->addItem([$k, $v]); |
|
| 27 | 27 | } |
| 28 | - }else{ |
|
| 29 | - foreach ($items as $item){ |
|
| 28 | + } else { |
|
| 29 | + foreach ($items as $item) { |
|
| 30 | 30 | $this->addItem($item); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function setItems($items){ |
|
| 36 | + public function setItems($items) { |
|
| 37 | 37 | $this->content=$items; |
| 38 | 38 | return $this; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getItems(){ |
|
| 41 | + public function getItems() { |
|
| 42 | 42 | return $this->content; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected function getItemToAdd($item){ |
|
| 45 | + protected function getItemToAdd($item) { |
|
| 46 | 46 | $itemO=$item; |
| 47 | - if($this->createCondition($item)===true){ |
|
| 47 | + if ($this->createCondition($item)===true) { |
|
| 48 | 48 | $itemO=$this->createItem($item); |
| 49 | 49 | } |
| 50 | 50 | return $itemO; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function setItemIdentifier($item,$classname,$index){ |
|
| 54 | - if($item instanceof BaseWidget){ |
|
| 55 | - if(JString::isNull($item->getIdentifier())){ |
|
| 53 | + protected function setItemIdentifier($item, $classname, $index) { |
|
| 54 | + if ($item instanceof BaseWidget) { |
|
| 55 | + if (JString::isNull($item->getIdentifier())) { |
|
| 56 | 56 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | * @param HtmlDoubleElement|string|array $item |
| 64 | 64 | * @return \Ajax\common\html\HtmlDoubleElement |
| 65 | 65 | */ |
| 66 | - public function addItem($item){ |
|
| 66 | + public function addItem($item) { |
|
| 67 | 67 | $itemO=$this->getItemToAdd($item); |
| 68 | 68 | $this->addContent($itemO); |
| 69 | 69 | return $itemO; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function insertItem($item,$position=0){ |
|
| 72 | + public function insertItem($item, $position=0) { |
|
| 73 | 73 | $itemO=$this->getItemToAdd($item); |
| 74 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
| 74 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
| 75 | 75 | return $itemO; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function removeItem($index){ |
|
| 97 | + public function removeItem($index) { |
|
| 98 | 98 | return array_splice($this->content, $index, 1); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function count(){ |
|
| 101 | + public function count() { |
|
| 102 | 102 | return \sizeof($this->content); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | return $this->addItem($function($object)); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function apply($callBack){ |
|
| 113 | - foreach ($this->content as $item){ |
|
| 112 | + public function apply($callBack) { |
|
| 113 | + foreach ($this->content as $item) { |
|
| 114 | 114 | $callBack($item); |
| 115 | 115 | } |
| 116 | 116 | return $this; |
@@ -130,23 +130,23 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | abstract protected function createItem($value); |
| 132 | 132 | |
| 133 | - protected function createCondition($value){ |
|
| 133 | + protected function createCondition($value) { |
|
| 134 | 134 | return \is_object($value)===false; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - protected function contentAs($tagName){ |
|
| 138 | - foreach ($this->content as $item){ |
|
| 137 | + protected function contentAs($tagName) { |
|
| 138 | + foreach ($this->content as $item) { |
|
| 139 | 139 | $item->setTagName($tagName); |
| 140 | 140 | } |
| 141 | 141 | return $this; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public function setProperties($properties){ |
|
| 144 | + public function setProperties($properties) { |
|
| 145 | 145 | $i=0; |
| 146 | - foreach ($properties as $k=>$v){ |
|
| 146 | + foreach ($properties as $k=>$v) { |
|
| 147 | 147 | $c=$this->content[$i++]; |
| 148 | - if(isset($c)) |
|
| 149 | - $c->setProperty($k,$v); |
|
| 148 | + if (isset($c)) |
|
| 149 | + $c->setProperty($k, $v); |
|
| 150 | 150 | else |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | * @param array $values |
| 160 | 160 | * @return HtmlCollection |
| 161 | 161 | */ |
| 162 | - public function setPropertyValues($property,$values){ |
|
| 162 | + public function setPropertyValues($property, $values) { |
|
| 163 | 163 | $i=0; |
| 164 | - if(\is_array($values)===false){ |
|
| 165 | - $values=\array_fill(0, $this->count(),$values); |
|
| 164 | + if (\is_array($values)===false) { |
|
| 165 | + $values=\array_fill(0, $this->count(), $values); |
|
| 166 | 166 | } |
| 167 | - foreach ($values as $value){ |
|
| 167 | + foreach ($values as $value) { |
|
| 168 | 168 | $c=$this->content[$i++]; |
| 169 | - if(isset($c)){ |
|
| 170 | - $c->setProperty($property,$value); |
|
| 169 | + if (isset($c)) { |
|
| 170 | + $c->setProperty($property, $value); |
|
| 171 | 171 | } |
| 172 | - else{ |
|
| 172 | + else { |
|
| 173 | 173 | return $this; |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 180 | 180 | $index=0; |
| 181 | 181 | $classname=\strtolower(JReflection::shortClassName($this)); |
| 182 | - foreach ($this->content as $item){ |
|
| 183 | - $this->setItemIdentifier($item,$classname,$index++); |
|
| 182 | + foreach ($this->content as $item) { |
|
| 183 | + $this->setItemIdentifier($item, $classname, $index++); |
|
| 184 | 184 | } |
| 185 | - return parent::compile($js,$view); |
|
| 185 | + return parent::compile($js, $view); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - public function getItemById($identifier){ |
|
| 188 | + public function getItemById($identifier) { |
|
| 189 | 189 | return $this->getElementById($identifier, $this->content); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | trait JsUtilsEventsTrait { |
| 12 | 12 | |
| 13 | 13 | |
| 14 | - protected $jquery_events=array ( |
|
| 15 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
| 14 | + protected $jquery_events=array( |
|
| 15 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 18 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Outputs a javascript library blur event |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @param boolean $stopPropagation |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function change($element='this', $js='',$preventDefault=false,$stopPropagation=false) { |
|
| 41 | - return $this->_add_event($element, $js, 'change',$preventDefault,$stopPropagation); |
|
| 40 | + public function change($element='this', $js='', $preventDefault=false, $stopPropagation=false) { |
|
| 41 | + return $this->_add_event($element, $js, 'change', $preventDefault, $stopPropagation); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param boolean $stopPropagation |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | - public function click($element='this', $js='', $ret_false=TRUE,$preventDefault=false,$stopPropagation=false) { |
|
| 54 | + public function click($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false) { |
|
| 55 | 55 | if (!is_array($js)) { |
| 56 | - $js=array ( |
|
| 56 | + $js=array( |
|
| 57 | 57 | $js |
| 58 | 58 | ); |
| 59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $js[]="return false;"; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - return $this->_add_event($element, $js, 'click',$preventDefault,$stopPropagation); |
|
| 65 | + return $this->_add_event($element, $js, 'click', $preventDefault, $stopPropagation); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |