21 parent::__construct(
$identifier, $model, $modelInstance);
22 $this->_rowClass=
"_json _element";
27 parent::_generateContent($table);
31 $fields=$this->_instanceViewer->getSimpleProperties();
32 $row=$this->
_createRow($table, $this->_modelClass,$fields);
33 $row->setProperty(
"style",
"display:none;");
34 $table->getBody()->_addRow($row);
38 $object=JReflection::jsonObject($this->_model);
39 if(isset($this->_rowModelCallback)){
43 $row=$this->
_generateRow($object, $fields,$table,
"_jsonArrayChecked");
44 $row->setClass($rowClass.
" _element");
54 $menu=$this->_pagination->getMenu();
58 $callback=$js->getScript($offset).$this->getHtmlComponent()->getInnerScript();
59 $callback.=$js->trigger(
"#".$id.
" [name='selection[]']",
"change",
false).
"$('#".$id.
" tbody .ui.checkbox').checkbox();".$js->execOn(
"change",
"#".$id.
" [name='selection[]']", $this->_getCheckedChange($js));
61 if(isset($this->_urls[
"refresh"])){
63 $js->jsonArrayOn(
"click",
"#".$menu->getIdentifier().
" a",
"#".$this->_identifier.
" tr.".$this->_modelClass, $this->_urls[
"refresh"],
"post",[
"params"=>
"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model).
"'}",
"jsCallback"=>$callback]);
70 return ";var page=parseInt($(self).attr('data-page')) || 1;var pages_visibles=$('#pagination-{$id} .item').length-2;
71 var lastPage=$('#pagination-{$id} ._lastPage');
72 var middle= Math.ceil((pages_visibles-1)/ 2);
73 var first=Math.max(1,page-middle);var max=lastPage.attr('data-max');
74 var last=Math.min(max,first+pages_visibles-1);
75 if(last-pages_visibles+1>=0)
76 first=Math.min(first,last-pages_visibles+1);
78 $('#pagination-{$id} .item.pageNum').each(function(){
79 $(this).attr('data-page',number);
83 $('#pagination-{$id} .item').removeClass('active');
84 $('#pagination-{$id} [data-page='+page+']:not(.no-active)').addClass('active');
85 $('#pagination-{$id} ._firstPage').attr('data-page',Math.max(1,page-1));
86 lastPage.attr('data-page',Math.min(lastPage.attr('data-max'),page+1));
87 $('#{$id}').trigger('pageChange');$('#{$id}').trigger('activeRowChange');$('#pagination-{$id}').show();";
93 if(isset($this->_searchField) && isset($js) && isset($this->_urls[
"refresh"])){
95 $callback=$js->getScript($offset).$this->getHtmlComponent()->getInnerScript();
96 $callback.=$js->trigger(
"#".$id.
" [name='selection[]']",
"change",
false).
"$('#".$id.
" tbody .ui.checkbox').checkbox();".$js->execOn(
"change",
"#".$id.
" [name='selection[]']", $this->_getCheckedChange($js));
97 $callback.=
"$('#pagination-{$id}').hide();$('#".$this->identifier.
"').trigger('searchTerminate',[$(self).val()]);";
98 $js->jsonArrayOn(
"change",
"#".$this->_searchField->getDataField()->getIdentifier(),
"#".$this->_identifier.
" tr.".$this->_modelClass, $this->_urls[
"refresh"],
"post",[
"params"=>
"{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model).
"'}",
"jsCallback"=>$callback]);
112 public function jsJsonArray($url, $method=
"get", $params=
"{}", $jsCallback=NULL,$parameters=[]){
113 $parameters=\array_merge($parameters,[
"modelSelector"=>
"#".$this->_identifier.
" tr.".$this->_modelClass,
"url"=>$url,
"method"=>$method,
"params"=>$params,
"jsCallback"=>$jsCallback]);
114 return new AjaxCall(
"jsonArray", $parameters);
118 return "$('#{$this->identifier} tbody').find('._json').remove();";
121 public function clearOn(
BaseHtml $element,$event, $stopPropagation=
false, $preventDefault=
false){
122 return $element->
addEvent($event, $this->
jsClear(),$stopPropagation,$preventDefault);
126 return $this->
clearOn($element,
"click",$stopPropagation,$preventDefault);
129 public function jsonArrayOn(
BaseHtml $element,$event,$url, $method=
"get", $params=
"{}", $jsCallback=NULL,$parameters=[]){
130 return $element->
_addEvent($event, $this->
jsJsonArray($url,$method,$params,$jsCallback,$parameters));
134 return $this->
jsonArrayOn($element,
"click", $url,$method,$params,$jsCallback,$parameters);
145 public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=
null){
146 return parent::paginate($page, $total_rowcount,$items_per_page,$pages_visibles);
BaseHtml for HTML components.
addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false)
_addEvent($event, $jsCode)