Browse Source

Fixes #1820: Update Progress to use bootstrap 3 markup

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
e23eaaeda2
  1. 3
      extensions/yii/bootstrap/CHANGELOG.md
  2. 37
      extensions/yii/bootstrap/Progress.php

3
extensions/yii/bootstrap/CHANGELOG.md

@ -7,7 +7,8 @@ Yii Framework 2 bootstrap extension Change Log
- Enh #1474: Added option to make NavBar 100% width (cebe)
- Enh #1553: Only add navbar-default class to NavBar when no other class is specified (cebe)
- Enh #1601: Added support for tagName and encodeLabel parameters in ButtonDropdown (omnilight)
- Bug #1459: Update Collapse to use bootstrap 3 classes (tonydspaniard)
- Chg #1459: Update Collapse to use bootstrap 3 classes (tonydspaniard)
- Chg #1820: Update Progress to use bootstrap 3 markup (samdark)
2.0.0 alpha, December 1, 2013
-----------------------------

37
extensions/yii/bootstrap/Progress.php

@ -26,34 +26,35 @@ use yii\helpers\Html;
* // styled
* echo Progress::widget([
* 'percent' => 65,
* 'barOptions' => ['class' => 'bar-danger']
* 'barOptions' => ['class' => 'progress-bar-danger']
* ]);
*
* // striped
* echo Progress::widget([
* 'percent' => 70,
* 'barOptions' => ['class' => 'bar-warning'],
* 'barOptions' => ['class' => 'progress-bar-warning'],
* 'options' => ['class' => 'progress-striped']
* ]);
*
* // striped animated
* echo Progress::widget([
* 'percent' => 70,
* 'barOptions' => ['class' => 'bar-success'],
* 'barOptions' => ['class' => 'progress-bar-success'],
* 'options' => ['class' => 'active progress-striped']
* ]);
*
* // stacked bars
* echo Progress::widget([
* 'bars' => [
* ['percent' => 30, 'options' => ['class' => 'bar-danger']],
* ['percent' => 30, 'label' => 'test', 'options' => ['class' => 'bar-success']],
* ['percent' => 35, 'options' => ['class' => 'bar-warning']],
* ['percent' => 30, 'options' => ['class' => 'progress-bar-danger']],
* ['percent' => 30, 'label' => 'test', 'options' => ['class' => 'progress-bar-success']],
* ['percent' => 35, 'options' => ['class' => 'progress-bar-warning']],
* ]
* ]);
* ```
* @see http://twitter.github.io/bootstrap/components.html#progress
* @see http://getbootstrap.com/components/#progress
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Progress extends Widget
@ -67,7 +68,7 @@ class Progress extends Widget
*/
public $percent = 0;
/**
* @var array the HTML attributes of the
* @var array the HTML attributes of the bar
*/
public $barOptions = [];
/**
@ -139,8 +140,22 @@ class Progress extends Widget
*/
protected function renderBar($percent, $label = '', $options = [])
{
Html::addCssClass($options, 'bar');
$options['style'] = "width:{$percent}%";
return Html::tag('div', $label, $options);
$defaultOptions = [
'role' => 'progressbar',
'aria-valuenow' => $percent,
'aria-valuemin' => 0,
'aria-valuemax' => 100,
'style' => "width:{$percent}%",
];
$options = array_merge($defaultOptions, $options);
Html::addCssClass($options, 'progress-bar');
$out = Html::beginTag('div', $options);
$out .= $label;
$out .= Html::tag('span', \Yii::t('yii', '{percent}% Complete', ['percent' => $percent]), [
'class' => 'sr-only'
]);
$out .= Html::endTag('div');
return $out;
}
}

Loading…
Cancel
Save