@@ -15,15 +15,28 @@ discard block |
||
| 15 | 15 | * @property InstanceViewer $_instanceViewer |
| 16 | 16 | */ |
| 17 | 17 | trait DataTableFieldAsTrait{ |
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @param \Closure $field |
|
| 21 | + */ |
|
| 18 | 22 | abstract public function addField($field); |
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @param integer $index |
|
| 26 | + * @param \Closure $field |
|
| 27 | + */ |
|
| 19 | 28 | abstract public function insertField($index,$field); |
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param \Closure $field |
|
| 32 | + */ |
|
| 20 | 33 | abstract public function insertInField($index,$field); |
| 21 | 34 | abstract public function fieldAs($index,$type,$attributes=NULL); |
| 22 | 35 | /** |
| 23 | 36 | * @param string $caption |
| 24 | 37 | * @param callable $callback |
| 25 | 38 | * @param boolean $visibleHover |
| 26 | - * @return callable |
|
| 39 | + * @return \Closure |
|
| 27 | 40 | */ |
| 28 | 41 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
| 29 | 42 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -33,7 +46,7 @@ discard block |
||
| 33 | 46 | * @param callable $thisCallback |
| 34 | 47 | * @param array $parameters |
| 35 | 48 | * @param callable $callback |
| 36 | - * @return callable |
|
| 49 | + * @return \Closure |
|
| 37 | 50 | */ |
| 38 | 51 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 39 | 52 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -103,7 +116,7 @@ discard block |
||
| 103 | 116 | * @param string $caption |
| 104 | 117 | * @param callable $callback |
| 105 | 118 | * @param boolean $visibleHover |
| 106 | - * @return DataTable |
|
| 119 | + * @return DataTableFieldAsTrait |
|
| 107 | 120 | */ |
| 108 | 121 | public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
| 109 | 122 | $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
@@ -115,7 +128,7 @@ discard block |
||
| 115 | 128 | * @param array $buttons |
| 116 | 129 | * @param callable $callback |
| 117 | 130 | * @param boolean $visibleHover |
| 118 | - * @return DataTable |
|
| 131 | + * @return DataTableFieldAsTrait |
|
| 119 | 132 | */ |
| 120 | 133 | public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
| 121 | 134 | $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
@@ -127,7 +140,7 @@ discard block |
||
| 127 | 140 | * @param int $index |
| 128 | 141 | * @param string $caption |
| 129 | 142 | * @param callable $callback |
| 130 | - * @return DataTable |
|
| 143 | + * @return DataTableFieldAsTrait |
|
| 131 | 144 | */ |
| 132 | 145 | public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
| 133 | 146 | $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
@@ -139,18 +152,27 @@ discard block |
||
| 139 | 152 | * @param int $index |
| 140 | 153 | * @param string $caption |
| 141 | 154 | * @param callable $callback |
| 142 | - * @return DataTable |
|
| 155 | + * @return DataTableFieldAsTrait |
|
| 143 | 156 | */ |
| 144 | 157 | public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
| 145 | 158 | $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
| 146 | 159 | return $this; |
| 147 | 160 | } |
| 148 | 161 | |
| 162 | + /** |
|
| 163 | + * @param string $icon |
|
| 164 | + * @param string $class |
|
| 165 | + * @param callable $callback |
|
| 166 | + */ |
|
| 149 | 167 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
| 150 | 168 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 151 | 169 | return $this; |
| 152 | 170 | } |
| 153 | 171 | |
| 172 | + /** |
|
| 173 | + * @param string $icon |
|
| 174 | + * @param string $class |
|
| 175 | + */ |
|
| 154 | 176 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
| 155 | 177 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 156 | 178 | return $this; |
@@ -169,7 +191,7 @@ discard block |
||
| 169 | 191 | * @param boolean $visibleHover |
| 170 | 192 | * @param array $deleteBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
| 171 | 193 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 172 | - * @return DataTable |
|
| 194 | + * @return DataTableFieldAsTrait |
|
| 173 | 195 | */ |
| 174 | 196 | public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
| 175 | 197 | $this->_deleteBehavior=$deleteBehavior; |
@@ -181,7 +203,7 @@ discard block |
||
| 181 | 203 | * @param string $visibleHover |
| 182 | 204 | * @param array $editBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
| 183 | 205 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 184 | - * @return DataTable |
|
| 206 | + * @return DataTableFieldAsTrait |
|
| 185 | 207 | */ |
| 186 | 208 | public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
| 187 | 209 | $this->_editBehavior=$editBehavior; |
@@ -194,7 +216,7 @@ discard block |
||
| 194 | 216 | * @param array $behavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get") |
| 195 | 217 | * @param callable $callbackEdit this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 196 | 218 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 197 | - * @return DataTable |
|
| 219 | + * @return DataTableFieldAsTrait |
|
| 198 | 220 | */ |
| 199 | 221 | public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
| 200 | 222 | $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
@@ -203,6 +225,9 @@ discard block |
||
| 203 | 225 | return $this; |
| 204 | 226 | } |
| 205 | 227 | |
| 228 | + /** |
|
| 229 | + * @param callable $callback |
|
| 230 | + */ |
|
| 206 | 231 | public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
| 207 | 232 | $this->_deleteBehavior=$deleteBehavior; |
| 208 | 233 | return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
@@ -14,19 +14,19 @@ discard block |
||
| 14 | 14 | * @property boolean $_visibleHover |
| 15 | 15 | * @property InstanceViewer $_instanceViewer |
| 16 | 16 | */ |
| 17 | -trait DataTableFieldAsTrait{ |
|
| 17 | +trait DataTableFieldAsTrait { |
|
| 18 | 18 | abstract public function addField($field); |
| 19 | - abstract public function insertField($index,$field); |
|
| 20 | - abstract public function insertInField($index,$field); |
|
| 21 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
| 19 | + abstract public function insertField($index, $field); |
|
| 20 | + abstract public function insertInField($index, $field); |
|
| 21 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
| 22 | 22 | /** |
| 23 | 23 | * @param string $caption |
| 24 | 24 | * @param callable $callback |
| 25 | 25 | * @param boolean $visibleHover |
| 26 | 26 | * @return callable |
| 27 | 27 | */ |
| 28 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
| 29 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
| 28 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
| 29 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -35,20 +35,20 @@ discard block |
||
| 35 | 35 | * @param callable $callback |
| 36 | 36 | * @return callable |
| 37 | 37 | */ |
| 38 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
| 39 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
| 40 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
| 41 | - if(isset($callback)){ |
|
| 42 | - if(\is_callable($callback)){ |
|
| 43 | - $callback($object,$instance,$this->_instanceViewer->count()+1); |
|
| 38 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
| 39 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
| 40 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
| 41 | + if (isset($callback)) { |
|
| 42 | + if (\is_callable($callback)) { |
|
| 43 | + $callback($object, $instance, $this->_instanceViewer->count()+1); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - if($object instanceof HtmlSemDoubleElement){ |
|
| 46 | + if ($object instanceof HtmlSemDoubleElement) { |
|
| 47 | 47 | $id=$this->_instanceViewer->getIdentifier(); |
| 48 | - $object->setProperty("data-ajax",$id); |
|
| 49 | - if($object->propertyContains("class","visibleover")){ |
|
| 48 | + $object->setProperty("data-ajax", $id); |
|
| 49 | + if ($object->propertyContains("class", "visibleover")) { |
|
| 50 | 50 | $this->_visibleHover=true; |
| 51 | - $object->setProperty("style","visibility:hidden;"); |
|
| 51 | + $object->setProperty("style", "visibility:hidden;"); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | return $object; |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | * @param string $caption |
| 61 | 61 | * @return HtmlButton |
| 62 | 62 | */ |
| 63 | - private function getFieldButton($caption,$visibleHover=true){ |
|
| 64 | - $bt= new HtmlButton("",$caption); |
|
| 65 | - if($visibleHover) |
|
| 63 | + private function getFieldButton($caption, $visibleHover=true) { |
|
| 64 | + $bt=new HtmlButton("", $caption); |
|
| 65 | + if ($visibleHover) |
|
| 66 | 66 | $this->_visibleOver($bt); |
| 67 | 67 | return $bt; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function getFieldButtons($buttons,$visibleHover=true){ |
|
| 71 | - $bts=new HtmlButtonGroups("",$buttons); |
|
| 72 | - if($visibleHover) |
|
| 70 | + private function getFieldButtons($buttons, $visibleHover=true) { |
|
| 71 | + $bts=new HtmlButtonGroups("", $buttons); |
|
| 72 | + if ($visibleHover) |
|
| 73 | 73 | $this->_visibleOver($bts); |
| 74 | 74 | return $bts; |
| 75 | 75 | } |
@@ -83,19 +83,19 @@ discard block |
||
| 83 | 83 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
| 84 | 84 | * @return DataTable |
| 85 | 85 | */ |
| 86 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 87 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
| 88 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 89 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
| 90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 86 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 87 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
| 88 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 89 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
| 90 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 91 | 91 | $this->_visibleOver($button); |
| 92 | 92 | return $button; |
| 93 | - }, $index,$attributes); |
|
| 93 | + }, $index, $attributes); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - protected function _visibleOver(BaseHtml $element){ |
|
| 96 | + protected function _visibleOver(BaseHtml $element) { |
|
| 97 | 97 | $this->_visibleHover=true; |
| 98 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
| 98 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param boolean $visibleHover |
| 106 | 106 | * @return DataTable |
| 107 | 107 | */ |
| 108 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
| 109 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
| 108 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
| 109 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | * @param boolean $visibleHover |
| 118 | 118 | * @return DataTable |
| 119 | 119 | */ |
| 120 | - public function addFieldButtons($buttons,$visibleHover=true,$callback=null){ |
|
| 121 | - $this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback)); |
|
| 120 | + public function addFieldButtons($buttons, $visibleHover=true, $callback=null) { |
|
| 121 | + $this->addField($this->getCallable("getFieldButtons", [$buttons, $visibleHover], $callback)); |
|
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * @param callable $callback |
| 130 | 130 | * @return DataTable |
| 131 | 131 | */ |
| 132 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 133 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 132 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 133 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,25 +141,25 @@ discard block |
||
| 141 | 141 | * @param callable $callback |
| 142 | 142 | * @return DataTable |
| 143 | 143 | */ |
| 144 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
| 145 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
| 144 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
| 145 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
| 146 | 146 | return $this; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 150 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 149 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 150 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
| 155 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
| 154 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
| 155 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
| 160 | - $bt=$this->getFieldButton("",$visibleHover); |
|
| 159 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
| 160 | + $bt=$this->getFieldButton("", $visibleHover); |
|
| 161 | 161 | $bt->asIcon($icon); |
| 162 | - if(isset($class)) |
|
| 162 | + if (isset($class)) |
|
| 163 | 163 | $bt->addClass($class); |
| 164 | 164 | return $bt; |
| 165 | 165 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 172 | 172 | * @return DataTable |
| 173 | 173 | */ |
| 174 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 174 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 175 | 175 | $this->_deleteBehavior=$deleteBehavior; |
| 176 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
| 176 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 184 | 184 | * @return DataTable |
| 185 | 185 | */ |
| 186 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 186 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 187 | 187 | $this->_editBehavior=$editBehavior; |
| 188 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
| 188 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -196,20 +196,20 @@ discard block |
||
| 196 | 196 | * @param callable $callbackDelete this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object |
| 197 | 197 | * @return DataTable |
| 198 | 198 | */ |
| 199 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
| 200 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
| 199 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
| 200 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
| 201 | 201 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 202 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
| 202 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
| 203 | 203 | return $this; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
| 206 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
| 207 | 207 | $this->_deleteBehavior=$deleteBehavior; |
| 208 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
| 208 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
| 211 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
| 212 | 212 | $this->_editBehavior=$editBehavior; |
| 213 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
| 213 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
| 214 | 214 | } |
| 215 | 215 | } |
@@ -62,15 +62,17 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function getFieldButton($caption,$visibleHover=true){ |
| 64 | 64 | $bt= new HtmlButton("",$caption); |
| 65 | - if($visibleHover) |
|
| 66 | - $this->_visibleOver($bt); |
|
| 65 | + if($visibleHover) { |
|
| 66 | + $this->_visibleOver($bt); |
|
| 67 | + } |
|
| 67 | 68 | return $bt; |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | private function getFieldButtons($buttons,$visibleHover=true){ |
| 71 | 72 | $bts=new HtmlButtonGroups("",$buttons); |
| 72 | - if($visibleHover) |
|
| 73 | - $this->_visibleOver($bts); |
|
| 73 | + if($visibleHover) { |
|
| 74 | + $this->_visibleOver($bts); |
|
| 75 | + } |
|
| 74 | 76 | return $bts; |
| 75 | 77 | } |
| 76 | 78 | |
@@ -87,8 +89,9 @@ discard block |
||
| 87 | 89 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
| 88 | 90 | $button=new HtmlButton($id,$value,$cssStyle); |
| 89 | 91 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
| 90 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 91 | - $this->_visibleOver($button); |
|
| 92 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
| 93 | + $this->_visibleOver($button); |
|
| 94 | + } |
|
| 92 | 95 | return $button; |
| 93 | 96 | }, $index,$attributes); |
| 94 | 97 | } |
@@ -159,8 +162,9 @@ discard block |
||
| 159 | 162 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
| 160 | 163 | $bt=$this->getFieldButton("",$visibleHover); |
| 161 | 164 | $bt->asIcon($icon); |
| 162 | - if(isset($class)) |
|
| 163 | - $bt->addClass($class); |
|
| 165 | + if(isset($class)) { |
|
| 166 | + $bt->addClass($class); |
|
| 167 | + } |
|
| 164 | 168 | return $bt; |
| 165 | 169 | } |
| 166 | 170 | |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * define the button style |
| 50 | - * @param string|int $cssStyle |
|
| 50 | + * @param string $cssStyle |
|
| 51 | 51 | * @return HtmlButton default : "" |
| 52 | 52 | */ |
| 53 | 53 | public function setStyle($cssStyle) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function setFocusable($value=true) { |
| 58 | - if ($value === true) |
|
| 58 | + if ($value===true) |
|
| 59 | 59 | $this->setProperty("tabindex", "0"); |
| 60 | 60 | else { |
| 61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function setAnimated($content, $animation="") { |
| 67 | 67 | $this->setTagName("div"); |
| 68 | - $this->addToProperty("class", "animated " . $animation); |
|
| 69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
| 68 | + $this->addToProperty("class", "animated ".$animation); |
|
| 69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
| 70 | 70 | $visible->setClass("visible content"); |
| 71 | 71 | $visible->setContent($this->content); |
| 72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
| 72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
| 73 | 73 | $hidden->setClass("hidden content"); |
| 74 | 74 | $hidden->setContent($content); |
| 75 | - $this->content=array ($visible,$hidden ); |
|
| 75 | + $this->content=array($visible, $hidden); |
|
| 76 | 76 | return $hidden; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function asIcon($icon) { |
| 85 | 85 | $iconO=$icon; |
| 86 | 86 | if (\is_string($icon)) { |
| 87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 88 | 88 | } |
| 89 | 89 | $this->addToProperty("class", "icon"); |
| 90 | 90 | $this->content=$iconO; |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | * @return HtmlLabel |
| 105 | 105 | */ |
| 106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
| 107 | - $this->tagName="div";$prefix=""; |
|
| 108 | - if($before) |
|
| 107 | + $this->tagName="div"; $prefix=""; |
|
| 108 | + if ($before) |
|
| 109 | 109 | $prefix="left "; |
| 110 | 110 | $this->addToProperty("class", $prefix."labeled"); |
| 111 | 111 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
| 112 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
| 113 | - if($isIcon){ |
|
| 112 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
| 113 | + if ($isIcon) { |
|
| 114 | 114 | $this->content->addClass("icon"); |
| 115 | 115 | } |
| 116 | 116 | $this->content->setTagName("div"); |
| 117 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
| 117 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
| 118 | 118 | $label->setBasic(); |
| 119 | 119 | $this->addContent($label, $before); |
| 120 | 120 | return $label; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function fromArray($array) { |
| 128 | 128 | $array=parent::fromArray($array); |
| 129 | - foreach ( $array as $key => $value ) { |
|
| 129 | + foreach ($array as $key => $value) { |
|
| 130 | 130 | $this->setProperty($key, $value); |
| 131 | 131 | } |
| 132 | 132 | return $array; |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | return $this->addToProperty("class", "positive"); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function setColor($color){ |
|
| 144 | - if(\is_array($this->content)){ |
|
| 145 | - foreach ($this->content as $content){ |
|
| 146 | - if($content instanceof HtmlButton) |
|
| 143 | + public function setColor($color) { |
|
| 144 | + if (\is_array($this->content)) { |
|
| 145 | + foreach ($this->content as $content) { |
|
| 146 | + if ($content instanceof HtmlButton) |
|
| 147 | 147 | $content->setColor($color); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return HtmlButton |
| 202 | 202 | */ |
| 203 | 203 | public static function social($identifier, $social, $value=NULL) { |
| 204 | - if ($value === NULL) |
|
| 204 | + if ($value===NULL) |
|
| 205 | 205 | $value=\ucfirst($social); |
| 206 | 206 | $return=new HtmlButton($identifier, $value); |
| 207 | 207 | $return->addIcon($social); |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * {@inheritDoc} |
| 239 | 239 | * @see HtmlSemDoubleElement::asLink() |
| 240 | 240 | */ |
| 241 | - public function asLink($href=NULL,$target=NULL) { |
|
| 242 | - parent::asLink($href,$target); |
|
| 241 | + public function asLink($href=NULL, $target=NULL) { |
|
| 242 | + parent::asLink($href, $target); |
|
| 243 | 243 | return $this; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | * @param string $icon |
| 253 | 253 | * @return HtmlButtonGroups |
| 254 | 254 | */ |
| 255 | - public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
| 256 | - $result=new HtmlButtonGroups($identifier,[$value]); |
|
| 257 | - $result->addDropdown($items,$asCombo); |
|
| 258 | - if(isset($icon)) |
|
| 255 | + public static function dropdown($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
| 256 | + $result=new HtmlButtonGroups($identifier, [$value]); |
|
| 257 | + $result->addDropdown($items, $asCombo); |
|
| 258 | + if (isset($icon)) |
|
| 259 | 259 | $result->setIcon($icon); |
| 260 | 260 | return $result; |
| 261 | 261 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function setFocusable($value=true) { |
| 58 | - if ($value === true) |
|
| 59 | - $this->setProperty("tabindex", "0"); |
|
| 60 | - else { |
|
| 58 | + if ($value === true) { |
|
| 59 | + $this->setProperty("tabindex", "0"); |
|
| 60 | + } else { |
|
| 61 | 61 | $this->removeProperty("tabindex"); |
| 62 | 62 | } |
| 63 | 63 | return $this; |
@@ -105,8 +105,9 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
| 107 | 107 | $this->tagName="div";$prefix=""; |
| 108 | - if($before) |
|
| 109 | - $prefix="left "; |
|
| 108 | + if($before) { |
|
| 109 | + $prefix="left "; |
|
| 110 | + } |
|
| 110 | 111 | $this->addToProperty("class", $prefix."labeled"); |
| 111 | 112 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
| 112 | 113 | $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
@@ -143,12 +144,13 @@ discard block |
||
| 143 | 144 | public function setColor($color){ |
| 144 | 145 | if(\is_array($this->content)){ |
| 145 | 146 | foreach ($this->content as $content){ |
| 146 | - if($content instanceof HtmlButton) |
|
| 147 | - $content->setColor($color); |
|
| 147 | + if($content instanceof HtmlButton) { |
|
| 148 | + $content->setColor($color); |
|
| 149 | + } |
|
| 148 | 150 | } |
| 151 | + } else { |
|
| 152 | + parent::setColor($color); |
|
| 149 | 153 | } |
| 150 | - else |
|
| 151 | - parent::setColor($color); |
|
| 152 | 154 | return $this; |
| 153 | 155 | } |
| 154 | 156 | |
@@ -201,8 +203,9 @@ discard block |
||
| 201 | 203 | * @return HtmlButton |
| 202 | 204 | */ |
| 203 | 205 | public static function social($identifier, $social, $value=NULL) { |
| 204 | - if ($value === NULL) |
|
| 205 | - $value=\ucfirst($social); |
|
| 206 | + if ($value === NULL) { |
|
| 207 | + $value=\ucfirst($social); |
|
| 208 | + } |
|
| 206 | 209 | $return=new HtmlButton($identifier, $value); |
| 207 | 210 | $return->addIcon($social); |
| 208 | 211 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -255,8 +258,9 @@ discard block |
||
| 255 | 258 | public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
| 256 | 259 | $result=new HtmlButtonGroups($identifier,[$value]); |
| 257 | 260 | $result->addDropdown($items,$asCombo); |
| 258 | - if(isset($icon)) |
|
| 259 | - $result->setIcon($icon); |
|
| 261 | + if(isset($icon)) { |
|
| 262 | + $result->setIcon($icon); |
|
| 263 | + } |
|
| 260 | 264 | return $result; |
| 261 | 265 | } |
| 262 | 266 | } |
@@ -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 |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | * @param boolean $stopPropagation |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function click($element='this', $js='', $ret_false=TRUE,$preventDefault=false,$stopPropagation=false) { |
|
| 52 | + public function click($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false) { |
|
| 53 | 53 | if (!is_array($js)) { |
| 54 | - $js=array ( |
|
| 54 | + $js=array( |
|
| 55 | 55 | $js |
| 56 | 56 | ); |
| 57 | 57 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $js[]="return false;"; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return $this->_add_event($element, $js, 'click',$preventDefault,$stopPropagation); |
|
| 63 | + return $this->_add_event($element, $js, 'click', $preventDefault, $stopPropagation); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
| 10 | 10 | use Ajax\semantic\html\base\constants\Side; |
| 11 | 11 | |
| 12 | -class HtmlStep extends HtmlSemCollection{ |
|
| 12 | +class HtmlStep extends HtmlSemCollection { |
|
| 13 | 13 | protected $_activeStep; |
| 14 | 14 | protected $_startStep; |
| 15 | 15 | |
| 16 | - public function __construct( $identifier,$steps=array()){ |
|
| 17 | - parent::__construct( $identifier,"div", "ui steps"); |
|
| 16 | + public function __construct($identifier, $steps=array()) { |
|
| 17 | + parent::__construct($identifier, "div", "ui steps"); |
|
| 18 | 18 | $this->addItems($steps); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 25 | 25 | */ |
| 26 | 26 | protected function createItem($value) { |
| 27 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
| 27 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
| 28 | 28 | return $itemO; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -32,50 +32,50 @@ discard block |
||
| 32 | 32 | * @param string|array $step |
| 33 | 33 | * @return HtmlStepItem |
| 34 | 34 | */ |
| 35 | - public function addStep($step){ |
|
| 35 | + public function addStep($step) { |
|
| 36 | 36 | return $this->addItem($step); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function setOrdered(){ |
|
| 39 | + public function setOrdered() { |
|
| 40 | 40 | return $this->addToProperty("class", "ordered"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function isOrdered(){ |
|
| 43 | + public function isOrdered() { |
|
| 44 | 44 | return $this->propertyContains("class", "ordered"); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setVertical(){ |
|
| 47 | + public function setVertical() { |
|
| 48 | 48 | return $this->addToProperty("class", "vertical"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function defineActiveStep(){ |
|
| 51 | + protected function defineActiveStep() { |
|
| 52 | 52 | $activestep=$this->_activeStep; |
| 53 | 53 | $count=$this->count(); |
| 54 | - if(!$this->isOrdered()){ |
|
| 55 | - for($i=$this->_startStep;$i<$count;$i++){ |
|
| 54 | + if (!$this->isOrdered()) { |
|
| 55 | + for ($i=$this->_startStep; $i<$count; $i++) { |
|
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 58 | + if ($i<$activestep) |
|
| 59 | 59 | $step->setCompleted(); |
| 60 | 60 | elseif ($i===$activestep) |
| 61 | 61 | $step->setActive(); |
| 62 | 62 | else |
| 63 | 63 | $step->setDisabled(); |
| 64 | 64 | } |
| 65 | - }else{ |
|
| 66 | - foreach ($this->content as $step){ |
|
| 65 | + } else { |
|
| 66 | + foreach ($this->content as $step) { |
|
| 67 | 67 | $step->removeStatus(); |
| 68 | 68 | } |
| 69 | - if($activestep<$count) |
|
| 69 | + if ($activestep<$count) |
|
| 70 | 70 | $this->content[$activestep]->setActive(); |
| 71 | 71 | } |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 76 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | 77 | $this->defineActiveStep(); |
| 78 | - return parent::compile($js,$view); |
|
| 78 | + return parent::compile($js, $view); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function setActiveStep($_activeStep) { |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | return $this; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
| 87 | - if(isset($toElement)){ |
|
| 88 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
| 86 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
| 87 | + if (isset($toElement)) { |
|
| 88 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 89 | 89 | } |
| 90 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
| 90 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function asLink(){ |
|
| 94 | - foreach ($this->content as $step){ |
|
| 93 | + public function asLink() { |
|
| 94 | + foreach ($this->content as $step) { |
|
| 95 | 95 | $step->asLink(); |
| 96 | 96 | } |
| 97 | 97 | return $this; |
@@ -55,26 +55,29 @@ |
||
| 55 | 55 | for($i=$this->_startStep;$i<$count;$i++){ |
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 59 | - $step->setCompleted(); |
|
| 60 | - elseif ($i===$activestep) |
|
| 61 | - $step->setActive(); |
|
| 62 | - else |
|
| 63 | - $step->setDisabled(); |
|
| 58 | + if($i<$activestep) { |
|
| 59 | + $step->setCompleted(); |
|
| 60 | + } elseif ($i===$activestep) { |
|
| 61 | + $step->setActive(); |
|
| 62 | + } else { |
|
| 63 | + $step->setDisabled(); |
|
| 64 | + } |
|
| 64 | 65 | } |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | foreach ($this->content as $step){ |
| 67 | 68 | $step->removeStatus(); |
| 68 | 69 | } |
| 69 | - if($activestep<$count) |
|
| 70 | - $this->content[$activestep]->setActive(); |
|
| 70 | + if($activestep<$count) { |
|
| 71 | + $this->content[$activestep]->setActive(); |
|
| 72 | + } |
|
| 71 | 73 | } |
| 72 | 74 | return $this; |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | - $this->defineActiveStep(); |
|
| 78 | + if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) { |
|
| 79 | + $this->defineActiveStep(); |
|
| 80 | + } |
|
| 78 | 81 | return parent::compile($js,$view); |
| 79 | 82 | } |
| 80 | 83 | |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | protected $image; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $content=NULL) { |
| 12 | - parent::__construct($identifier,"item",$content); |
|
| 12 | + parent::__construct($identifier, "item", $content); |
|
| 13 | 13 | } |
| 14 | - protected function initContent($content){ |
|
| 15 | - if(\is_array($content)){ |
|
| 16 | - if(JArray::isAssociative($content)===false){ |
|
| 14 | + protected function initContent($content) { |
|
| 15 | + if (\is_array($content)) { |
|
| 16 | + if (JArray::isAssociative($content)===false) { |
|
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else { |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -25,38 +25,38 @@ discard block |
||
| 25 | 25 | $desc=@$content["description"]; |
| 26 | 26 | $items=@$content["items"]; |
| 27 | 27 | } |
| 28 | - if(isset($icon)){ |
|
| 28 | + if (isset($icon)) { |
|
| 29 | 29 | $this->setIcon($icon); |
| 30 | 30 | } |
| 31 | - if(isset($image)){ |
|
| 31 | + if (isset($image)) { |
|
| 32 | 32 | $this->setImage($image); |
| 33 | 33 | } |
| 34 | - if(isset($title)){ |
|
| 35 | - $this->setTitle($title,$desc); |
|
| 36 | - }elseif (isset($header)){ |
|
| 37 | - $this->setTitle($header,$desc,"header"); |
|
| 34 | + if (isset($title)) { |
|
| 35 | + $this->setTitle($title, $desc); |
|
| 36 | + }elseif (isset($header)) { |
|
| 37 | + $this->setTitle($header, $desc, "header"); |
|
| 38 | 38 | } |
| 39 | - if(isset($items)){ |
|
| 39 | + if (isset($items)) { |
|
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else { |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - public function addList($items=array(),$ordered=false) { |
|
| 46 | + public function addList($items=array(), $ordered=false) { |
|
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 48 | + if ($ordered) |
|
| 49 | 49 | $list->setOrdered(); |
| 50 | 50 | $list->setClass("list"); |
| 51 | 51 | $this->content["list"]=$list; |
| 52 | 52 | return $list; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function getList(){ |
|
| 55 | + public function getList() { |
|
| 56 | 56 | return $this->content["list"]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function getItem($index){ |
|
| 59 | + public function getItem($index) { |
|
| 60 | 60 | return $this->getList()->getItem($index); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else{ |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -33,20 +33,21 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | if(isset($title)){ |
| 35 | 35 | $this->setTitle($title,$desc); |
| 36 | - }elseif (isset($header)){ |
|
| 36 | + } elseif (isset($header)){ |
|
| 37 | 37 | $this->setTitle($header,$desc,"header"); |
| 38 | 38 | } |
| 39 | 39 | if(isset($items)){ |
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | public function addList($items=array(),$ordered=false) { |
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 49 | - $list->setOrdered(); |
|
| 48 | + if($ordered) { |
|
| 49 | + $list->setOrdered(); |
|
| 50 | + } |
|
| 50 | 51 | $list->setClass("list"); |
| 51 | 52 | $this->content["list"]=$list; |
| 52 | 53 | return $list; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class HtmlPopup extends HtmlSemDoubleElement { |
| 13 | 13 | private $_container; |
| 14 | - public function __construct(BaseHtml $container,$identifier, $content="") { |
|
| 14 | + public function __construct(BaseHtml $container, $identifier, $content="") { |
|
| 15 | 15 | parent::__construct($identifier, "div"); |
| 16 | 16 | $this->_container=$container; |
| 17 | 17 | $this->setClass("ui popup"); |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | * {@inheritDoc} |
| 24 | 24 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::addList() |
| 25 | 25 | */ |
| 26 | - public function addList($items=array(),$header=NULL){ |
|
| 27 | - if(!$this->content instanceof HtmlGrid){ |
|
| 28 | - $this->content=new HtmlGrid("Grid-".$this->identifier,0); |
|
| 26 | + public function addList($items=array(), $header=NULL) { |
|
| 27 | + if (!$this->content instanceof HtmlGrid) { |
|
| 28 | + $this->content=new HtmlGrid("Grid-".$this->identifier, 0); |
|
| 29 | 29 | } |
| 30 | 30 | $grid=$this->content; |
| 31 | 31 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $colCount++; |
| 34 | 34 | $grid->setColsCount($colCount); |
| 35 | 35 | |
| 36 | - $list=new HtmlList("",$items); |
|
| 36 | + $list=new HtmlList("", $items); |
|
| 37 | 37 | $list->asLink(); |
| 38 | - if(isset($header)){ |
|
| 39 | - $list->addHeader(4,$header); |
|
| 38 | + if (isset($header)) { |
|
| 39 | + $list->addHeader(4, $header); |
|
| 40 | 40 | } |
| 41 | - $grid->getCell(0,$colCount-1)->setContent($list); |
|
| 41 | + $grid->getCell(0, $colCount-1)->setContent($list); |
|
| 42 | 42 | $grid->setDivided()->setRelaxed(true); |
| 43 | 43 | return $list; |
| 44 | 44 | } |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * A popup can have no maximum width and continue to flow to fit its content |
| 48 | 48 | */ |
| 49 | - public function setFlowing(){ |
|
| 49 | + public function setFlowing() { |
|
| 50 | 50 | return $this->addToProperty("class", "flowing"); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * A popup can provide more basic formatting |
| 55 | 55 | */ |
| 56 | - public function setBasic(){ |
|
| 56 | + public function setBasic() { |
|
| 57 | 57 | return $this->addToProperty("class", "basic"); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | * {@inheritDoc} |
| 62 | 62 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 63 | 63 | */ |
| 64 | - public function run(JsUtils $js){ |
|
| 64 | + public function run(JsUtils $js) { |
|
| 65 | 65 | parent::run($js); |
| 66 | 66 | $this->_params["popup"]="#".$this->identifier; |
| 67 | - $js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params); |
|
| 67 | + $js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setOn($event="click"){ |
|
| 70 | + public function setOn($event="click") { |
|
| 71 | 71 | $this->_params["on"]=$event; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setInline($value=true){ |
|
| 75 | + public function setInline($value=true) { |
|
| 76 | 76 | $this->_params["inline"]=$value; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setPosition($position){ |
|
| 80 | + public function setPosition($position) { |
|
| 81 | 81 | $this->_params["position"]=$position; |
| 82 | 82 | return $this; |
| 83 | 83 | } |
@@ -16,18 +16,18 @@ discard block |
||
| 16 | 16 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 17 | 17 | |
| 18 | 18 | abstract public function getUrl($url); |
| 19 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 19 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 20 | 20 | |
| 21 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 21 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 22 | 22 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 23 | 23 | $retour=$this->_getAjaxUrl($url, $attr); |
| 24 | 24 | $responseElement=$this->_getResponseElement($responseElement); |
| 25 | 25 | $retour.="var self=this;\n"; |
| 26 | - if($hasLoader===true){ |
|
| 26 | + if ($hasLoader===true) { |
|
| 27 | 27 | $this->addLoading($retour, $responseElement); |
| 28 | 28 | } |
| 29 | 29 | $retour.="$.".$method."(url,".self::_correctParams($params).").done(function( data ) {\n"; |
| 30 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 30 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 31 | 31 | if ($immediatly) |
| 32 | 32 | $this->jquery_code_for_compile[]=$retour; |
| 33 | 33 | return $retour; |
@@ -35,33 +35,33 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - protected function _getAjaxUrl($url,$attr){ |
|
| 38 | + protected function _getAjaxUrl($url, $attr) { |
|
| 39 | 39 | $url=$this->_correctAjaxUrl($url); |
| 40 | 40 | $retour="url='".$url."';"; |
| 41 | 41 | $slash="/"; |
| 42 | - if(JString::endswith($url, "/")===true) |
|
| 42 | + if (JString::endswith($url, "/")===true) |
|
| 43 | 43 | $slash=""; |
| 44 | - if(JString::isNotNull($attr)){ |
|
| 44 | + if (JString::isNotNull($attr)) { |
|
| 45 | 45 | if ($attr==="value") |
| 46 | 46 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 47 | 47 | elseif ($attr==="html") |
| 48 | 48 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 49 | - elseif($attr!==null && $attr!=="") |
|
| 49 | + elseif ($attr!==null && $attr!=="") |
|
| 50 | 50 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 51 | 51 | } |
| 52 | 52 | return $retour; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
| 56 | - $retour="";$call=null; |
|
| 55 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
| 56 | + $retour=""; $call=null; |
|
| 57 | 57 | if ($responseElement!=="") { |
| 58 | - if(isset($ajaxTransition)){ |
|
| 58 | + if (isset($ajaxTransition)) { |
|
| 59 | 59 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 60 | - }elseif(isset($this->ajaxTransition)){ |
|
| 60 | + }elseif (isset($this->ajaxTransition)) { |
|
| 61 | 61 | $call=$this->ajaxTransition; |
| 62 | 62 | } |
| 63 | - if(\is_callable($call)) |
|
| 64 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 63 | + if (\is_callable($call)) |
|
| 64 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 65 | 65 | else |
| 66 | 66 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
| 67 | 67 | } |
@@ -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=Javascript::prep_value($responseElement); |
| 75 | 75 | } |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | protected function _correctAjaxUrl($url) { |
| 80 | 80 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 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->getUrl($url); |
| 84 | 84 | } |
| 85 | 85 | return $url; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public static function _correctParams($params){ |
|
| 89 | - if(JString::isNull($params)){ |
|
| 88 | + public static function _correctParams($params) { |
|
| 89 | + if (JString::isNull($params)) { |
|
| 90 | 90 | return ""; |
| 91 | 91 | } |
| 92 | - if(\preg_match("@^\{.*?\}$@", $params)){ |
|
| 92 | + if (\preg_match("@^\{.*?\}$@", $params)) { |
|
| 93 | 93 | return '$.param('.$params.')'; |
| 94 | 94 | } |
| 95 | 95 | return $params; |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - protected function setAjaxDataCall($params){ |
|
| 110 | + protected function setAjaxDataCall($params) { |
|
| 111 | 111 | $result=null; |
| 112 | - if(!\is_callable($params)){ |
|
| 113 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
| 114 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
| 112 | + if (!\is_callable($params)) { |
|
| 113 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
| 114 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
| 115 | 115 | }; |
| 116 | 116 | } |
| 117 | 117 | return $result; |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 132 | 132 | * @param string|callable $ajaxTransition |
| 133 | 133 | */ |
| 134 | - private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 135 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 134 | + private function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 135 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 146 | 146 | * @param string|callable $ajaxTransition |
| 147 | 147 | */ |
| 148 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 149 | - return $this->_get($url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 148 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 149 | + return $this->_get($url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 161 | 161 | * @param string|callable $ajaxTransition |
| 162 | 162 | */ |
| 163 | - public function ajax($method,$url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 163 | + public function ajax($method, $url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 164 | 164 | $method=\strtolower($method); |
| 165 | - return $this->_ajax($method,$url,$params,$responseElement,$jsCallback,null,$hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 165 | + return $this->_ajax($method, $url, $params, $responseElement, $jsCallback, null, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param string $context |
| 176 | 176 | * @param boolean $immediatly |
| 177 | 177 | */ |
| 178 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 178 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 179 | 179 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 180 | 180 | $retour=$this->_getAjaxUrl($url, $attr); |
| 181 | 181 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | * @param string $context |
| 199 | 199 | * @param boolean $immediatly |
| 200 | 200 | */ |
| 201 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
| 202 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
| 201 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
| 202 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param string $url the request address |
| 210 | 210 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 211 | 211 | */ |
| 212 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 212 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 213 | 213 | $preventDefault=true; |
| 214 | 214 | $stopPropagation=true; |
| 215 | 215 | $jsCallback=null; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $params="{}"; |
| 220 | 220 | $immediatly=true; |
| 221 | 221 | extract($parameters); |
| 222 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 222 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | * @param string $jsCallback javascript code to execute after the request |
| 231 | 231 | * @param string $context jquery DOM element, array container. |
| 232 | 232 | */ |
| 233 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
| 234 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
| 233 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
| 234 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -244,22 +244,22 @@ discard block |
||
| 244 | 244 | * @param string $rowClass the css class for the new element |
| 245 | 245 | * @param boolean $immediatly |
| 246 | 246 | */ |
| 247 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
| 247 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
| 248 | 248 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 249 | 249 | $retour=$this->_getAjaxUrl($url, $attr); |
| 250 | - if($context===null){ |
|
| 250 | + if ($context===null) { |
|
| 251 | 251 | $parent="$('".$maskSelector."').parent()"; |
| 252 | - $newElm = "$('#'+newId)"; |
|
| 253 | - }else{ |
|
| 252 | + $newElm="$('#'+newId)"; |
|
| 253 | + } else { |
|
| 254 | 254 | $parent=$context; |
| 255 | - $newElm = $context.".find('#'+newId)"; |
|
| 255 | + $newElm=$context.".find('#'+newId)"; |
|
| 256 | 256 | } |
| 257 | 257 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
| 258 | 258 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 259 | 259 | $retour.=$parent.".find('._json').remove();"; |
| 260 | 260 | $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(); |
| 261 | 261 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 262 | - $retour.= $appendTo; |
|
| 262 | + $retour.=$appendTo; |
|
| 263 | 263 | $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"; |
| 264 | 264 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 265 | 265 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | * @param string $context jquery DOM element, array container. |
| 279 | 279 | * @param boolean $immediatly |
| 280 | 280 | */ |
| 281 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
| 282 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
| 281 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
| 282 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | * @param string $rowClass the css class for the new element |
| 293 | 293 | * @param string $context jquery DOM element, array container. |
| 294 | 294 | */ |
| 295 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
| 296 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
| 295 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
| 296 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | * @param string $url the request url |
| 304 | 304 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
| 305 | 305 | */ |
| 306 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 306 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 307 | 307 | $preventDefault=true; |
| 308 | 308 | $stopPropagation=true; |
| 309 | 309 | $jsCallback=null; |
| 310 | 310 | $attr="id"; |
| 311 | 311 | $method="get"; |
| 312 | - $context = null; |
|
| 312 | + $context=null; |
|
| 313 | 313 | $params="{}"; |
| 314 | 314 | $immediatly=true; |
| 315 | 315 | $rowClass="_json"; |
| 316 | 316 | extract($parameters); |
| 317 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 317 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 329 | 329 | * @param string|callable $ajaxTransition |
| 330 | 330 | */ |
| 331 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
| 332 | - return $this->_get($url, $params,$responseElement,$jsCallback,$attr,false,$jqueryDone,$ajaxTransition); |
|
| 331 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
| 332 | + return $this->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $ajaxTransition=null; |
| 353 | 353 | $params="{}"; |
| 354 | 354 | extract($parameters); |
| 355 | - return $this->_add_event($element, $this->_get($url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 355 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $ajaxTransition=null; |
| 377 | 377 | $params="{}"; |
| 378 | 378 | extract($parameters); |
| 379 | - return $this->_add_event($element, $this->_ajax($method,$url, $params,$responseElement,$jsCallback,$attr, $hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 379 | + return $this->_add_event($element, $this->_ajax($method, $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 407 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 406 | + private function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 407 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 418 | 418 | * @param string|callable $ajaxTransition |
| 419 | 419 | */ |
| 420 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 421 | - return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 420 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 421 | + return $this->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -433,8 +433,8 @@ discard block |
||
| 433 | 433 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 434 | 434 | * @param string|callable $ajaxTransition |
| 435 | 435 | */ |
| 436 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 437 | - return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 436 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 437 | + return $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | $jqueryDone="html"; |
| 458 | 458 | $ajaxTransition=null; |
| 459 | 459 | extract($parameters); |
| 460 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 460 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
@@ -473,20 +473,20 @@ discard block |
||
| 473 | 473 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - private function _postForm($url, $form, $responseElement, $params=null,$validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 476 | + private function _postForm($url, $form, $responseElement, $params=null, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 477 | 477 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 478 | 478 | $retour=$this->_getAjaxUrl($url, $attr); |
| 479 | 479 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 480 | - if(isset($params)){ |
|
| 480 | + if (isset($params)) { |
|
| 481 | 481 | $retour.="params+='&'+".self::_correctParams($params).";\n"; |
| 482 | 482 | } |
| 483 | 483 | $responseElement=$this->_getResponseElement($responseElement); |
| 484 | 484 | $retour.="var self=this;\n"; |
| 485 | - if($hasLoader===true){ |
|
| 485 | + if ($hasLoader===true) { |
|
| 486 | 486 | $this->addLoading($retour, $responseElement); |
| 487 | 487 | } |
| 488 | 488 | $retour.="$.post(url,params).done(function( data ) {\n"; |
| 489 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 489 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 490 | 490 | |
| 491 | 491 | if ($validation) { |
| 492 | 492 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -510,8 +510,8 @@ discard block |
||
| 510 | 510 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 511 | 511 | * @param string|callable $ajaxTransition |
| 512 | 512 | */ |
| 513 | - public function postForm($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 514 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 513 | + public function postForm($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 514 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -528,8 +528,8 @@ discard block |
||
| 528 | 528 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 529 | 529 | * @param string|callable $ajaxTransition |
| 530 | 530 | */ |
| 531 | - public function postFormDeferred($url, $form, $responseElement, $params=NULL,$validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 532 | - return $this->_postForm($url, $form, $responseElement, $params,$validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 531 | + public function postFormDeferred($url, $form, $responseElement, $params=NULL, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 532 | + return $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | $jqueryDone="html"; |
| 555 | 555 | $ajaxTransition=null; |
| 556 | 556 | extract($parameters); |
| 557 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement,$params, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 557 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $params, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | $retour.="$.".$method."(url,".self::_correctParams($params).").done(function( data ) {\n"; |
| 30 | 30 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
| 31 | - if ($immediatly) |
|
| 32 | - $this->jquery_code_for_compile[]=$retour; |
|
| 31 | + if ($immediatly) { |
|
| 32 | + $this->jquery_code_for_compile[]=$retour; |
|
| 33 | + } |
|
| 33 | 34 | return $retour; |
| 34 | 35 | } |
| 35 | 36 | |
@@ -39,15 +40,17 @@ discard block |
||
| 39 | 40 | $url=$this->_correctAjaxUrl($url); |
| 40 | 41 | $retour="url='".$url."';"; |
| 41 | 42 | $slash="/"; |
| 42 | - if(JString::endswith($url, "/")===true) |
|
| 43 | - $slash=""; |
|
| 43 | + if(JString::endswith($url, "/")===true) { |
|
| 44 | + $slash=""; |
|
| 45 | + } |
|
| 44 | 46 | if(JString::isNotNull($attr)){ |
| 45 | - if ($attr==="value") |
|
| 46 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 47 | - elseif ($attr==="html") |
|
| 48 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 49 | - elseif($attr!==null && $attr!=="") |
|
| 50 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 47 | + if ($attr==="value") { |
|
| 48 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 49 | + } elseif ($attr==="html") { |
|
| 50 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 51 | + } elseif($attr!==null && $attr!=="") { |
|
| 52 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 53 | + } |
|
| 51 | 54 | } |
| 52 | 55 | return $retour; |
| 53 | 56 | } |
@@ -57,13 +60,14 @@ discard block |
||
| 57 | 60 | if ($responseElement!=="") { |
| 58 | 61 | if(isset($ajaxTransition)){ |
| 59 | 62 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 60 | - }elseif(isset($this->ajaxTransition)){ |
|
| 63 | + } elseif(isset($this->ajaxTransition)){ |
|
| 61 | 64 | $call=$this->ajaxTransition; |
| 62 | 65 | } |
| 63 | - if(\is_callable($call)) |
|
| 64 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 65 | - else |
|
| 66 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 66 | + if(\is_callable($call)) { |
|
| 67 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 68 | + } else { |
|
| 69 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 70 | + } |
|
| 67 | 71 | } |
| 68 | 72 | $retour.="\t".$jsCallback."\n"; |
| 69 | 73 | return $retour; |
@@ -77,8 +81,9 @@ discard block |
||
| 77 | 81 | } |
| 78 | 82 | |
| 79 | 83 | protected function _correctAjaxUrl($url) { |
| 80 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 81 | - $url=substr($url, 0, strlen($url)-1); |
|
| 84 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 85 | + $url=substr($url, 0, strlen($url)-1); |
|
| 86 | + } |
|
| 82 | 87 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 83 | 88 | $url=$this->getUrl($url); |
| 84 | 89 | } |
@@ -184,8 +189,9 @@ discard block |
||
| 184 | 189 | $retour.="\t".$jsCallback."\n". |
| 185 | 190 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 186 | 191 | "});\n"; |
| 187 | - if ($immediatly) |
|
| 188 | - $this->jquery_code_for_compile[]=$retour; |
|
| 192 | + if ($immediatly) { |
|
| 193 | + $this->jquery_code_for_compile[]=$retour; |
|
| 194 | + } |
|
| 189 | 195 | return $retour; |
| 190 | 196 | } |
| 191 | 197 | |
@@ -250,7 +256,7 @@ discard block |
||
| 250 | 256 | if($context===null){ |
| 251 | 257 | $parent="$('".$maskSelector."').parent()"; |
| 252 | 258 | $newElm = "$('#'+newId)"; |
| 253 | - }else{ |
|
| 259 | + } else{ |
|
| 254 | 260 | $parent=$context; |
| 255 | 261 | $newElm = $context.".find('#'+newId)"; |
| 256 | 262 | } |
@@ -263,8 +269,9 @@ discard block |
||
| 263 | 269 | $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"; |
| 264 | 270 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 265 | 271 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 266 | - if ($immediatly) |
|
| 267 | - $this->jquery_code_for_compile[]=$retour; |
|
| 272 | + if ($immediatly) { |
|
| 273 | + $this->jquery_code_for_compile[]=$retour; |
|
| 274 | + } |
|
| 268 | 275 | return $retour; |
| 269 | 276 | } |
| 270 | 277 | |
@@ -494,8 +501,9 @@ discard block |
||
| 494 | 501 | }});\n"; |
| 495 | 502 | $retour.="$('#".$form."').submit();\n"; |
| 496 | 503 | } |
| 497 | - if ($immediatly) |
|
| 498 | - $this->jquery_code_for_compile[]=$retour; |
|
| 504 | + if ($immediatly) { |
|
| 505 | + $this->jquery_code_for_compile[]=$retour; |
|
| 506 | + } |
|
| 499 | 507 | return $retour; |
| 500 | 508 | } |
| 501 | 509 | |