@@ -33,6 +33,10 @@ discard block |
||
| 33 | 33 | protected $_refreshSelector; |
| 34 | 34 | |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param string $identifier |
|
| 38 | + * @param string $model |
|
| 39 | + */ |
|
| 36 | 40 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 37 | 41 | parent::__construct($identifier, $model,$modelInstance); |
| 38 | 42 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -56,6 +60,9 @@ discard block |
||
| 56 | 60 | |
| 57 | 61 | |
| 58 | 62 | |
| 63 | + /** |
|
| 64 | + * @param string $op |
|
| 65 | + */ |
|
| 59 | 66 | protected function _generateBehavior($op,$params,JsUtils $js){ |
| 60 | 67 | if(isset($this->_urls[$op])){ |
| 61 | 68 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -185,6 +192,9 @@ discard block |
||
| 185 | 192 | return $this; |
| 186 | 193 | } |
| 187 | 194 | |
| 195 | + /** |
|
| 196 | + * @param PositionInTable $part |
|
| 197 | + */ |
|
| 188 | 198 | private function addToolbarRow($part,$table,$captions){ |
| 189 | 199 | $hasPart=$table->hasPart($part); |
| 190 | 200 | if($hasPart){ |
@@ -224,8 +234,8 @@ discard block |
||
| 224 | 234 | * Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
| 225 | 235 | * @param number $page the active page number |
| 226 | 236 | * @param number $total_rowcount the total number of items |
| 227 | - * @param number $items_per_page The number of items per page |
|
| 228 | - * @param number $pages_visibles The number of visible pages in the Pagination component |
|
| 237 | + * @param integer $items_per_page The number of items per page |
|
| 238 | + * @param integer $pages_visibles The number of visible pages in the Pagination component |
|
| 229 | 239 | * @return DataTable |
| 230 | 240 | */ |
| 231 | 241 | public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=4){ |
@@ -235,9 +245,9 @@ discard block |
||
| 235 | 245 | |
| 236 | 246 | /** |
| 237 | 247 | * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
| 238 | - * @param number $page the active page number |
|
| 239 | - * @param number $items_per_page The number of items per page |
|
| 240 | - * @param number $pages_visibles The number of visible pages in the Pagination component |
|
| 248 | + * @param integer $page the active page number |
|
| 249 | + * @param integer $items_per_page The number of items per page |
|
| 250 | + * @param integer $pages_visibles The number of visible pages in the Pagination component |
|
| 241 | 251 | * @return DataTable |
| 242 | 252 | */ |
| 243 | 253 | public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
@@ -303,6 +313,9 @@ discard block |
||
| 303 | 313 | return $this; |
| 304 | 314 | } |
| 305 | 315 | |
| 316 | + /** |
|
| 317 | + * @return string |
|
| 318 | + */ |
|
| 306 | 319 | public function getRefreshSelector() { |
| 307 | 320 | if(isset($this->_refreshSelector)) |
| 308 | 321 | return $this->_refreshSelector; |
@@ -47,10 +47,12 @@ discard block |
||
| 47 | 47 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 48 | 48 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 49 | 49 | } |
| 50 | - if(\is_array($this->_deleteBehavior)) |
|
| 51 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 52 | - if(\is_array($this->_editBehavior)) |
|
| 53 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 50 | + if(\is_array($this->_deleteBehavior)) { |
|
| 51 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 52 | + } |
|
| 53 | + if(\is_array($this->_editBehavior)) { |
|
| 54 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 55 | + } |
|
| 54 | 56 | return parent::run($js); |
| 55 | 57 | } |
| 56 | 58 | |
@@ -85,12 +87,14 @@ discard block |
||
| 85 | 87 | |
| 86 | 88 | $table->setRowCount(0, \sizeof($captions)); |
| 87 | 89 | $table->setHeaderValues($captions); |
| 88 | - if(isset($this->_compileParts)) |
|
| 89 | - $table->setCompileParts($this->_compileParts); |
|
| 90 | + if(isset($this->_compileParts)) { |
|
| 91 | + $table->setCompileParts($this->_compileParts); |
|
| 92 | + } |
|
| 90 | 93 | |
| 91 | 94 | if(isset($this->_searchField) && isset($js)){ |
| 92 | - if(isset($this->_urls["refresh"])) |
|
| 93 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 95 | + if(isset($this->_urls["refresh"])) { |
|
| 96 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 97 | + } |
|
| 94 | 98 | } |
| 95 | 99 | |
| 96 | 100 | $this->_generateContent($table); |
@@ -145,8 +149,9 @@ discard block |
||
| 145 | 149 | $menu->floatRight(); |
| 146 | 150 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 147 | 151 | $footer->setValues($menu); |
| 148 | - if(isset($this->_urls["refresh"])) |
|
| 149 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 152 | + if(isset($this->_urls["refresh"])) { |
|
| 153 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 154 | + } |
|
| 150 | 155 | } |
| 151 | 156 | |
| 152 | 157 | protected function _getFieldName($index){ |
@@ -189,7 +194,7 @@ discard block |
||
| 189 | 194 | $hasPart=$table->hasPart($part); |
| 190 | 195 | if($hasPart){ |
| 191 | 196 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 192 | - }else{ |
|
| 197 | + } else{ |
|
| 193 | 198 | $row=$table->getPart($part)->getRow(0); |
| 194 | 199 | } |
| 195 | 200 | $row->mergeCol(); |
@@ -214,7 +219,7 @@ discard block |
||
| 214 | 219 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
| 215 | 220 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
| 216 | 221 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
| 217 | - }else{ |
|
| 222 | + } else{ |
|
| 218 | 223 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
| 219 | 224 | } |
| 220 | 225 | return $this; |
@@ -288,8 +293,9 @@ discard block |
||
| 288 | 293 | |
| 289 | 294 | protected function getTargetSelector() { |
| 290 | 295 | $result=$this->_targetSelector; |
| 291 | - if(!isset($result)) |
|
| 292 | - $result="#".$this->identifier; |
|
| 296 | + if(!isset($result)) { |
|
| 297 | + $result="#".$this->identifier; |
|
| 298 | + } |
|
| 293 | 299 | return $result; |
| 294 | 300 | } |
| 295 | 301 | |
@@ -304,8 +310,9 @@ discard block |
||
| 304 | 310 | } |
| 305 | 311 | |
| 306 | 312 | public function getRefreshSelector() { |
| 307 | - if(isset($this->_refreshSelector)) |
|
| 308 | - return $this->_refreshSelector; |
|
| 313 | + if(isset($this->_refreshSelector)) { |
|
| 314 | + return $this->_refreshSelector; |
|
| 315 | + } |
|
| 309 | 316 | return "#".$this->identifier." tbody"; |
| 310 | 317 | } |
| 311 | 318 | |