commit
0508a4bbad
25 changed files with 11333 additions and 0 deletions
@ -0,0 +1,149 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use Yii; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Alert renders an alert bootstrap component. |
||||
* |
||||
* For example, |
||||
* |
||||
* ```php |
||||
* echo Alert::widget([ |
||||
* 'body' => 'Say hello...', |
||||
* 'closeButton' => [ |
||||
* 'label' => '×', |
||||
* 'tag' => 'a', |
||||
* ], |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* The following example will show the content enclosed between the [[begin()]] |
||||
* and [[end()]] calls within the alert box: |
||||
* |
||||
* ```php |
||||
* Alert::begin([ |
||||
* 'closeButton' => ['label' => '×'], |
||||
* ]); |
||||
* |
||||
* echo 'Say hello...'; |
||||
* |
||||
* Alert::end(); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#alerts |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Alert extends Widget |
||||
{ |
||||
/** |
||||
* @var string the body content in the alert component. Note that anything between |
||||
* the [[begin()]] and [[end()]] calls of the Alert widget will also be treated |
||||
* as the body content, and will be rendered before this. |
||||
*/ |
||||
public $body; |
||||
/** |
||||
* @var array the options for rendering the close button tag. |
||||
* The close button is displayed in the header of the modal window. Clicking |
||||
* on the button will hide the modal window. If this is null, no close button will be rendered. |
||||
* |
||||
* The following special options are supported: |
||||
* |
||||
* - tag: string, the tag name of the button. Defaults to 'button'. |
||||
* - label: string, the label of the button. Defaults to '×'. |
||||
* |
||||
* The rest of the options will be rendered as the HTML attributes of the button tag. |
||||
* Please refer to the [Alert plugin help](http://twitter.github.com/bootstrap/javascript.html#alerts) |
||||
* for the supported HTML attributes. |
||||
*/ |
||||
public $closeButton = []; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->initOptions(); |
||||
|
||||
echo Html::beginTag('div', $this->options) . "\n"; |
||||
echo $this->renderBodyBegin() . "\n"; |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo "\n" . $this->renderBodyEnd(); |
||||
echo "\n" . Html::endTag('div'); |
||||
|
||||
$this->registerPlugin('alert'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the close button if any before rendering the content. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderBodyBegin() |
||||
{ |
||||
return $this->renderCloseButton(); |
||||
} |
||||
|
||||
/** |
||||
* Renders the alert body (if any). |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderBodyEnd() |
||||
{ |
||||
return $this->body . "\n"; |
||||
} |
||||
|
||||
/** |
||||
* Renders the close button. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderCloseButton() |
||||
{ |
||||
if ($this->closeButton !== null) { |
||||
$tag = ArrayHelper::remove($this->closeButton, 'tag', 'button'); |
||||
$label = ArrayHelper::remove($this->closeButton, 'label', '×'); |
||||
if ($tag === 'button' && !isset($this->closeButton['type'])) { |
||||
$this->closeButton['type'] = 'button'; |
||||
} |
||||
return Html::tag($tag, $label, $this->closeButton); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Initializes the widget options. |
||||
* This method sets the default values for various options. |
||||
*/ |
||||
protected function initOptions() |
||||
{ |
||||
$this->options = array_merge(['class' => 'fade in'], $this->options); |
||||
|
||||
Html::addCssClass($this->options, 'alert'); |
||||
|
||||
if ($this->closeButton !== null) { |
||||
$this->closeButton = array_merge([ |
||||
'data-dismiss' => 'alert', |
||||
'aria-hidden' => 'true', |
||||
'class' => 'close', |
||||
], $this->closeButton); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\web\AssetBundle; |
||||
|
||||
/** |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class BootstrapAsset extends AssetBundle |
||||
{ |
||||
public $sourcePath = '@yii/bootstrap/assets'; |
||||
public $css = [ |
||||
'css/bootstrap.css', |
||||
]; |
||||
} |
||||
@ -0,0 +1,27 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\web\AssetBundle; |
||||
|
||||
/** |
||||
* |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class BootstrapPluginAsset extends AssetBundle |
||||
{ |
||||
public $sourcePath = '@yii/bootstrap/assets'; |
||||
public $js = [ |
||||
'js/bootstrap.js', |
||||
]; |
||||
public $depends = [ |
||||
'yii\web\JqueryAsset', |
||||
'yii\bootstrap\BootstrapAsset', |
||||
]; |
||||
} |
||||
@ -0,0 +1,27 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\web\AssetBundle; |
||||
|
||||
/** |
||||
* Bootstrap 2 theme for Bootstrap 3 |
||||
* |
||||
* @author Alexander Makarov <sam@rmcreative.ru> |
||||
* @since 2.0 |
||||
*/ |
||||
class BootstrapThemeAsset extends AssetBundle |
||||
{ |
||||
public $sourcePath = '@yii/bootstrap/assets'; |
||||
public $css = [ |
||||
'css/bootstrap-theme.css', |
||||
]; |
||||
public $depends = [ |
||||
'yii\bootstrap\BootstrapAsset', |
||||
]; |
||||
} |
||||
@ -0,0 +1,62 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Button renders a bootstrap button. |
||||
* |
||||
* For example, |
||||
* |
||||
* ```php |
||||
* echo Button::widget([ |
||||
* 'label' => 'Action', |
||||
* 'options' => ['class' => 'btn-lg'], |
||||
* ]); |
||||
* ``` |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#buttons |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Button extends Widget |
||||
{ |
||||
/** |
||||
* @var string the tag to use to render the button |
||||
*/ |
||||
public $tagName = 'button'; |
||||
/** |
||||
* @var string the button label |
||||
*/ |
||||
public $label = 'Button'; |
||||
/** |
||||
* @var boolean whether the label should be HTML-encoded. |
||||
*/ |
||||
public $encodeLabel = true; |
||||
|
||||
|
||||
/** |
||||
* 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->options, 'btn'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo Html::tag($this->tagName, $this->encodeLabel ? Html::encode($this->label) : $this->label, $this->options); |
||||
$this->registerPlugin('button'); |
||||
} |
||||
} |
||||
@ -0,0 +1,109 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* ButtonDropdown renders a group or split button dropdown bootstrap component. |
||||
* |
||||
* For example, |
||||
* |
||||
* ```php |
||||
* // a button group using Dropdown widget |
||||
* echo ButtonDropdown::widget([ |
||||
* 'label' => 'Action', |
||||
* 'dropdown' => [ |
||||
* 'items' => [ |
||||
* ['label' => 'DropdownA', 'url' => '/'], |
||||
* ['label' => 'DropdownB', 'url' => '#'], |
||||
* ], |
||||
* ], |
||||
* ]); |
||||
* ``` |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#buttons |
||||
* @see http://twitter.github.io/bootstrap/components.html#buttonDropdowns |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class ButtonDropdown extends Widget |
||||
{ |
||||
/** |
||||
* @var string the button label |
||||
*/ |
||||
public $label = 'Button'; |
||||
/** |
||||
* @var array the HTML attributes of the button. |
||||
*/ |
||||
public $options = []; |
||||
/** |
||||
* @var array the configuration array for [[Dropdown]]. |
||||
*/ |
||||
public $dropdown = []; |
||||
/** |
||||
* @var boolean whether to display a group of split-styled button group. |
||||
*/ |
||||
public $split = false; |
||||
|
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo $this->renderButton() . "\n" . $this->renderDropdown(); |
||||
$this->registerPlugin('button'); |
||||
} |
||||
|
||||
/** |
||||
* Generates the button dropdown. |
||||
* @return string the rendering result. |
||||
*/ |
||||
protected function renderButton() |
||||
{ |
||||
Html::addCssClass($this->options, 'btn'); |
||||
if ($this->split) { |
||||
$tag = 'button'; |
||||
$options = $this->options; |
||||
$this->options['data-toggle'] = 'dropdown'; |
||||
Html::addCssClass($this->options, 'dropdown-toggle'); |
||||
$splitButton = Button::widget([ |
||||
'label' => '<span class="caret"></span>', |
||||
'encodeLabel' => false, |
||||
'options' => $this->options, |
||||
]); |
||||
} else { |
||||
$tag = 'a'; |
||||
$this->label .= ' <span class="caret"></span>'; |
||||
$options = $this->options; |
||||
if (!isset($options['href'])) { |
||||
$options['href'] = '#'; |
||||
} |
||||
Html::addCssClass($options, 'dropdown-toggle'); |
||||
$options['data-toggle'] = 'dropdown'; |
||||
$splitButton = ''; |
||||
} |
||||
return Button::widget([ |
||||
'tagName' => $tag, |
||||
'label' => $this->label, |
||||
'options' => $options, |
||||
'encodeLabel' => false, |
||||
]) . "\n" . $splitButton; |
||||
} |
||||
|
||||
/** |
||||
* Generates the dropdown menu. |
||||
* @return string the rendering result. |
||||
*/ |
||||
protected function renderDropdown() |
||||
{ |
||||
$config = $this->dropdown; |
||||
$config['clientOptions'] = false; |
||||
return Dropdown::widget($config); |
||||
} |
||||
} |
||||
@ -0,0 +1,97 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* ButtonGroup renders a button group bootstrap component. |
||||
* |
||||
* For example, |
||||
* |
||||
* ```php |
||||
* // a button group with items configuration |
||||
* echo ButtonGroup::widget([ |
||||
* 'buttons' => [ |
||||
* ['label' => 'A'], |
||||
* ['label' => 'B'], |
||||
* ] |
||||
* ]); |
||||
* |
||||
* // button group with an item as a string |
||||
* echo ButtonGroup::widget([ |
||||
* 'buttons' => [ |
||||
* Button::widget(['label' => 'A']), |
||||
* ['label' => 'B'], |
||||
* ] |
||||
* ]); |
||||
* ``` |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#buttons |
||||
* @see http://twitter.github.io/bootstrap/components.html#buttonGroups |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class ButtonGroup extends Widget |
||||
{ |
||||
/** |
||||
* @var array list of buttons. Each array element represents a single button |
||||
* which can be specified as a string or an array of the following structure: |
||||
* |
||||
* - label: string, required, the button label. |
||||
* - options: array, optional, the HTML attributes of the button. |
||||
*/ |
||||
public $buttons = []; |
||||
/** |
||||
* @var boolean whether to HTML-encode the button labels. |
||||
*/ |
||||
public $encodeLabels = true; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
* If you override this method, make sure you call the parent implementation first. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'btn-group'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo Html::tag('div', $this->renderButtons(), $this->options); |
||||
BootstrapAsset::register($this->getView()); |
||||
} |
||||
|
||||
/** |
||||
* Generates the buttons that compound the group as specified on [[items]]. |
||||
* @return string the rendering result. |
||||
*/ |
||||
protected function renderButtons() |
||||
{ |
||||
$buttons = []; |
||||
foreach ($this->buttons as $button) { |
||||
if (is_array($button)) { |
||||
$label = ArrayHelper::getValue($button, 'label'); |
||||
$options = ArrayHelper::getValue($button, 'options'); |
||||
$buttons[] = Button::widget([ |
||||
'label' => $label, |
||||
'options' => $options, |
||||
'encodeLabel' => $this->encodeLabels |
||||
]); |
||||
} else { |
||||
$buttons[] = $button; |
||||
} |
||||
} |
||||
return implode("\n", $buttons); |
||||
} |
||||
} |
||||
@ -0,0 +1,170 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Carousel renders a carousel bootstrap javascript component. |
||||
* |
||||
* For example: |
||||
* |
||||
* ```php |
||||
* echo Carousel::widget([ |
||||
* 'items' => [ |
||||
* // the item contains only the image |
||||
* '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg"/>', |
||||
* // equivalent to the above |
||||
* ['content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-02.jpg"/>'], |
||||
* // the item contains both the image and the caption |
||||
* [ |
||||
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-03.jpg"/>', |
||||
* 'caption' => '<h4>This is title</h4><p>This is the caption text</p>', |
||||
* 'options' => [...], |
||||
* ], |
||||
* ] |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#carousel |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Carousel extends Widget |
||||
{ |
||||
/** |
||||
* @var array|boolean the labels for the previous and the next control buttons. |
||||
* If false, it means the previous and the next control buttons should not be displayed. |
||||
*/ |
||||
public $controls = ['‹', '›']; |
||||
/** |
||||
* @var array list of slides in the carousel. Each array element represents a single |
||||
* slide with the following structure: |
||||
* |
||||
* ```php |
||||
* [ |
||||
* // required, slide content (HTML), such as an image tag |
||||
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg"/>', |
||||
* // optional, the caption (HTML) of the slide |
||||
* 'caption' => '<h4>This is title</h4><p>This is the caption text</p>', |
||||
* // optional the HTML attributes of the slide container |
||||
* 'options' => [], |
||||
* ] |
||||
* ``` |
||||
*/ |
||||
public $items = []; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'carousel'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo Html::beginTag('div', $this->options) . "\n"; |
||||
echo $this->renderIndicators() . "\n"; |
||||
echo $this->renderItems() . "\n"; |
||||
echo $this->renderControls() . "\n"; |
||||
echo Html::endTag('div') . "\n"; |
||||
$this->registerPlugin('carousel'); |
||||
} |
||||
|
||||
/** |
||||
* Renders carousel indicators. |
||||
* @return string the rendering result |
||||
*/ |
||||
public function renderIndicators() |
||||
{ |
||||
$indicators = []; |
||||
for ($i = 0, $count = count($this->items); $i < $count; $i++) { |
||||
$options = ['data-target' => '#' . $this->options['id'], 'data-slide-to' => $i]; |
||||
if ($i === 0) { |
||||
Html::addCssClass($options, 'active'); |
||||
} |
||||
$indicators[] = Html::tag('li', '', $options); |
||||
} |
||||
return Html::tag('ol', implode("\n", $indicators), ['class' => 'carousel-indicators']); |
||||
} |
||||
|
||||
/** |
||||
* Renders carousel items as specified on [[items]]. |
||||
* @return string the rendering result |
||||
*/ |
||||
public function renderItems() |
||||
{ |
||||
$items = []; |
||||
for ($i = 0, $count = count($this->items); $i < $count; $i++) { |
||||
$items[] = $this->renderItem($this->items[$i], $i); |
||||
} |
||||
return Html::tag('div', implode("\n", $items), ['class' => 'carousel-inner']); |
||||
} |
||||
|
||||
/** |
||||
* Renders a single carousel item |
||||
* @param string|array $item a single item from [[items]] |
||||
* @param integer $index the item index as the first item should be set to `active` |
||||
* @return string the rendering result |
||||
* @throws InvalidConfigException if the item is invalid |
||||
*/ |
||||
public function renderItem($item, $index) |
||||
{ |
||||
if (is_string($item)) { |
||||
$content = $item; |
||||
$caption = null; |
||||
$options = []; |
||||
} elseif (isset($item['content'])) { |
||||
$content = $item['content']; |
||||
$caption = ArrayHelper::getValue($item, 'caption'); |
||||
if ($caption !== null) { |
||||
$caption = Html::tag('div', $caption, ['class' => 'carousel-caption']); |
||||
} |
||||
$options = ArrayHelper::getValue($item, 'options', []); |
||||
} else { |
||||
throw new InvalidConfigException('The "content" option is required.'); |
||||
} |
||||
|
||||
Html::addCssClass($options, 'item'); |
||||
if ($index === 0) { |
||||
Html::addCssClass($options, 'active'); |
||||
} |
||||
|
||||
return Html::tag('div', $content . "\n" . $caption, $options); |
||||
} |
||||
|
||||
/** |
||||
* Renders previous and next control buttons. |
||||
* @throws InvalidConfigException if [[controls]] is invalid. |
||||
*/ |
||||
public function renderControls() |
||||
{ |
||||
if (isset($this->controls[0], $this->controls[1])) { |
||||
return Html::a($this->controls[0], '#' . $this->options['id'], [ |
||||
'class' => 'left carousel-control', |
||||
'data-slide' => 'prev', |
||||
]) . "\n" |
||||
. Html::a($this->controls[1], '#' . $this->options['id'], [ |
||||
'class' => 'right carousel-control', |
||||
'data-slide' => 'next', |
||||
]); |
||||
} elseif ($this->controls === false) { |
||||
return ''; |
||||
} else { |
||||
throw new InvalidConfigException('The "controls" property must be either false or an array of two elements.'); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,133 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Collapse renders an accordion bootstrap javascript component. |
||||
* |
||||
* For example: |
||||
* |
||||
* ```php |
||||
* echo Collapse::widget([ |
||||
* 'items' => [ |
||||
* // equivalent to the above |
||||
* 'Collapsible Group Item #1' => [ |
||||
* 'content' => 'Anim pariatur cliche...', |
||||
* // open its content by default |
||||
* 'contentOptions' => ['class' => 'in'] |
||||
* ], |
||||
* // another group item |
||||
* 'Collapsible Group Item #2' => [ |
||||
* 'content' => 'Anim pariatur cliche...', |
||||
* 'contentOptions' => [...], |
||||
* 'options' => [...], |
||||
* ], |
||||
* ] |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#collapse |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Collapse extends Widget |
||||
{ |
||||
/** |
||||
* @var array list of groups in the collapse widget. Each array element represents a single |
||||
* group with the following structure: |
||||
* |
||||
* ```php |
||||
* // item key is the actual group header |
||||
* 'Collapsible Group Item #1' => [ |
||||
* // required, the content (HTML) of the group |
||||
* 'content' => 'Anim pariatur cliche...', |
||||
* // optional the HTML attributes of the content group |
||||
* 'contentOptions' => [], |
||||
* // optional the HTML attributes of the group |
||||
* 'options' => [], |
||||
* ] |
||||
* ``` |
||||
*/ |
||||
public $items = []; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'accordion'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo Html::beginTag('div', $this->options) . "\n"; |
||||
echo $this->renderItems() . "\n"; |
||||
echo Html::endTag('div') . "\n"; |
||||
$this->registerPlugin('collapse'); |
||||
} |
||||
|
||||
/** |
||||
* Renders collapsible items as specified on [[items]]. |
||||
* @return string the rendering result |
||||
*/ |
||||
public function renderItems() |
||||
{ |
||||
$items = []; |
||||
$index = 0; |
||||
foreach ($this->items as $header => $item) { |
||||
$options = ArrayHelper::getValue($item, 'options', []); |
||||
Html::addCssClass($options, 'accordion-group'); |
||||
$items[] = Html::tag('div', $this->renderItem($header, $item, ++$index), $options); |
||||
} |
||||
|
||||
return implode("\n", $items); |
||||
} |
||||
|
||||
/** |
||||
* Renders a single collapsible item group |
||||
* @param string $header a label of the item group [[items]] |
||||
* @param array $item a single item from [[items]] |
||||
* @param integer $index the item index as each item group content must have an id |
||||
* @return string the rendering result |
||||
* @throws InvalidConfigException |
||||
*/ |
||||
public function renderItem($header, $item, $index) |
||||
{ |
||||
if (isset($item['content'])) { |
||||
$id = $this->options['id'] . '-collapse' . $index; |
||||
$options = ArrayHelper::getValue($item, 'contentOptions', []); |
||||
$options['id'] = $id; |
||||
Html::addCssClass($options, 'accordion-body collapse'); |
||||
|
||||
$header = Html::a($header, '#' . $id, [ |
||||
'class' => 'accordion-toggle', |
||||
'data-toggle' => 'collapse', |
||||
'data-parent' => '#' . $this->options['id'] |
||||
]) . "\n"; |
||||
|
||||
$content = Html::tag('div', $item['content'], ['class' => 'accordion-inner']) . "\n"; |
||||
} else { |
||||
throw new InvalidConfigException('The "content" option is required.'); |
||||
} |
||||
$group = []; |
||||
|
||||
$group[] = Html::tag('div', $header, ['class' => 'accordion-heading']); |
||||
$group[] = Html::tag('div', $content, $options); |
||||
|
||||
return implode("\n", $group); |
||||
} |
||||
} |
||||
@ -0,0 +1,92 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Dropdown renders a Bootstrap dropdown menu component. |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#dropdowns |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Dropdown extends Widget |
||||
{ |
||||
/** |
||||
* @var array list of menu items in the dropdown. Each array element can be either an HTML string, |
||||
* or an array representing a single menu with the following structure: |
||||
* |
||||
* - label: string, required, the label of the item link |
||||
* - url: string, optional, the url of the item link. Defaults to "#". |
||||
* - visible: boolean, optional, whether this menu item is visible. Defaults to true. |
||||
* - linkOptions: array, optional, the HTML attributes of the item link. |
||||
* - options: array, optional, the HTML attributes of the item. |
||||
* |
||||
* To insert divider use `<li role="presentation" class="divider"></li>`. |
||||
*/ |
||||
public $items = []; |
||||
/** |
||||
* @var boolean whether the labels for header items should be HTML-encoded. |
||||
*/ |
||||
public $encodeLabels = true; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
* If you override this method, make sure you call the parent implementation first. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'dropdown-menu'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo $this->renderItems($this->items); |
||||
$this->registerPlugin('dropdown'); |
||||
} |
||||
|
||||
/** |
||||
* Renders menu items. |
||||
* @param array $items the menu items to be rendered |
||||
* @return string the rendering result. |
||||
* @throws InvalidConfigException if the label option is not specified in one of the items. |
||||
*/ |
||||
protected function renderItems($items) |
||||
{ |
||||
$lines = []; |
||||
foreach ($items as $i => $item) { |
||||
if (isset($item['visible']) && !$item['visible']) { |
||||
unset($items[$i]); |
||||
continue; |
||||
} |
||||
if (is_string($item)) { |
||||
$lines[] = $item; |
||||
continue; |
||||
} |
||||
if (!isset($item['label'])) { |
||||
throw new InvalidConfigException("The 'label' option is required."); |
||||
} |
||||
$label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; |
||||
$options = ArrayHelper::getValue($item, 'options', []); |
||||
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); |
||||
$linkOptions['tabindex'] = '-1'; |
||||
$content = Html::a($label, ArrayHelper::getValue($item, 'url', '#'), $linkOptions); |
||||
$lines[] = Html::tag('li', $content, $options); |
||||
} |
||||
|
||||
return Html::tag('ul', implode("\n", $lines), $this->options); |
||||
} |
||||
} |
||||
@ -0,0 +1,227 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use Yii; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Modal renders a modal window that can be toggled by clicking on a button. |
||||
* |
||||
* The following example will show the content enclosed between the [[begin()]] |
||||
* and [[end()]] calls within the modal window: |
||||
* |
||||
* ~~~php |
||||
* Modal::begin([ |
||||
* 'header' => '<h2>Hello world</h2>', |
||||
* 'toggleButton' => ['label' => 'click me'], |
||||
* ]); |
||||
* |
||||
* echo 'Say hello...'; |
||||
* |
||||
* Modal::end(); |
||||
* ~~~ |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#modals |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Modal extends Widget |
||||
{ |
||||
/** |
||||
* @var string the header content in the modal window. |
||||
*/ |
||||
public $header; |
||||
/** |
||||
* @var string the footer content in the modal window. |
||||
*/ |
||||
public $footer; |
||||
/** |
||||
* @var array the options for rendering the close button tag. |
||||
* The close button is displayed in the header of the modal window. Clicking |
||||
* on the button will hide the modal window. If this is null, no close button will be rendered. |
||||
* |
||||
* The following special options are supported: |
||||
* |
||||
* - tag: string, the tag name of the button. Defaults to 'button'. |
||||
* - label: string, the label of the button. Defaults to '×'. |
||||
* |
||||
* The rest of the options will be rendered as the HTML attributes of the button tag. |
||||
* Please refer to the [Modal plugin help](http://twitter.github.com/bootstrap/javascript.html#modals) |
||||
* for the supported HTML attributes. |
||||
*/ |
||||
public $closeButton = []; |
||||
/** |
||||
* @var array the options for rendering the toggle button tag. |
||||
* The toggle button is used to toggle the visibility of the modal window. |
||||
* If this property is null, no toggle button will be rendered. |
||||
* |
||||
* The following special options are supported: |
||||
* |
||||
* - tag: string, the tag name of the button. Defaults to 'button'. |
||||
* - label: string, the label of the button. Defaults to 'Show'. |
||||
* |
||||
* The rest of the options will be rendered as the HTML attributes of the button tag. |
||||
* Please refer to the [Modal plugin help](http://twitter.github.com/bootstrap/javascript.html#modals) |
||||
* for the supported HTML attributes. |
||||
*/ |
||||
public $toggleButton; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$this->initOptions(); |
||||
|
||||
echo $this->renderToggleButton() . "\n"; |
||||
echo Html::beginTag('div', $this->options) . "\n"; |
||||
echo Html::beginTag('div', ['class' => 'modal-dialog']) . "\n"; |
||||
echo Html::beginTag('div', ['class' => 'modal-content']) . "\n"; |
||||
echo $this->renderHeader() . "\n"; |
||||
echo $this->renderBodyBegin() . "\n"; |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo "\n" . $this->renderBodyEnd(); |
||||
echo "\n" . $this->renderFooter(); |
||||
echo "\n" . Html::endTag('div'); // modal-content |
||||
echo "\n" . Html::endTag('div'); // modal-dialog |
||||
echo "\n" . Html::endTag('div'); |
||||
|
||||
$this->registerPlugin('modal'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the header HTML markup of the modal |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderHeader() |
||||
{ |
||||
$button = $this->renderCloseButton(); |
||||
if ($button !== null) { |
||||
$this->header = $button . "\n" . $this->header; |
||||
} |
||||
if ($this->header !== null) { |
||||
return Html::tag('div', "\n" . $this->header . "\n", ['class' => 'modal-header']); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Renders the opening tag of the modal body. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderBodyBegin() |
||||
{ |
||||
return Html::beginTag('div', ['class' => 'modal-body']); |
||||
} |
||||
|
||||
/** |
||||
* Renders the closing tag of the modal body. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderBodyEnd() |
||||
{ |
||||
return Html::endTag('div'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the HTML markup for the footer of the modal |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderFooter() |
||||
{ |
||||
if ($this->footer !== null) { |
||||
return Html::tag('div', "\n" . $this->footer . "\n", ['class' => 'modal-footer']); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Renders the toggle button. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderToggleButton() |
||||
{ |
||||
if ($this->toggleButton !== null) { |
||||
$tag = ArrayHelper::remove($this->toggleButton, 'tag', 'button'); |
||||
$label = ArrayHelper::remove($this->toggleButton, 'label', 'Show'); |
||||
if ($tag === 'button' && !isset($this->toggleButton['type'])) { |
||||
$this->toggleButton['type'] = 'button'; |
||||
} |
||||
return Html::tag($tag, $label, $this->toggleButton); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Renders the close button. |
||||
* @return string the rendering result |
||||
*/ |
||||
protected function renderCloseButton() |
||||
{ |
||||
if ($this->closeButton !== null) { |
||||
$tag = ArrayHelper::remove($this->closeButton, 'tag', 'button'); |
||||
$label = ArrayHelper::remove($this->closeButton, 'label', '×'); |
||||
if ($tag === 'button' && !isset($this->closeButton['type'])) { |
||||
$this->closeButton['type'] = 'button'; |
||||
} |
||||
return Html::tag($tag, $label, $this->closeButton); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Initializes the widget options. |
||||
* This method sets the default values for various options. |
||||
*/ |
||||
protected function initOptions() |
||||
{ |
||||
$this->options = array_merge([ |
||||
'class' => 'fade', |
||||
'role' => 'dialog', |
||||
'tabindex' => -1, |
||||
], $this->options); |
||||
Html::addCssClass($this->options, 'modal'); |
||||
|
||||
if ($this->clientOptions !== false) { |
||||
$this->clientOptions = array_merge(['show' => false], $this->clientOptions); |
||||
} |
||||
|
||||
if ($this->closeButton !== null) { |
||||
$this->closeButton = array_merge([ |
||||
'data-dismiss' => 'modal', |
||||
'aria-hidden' => 'true', |
||||
'class' => 'close', |
||||
], $this->closeButton); |
||||
} |
||||
|
||||
if ($this->toggleButton !== null) { |
||||
$this->toggleButton = array_merge([ |
||||
'data-toggle' => 'modal', |
||||
], $this->toggleButton); |
||||
if (!isset($this->toggleButton['data-target']) && !isset($this->toggleButton['href'])) { |
||||
$this->toggleButton['data-target'] = '#' . $this->options['id']; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,214 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use Yii; |
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Nav renders a nav HTML component. |
||||
* |
||||
* For example: |
||||
* |
||||
* ```php |
||||
* echo Nav::widget([ |
||||
* 'items' => [ |
||||
* [ |
||||
* 'label' => 'Home', |
||||
* 'url' => ['site/index'], |
||||
* 'linkOptions' => [...], |
||||
* ], |
||||
* [ |
||||
* 'label' => 'Dropdown', |
||||
* 'items' => [ |
||||
* [ |
||||
* 'label' => 'Level 1 -DropdownA', |
||||
* 'url' => '#', |
||||
* 'items' => [ |
||||
* ['label' => 'Level 2 -DropdownA', 'url' => '#'], |
||||
* ], |
||||
* ], |
||||
* ['label' => 'Level 1 -DropdownB', 'url' => '#'], |
||||
* ], |
||||
* ], |
||||
* ], |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/components.html#nav |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Nav extends Widget |
||||
{ |
||||
/** |
||||
* @var array list of items in the nav widget. Each array element represents a single |
||||
* menu item which can be either a string or an array with the following structure: |
||||
* |
||||
* - label: string, required, the nav item label. |
||||
* - url: optional, the item's URL. Defaults to "#". |
||||
* - visible: boolean, optional, whether this menu item is visible. Defaults to true. |
||||
* - linkOptions: array, optional, the HTML attributes of the item's link. |
||||
* - options: array, optional, the HTML attributes of the item container (LI). |
||||
* - active: boolean, optional, whether the item should be on active state or not. |
||||
* - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget, |
||||
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus. |
||||
* |
||||
* If a menu item is a string, it will be rendered directly without HTML encoding. |
||||
*/ |
||||
public $items = []; |
||||
/** |
||||
* @var boolean whether the nav items labels should be HTML-encoded. |
||||
*/ |
||||
public $encodeLabels = true; |
||||
/** |
||||
* @var boolean whether to automatically activate items according to whether their route setting |
||||
* matches the currently requested route. |
||||
* @see isItemActive |
||||
*/ |
||||
public $activateItems = true; |
||||
/** |
||||
* @var string the route used to determine if a menu item is active or not. |
||||
* If not set, it will use the route of the current request. |
||||
* @see params |
||||
* @see isItemActive |
||||
*/ |
||||
public $route; |
||||
/** |
||||
* @var array the parameters used to determine if a menu item is active or not. |
||||
* If not set, it will use `$_GET`. |
||||
* @see route |
||||
* @see isItemActive |
||||
*/ |
||||
public $params; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
if ($this->route === null && Yii::$app->controller !== null) { |
||||
$this->route = Yii::$app->controller->getRoute(); |
||||
} |
||||
if ($this->params === null) { |
||||
$this->params = $_GET; |
||||
} |
||||
Html::addCssClass($this->options, 'nav'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo $this->renderItems(); |
||||
BootstrapAsset::register($this->getView()); |
||||
} |
||||
|
||||
/** |
||||
* Renders widget items. |
||||
*/ |
||||
public function renderItems() |
||||
{ |
||||
$items = []; |
||||
foreach ($this->items as $i => $item) { |
||||
if (isset($item['visible']) && !$item['visible']) { |
||||
unset($items[$i]); |
||||
continue; |
||||
} |
||||
$items[] = $this->renderItem($item); |
||||
} |
||||
|
||||
return Html::tag('ul', implode("\n", $items), $this->options); |
||||
} |
||||
|
||||
/** |
||||
* Renders a widget's item. |
||||
* @param string|array $item the item to render. |
||||
* @return string the rendering result. |
||||
* @throws InvalidConfigException |
||||
*/ |
||||
public function renderItem($item) |
||||
{ |
||||
if (is_string($item)) { |
||||
return $item; |
||||
} |
||||
if (!isset($item['label'])) { |
||||
throw new InvalidConfigException("The 'label' option is required."); |
||||
} |
||||
$label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; |
||||
$options = ArrayHelper::getValue($item, 'options', []); |
||||
$items = ArrayHelper::getValue($item, 'items'); |
||||
$url = Html::url(ArrayHelper::getValue($item, 'url', '#')); |
||||
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', []); |
||||
|
||||
if (isset($item['active'])) { |
||||
$active = ArrayHelper::remove($item, 'active', false); |
||||
} else { |
||||
$active = $this->isItemActive($item); |
||||
} |
||||
|
||||
if ($active) { |
||||
Html::addCssClass($options, 'active'); |
||||
} |
||||
|
||||
if ($items !== null) { |
||||
$linkOptions['data-toggle'] = 'dropdown'; |
||||
Html::addCssClass($options, 'dropdown'); |
||||
Html::addCssClass($urlOptions, 'dropdown-toggle'); |
||||
$label .= ' ' . Html::tag('b', '', ['class' => 'caret']); |
||||
if (is_array($items)) { |
||||
$items = Dropdown::widget([ |
||||
'items' => $items, |
||||
'encodeLabels' => $this->encodeLabels, |
||||
'clientOptions' => false, |
||||
]); |
||||
} |
||||
} |
||||
|
||||
return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Checks whether a menu item is active. |
||||
* This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item. |
||||
* When the `url` option of a menu item is specified in terms of an array, its first element is treated |
||||
* as the route for the item and the rest of the elements are the associated parameters. |
||||
* Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item |
||||
* be considered active. |
||||
* @param array $item the menu item to be checked |
||||
* @return boolean whether the menu item is active |
||||
*/ |
||||
protected function isItemActive($item) |
||||
{ |
||||
if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) { |
||||
$route = $item['url'][0]; |
||||
if ($route[0] !== '/' && Yii::$app->controller) { |
||||
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route; |
||||
} |
||||
if (ltrim($route, '/') !== $this->route) { |
||||
return false; |
||||
} |
||||
unset($item['url']['#']); |
||||
if (count($item['url']) > 1) { |
||||
foreach (array_splice($item['url'], 1) as $name => $value) { |
||||
if (!isset($this->params[$name]) || $this->params[$name] != $value) { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
@ -0,0 +1,108 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* NavBar renders a navbar HTML component. |
||||
* |
||||
* Any content enclosed between the [[begin()]] and [[end()]] calls of NavBar |
||||
* is treated as the content of the navbar. You may use widgets such as [[Nav]] |
||||
* or [[\yii\widgets\Menu]] to build up such content. For example, |
||||
* |
||||
* ```php |
||||
* use yii\bootstrap\NavBar; |
||||
* use yii\widgets\Menu; |
||||
* |
||||
* NavBar::begin(['brandLabel' => 'NavBar Test']); |
||||
* echo Nav::widget([ |
||||
* 'items' => [ |
||||
* ['label' => 'Home', 'url' => ['/site/index']], |
||||
* ['label' => 'About', 'url' => ['/site/about']], |
||||
* ], |
||||
* ]); |
||||
* NavBar::end(); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/components.html#navbar |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class NavBar extends Widget |
||||
{ |
||||
/** |
||||
* @var string the text of the brand. Note that this is not HTML-encoded. |
||||
* @see http://twitter.github.io/bootstrap/components.html#navbar |
||||
*/ |
||||
public $brandLabel; |
||||
/** |
||||
* @param array|string $url the URL for the brand's hyperlink tag. This parameter will be processed by [[Html::url()]] |
||||
* and will be used for the "href" attribute of the brand link. Defaults to site root. |
||||
*/ |
||||
public $brandUrl = '/'; |
||||
/** |
||||
* @var array the HTML attributes of the brand link. |
||||
*/ |
||||
public $brandOptions = []; |
||||
|
||||
public $screenReaderToggleText = 'Toggle navigation'; |
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
$this->clientOptions = false; |
||||
Html::addCssClass($this->options, 'navbar navbar-default'); |
||||
Html::addCssClass($this->brandOptions, 'navbar-brand'); |
||||
if (empty($this->options['role'])) { |
||||
$this->options['role'] = 'navigation'; |
||||
} |
||||
|
||||
echo Html::beginTag('nav', $this->options); |
||||
echo Html::beginTag('div', ['class' => 'container']); |
||||
|
||||
echo Html::beginTag('div', ['class' => 'navbar-header']); |
||||
echo $this->renderToggleButton(); |
||||
if ($this->brandLabel !== null) { |
||||
echo Html::a($this->brandLabel, $this->brandUrl, $this->brandOptions); |
||||
} |
||||
echo Html::endTag('div'); |
||||
|
||||
echo Html::beginTag('div', ['class' => 'collapse navbar-collapse navbar-ex1-collapse']); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
|
||||
echo Html::endTag('div'); |
||||
echo Html::endTag('div'); |
||||
echo Html::endTag('nav'); |
||||
BootstrapPluginAsset::register($this->getView()); |
||||
} |
||||
|
||||
/** |
||||
* Renders collapsible toggle button. |
||||
* @return string the rendering toggle button. |
||||
*/ |
||||
protected function renderToggleButton() |
||||
{ |
||||
$bar = Html::tag('span', '', ['class' => 'icon-bar']); |
||||
$screenReader = '<span class="sr-only">'.$this->screenReaderToggleText.'</span>'; |
||||
return Html::button("{$screenReader}\n{$bar}\n{$bar}\n{$bar}", [ |
||||
'class' => 'navbar-toggle', |
||||
'data-toggle' => 'collapse', |
||||
'data-target' => '.navbar-ex1-collapse', |
||||
]); |
||||
} |
||||
} |
||||
@ -0,0 +1,146 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Progress renders a bootstrap progress bar component. |
||||
* |
||||
* For example, |
||||
* |
||||
* ```php |
||||
* // default with label |
||||
* echo Progress::widget([ |
||||
* 'percent' => 60, |
||||
* 'label' => 'test', |
||||
* ]); |
||||
* |
||||
* // styled |
||||
* echo Progress::widget([ |
||||
* 'percent' => 65, |
||||
* 'barOptions' => ['class' => 'bar-danger'] |
||||
* ]); |
||||
* |
||||
* // striped |
||||
* echo Progress::widget([ |
||||
* 'percent' => 70, |
||||
* 'barOptions' => ['class' => 'bar-warning'], |
||||
* 'options' => ['class' => 'progress-striped'] |
||||
* ]); |
||||
* |
||||
* // striped animated |
||||
* echo Progress::widget([ |
||||
* 'percent' => 70, |
||||
* 'barOptions' => ['class' => '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' => array['class' => 'bar-warning']], |
||||
* ] |
||||
* ]); |
||||
* ``` |
||||
* @see http://twitter.github.io/bootstrap/components.html#progress |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Progress extends Widget |
||||
{ |
||||
/** |
||||
* @var string the button label |
||||
*/ |
||||
public $label; |
||||
/** |
||||
* @var integer the amount of progress as a percentage. |
||||
*/ |
||||
public $percent = 0; |
||||
/** |
||||
* @var array the HTML attributes of the |
||||
*/ |
||||
public $barOptions = []; |
||||
/** |
||||
* @var array a set of bars that are stacked together to form a single progress bar. |
||||
* Each bar is an array of the following structure: |
||||
* |
||||
* ```php |
||||
* [ |
||||
* // required, the amount of progress as a percentage. |
||||
* 'percent' => 30, |
||||
* // optional, the label to be displayed on the bar |
||||
* 'label' => '30%', |
||||
* // optional, array, additional HTML attributes for the bar tag |
||||
* 'options' => [], |
||||
* ] |
||||
*/ |
||||
public $bars; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
* If you override this method, make sure you call the parent implementation first. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'progress'); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo Html::beginTag('div', $this->options) . "\n"; |
||||
echo $this->renderProgress() . "\n"; |
||||
echo Html::endTag('div') . "\n"; |
||||
BootstrapAsset::register($this->getView()); |
||||
} |
||||
|
||||
/** |
||||
* Renders the progress. |
||||
* @return string the rendering result. |
||||
* @throws InvalidConfigException if the "percent" option is not set in a stacked progress bar. |
||||
*/ |
||||
protected function renderProgress() |
||||
{ |
||||
if (empty($this->bars)) { |
||||
return $this->renderBar($this->percent, $this->label, $this->barOptions); |
||||
} |
||||
$bars = []; |
||||
foreach ($this->bars as $bar) { |
||||
$label = ArrayHelper::getValue($bar, 'label', ''); |
||||
if (!isset($bar['percent'])) { |
||||
throw new InvalidConfigException("The 'percent' option is required."); |
||||
} |
||||
$options = ArrayHelper::getValue($bar, 'options', []); |
||||
$bars[] = $this->renderBar($bar['percent'], $label, $options); |
||||
} |
||||
return implode("\n", $bars); |
||||
} |
||||
|
||||
/** |
||||
* Generates a bar |
||||
* @param int $percent the percentage of the bar |
||||
* @param string $label, optional, the label to display at the bar |
||||
* @param array $options the HTML attributes of the bar |
||||
* @return string the rendering result. |
||||
*/ |
||||
protected function renderBar($percent, $label = '', $options = []) |
||||
{ |
||||
Html::addCssClass($options, 'bar'); |
||||
$options['style'] = "width:{$percent}%"; |
||||
return Html::tag('div', $label, $options); |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
|
||||
Twitter Bootstrap Extension for Yii 2 |
||||
===================================== |
||||
|
||||
This is the Twitter Bootstrap extension for Yii 2. It encapsulates Bootstrap components |
||||
and plugins in terms of Yii widgets, and thus makes using Bootstrap components/plugins |
||||
in Yii applications extremely easy. For example, the following |
||||
single line of code in a view file would render a Bootstrap Progress plugin: |
||||
|
||||
```php |
||||
<?= yii\bootstrap\Progress::widget(['percent' => 60, 'label' => 'test']) ?> |
||||
``` |
||||
|
||||
|
||||
Installation |
||||
------------ |
||||
|
||||
The preferred way to install this extension is [composer](http://getcomposer.org/download/). |
||||
|
||||
Either run |
||||
|
||||
``` |
||||
php composer.phar require yiisoft/yii2-bootstrap "*" |
||||
``` |
||||
|
||||
or add |
||||
|
||||
``` |
||||
"yiisoft/yii2-bootstrap": "*" |
||||
``` |
||||
|
||||
to the require section of your `composer.json` file. |
||||
|
||||
@ -0,0 +1,199 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use yii\base\InvalidConfigException; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* Tabs renders a Tab bootstrap javascript component. |
||||
* |
||||
* For example: |
||||
* |
||||
* ```php |
||||
* echo Tabs::widget([ |
||||
* 'items' => [ |
||||
* [ |
||||
* 'label' => 'One', |
||||
* 'content' => 'Anim pariatur cliche...', |
||||
* 'active' => true |
||||
* ], |
||||
* [ |
||||
* 'label' => 'Two', |
||||
* 'content' => 'Anim pariatur cliche...', |
||||
* 'headerOptions' => [...], |
||||
* 'options' => ['id' => 'myveryownID'], |
||||
* ], |
||||
* [ |
||||
* 'label' => 'Dropdown', |
||||
* 'items' => [ |
||||
* [ |
||||
* 'label' => 'DropdownA', |
||||
* 'content' => 'DropdownA, Anim pariatur cliche...', |
||||
* ], |
||||
* [ |
||||
* 'label' => 'DropdownB', |
||||
* 'content' => 'DropdownB, Anim pariatur cliche...', |
||||
* ], |
||||
* ], |
||||
* ], |
||||
* ], |
||||
* ]); |
||||
* ``` |
||||
* |
||||
* @see http://twitter.github.io/bootstrap/javascript.html#tabs |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Tabs extends Widget |
||||
{ |
||||
/** |
||||
* @var array list of tabs in the tabs widget. Each array element represents a single |
||||
* tab with the following structure: |
||||
* |
||||
* - label: string, required, the tab header label. |
||||
* - headerOptions: array, optional, the HTML attributes of the tab header. |
||||
* - content: array, required if `items` is not set. The content (HTML) of the tab pane. |
||||
* - options: array, optional, the HTML attributes of the tab pane container. |
||||
* - active: boolean, optional, whether the item tab header and pane should be visible or not. |
||||
* - items: array, optional, if not set then `content` will be required. The `items` specify a dropdown items |
||||
* configuration array. Each item can hold two extra keys, besides the above ones: |
||||
* * active: boolean, optional, whether the item tab header and pane should be visible or not. |
||||
* * content: string, required if `items` is not set. The content (HTML) of the tab pane. |
||||
* * contentOptions: optional, array, the HTML attributes of the tab content container. |
||||
*/ |
||||
public $items = []; |
||||
/** |
||||
* @var array list of HTML attributes for the item container tags. This will be overwritten |
||||
* by the "options" set in individual [[items]]. The following special options are recognized: |
||||
* |
||||
* - tag: string, defaults to "div", the tag name of the item container tags. |
||||
*/ |
||||
public $itemOptions = []; |
||||
/** |
||||
* @var array list of HTML attributes for the header container tags. This will be overwritten |
||||
* by the "headerOptions" set in individual [[items]]. |
||||
*/ |
||||
public $headerOptions = []; |
||||
/** |
||||
* @var boolean whether the labels for header items should be HTML-encoded. |
||||
*/ |
||||
public $encodeLabels = true; |
||||
/** |
||||
* @var string, specifies the Bootstrap tab styling. |
||||
*/ |
||||
public $navType = 'nav-tabs'; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
Html::addCssClass($this->options, 'nav ' . $this->navType); |
||||
} |
||||
|
||||
/** |
||||
* Renders the widget. |
||||
*/ |
||||
public function run() |
||||
{ |
||||
echo $this->renderItems(); |
||||
$this->registerPlugin('tab'); |
||||
} |
||||
|
||||
/** |
||||
* Renders tab items as specified on [[items]]. |
||||
* @return string the rendering result. |
||||
* @throws InvalidConfigException. |
||||
*/ |
||||
protected function renderItems() |
||||
{ |
||||
$headers = []; |
||||
$panes = []; |
||||
foreach ($this->items as $n => $item) { |
||||
if (!isset($item['label'])) { |
||||
throw new InvalidConfigException("The 'label' option is required."); |
||||
} |
||||
$label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; |
||||
$headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); |
||||
|
||||
if (isset($item['items'])) { |
||||
$label .= ' <b class="caret"></b>'; |
||||
Html::addCssClass($headerOptions, 'dropdown'); |
||||
|
||||
if ($this->renderDropdown($item['items'], $panes)) { |
||||
Html::addCssClass($headerOptions, 'active'); |
||||
} |
||||
|
||||
$header = Html::a($label, "#", ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']) . "\n" |
||||
. Dropdown::widget(['items' => $item['items'], 'clientOptions' => false]); |
||||
} elseif (isset($item['content'])) { |
||||
$options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); |
||||
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); |
||||
|
||||
Html::addCssClass($options, 'tab-pane'); |
||||
if (ArrayHelper::remove($item, 'active')) { |
||||
Html::addCssClass($options, 'active'); |
||||
Html::addCssClass($headerOptions, 'active'); |
||||
} |
||||
$header = Html::a($label, '#' . $options['id'], ['data-toggle' => 'tab']); |
||||
$panes[] = Html::tag('div', $item['content'], $options); |
||||
} else { |
||||
throw new InvalidConfigException("Either the 'content' or 'items' option must be set."); |
||||
} |
||||
|
||||
$headers[] = Html::tag('li', $header, $headerOptions); |
||||
} |
||||
|
||||
return Html::tag('ul', implode("\n", $headers), $this->options) . "\n" |
||||
. Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']); |
||||
} |
||||
|
||||
/** |
||||
* Normalizes dropdown item options by removing tab specific keys `content` and `contentOptions`, and also |
||||
* configure `panes` accordingly. |
||||
* @param array $items the dropdown items configuration. |
||||
* @param array $panes the panes reference array. |
||||
* @return boolean whether any of the dropdown items is `active` or not. |
||||
* @throws InvalidConfigException |
||||
*/ |
||||
protected function renderDropdown(&$items, &$panes) |
||||
{ |
||||
$itemActive = false; |
||||
|
||||
foreach ($items as $n => &$item) { |
||||
if (is_string($item)) { |
||||
continue; |
||||
} |
||||
if (!isset($item['content'])) { |
||||
throw new InvalidConfigException("The 'content' option is required."); |
||||
} |
||||
|
||||
$content = ArrayHelper::remove($item, 'content'); |
||||
$options = ArrayHelper::remove($item, 'contentOptions', []); |
||||
Html::addCssClass($options, 'tab-pane'); |
||||
if (ArrayHelper::remove($item, 'active')) { |
||||
Html::addCssClass($options, 'active'); |
||||
Html::addCssClass($item['options'], 'active'); |
||||
$itemActive = true; |
||||
} |
||||
|
||||
$options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-dd-tab' . $n); |
||||
$item['url'] = '#' . $options['id']; |
||||
$item['linkOptions']['data-toggle'] = 'tab'; |
||||
|
||||
$panes[] = Html::tag('div', $content, $options); |
||||
|
||||
unset($item); |
||||
} |
||||
return $itemActive; |
||||
} |
||||
} |
||||
@ -0,0 +1,81 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\bootstrap; |
||||
|
||||
use Yii; |
||||
use yii\helpers\Json; |
||||
|
||||
/** |
||||
* \yii\bootstrap\Widget is the base class for all bootstrap widgets. |
||||
* |
||||
* @author Antonio Ramirez <amigo.cobos@gmail.com> |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Widget extends \yii\base\Widget |
||||
{ |
||||
/** |
||||
* @var array the HTML attributes for the widget container tag. |
||||
*/ |
||||
public $options = []; |
||||
/** |
||||
* @var array the options for the underlying Bootstrap JS plugin. |
||||
* Please refer to the corresponding Bootstrap plugin Web page for possible options. |
||||
* For example, [this page](http://twitter.github.io/bootstrap/javascript.html#modals) shows |
||||
* how to use the "Modal" plugin and the supported options (e.g. "remote"). |
||||
*/ |
||||
public $clientOptions = []; |
||||
/** |
||||
* @var array the event handlers for the underlying Bootstrap JS plugin. |
||||
* Please refer to the corresponding Bootstrap plugin Web page for possible events. |
||||
* For example, [this page](http://twitter.github.io/bootstrap/javascript.html#modals) shows |
||||
* how to use the "Modal" plugin and the supported events (e.g. "shown"). |
||||
*/ |
||||
public $clientEvents = []; |
||||
|
||||
|
||||
/** |
||||
* Initializes the widget. |
||||
* This method will register the bootstrap asset bundle. If you override this method, |
||||
* make sure you call the parent implementation first. |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
if (!isset($this->options['id'])) { |
||||
$this->options['id'] = $this->getId(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers a specific Bootstrap plugin and the related events |
||||
* @param string $name the name of the Bootstrap plugin |
||||
*/ |
||||
protected function registerPlugin($name) |
||||
{ |
||||
$view = $this->getView(); |
||||
|
||||
BootstrapPluginAsset::register($view); |
||||
|
||||
$id = $this->options['id']; |
||||
|
||||
if ($this->clientOptions !== false) { |
||||
$options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); |
||||
$js = "jQuery('#$id').$name($options);"; |
||||
$view->registerJs($js); |
||||
} |
||||
|
||||
if (!empty($this->clientEvents)) { |
||||
$js = []; |
||||
foreach ($this->clientEvents as $event => $handler) { |
||||
$js[] = "jQuery('#$id').on('$event', $handler);"; |
||||
} |
||||
$view->registerJs(implode("\n", $js)); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,384 @@
|
||||
.btn-default, |
||||
.btn-primary, |
||||
.btn-success, |
||||
.btn-info, |
||||
.btn-warning, |
||||
.btn-danger { |
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); |
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075); |
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075); |
||||
} |
||||
|
||||
.btn-default:active, |
||||
.btn-primary:active, |
||||
.btn-success:active, |
||||
.btn-info:active, |
||||
.btn-warning:active, |
||||
.btn-danger:active, |
||||
.btn-default.active, |
||||
.btn-primary.active, |
||||
.btn-success.active, |
||||
.btn-info.active, |
||||
.btn-warning.active, |
||||
.btn-danger.active { |
||||
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); |
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); |
||||
} |
||||
|
||||
.btn:active, |
||||
.btn.active { |
||||
background-image: none; |
||||
} |
||||
|
||||
.btn-default { |
||||
text-shadow: 0 1px 0 #fff; |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ffffff), to(#e6e6e6)); |
||||
background-image: -webkit-linear-gradient(top, #ffffff, 0%, #e6e6e6, 100%); |
||||
background-image: -moz-linear-gradient(top, #ffffff 0%, #e6e6e6 100%); |
||||
background-image: linear-gradient(to bottom, #ffffff 0%, #e6e6e6 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #e0e0e0; |
||||
border-color: #ccc; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0); |
||||
} |
||||
|
||||
.btn-default:active, |
||||
.btn-default.active { |
||||
background-color: #e6e6e6; |
||||
border-color: #e0e0e0; |
||||
} |
||||
|
||||
.btn-primary { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); |
||||
background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); |
||||
background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); |
||||
background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #2d6ca2; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); |
||||
} |
||||
|
||||
.btn-primary:active, |
||||
.btn-primary.active { |
||||
background-color: #3071a9; |
||||
border-color: #2d6ca2; |
||||
} |
||||
|
||||
.btn-success { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5cb85c), to(#449d44)); |
||||
background-image: -webkit-linear-gradient(top, #5cb85c, 0%, #449d44, 100%); |
||||
background-image: -moz-linear-gradient(top, #5cb85c 0%, #449d44 100%); |
||||
background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #419641; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0); |
||||
} |
||||
|
||||
.btn-success:active, |
||||
.btn-success.active { |
||||
background-color: #449d44; |
||||
border-color: #419641; |
||||
} |
||||
|
||||
.btn-warning { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f0ad4e), to(#ec971f)); |
||||
background-image: -webkit-linear-gradient(top, #f0ad4e, 0%, #ec971f, 100%); |
||||
background-image: -moz-linear-gradient(top, #f0ad4e 0%, #ec971f 100%); |
||||
background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #eb9316; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0); |
||||
} |
||||
|
||||
.btn-warning:active, |
||||
.btn-warning.active { |
||||
background-color: #ec971f; |
||||
border-color: #eb9316; |
||||
} |
||||
|
||||
.btn-danger { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9534f), to(#c9302c)); |
||||
background-image: -webkit-linear-gradient(top, #d9534f, 0%, #c9302c, 100%); |
||||
background-image: -moz-linear-gradient(top, #d9534f 0%, #c9302c 100%); |
||||
background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #c12e2a; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0); |
||||
} |
||||
|
||||
.btn-danger:active, |
||||
.btn-danger.active { |
||||
background-color: #c9302c; |
||||
border-color: #c12e2a; |
||||
} |
||||
|
||||
.btn-info { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5bc0de), to(#31b0d5)); |
||||
background-image: -webkit-linear-gradient(top, #5bc0de, 0%, #31b0d5, 100%); |
||||
background-image: -moz-linear-gradient(top, #5bc0de 0%, #31b0d5 100%); |
||||
background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #2aabd2; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0); |
||||
} |
||||
|
||||
.btn-info:active, |
||||
.btn-info.active { |
||||
background-color: #31b0d5; |
||||
border-color: #2aabd2; |
||||
} |
||||
|
||||
.thumbnail, |
||||
.img-thumbnail { |
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); |
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); |
||||
} |
||||
|
||||
.dropdown-menu > li > a:hover, |
||||
.dropdown-menu > li > a:focus, |
||||
.dropdown-menu > .active > a, |
||||
.dropdown-menu > .active > a:hover, |
||||
.dropdown-menu > .active > a:focus { |
||||
background-color: #357ebd; |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#357ebd)); |
||||
background-image: -webkit-linear-gradient(top, #428bca, 0%, #357ebd, 100%); |
||||
background-image: -moz-linear-gradient(top, #428bca 0%, #357ebd 100%); |
||||
background-image: linear-gradient(to bottom, #428bca 0%, #357ebd 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0); |
||||
} |
||||
|
||||
.navbar { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ffffff), to(#f8f8f8)); |
||||
background-image: -webkit-linear-gradient(top, #ffffff, 0%, #f8f8f8, 100%); |
||||
background-image: -moz-linear-gradient(top, #ffffff 0%, #f8f8f8 100%); |
||||
background-image: linear-gradient(to bottom, #ffffff 0%, #f8f8f8 100%); |
||||
background-repeat: repeat-x; |
||||
border-radius: 4px; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0); |
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); |
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); |
||||
} |
||||
|
||||
.navbar .navbar-nav > .active > a { |
||||
background-color: #f8f8f8; |
||||
} |
||||
|
||||
.navbar-brand, |
||||
.navbar-nav > li > a { |
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25); |
||||
} |
||||
|
||||
.navbar-inverse { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#3c3c3c), to(#222222)); |
||||
background-image: -webkit-linear-gradient(top, #3c3c3c, 0%, #222222, 100%); |
||||
background-image: -moz-linear-gradient(top, #3c3c3c 0%, #222222 100%); |
||||
background-image: linear-gradient(to bottom, #3c3c3c 0%, #222222 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0); |
||||
} |
||||
|
||||
.navbar-inverse .navbar-nav > .active > a { |
||||
background-color: #222222; |
||||
} |
||||
|
||||
.navbar-inverse .navbar-brand, |
||||
.navbar-inverse .navbar-nav > li > a { |
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); |
||||
} |
||||
|
||||
.navbar-static-top, |
||||
.navbar-fixed-top, |
||||
.navbar-fixed-bottom { |
||||
border-radius: 0; |
||||
} |
||||
|
||||
.alert { |
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2); |
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05); |
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05); |
||||
} |
||||
|
||||
.alert-success { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#dff0d8), to(#c8e5bc)); |
||||
background-image: -webkit-linear-gradient(top, #dff0d8, 0%, #c8e5bc, 100%); |
||||
background-image: -moz-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%); |
||||
background-image: linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #b2dba1; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0); |
||||
} |
||||
|
||||
.alert-info { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9edf7), to(#b9def0)); |
||||
background-image: -webkit-linear-gradient(top, #d9edf7, 0%, #b9def0, 100%); |
||||
background-image: -moz-linear-gradient(top, #d9edf7 0%, #b9def0 100%); |
||||
background-image: linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #9acfea; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0); |
||||
} |
||||
|
||||
.alert-warning { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#fcf8e3), to(#f8efc0)); |
||||
background-image: -webkit-linear-gradient(top, #fcf8e3, 0%, #f8efc0, 100%); |
||||
background-image: -moz-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%); |
||||
background-image: linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #f5e79e; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0); |
||||
} |
||||
|
||||
.alert-danger { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f2dede), to(#e7c3c3)); |
||||
background-image: -webkit-linear-gradient(top, #f2dede, 0%, #e7c3c3, 100%); |
||||
background-image: -moz-linear-gradient(top, #f2dede 0%, #e7c3c3 100%); |
||||
background-image: linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #dca7a7; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0); |
||||
} |
||||
|
||||
.progress { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#ebebeb), to(#f5f5f5)); |
||||
background-image: -webkit-linear-gradient(top, #ebebeb, 0%, #f5f5f5, 100%); |
||||
background-image: -moz-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%); |
||||
background-image: linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0); |
||||
} |
||||
|
||||
.progress-bar { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3071a9)); |
||||
background-image: -webkit-linear-gradient(top, #428bca, 0%, #3071a9, 100%); |
||||
background-image: -moz-linear-gradient(top, #428bca 0%, #3071a9 100%); |
||||
background-image: linear-gradient(to bottom, #428bca 0%, #3071a9 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3071a9', GradientType=0); |
||||
} |
||||
|
||||
.progress-bar-success { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5cb85c), to(#449d44)); |
||||
background-image: -webkit-linear-gradient(top, #5cb85c, 0%, #449d44, 100%); |
||||
background-image: -moz-linear-gradient(top, #5cb85c 0%, #449d44 100%); |
||||
background-image: linear-gradient(to bottom, #5cb85c 0%, #449d44 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0); |
||||
} |
||||
|
||||
.progress-bar-info { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#5bc0de), to(#31b0d5)); |
||||
background-image: -webkit-linear-gradient(top, #5bc0de, 0%, #31b0d5, 100%); |
||||
background-image: -moz-linear-gradient(top, #5bc0de 0%, #31b0d5 100%); |
||||
background-image: linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0); |
||||
} |
||||
|
||||
.progress-bar-warning { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f0ad4e), to(#ec971f)); |
||||
background-image: -webkit-linear-gradient(top, #f0ad4e, 0%, #ec971f, 100%); |
||||
background-image: -moz-linear-gradient(top, #f0ad4e 0%, #ec971f 100%); |
||||
background-image: linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0); |
||||
} |
||||
|
||||
.progress-bar-danger { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9534f), to(#c9302c)); |
||||
background-image: -webkit-linear-gradient(top, #d9534f, 0%, #c9302c, 100%); |
||||
background-image: -moz-linear-gradient(top, #d9534f 0%, #c9302c 100%); |
||||
background-image: linear-gradient(to bottom, #d9534f 0%, #c9302c 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0); |
||||
} |
||||
|
||||
.list-group { |
||||
border-radius: 4px; |
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); |
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075); |
||||
} |
||||
|
||||
.list-group-item.active, |
||||
.list-group-item.active:hover, |
||||
.list-group-item.active:focus { |
||||
text-shadow: 0 -1px 0 #3071a9; |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#3278b3)); |
||||
background-image: -webkit-linear-gradient(top, #428bca, 0%, #3278b3, 100%); |
||||
background-image: -moz-linear-gradient(top, #428bca 0%, #3278b3 100%); |
||||
background-image: linear-gradient(to bottom, #428bca 0%, #3278b3 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #3278b3; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff3278b3', GradientType=0); |
||||
} |
||||
|
||||
.panel { |
||||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); |
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); |
||||
} |
||||
|
||||
.panel-default > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f5f5f5), to(#e8e8e8)); |
||||
background-image: -webkit-linear-gradient(top, #f5f5f5, 0%, #e8e8e8, 100%); |
||||
background-image: -moz-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%); |
||||
background-image: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0); |
||||
} |
||||
|
||||
.panel-primary > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#428bca), to(#357ebd)); |
||||
background-image: -webkit-linear-gradient(top, #428bca, 0%, #357ebd, 100%); |
||||
background-image: -moz-linear-gradient(top, #428bca 0%, #357ebd 100%); |
||||
background-image: linear-gradient(to bottom, #428bca 0%, #357ebd 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff357ebd', GradientType=0); |
||||
} |
||||
|
||||
.panel-success > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#dff0d8), to(#d0e9c6)); |
||||
background-image: -webkit-linear-gradient(top, #dff0d8, 0%, #d0e9c6, 100%); |
||||
background-image: -moz-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%); |
||||
background-image: linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0); |
||||
} |
||||
|
||||
.panel-info > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#d9edf7), to(#c4e3f3)); |
||||
background-image: -webkit-linear-gradient(top, #d9edf7, 0%, #c4e3f3, 100%); |
||||
background-image: -moz-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%); |
||||
background-image: linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0); |
||||
} |
||||
|
||||
.panel-warning > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#fcf8e3), to(#faf2cc)); |
||||
background-image: -webkit-linear-gradient(top, #fcf8e3, 0%, #faf2cc, 100%); |
||||
background-image: -moz-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%); |
||||
background-image: linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0); |
||||
} |
||||
|
||||
.panel-danger > .panel-heading { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#f2dede), to(#ebcccc)); |
||||
background-image: -webkit-linear-gradient(top, #f2dede, 0%, #ebcccc, 100%); |
||||
background-image: -moz-linear-gradient(top, #f2dede 0%, #ebcccc 100%); |
||||
background-image: linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%); |
||||
background-repeat: repeat-x; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0); |
||||
} |
||||
|
||||
.well { |
||||
background-image: -webkit-gradient(linear, left 0%, left 100%, from(#e8e8e8), to(#f5f5f5)); |
||||
background-image: -webkit-linear-gradient(top, #e8e8e8, 0%, #f5f5f5, 100%); |
||||
background-image: -moz-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%); |
||||
background-image: linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%); |
||||
background-repeat: repeat-x; |
||||
border-color: #dcdcdc; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0); |
||||
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255, 255, 255, 0.1); |
||||
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(255, 255, 255, 0.1); |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
{ |
||||
"name": "yiisoft/yii2-bootstrap", |
||||
"description": "The Twitter Bootstrap extension for the Yii framework", |
||||
"keywords": ["yii", "bootstrap"], |
||||
"type": "yii2-extension", |
||||
"license": "BSD-3-Clause", |
||||
"support": { |
||||
"issues": "https://github.com/yiisoft/yii2/issues?state=open", |
||||
"forum": "http://www.yiiframework.com/forum/", |
||||
"wiki": "http://www.yiiframework.com/wiki/", |
||||
"irc": "irc://irc.freenode.net/yii", |
||||
"source": "https://github.com/yiisoft/yii2" |
||||
}, |
||||
"minimum-stability": "dev", |
||||
"require": { |
||||
"yiisoft/yii2": "*" |
||||
}, |
||||
"autoload": { |
||||
"psr-0": { "yii\\bootstrap\\": "" } |
||||
}, |
||||
"target-dir": "yii/bootstrap" |
||||
} |
||||
Loading…
Reference in new issue