@@ -17,6 +17,7 @@ class Button extends Input
17
17
private $ domId ;
18
18
private $ title ;
19
19
private $ trigger ;
20
+ private $ color ;
20
21
21
22
public function __construct (string $ title )
22
23
{
@@ -28,7 +29,7 @@ public function __construct(string $title)
28
29
* @param array $xhr
29
30
* @param string $formSelector
30
31
*/
31
- public function bindRequest ($ xhr = ['url ' =>'' ,'method ' =>'' ,'data ' =>[],'callback ' =>'null ' ],$ formSelector = '' )
32
+ public function bindRequest (array $ xhr = ['url ' =>'' ,'method ' =>'' ,'data ' =>[],'callback ' =>'null ' ],$ formSelector = '' )
32
33
{
33
34
$ xhr = array_merge (['url ' =>'' ,'method ' =>'' ,'data ' =>[],'callback ' =>'null ' ],$ xhr );
34
35
$ data = json_encode ($ xhr ['data ' ]);
@@ -94,11 +95,36 @@ public function bindDialog(\Closure $closure,array $xhr = ['url' => '', 'method'
94
95
return $ this ;
95
96
}
96
97
98
+ /**
99
+ * @param string $color red blue green yellow
100
+ * @return $this
101
+ */
102
+ public function color (string $ color )
103
+ {
104
+ switch ($ color ){
105
+ case 'red ' :
106
+ $ this ->color = '-red ' ;
107
+ break ;
108
+ case 'blue ' :
109
+ $ this ->color = '-blue ' ;
110
+ break ;
111
+ case 'green ' :
112
+ $ this ->color = '-green ' ;
113
+ break ;
114
+ case 'yellow ' :
115
+ $ this ->color = '-yellow ' ;
116
+ break ;
117
+ default :
118
+ $ this ->color = '' ;
119
+ }
120
+ return $ this ;
121
+ }
122
+
97
123
public function __toString ()
98
124
{
99
125
$ this ->annotate ();
100
126
$ content = <<<EOF
101
- <button type=" {$ this ->type }" id=" {$ this ->domId }" class="dlp dlp-button" {$ this ->annotation }> {$ this ->title }</button>
127
+ <button type=" {$ this ->type }" id=" {$ this ->domId }" class="dlp dlp-button { $ this -> color } " {$ this ->annotation }> {$ this ->title }</button>
102
128
<script> {$ this ->trigger }</script>
103
129
EOF ;
104
130
return $ content ;
0 commit comments