1 | <?php |
||
14 | class HtmlButtonGroups extends HtmlSemCollection { |
||
15 | |||
16 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
||
17 | parent::__construct($identifier, "div", "ui buttons"); |
||
18 | if ($asIcons === true) |
||
19 | $this->asIcons(); |
||
20 | $this->addElements($elements, $asIcons); |
||
21 | } |
||
22 | protected function createItem($value){ |
||
23 | return new HtmlButton("button-" . $this->identifier . "-" . \sizeof($this->content), $value); |
||
24 | } |
||
25 | |||
26 | |||
27 | public function addElement($element, $asIcon=false) { |
||
28 | $item=$this->addItem($element); |
||
29 | if($asIcon) |
||
30 | $item->asIcon($element); |
||
31 | return $item; |
||
32 | } |
||
33 | |||
34 | public function addElements($elements, $asIcons=false) { |
||
35 | foreach ( $elements as $element ) { |
||
36 | $this->addElement($element, $asIcons); |
||
37 | } |
||
38 | return $this; |
||
39 | } |
||
40 | |||
41 | public function insertOr($aferIndex=0, $or="or") { |
||
42 | $orElement=new HtmlSemDoubleElement("or-" . $this->identifier, "div", "or"); |
||
43 | $orElement->setProperty("data-text", $or); |
||
44 | array_splice($this->content, $aferIndex + 1, 0, array ($orElement )); |
||
45 | return $this; |
||
46 | } |
||
47 | |||
48 | /* |
||
49 | * (non-PHPdoc) |
||
50 | * @see \Ajax\bootstrap\html\HtmlSingleElement::fromArray() |
||
51 | */ |
||
52 | public function fromArray($array) { |
||
53 | $this->addElements($array); |
||
54 | } |
||
55 | |||
56 | public function asIcons() { |
||
57 | foreach ( $this->content as $item ) { |
||
58 | if($item instanceof HtmlButton) |
||
59 | $item->asIcon($item->getContent()); |
||
60 | } |
||
61 | return $this->addToProperty("class", "icons"); |
||
62 | } |
||
63 | |||
64 | public function setVertical() { |
||
67 | |||
68 | public function setLabeled() { |
||
71 | |||
72 | /** |
||
73 | * Return the element at index |
||
74 | * @param int $index |
||
75 | * @return HtmlButton |
||
76 | */ |
||
77 | public function getElement($index) { |
||
78 | return $this->getItem($index); |
||
80 | |||
81 | public function setElement($index, $button) { |
||
85 | |||
86 | /* |
||
87 | * (non-PHPdoc) |
||
88 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
||
89 | */ |
||
90 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
||
96 | |||
97 | public function getElements() { |
||
100 | |||
101 | public function addClasses($classes=array()) { |
||
108 | |||
109 | /* |
||
110 | * (non-PHPdoc) |
||
111 | * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject() |
||
112 | */ |
||
113 | public function fromDatabaseObject($object, $function) { |
||
116 | } |