Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Migrate Tooltip to TypeScript
Change-Id: I7de5841838784f5f3062e0657c30b272c0be7670 Resolves: #82607 Releases: master Reviewed-on: https://review.typo3.org/56224 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de> Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de> Reviewed-by: Łukasz Uznański <l.uznanski@macopedia.pl> Tested-by: Łukasz Uznański <l.uznanski@macopedia.pl> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
- Loading branch information
1 parent
d1ce4b2
commit 22de216
Showing
3 changed files
with
64 additions
and
55 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
62 changes: 62 additions & 0 deletions
62
typo3/sysext/backend/Resources/Private/TypeScript/Tooltip.ts
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
import 'bootstrap'; | ||
import * as $ from 'jquery'; | ||
|
||
/** | ||
* The main tooltip object | ||
* | ||
* Hint: Due to the current usage of tooltips, this class can't be static right now | ||
*/ | ||
class Tooltip { | ||
constructor() { | ||
$((): void => { | ||
this.initialize('[data-toggle="tooltip"]'); | ||
}); | ||
} | ||
|
||
public initialize(selector: string, options?: object): void { | ||
options = options || {}; | ||
$(selector).tooltip(options); | ||
} | ||
|
||
/** | ||
* Show tooltip on $element | ||
* | ||
* @param {Object} $element | ||
* @param {String} title | ||
*/ | ||
public show($element: JQuery, title: string): void { | ||
$element | ||
.attr('data-placement', 'auto') | ||
.attr('data-title', title) | ||
.tooltip('show'); | ||
} | ||
|
||
/** | ||
* Hide tooltip on $element | ||
* | ||
* @param {Object} $element | ||
*/ | ||
public hide($element: JQuery): void { | ||
$element.tooltip('hide'); | ||
} | ||
} | ||
|
||
const tooltipObject = new Tooltip(); | ||
|
||
// expose as global object | ||
TYPO3.Tooltip = tooltipObject; | ||
|
||
export = tooltipObject; |
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