phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlButtonGroups.php
Go to the documentation of this file.
1<?php
2
4
9
18 protected $_dropdown;
19 public function __construct($identifier, $elements=array(), $asIcons=false) {
20 parent::__construct($identifier, "div", "ui buttons");
21 if ($asIcons === true)
22 $this->asIcons();
23 $this->addElements($elements, $asIcons);
24 }
25 protected function createItem($value){
26 return new HtmlButton("", $value);
27 }
28
34 public function addDropdown($items,$asCombo=false){
35 $dd= new HtmlDropdown("dd-".$this->identifier,null,$items);
36 $dd->asButton();
37 if($asCombo){
38 $dd->setAction("combo");
39 $dd->addToProperty("class", "combo");
40 }
41 $this->_dropdown=$dd;
42 return $this->addElement($dd);
43 }
44
45
51 public function addElement($element, $asIcon=false) {
52 $item=$this->addItem($element);
53 if($asIcon && $item instanceof HtmlButton)
54 $item->asIcon($element);
55 return $item;
56 }
57
58 public function addElements($elements, $asIcons=false) {
59 foreach ( $elements as $element ) {
60 $this->addElement($element, $asIcons);
61 }
62 return $this;
63 }
64
65 public function insertOr($aferIndex=0, $or="or") {
66 $orElement=new HtmlSemDoubleElement("", "div", "or");
67 $orElement->setProperty("data-text", $or);
68 array_splice($this->content, $aferIndex + 1, 0, array ($orElement ));
69 return $this;
70 }
71
72 /*
73 * (non-PHPdoc)
74 * @see \Ajax\bootstrap\html\HtmlSingleElement::fromArray()
75 */
76 public function fromArray($array) {
77 $this->addElements($array);
78 }
79
80 public function asIcons() {
81 foreach ( $this->content as $item ) {
82 if($item instanceof HtmlButton)
83 $item->asIcon($item->getContent());
84 }
85 return $this->addToProperty("class", "icons");
86 }
87
93 public function addIcons($icons){
94 foreach ( $this->content as $index=>$item ) {
95 if($item instanceof HtmlButton && isset($icons[$index]))
96 $item->addIcon($icons[$index]);
97 }
98 return $this;
99 }
100
101 public function setVertical() {
102 return $this->addToProperty("class", "vertical");
103 }
104
105 public function setLabeled() {
106 return $this->addToProperty("class", "labeled icon");
107 }
108
114 public function getElement($index) {
115 return parent::getItem($index);
116 }
117
121 public function getItem($index) {
122 return parent::getItem($index);
123 }
124
125 public function setElement($index, $button) {
126 $this->setItem($index, $button);
127 return $this;
128 }
129
130 /*
131 * (non-PHPdoc)
132 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
133 */
134 public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
135 foreach ( $this->content as $element ) {
136 $element->on($event, $jsCode, $stopPropagation, $preventDefault);
137 }
138 return $this;
139 }
140
141 public function getElements() {
142 return $this->content;
143 }
144
145 public function addClasses($classes=array()) {
146 $i=0;
147 if(!\is_array($classes)){
148 $classes=array_fill (0,$this->count(),$classes);
149 }
150 foreach ( $this->content as $button ) {
151 $button->addToProperty("class", $classes[$i++]);
152 }
153 return $this;
154 }
155
156 /*
157 * (non-PHPdoc)
158 * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
159 */
160 public function fromDatabaseObject($object, $function) {
161 $this->addElement($function($object));
162 }
163
164 public function run(JsUtils $js){
165 $result= parent::run($js);
166 return $result->setItemSelector(".ui.button");
167 }
168
169 public function getDropdown() {
170 return $this->_dropdown;
171 }
172
173}
JQuery PHP library.
Definition JsUtils.php:23
addItem($item)
adds and returns an item
Base class for Semantic Html collections.
Base class for Semantic double elements.
addToProperty($name, $value, $separator=" ")
Semantic UI Buttongroups component.
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\Bas...
getElement($index)
Return the element at index.
addIcons($icons)
Adds an icon on each button.
__construct($identifier, $elements=array(), $asIcons=false)
on($event, $jsCode, $stopPropagation=false, $preventDefault=false)
Semantic Button component.