Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
-> change package name 'shqear/yii2-bootstrap-expand-btn'
Browse files Browse the repository at this point in the history
-> update ExpandButton
-> release first version
  • Loading branch information
shqear93 committed Apr 28, 2016
1 parent 39a05e9 commit 9b5662b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 67 deletions.
92 changes: 41 additions & 51 deletions ExpandButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,49 @@

use yii\base\Widget;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\base\Exception;

/**
* Description of ExpandButton
*/
class ExpandButton extends Widget
{
public $label = 'Button';
const TYPE_PRIMARY = 'primary';
const TYPE_SUCCESS = 'success';
const TYPE_INFO = 'info';
const TYPE_WARNING = 'warning';
const TYPE_DANGER = 'danger';
const TYPE_LINK = 'link';

public $label = null;

/**
* @var array the HTML attributes of the button.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = ['class' => 'button'];
public $options = ['class' => 'btn'];

/**
* The button url, used only for split button
* @var string Button url
*/
public $url = '#';
public $url = null;

/**
* The button url, used only for split button
* @var string Button url
*/
public $urlOptions = [];

/**
* @var string icon class
*/
public $iconClass = 'glyphicon glyphicon-star';

/**
* @var string button type
*/
public $type = self::TYPE_PRIMARY;

/**
* @var string the tag to use to render the button
Expand All @@ -46,59 +69,26 @@ class ExpandButton extends Widget
*/
public function run()
{
/*$dropdown = Dropdown::begin($this->getDropdownConfig());
echo "\n" . $this->renderButton($dropdown);
Dropdown::end();
$this->registerPlugin('button');*/
}

/**
* Generates the button dropdown.
* @return string the rendering result.
*/
protected function renderButton($dropdown)
{
/*$dropdownId = $dropdown->getId();
$label = $this->label;
if ($this->encodeLabel) {
$label = Html::encode($label);
}
if ($this->split) {
$this->tagName = 'a';
Html::addCssClass($this->options, 'button');
Html::addCssClass($this->options, 'split');
$options = $this->options;
$label .= Html::tag('span', '', ['data-dropdown' => $dropdownId]);
ExpandButtonAsset::register(\Yii::$app->view);
if ($this->url) {
echo Html::a($this->renderButton(), $this->url, $this->urlOptions);
} else {
Html::addCssClass($this->options, 'dropdown');
$options = $this->options;
$options['data-dropdown'] = $dropdownId;
echo $this->renderButton();
}
return Button::widget([
'tagName' => $this->tagName,
'label' => $label,
'options' => $options,
'url' => $this->url,
'encodeLabel' => false,
]) . "<br />\n";*/
}

/**
* Get config for [[Dropdown]] widget
* @return array config options
* Generates the expand button.
* @return string the rendering result.
* @throws Exception
*/
protected function getDropdownConfig()
protected function renderButton()
{
/*$config = $this->dropdown;
$config['id'] = ArrayHelper::getValue($config, 'id', null);
$config['clientOptions'] = false;
$config['view'] = $this->getView();
return $config;*/
if (empty($this->label)) {
throw new Exception('you must set \'label\' for expand button');
}
Html::addCssClass($this->options, ['btn-' . $this->type, 'btn-expand']);
$label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
return Html::tag($this->tagName, Html::tag('i', null, ['class' => $this->iconClass]) . ' ' . $label, $this->options);
}

}
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
Yii2 Extension:

Yii2 Bootstrap Expand Btn
=============
Provide expanding buttons for Bootstrap 3.


Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist shqear/bootstrap-expand-btn "*"
php composer.phar require --prefer-dist shqear/yii2-bootstrap-expand-btn "*"
```

or add

```
"shqear/bootstrap-expand-btn": "*"
"shqear/yii2-bootstrap-expand-btn": "*"
```

to the require section of your `composer.json` file.


![Bootstrap Expand Btn](expand-btn.gif)

Usage
-----
coming soon...

Examples
--------
coming soon...
```php
echo ExpandButton::widget([
'label' => 'Test Button', 'type' => ExpandButton::TYPE_INFO,
]);
```

Legals
------
based on : http://smarchal.com/bootstrap-expand-btn

- Author : [Khaled AbuShqear] ([email protected])
- Licence : [MIT](http://opensource.org/licenses/MIT)
- Contact : [@zessx](https://fb.me/shqear)
- Contact : [[email protected]](https://fb.me/shqear)
- Link : [http://smarchal.com/bootstrap-expand-btn]()

0 comments on commit 9b5662b

Please sign in to comment.