Skip to content

Commit

Permalink
fix tooltip tag closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Jan 1, 2019
1 parent 1215b50 commit 2ebdff3
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. This project make usage of the [Yii Versioning Strategy](https://github.com/yiisoft/yii2/blob/master/docs/internals/versions.md).

## 1.0.1.1 (1.1.2019)

+ [#24](https://github.com/luyadev/luya-bootstrap4/issues/24) Fixed tooltip tag and added test.

## 1.0.1 (3. December 2018)

+ [#20](https://github.com/luyadev/luya-bootstrap4/pull/20) Russian translations.
Expand Down
108 changes: 55 additions & 53 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion src/tags/TooltipTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,59 @@
/**
* Bootstrap 4 Tooltip Tag.
*
* Usage either trough add the module to the config or link the tag directly:
*
* ```php
* 'tags' => [
* 'tooltip' => ['class' => 'luya\bootstrap4\tags\TooltipTag'],
* ],
* ```
*
* @author Basil Suter <[email protected]>
* @since 1.0.0
*/
class TooltipTag extends BaseTag
{
/**
* @var string Whether it should possition: top, bottom, left, right. You can configure this while setup the tag.
*/
public $position = 'top';

/**
* @inheritDoc
*/
public function init()
{
parent::init();
$this->view->registerJs('$(\'[data-toggle="tooltip"]\').tooltip()', View::POS_READY);
}

/**
* @inheritDoc
*/
public function example()
{
return 'tooltip[Tooltip on Top](This is the tooltip text!)';
}

/**
* @inheritDoc
*/
public function readme()
{
return 'Generate a Tooltip element over a text (span) Element.';
}

/**
* @inheritDoc
*/
public function parse($value, $sub)
{
return Html::tag('span', $value, ['data-toggle' => 'tooltip', 'title' => $sub, 'data-placement' => $this->position]);
return Html::tag('span', $value, [
'data-toggle' => 'tooltip',
'title' => $sub,
'data-placement' => $this->position,
'class' => 'tooltip-info-span',
]);
}
}
Loading

0 comments on commit 2ebdff3

Please sign in to comment.