-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
134 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
]); | ||
} | ||
} |
Oops, something went wrong.