-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathProgress.php
More file actions
76 lines (71 loc) · 1.97 KB
/
Copy pathProgress.php
File metadata and controls
76 lines (71 loc) · 1.97 KB
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
<?php namespace webmaxx\materialize;
use yii\helpers\Html;
/**
* Badge renders a materialize button.
*
* For example,
*
* ```php
* echo Progress::widget([
* 'percent' => 70,
* 'options' => ['class' => 'red'],
* ]);
* ```
* or
*
* ```php
* echo Progress::widget([
* 'determinate' => false,
* 'options' => ['class' => 'red'],
* ]);
* ```
* @see http://materializecss.com/preloader.html
* @author webmaxx <webmaxx@webmaxx.name>
* @since 2.0
*/
class Progress extends Widget
{
/**
* @var integer the percent of progress
*/
public $percent = 0;
/**
* @var bool the determinate or indeterminate progress
*/
public $determinate = true;
/**
* @var array the HTML attributes for the widget container tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $wrapOptions = [];
/**
* Initializes the widget.
* If you override this method, make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
$this->clientOptions = false;
Html::addCssClass($this->wrapOptions, 'progress');
if ($this->determinate)
Html::addCssClass($this->options, 'determinate');
else
Html::addCssClass($this->options, 'indeterminate');
if ($this->percent) {
if (!isset($this->options['style'])) {
$this->options['style'] = 'width: ' . $this->percent . '%';
} else {
$this->options['style'] = explode(';', trim($this->options['style'], ';'));
$this->options['style'][] = 'width: ' . $this->percent . '%;';
$this->options['style'] = implode(';', $this->options['style']);
}
}
}
/**
* Renders the widget.
*/
public function run()
{
return Html::tag('div', Html::tag('div', '', $this->options), $this->wrapOptions);
}
}