@@ -37,6 +37,10 @@ discard block |
||
| 37 | 37 | protected $_targetSelector; |
| 38 | 38 | protected $_checkedMessage; |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $identifier |
|
| 42 | + * @param string $model |
|
| 43 | + */ |
|
| 40 | 44 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 41 | 45 | parent::__construct($identifier, $model,$modelInstance); |
| 42 | 46 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -76,6 +80,9 @@ discard block |
||
| 76 | 80 | if(allChecked) {\$parentCheckbox.checkbox('set checked');}else if(allUnchecked){\$parentCheckbox.checkbox('set unchecked');}else{\$parentCheckbox.checkbox('set indeterminate');};".$checkedMessageCall); |
| 77 | 81 | } |
| 78 | 82 | |
| 83 | + /** |
|
| 84 | + * @param string $op |
|
| 85 | + */ |
|
| 79 | 86 | protected function _generateBehavior($op,JsUtils $js){ |
| 80 | 87 | if(isset($this->_urls[$op])) |
| 81 | 88 | $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
@@ -211,6 +218,9 @@ discard block |
||
| 211 | 218 | return $this; |
| 212 | 219 | } |
| 213 | 220 | |
| 221 | + /** |
|
| 222 | + * @param PositionInTable $part |
|
| 223 | + */ |
|
| 214 | 224 | private function addToolbarRow($part,$table,$captions){ |
| 215 | 225 | $hasPart=$table->hasPart($part); |
| 216 | 226 | if($hasPart){ |
@@ -267,7 +277,7 @@ discard block |
||
| 267 | 277 | * @param string $caption |
| 268 | 278 | * @param callable $callback |
| 269 | 279 | * @param boolean $visibleHover |
| 270 | - * @return callable |
|
| 280 | + * @return \Closure |
|
| 271 | 281 | */ |
| 272 | 282 | private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
| 273 | 283 | return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
@@ -277,7 +287,7 @@ discard block |
||
| 277 | 287 | * @param callable $thisCallback |
| 278 | 288 | * @param array $parameters |
| 279 | 289 | * @param callable $callback |
| 280 | - * @return callable |
|
| 290 | + * @return \Closure |
|
| 281 | 291 | */ |
| 282 | 292 | private function getCallable($thisCallback,$parameters,$callback=null){ |
| 283 | 293 | $result=function($instance) use($thisCallback,$parameters,$callback){ |
@@ -346,11 +356,19 @@ discard block |
||
| 346 | 356 | return $this; |
| 347 | 357 | } |
| 348 | 358 | |
| 359 | + /** |
|
| 360 | + * @param string $icon |
|
| 361 | + * @param string $class |
|
| 362 | + */ |
|
| 349 | 363 | private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
| 350 | 364 | $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 351 | 365 | return $this; |
| 352 | 366 | } |
| 353 | 367 | |
| 368 | + /** |
|
| 369 | + * @param string $icon |
|
| 370 | + * @param string $class |
|
| 371 | + */ |
|
| 354 | 372 | private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
| 355 | 373 | $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
| 356 | 374 | return $this; |
@@ -437,6 +455,9 @@ discard block |
||
| 437 | 455 | }, $index,$attributes); |
| 438 | 456 | } |
| 439 | 457 | |
| 458 | + /** |
|
| 459 | + * @param HtmlButton $element |
|
| 460 | + */ |
|
| 440 | 461 | protected function _visibleOver($element){ |
| 441 | 462 | $this->_visibleHover=true; |
| 442 | 463 | return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
@@ -51,10 +51,12 @@ discard block |
||
| 51 | 51 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 52 | 52 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 53 | 53 | } |
| 54 | - if($this->_hasDelete) |
|
| 55 | - $this->_generateBehavior("delete", $js); |
|
| 56 | - if($this->_hasEdit) |
|
| 57 | - $this->_generateBehavior("edit", $js); |
|
| 54 | + if($this->_hasDelete) { |
|
| 55 | + $this->_generateBehavior("delete", $js); |
|
| 56 | + } |
|
| 57 | + if($this->_hasEdit) { |
|
| 58 | + $this->_generateBehavior("edit", $js); |
|
| 59 | + } |
|
| 58 | 60 | return parent::run($js); |
| 59 | 61 | } |
| 60 | 62 | |
@@ -77,8 +79,9 @@ discard block |
||
| 77 | 79 | } |
| 78 | 80 | |
| 79 | 81 | protected function _generateBehavior($op,JsUtils $js){ |
| 80 | - if(isset($this->_urls[$op])) |
|
| 81 | - $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
| 82 | + if(isset($this->_urls[$op])) { |
|
| 83 | + $js->getOnClick("#".$this->identifier." .".$op, $this->_urls[$op],$this->getTargetSelector(),["preventDefault"=>false,"attr"=>"data-ajax"]); |
|
| 84 | + } |
|
| 82 | 85 | } |
| 83 | 86 | |
| 84 | 87 | /** |
@@ -103,12 +106,14 @@ discard block |
||
| 103 | 106 | |
| 104 | 107 | $table->setRowCount(0, \sizeof($captions)); |
| 105 | 108 | $table->setHeaderValues($captions); |
| 106 | - if(isset($this->_compileParts)) |
|
| 107 | - $table->setCompileParts($this->_compileParts); |
|
| 109 | + if(isset($this->_compileParts)) { |
|
| 110 | + $table->setCompileParts($this->_compileParts); |
|
| 111 | + } |
|
| 108 | 112 | |
| 109 | 113 | if(isset($this->_searchField) && isset($js)){ |
| 110 | - if(isset($this->_urls["refresh"])) |
|
| 111 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 114 | + if(isset($this->_urls["refresh"])) { |
|
| 115 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 116 | + } |
|
| 112 | 117 | } |
| 113 | 118 | |
| 114 | 119 | $this->_generateContent($table); |
@@ -133,8 +138,9 @@ discard block |
||
| 133 | 138 | private function _generateMainCheckbox(&$captions){ |
| 134 | 139 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
| 135 | 140 | $checkedMessageCall=""; |
| 136 | - if($this->_hasCheckedMessage) |
|
| 137 | - $checkedMessageCall="updateChecked();"; |
|
| 141 | + if($this->_hasCheckedMessage) { |
|
| 142 | + $checkedMessageCall="updateChecked();"; |
|
| 143 | + } |
|
| 138 | 144 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall); |
| 139 | 145 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall); |
| 140 | 146 | \array_unshift($captions, $ck); |
@@ -171,8 +177,9 @@ discard block |
||
| 171 | 177 | $menu->floatRight(); |
| 172 | 178 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 173 | 179 | $footer->setValues($menu); |
| 174 | - if(isset($this->_urls["refresh"])) |
|
| 175 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 180 | + if(isset($this->_urls["refresh"])) { |
|
| 181 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 182 | + } |
|
| 176 | 183 | } |
| 177 | 184 | |
| 178 | 185 | protected function _getFieldName($index){ |
@@ -215,7 +222,7 @@ discard block |
||
| 215 | 222 | $hasPart=$table->hasPart($part); |
| 216 | 223 | if($hasPart){ |
| 217 | 224 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 218 | - }else{ |
|
| 225 | + } else{ |
|
| 219 | 226 | $row=$table->getPart($part)->getRow(0); |
| 220 | 227 | } |
| 221 | 228 | $row->mergeCol(); |
@@ -240,7 +247,7 @@ discard block |
||
| 240 | 247 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
| 241 | 248 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
| 242 | 249 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
| 243 | - }else{ |
|
| 250 | + } else{ |
|
| 244 | 251 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
| 245 | 252 | } |
| 246 | 253 | return $this; |
@@ -305,8 +312,9 @@ discard block |
||
| 305 | 312 | */ |
| 306 | 313 | private function getFieldButton($caption,$visibleHover=true){ |
| 307 | 314 | $bt= new HtmlButton("",$caption); |
| 308 | - if($visibleHover) |
|
| 309 | - $this->_visibleOver($bt); |
|
| 315 | + if($visibleHover) { |
|
| 316 | + $this->_visibleOver($bt); |
|
| 317 | + } |
|
| 310 | 318 | return $bt; |
| 311 | 319 | } |
| 312 | 320 | |
@@ -359,8 +367,9 @@ discard block |
||
| 359 | 367 | private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
| 360 | 368 | $bt=$this->getFieldButton("",$visibleHover); |
| 361 | 369 | $bt->asIcon($icon); |
| 362 | - if(isset($class)) |
|
| 363 | - $bt->addToProperty("class", $class); |
|
| 370 | + if(isset($class)) { |
|
| 371 | + $bt->addToProperty("class", $class); |
|
| 372 | + } |
|
| 364 | 373 | return $bt; |
| 365 | 374 | } |
| 366 | 375 | |
@@ -431,8 +440,9 @@ discard block |
||
| 431 | 440 | return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
| 432 | 441 | $button=new HtmlButton($id,$value,$cssStyle); |
| 433 | 442 | $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
| 434 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
| 435 | - $this->_visibleOver($button); |
|
| 443 | + if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) { |
|
| 444 | + $this->_visibleOver($button); |
|
| 445 | + } |
|
| 436 | 446 | return $button; |
| 437 | 447 | }, $index,$attributes); |
| 438 | 448 | } |
@@ -444,8 +454,9 @@ discard block |
||
| 444 | 454 | |
| 445 | 455 | protected function getTargetSelector() { |
| 446 | 456 | $result=$this->_targetSelector; |
| 447 | - if(!isset($result)) |
|
| 448 | - $result="#".$this->identifier; |
|
| 457 | + if(!isset($result)) { |
|
| 458 | + $result="#".$this->identifier; |
|
| 459 | + } |
|
| 449 | 460 | return $result; |
| 450 | 461 | } |
| 451 | 462 | |
@@ -483,8 +494,9 @@ discard block |
||
| 483 | 494 | * @param callable $callback |
| 484 | 495 | */ |
| 485 | 496 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
| 486 | - if(isset($checkedMessage)) |
|
| 487 | - $this->_checkedMessage=$checkedMessage; |
|
| 497 | + if(isset($checkedMessage)) { |
|
| 498 | + $this->_checkedMessage=$checkedMessage; |
|
| 499 | + } |
|
| 488 | 500 | $checkedMessage=$this->getCheckedMessage(); |
| 489 | 501 | $this->_hasCheckboxes=true; |
| 490 | 502 | $this->_hasCheckedMessage=true; |