1 | <?php |
||
2 | namespace Ajax\ui\components; |
||
3 | |||
4 | use Ajax\common\components\SimpleComponent; |
||
5 | use Ajax\JsUtils; |
||
6 | use Ajax\service\JString; |
||
7 | |||
8 | /** |
||
9 | * Composant JQuery UI Button |
||
10 | * |
||
11 | * @author jc |
||
12 | * @version 1.001 |
||
13 | */ |
||
14 | class Button extends SimpleComponent { |
||
15 | |||
16 | public function __construct(JsUtils $js) { |
||
17 | parent::__construct($js); |
||
18 | $this->uiName = "button"; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Disables the button if set to true. |
||
23 | * |
||
24 | * @param Boolean $value |
||
25 | * default : false |
||
26 | * @return $this |
||
27 | */ |
||
28 | public function setDisabled($value) { |
||
29 | return $this->setParamCtrl("disabled", $value, "is_bool"); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Icons to display, with or without text (see text option). |
||
34 | * By default, the primary icon is displayed on the left of the label text and the secondary is displayed on the right. |
||
35 | * The positioning can be controlled via CSS. |
||
36 | * The value for the primary and secondary properties must match an icon class name, e.g., "ui-icon-gear". |
||
37 | * For using only one icon: icons: { primary: "ui-icon-locked" }. For using two icons: icons: { primary: "ui-icon-gear", secondary: "ui-icon-triangle-1-s" }. |
||
38 | * |
||
39 | * @param String $value |
||
40 | * default : { primary: null, secondary: null } |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function setIcons($value) { |
||
44 | if (is_string($value)) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
45 | if (JString::startsWith($value, "{")); |
||
46 | $value = "%" . $value . "%"; |
||
47 | } |
||
48 | return $this->setParam("icons", $value); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Whether to show the label. |
||
53 | * When set to false no text will be displayed, but the icons option must be enabled, otherwise the text option will be ignored. |
||
54 | * |
||
55 | * @param Boolean $value |
||
56 | * default : false |
||
57 | * @return $this |
||
58 | */ |
||
59 | public function setText($value) { |
||
60 | return $this->setParamCtrl("text", $value, "is_bool"); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Text to show in the button. |
||
65 | * When not specified (null), the element's HTML content is used, or its value attribute if the element is an input element of type submit or reset, |
||
66 | * or the HTML content of the associated label element if the element is an input of type radio or checkbox. |
||
67 | * |
||
68 | * @param string $value |
||
69 | * default : null |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function setLabel($value) { |
||
73 | return $this->setParam("label", $value); |
||
74 | } |
||
75 | } |
||
76 |