From 86ee7fcd9645dd1b3180b2bdfd1e37b13a481af8 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Thu, 14 Aug 2014 06:49:45 -0600 Subject: [PATCH] Fix #132: Upgrade to v2.9.0 --- widgets/Growl.php | 49 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/widgets/Growl.php b/widgets/Growl.php index 63b2390..1cda561 100644 --- a/widgets/Growl.php +++ b/widgets/Growl.php @@ -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; @@ -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 null or not set, + * the alert will not be clickable. */ - public $url = ''; + public $linkUrl = ''; /** * @var bool show title separator. Only applicable if `title` is set. @@ -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/ @@ -109,7 +130,7 @@ 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'])) { @@ -117,15 +138,17 @@ protected function initOptions() } else { Html::addCssClass($this->options, 'alert'); } - $divider = !empty($this->showSeparator) && !empty($this->title) ? '
' : ''; - $content = $this->renderCloseButton(); - $content .= <<< HTML - - - {$divider} - - -HTML; + $divider = !empty($this->showSeparator) && !empty($this->title) ? '
' . "\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(); }