-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathButtonDropdown.php
87 lines (77 loc) · 2.28 KB
/
ButtonDropdown.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
declare(strict_types=1);
/**
* This file is part of the EaseTWBootstrap3 package
*
* https://github.com/VitexSoftware/php-ease-twbootstrap
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ease\TWB;
class ButtonDropdown extends \Ease\Html\DivTag
{
/**
* Rozbalovací nabídka.
*/
public \Ease\Html\UlTag $dropdown;
public \Ease\Html\ButtonTag $button;
/**
* Tlačítko s rozbalovacím menu.
*
* @param string $label popisek tlačítka
* @param string $type primary|info|success|warning|danger|inverse|link
* @param string $size lg = velký, sm = menší, xs = nejmenší
* @param array<string, string> $items položky menu
* @param array<string, string> $properties Parametry tagu
*/
public function __construct(
$label = null,
$type = 'default',
$size = null,
$items = null,
$properties = []
) {
parent::__construct(null, $properties);
$this->setTagClass('btn-group');
$btnClass = 'btn btn-'.$type.' ';
if (!empty($size)) {
$btnClass .= 'btn-'.$size;
}
$this->button = $this->addItem(new \Ease\Html\ButtonTag(
[$label.' <span class="caret"></span>'],
['class' => $btnClass.' dropdown-toggle', 'type' => 'button', 'data-toggle' => 'dropdown'],
));
$this->dropdown = $this->addItem(new \Ease\Html\UlTag(
null,
['class' => 'dropdown-menu', 'role' => 'menu'],
));
if (\count($items)) {
foreach ($items as $item) {
$this->addMenuItem($item);
}
}
}
/**
* Vloží položku do menu tlačítka.
*
* @param type $pageItem
*
* @return \Ease\Html\LiTag
*/
public function addMenuItem($pageItem)
{
return $this->dropdown->addItemSmart($pageItem);
}
/**
* delící čára menu.
*
* @return \Ease\Html\LiTag
*/
public static function divider()
{
return new \Ease\Html\LiTag(null, ['class' => 'divider']);
}
}