-
Notifications
You must be signed in to change notification settings - Fork 1
/
ActiveToolbarButton.php
52 lines (43 loc) · 1.26 KB
/
ActiveToolbarButton.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
<?php
namespace pipekung\widgets;
use Yii;
use yii\helpers\Html;
/**
* Description of ActiveToolbarButton
*
* For example:
*
* echo ActiveToolbarButton::widget();
* ```
*
* @author Pipekung Specialz <chanja@kku.ac.th>
* @since 2.0
*/
class ActiveToolbarButton extends Widget {
public function init() {
parent::init();
$this->options['class'] = 'btn-group';
$this->options['style'] = 'margin-bottom: 20px;';
}
public function run() {
echo Html::beginTag('div', $this->options) . "\n";
echo $this->renderItems() . "\n";
echo Html::endTag('div') . "\n";
$this->registerScript();
}
public function renderItems() {
$items = [
Html::a('<i class="glyphicon glyphicon-plus-sign"></i> ' . 'Create', ['create'], ['class' => 'btn btn-success']),
Html::button('<i class="glyphicon glyphicon-search"></i> Search', ['type' => 'button', 'class' => 'btn btn-default']),
];
return implode("\n", $items);
}
public function registerScript() {
$id = $this->options['id'];
Yii::$app->view->registerJs("
$(document).on('click', 'div#$id button', function() {
$('.search').toggle('fade');
});
");
}
}