mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-23 10:09:40 +08:00
made some changes, fix some pitfalls, remove PHP_EOL
This commit is contained in:
@@ -7,9 +7,7 @@
|
||||
|
||||
namespace yii\bootstrap\helpers\base;
|
||||
|
||||
use yii\bootstrap\enum\AlertEnum;
|
||||
use yii\bootstrap\enum\ButtonEnum;
|
||||
use yii\bootstrap\enum\BootstrapEnum;
|
||||
use yii\bootstrap\enum\Enum;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/**
|
||||
@@ -20,6 +18,24 @@ use yii\helpers\Html;
|
||||
*/
|
||||
class Button
|
||||
{
|
||||
/**
|
||||
* constants
|
||||
*/
|
||||
const TYPE_DEFAULT = 'btn';
|
||||
const TYPE_PRIMARY = 'btn-primary';
|
||||
const TYPE_INFO = 'btn-info';
|
||||
const TYPE_SUCCESS = 'btn-success';
|
||||
const TYPE_WARNING = 'btn-warning';
|
||||
const TYPE_DANGER = 'btn-danger';
|
||||
const TYPE_INVERSE = 'btn-inverse';
|
||||
const TYPE_LINK = 'btn-link';
|
||||
|
||||
const SIZE_DEFAULT = '';
|
||||
const SIZE_LARGE = 'btn-large';
|
||||
const SIZE_SMALL = 'btn-small';
|
||||
const SIZE_MINI = 'btn-mini';
|
||||
const SIZE_BLOCK = 'btn-block';
|
||||
|
||||
/**
|
||||
* Returns a dismissal alert link
|
||||
* @param string $text
|
||||
@@ -28,7 +44,7 @@ class Button
|
||||
*/
|
||||
public static function closeLink($text = '×', $dismiss = null)
|
||||
{
|
||||
$options = array('class' => BootstrapEnum::CLOSE);
|
||||
$options = array('class' => Enum::CLOSE);
|
||||
if(null !== $dismiss)
|
||||
$options['data-dismiss'] = $dismiss;
|
||||
return Html::a($text, '#', $options);
|
||||
@@ -42,7 +58,7 @@ class Button
|
||||
*/
|
||||
public static function closeButton($text = '×', $dismiss = null)
|
||||
{
|
||||
$options = array('type' => 'button', 'class' => BootstrapEnum::CLOSE);
|
||||
$options = array('type' => 'button', 'class' => Enum::CLOSE);
|
||||
if(null !== $dismiss)
|
||||
$options['data-dismiss'] = $dismiss;
|
||||
|
||||
@@ -60,9 +76,9 @@ class Button
|
||||
{
|
||||
// TODO: consider method add or append to ArrayHelper class
|
||||
if (isset($htmlOptions['class']))
|
||||
$htmlOptions['class'] .= ' ' . ButtonEnum::TYPE_LINK;
|
||||
$htmlOptions['class'] .= ' ' . static::TYPE_LINK;
|
||||
else
|
||||
$htmlOptions['class'] = ButtonEnum::TYPE_LINK;
|
||||
$htmlOptions['class'] = static::TYPE_LINK;
|
||||
|
||||
return Html::a($label, '#', $htmlOptions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user