|
1
|
|
|
<?php |
|
2
|
|
|
namespace Ajax\semantic\html\collections\table\traits; |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
use Ajax\JsUtils; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @author jc |
|
9
|
|
|
* @property HtmlTable $_self |
|
10
|
|
|
*/ |
|
11
|
|
|
trait TableTrait{ |
|
12
|
|
|
|
|
13
|
|
|
abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
|
14
|
|
|
abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
|
15
|
|
|
|
|
16
|
|
|
protected function addToPropertyTable($property,$value){ |
|
17
|
|
|
return $this->_self->addToProperty($property, $value); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function setCelled() { |
|
21
|
|
|
return $this->addToPropertyTable("class", "celled"); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function setBasic($very=false) { |
|
25
|
|
|
$table=$this->_self; |
|
26
|
|
|
if ($very) |
|
27
|
|
|
$table->addToPropertyCtrl("class", "very", array ("very" )); |
|
28
|
|
|
return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function setCompact($very=false) { |
|
32
|
|
|
$table=$this->_self; |
|
33
|
|
|
if ($very) |
|
34
|
|
|
$table->addToPropertyCtrl("class", "very", array ("very" )); |
|
35
|
|
|
return $table->addToPropertyCtrl("class", "compact", array ("compact" )); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function setCollapsing() { |
|
39
|
|
|
return $this->addToPropertyTable("class", "collapsing"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function setDefinition() { |
|
43
|
|
|
return $this->addToPropertyTable("class", "definition"); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function setStructured() { |
|
47
|
|
|
return $this->addToPropertyTable("class", "structured"); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function setSortable($colIndex=NULL) { |
|
51
|
|
|
$table=$this->_self; |
|
52
|
|
|
if (isset($colIndex) && $table->hasPart("thead")) { |
|
53
|
|
|
$table->getHeader()->sort($colIndex); |
|
54
|
|
|
} |
|
55
|
|
|
return $table->addToProperty("class", "sortable"); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function setSingleLine() { |
|
59
|
|
|
return $this->addToPropertyTable("class", "single line"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function setFixed() { |
|
63
|
|
|
return $this->addToPropertyTable("class", "fixed"); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function setSelectable() { |
|
67
|
|
|
return $this->addToPropertyTable("class", "selectable"); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function setStriped() { |
|
71
|
|
|
return $this->addToPropertyTable("class", "striped"); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false){ |
|
75
|
|
|
return $this->onRow("click", $jsCode,$stopPropagation,$preventDefault); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function onRow($event,$jsCode, $stopPropagation=false, $preventDefault=false){ |
|
79
|
|
|
return $this->_self->addEvent($event."{{tr}}",$jsCode,$stopPropagation,$preventDefault); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getOnRow($event, $url, $responseElement="", $parameters=array()){ |
|
83
|
|
|
$parameters=\array_merge($parameters,["stopPropagation"=>false,"preventDefault"=>false]); |
|
84
|
|
|
return $this->_self->getOn($event."{{tbody tr}}", $url,$responseElement,$parameters); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function onPageChange($jsCode){ |
|
88
|
|
|
$this->_self->_addEvent("pageChange", $jsCode); |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function onSearchTerminate($jsCode){ |
|
93
|
|
|
$this->_self->_addEvent("searchTerminate", $jsCode); |
|
94
|
|
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getEventsScript(){ |
|
98
|
|
|
return $this->_self->getBsComponent()->getScript(); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function addEventsOnRun(JsUtils $js=NULL) { |
|
102
|
|
|
$script=parent::addEventsOnRun($js); |
|
103
|
|
|
$innerScript=$this->_self->getInnerScript(); |
|
104
|
|
|
if(!isset($innerScript)){ |
|
105
|
|
|
$this->_self->setInnerScript($script); |
|
106
|
|
|
} |
|
107
|
|
|
return $script; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|