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