28 parent::__construct(
$identifier,
"", $cssStyle, $onClick);
29 $this->_template=include
'templates/tplDropdown.php';
30 $this->btnCaption=$value;
33 if ($cssStyle!==NULL) {
43 $this->mTagName=$value;
53 if (is_int($cssStyle)) {
54 return $this->
addToMember($this->
class, CssRef::buttonStyles()[$cssStyle]);
56 if (JString::startsWith($cssStyle,
"btn-")===
false) {
57 $cssStyle=
"btn".$cssStyle;
59 return $this->
addToMemberCtrl($this->
class, $cssStyle, CssRef::buttonStyles());
67 $this->btnCaption=$value;
79 return $this->
addToProperty(
"class", CssRef::sizes(
"btn-group")[$size]);
90 public function addItem($caption, $href=
"#") {
96 $item->setCaption($caption)->setHref($href);
98 $this->items []=$item;
107 return $this->
addItem(
"-".$caption);
113 foreach (
$items as $item ) {
114 if (is_string($item)) {
116 }
else if (\is_array($item)) {
117 $dropDownItem=
new HtmlDropdownItem($this->identifier.
"-dropdown-item-".$iid);
118 $dropDownItem->fromArray($item);
119 $this->items []=$dropDownItem;
121 $this->items []=$item;
133 if (array_keys($array)!==range(0, count($array)-1))
134 return parent::fromArray($array);
140 $this->items=array ();
150 return $this->items [$index];
158 $this->mClass=$value;
175 foreach ( $this->items as $dropdownItem ) {
176 $dropdownItem->runNav($js);
179 $this->_bsComponent=$js->
bootstrap()->dropdown(
"#".$this->identifier);
190 $this->
class=
"btn dropdown-toggle";
191 return parent::setTagName(
$tagName);
208 if (is_int($alignment))
209 $alignment=
"dropdown-menu-".CssRef::alignment()[$alignment];
210 return $this->
addToMemberCtrl($this->
class, $alignment, CssRef::alignment());
221 public function asButton($cssStyle=
"btn-primary") {
233 return $this->
addEvent(
"show.bs.dropdown", $jsCode);
242 return $this->
addEvent(
"shown.bs.dropdown", $jsCode);
251 return $this->
addEvent(
"hide.bs.dropdown", $jsCode);
260 return $this->
addEvent(
"hidden.bs.dropdown", $jsCode);
267 public function on($event, $jsCode, $stopPropagation =
false, $preventDefault =
false) {
268 foreach ($this->items as $item){
269 $item->on($event, $jsCode,$stopPropagation,$preventDefault);
277 $this->
addItem($function($object));
bootstrap(Bootstrap $bootstrap=NULL)
getter or setter of the Twitter Bootstrap variable
Twitter Bootstrap HTML Dropdown component.
__construct($identifier, $value="", $items=array(), $cssStyle=null, $onClick=null)
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\Bas...
setBtnCaption($btnCaption)
setStyle($cssStyle)
define the button style avaible values : "btn-default","btn-primary","btn-success",...
onShow($jsCode)
This event fires immediately when the show instance method is called.
setMTagName($value)
Define the tagName of the main element.
setValue($value)
Set the button value.
addItem($caption, $href="#")
add an HtmlDropdownItem
getItem($index)
Return the item at $index.
setSize($size)
define the buttons size available values : "btn-group-lg","","btn-group-sm","btn-group-xs"
onHide($jsCode)
This event is fired immediately when the hide method has been called.
asButton($cssStyle="btn-primary")
onHidden($jsCode)
This event is fired when a dropdown element has been hidden from the user (will wait for CSS transiti...
on($event, $jsCode, $stopPropagation=false, $preventDefault=false)
onShown($jsCode)
This event is fired when a dropdown element has been made visible to the user (will wait for CSS tran...
setTagName($tagName)
Sets the tagName's dropdown.
fromDatabaseObject($object, $function)
Default HTML values for Twitter Bootstrap HTML components.
Inner element for Twitter Bootstrap HTML Dropdown component.
BaseHtml for HTML components.
addToMember(&$name, $value, $separator=' ')
compile(JsUtils $js=NULL, &$view=NULL)
addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ")
addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false)
addEventsOnRun(JsUtils $js=NULL)
addToProperty($name, $value, $separator=" ")
addToPropertyCtrl($name, $value, $typeCtrl)