phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlButton.php
Go to the documentation of this file.
1<?php
2
3namespace Ajax\bootstrap\html;
4
8
16
24 public function __construct($identifier, $value="", $cssStyle=null, $onClick=null) {
25 parent::__construct($identifier, "button");
26 $this->setProperty("class", "btn btn-default");
27 $this->setProperty("role", "button");
28 $this->content=$value;
29 if (isset($cssStyle)) {
30 $this->setStyle($cssStyle);
31 }
32 if (isset($onClick)) {
33 $this->onClick($onClick);
34 }
35 }
36
42 public function setValue($value) {
43 $this->content=$value;
44 return $this;
45 }
46
53 public function setStyle($cssStyle) {
54 return $this->addToPropertyCtrl("class", CssRef::getStyle($cssStyle, "btn"), CssRef::Styles("btn"));
55 }
56
63 public function setSize($size) {
64 if (is_int($size)) {
65 return $this->addToPropertyUnique("class", CssRef::sizes()[$size], CssRef::sizes());
66 }
67 return $this->addToPropertyCtrl("class", $size, CssRef::sizes());
68 }
69
74 public function setActive() {
75 return $this->addToPropertyCtrl("class", "active", array (
76 "active"
77 ));
78 }
79
84 public function setDisabled() {
85 return $this->addToPropertyCtrl("class", "disabled", array (
86 "disabled"
87 ));
88 }
89
90 public function setToggled() {
91 return $this->setProperty("data-toggle", "button");
92 }
93
94 /*
95 * (non-PHPdoc)
96 * @see BaseHtml::run()
97 */
98 public function run(JsUtils $js) {
99 $this->_bsComponent=$js->bootstrap()->generic("#".$this->identifier);
100 if (array_key_exists("data-toggle", $this->properties)) {
101 $this->_bsComponent->addCode("$.fn.toggled=function(){return this.hasClass('active');};");
102 }
103 $this->addEventsOnRun($js);
104 return $this->_bsComponent;
105 }
106
107
108
109 /*
110 * (non-PHPdoc)
111 * @see \Ajax\bootstrap\html\BaseHtml::fromArray()
112 */
113 public function fromArray($array) {
114 $array=parent::fromArray($array);
115 foreach ( $array as $key => $value ) {
116 $this->setProperty($key, $value);
117 }
118 return $array;
119 }
120}
JQuery PHP library.
Definition JsUtils.php:23
bootstrap(Bootstrap $bootstrap=NULL)
getter or setter of the Twitter Bootstrap variable
Definition JsUtils.php:140
Twitter Bootstrap Button component.
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()
setStyle($cssStyle)
define the button style avaible values : "btn-default","btn-primary","btn-success",...
setValue($value)
Set the button value.
setActive()
Sets the "active" css class to the button.
setSize($size)
define the button size available values : "btn-lg","","btn-sm","btn-xs"
__construct($identifier, $value="", $cssStyle=null, $onClick=null)
Constructs an HTML Bootstrap button.
setDisabled()
Disables the button.
Default HTML values for Twitter Bootstrap HTML components.
Definition CssRef.php:12
onClick($jsCode, $stopPropagation=false, $preventDefault=true)