Skip to content

Commit

Permalink
Fix #132: Upgrade to v2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Aug 14, 2014
1 parent 55c8291 commit 86ee7fc
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions widgets/Growl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014
* @package yii2-widgets
* @version 2.9.0
* @version 2.8.0
*/

namespace kartik\widgets;
Expand Down Expand Up @@ -46,9 +46,10 @@ class Growl extends Widget
public $title = '';

/**
* @var string the url for navigation on clicking the alert
* @var string the url to redirect to on clicking the alert. If this is <code>null</code> or not set,
* the alert will not be clickable.
*/
public $url = '';
public $linkUrl = '';

/**
* @var bool show title separator. Only applicable if `title` is set.
Expand Down Expand Up @@ -76,6 +77,26 @@ class Growl extends Widget
*/
public $useAnimation = true;

/**
* @var array the HTML attributes for the growl icon container.
*/
public $iconOptions = [];

/**
* @var array the HTML attributes for the growl title container.
*/
public $titleOptions = [];

/**
* @var array the HTML attributes for the growl message body.
*/
public $bodyOptions = [];

/**
* @var array the HTML attributes for the growl url link
*/
public $linkOptions = [];

/**
* @var array the bootstrap growl plugin configuration options
* @see http://bootstrap-growl.remabledesigns.com/
Expand Down Expand Up @@ -109,23 +130,25 @@ protected function initOptions()
'message' => $this->body,
'icon' => $this->icon,
'title' => $this->title,
'url' => $this->url
'url' => $this->linkUrl
];
$this->pluginOptions['type'] = $this->type;
if (empty($this->options['class'])) {
$this->options['class'] = 'alert col-xs-10 col-sm-10 col-md-3';
} else {
Html::addCssClass($this->options, 'alert');
}
$divider = !empty($this->showSeparator) && !empty($this->title) ? '<hr class="kv-alert-separator">' : '';
$content = $this->renderCloseButton();
$content .= <<< HTML
<span data-growl="icon"></span>
<span data-growl="title"></span>
{$divider}
<span data-growl="message"></span>
<a href="#" data-growl="url"></a>
HTML;
$divider = !empty($this->showSeparator) && !empty($this->title) ? '<hr class="kv-alert-separator">' . "\n" : '';
$this->iconOptions['data-growl'] = 'icon';
$this->titleOptions['data-growl'] = 'title';
$this->bodyOptions['data-growl'] = 'message';
$this->linkOptions['data-growl'] = 'url';
$content = $this->renderCloseButton() . "\n" .
Html::tag('span', '', $this->iconOptions) . "\n" .
Html::tag('span', '', $this->titleOptions) . "\n" .
$divider .
Html::tag('span', '', $this->bodyOptions) . "\n" .
Html::a('', '#', $this->linkOptions);
$this->pluginOptions['template'] = Html::tag('div', $content, $this->options);
$this->registerAssets();
}
Expand Down

0 comments on commit 86ee7fc

Please sign in to comment.