Commit 22de2160 authored by Andreas Wolf's avatar Andreas Wolf Committed by Anja Leichsenring
Browse files

[TASK] Migrate Tooltip to TypeScript

Change-Id: I7de5841838784f5f3062e0657c30b272c0be7670
Resolves: #82607
Releases: master
Reviewed-on: https://review.typo3.org/56224

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Łukasz Uznański's avatarŁukasz Uznański <l.uznanski@macopedia.pl>
Tested-by: Łukasz Uznański's avatarŁukasz Uznański <l.uznanski@macopedia.pl>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent d1ce4b2b
......@@ -17,6 +17,7 @@ declare namespace TYPO3 {
export let Severity: any;
export let ShortcutMenu: any;
export let Storage: any;
export let Tooltip: any;
export let Utility: any;
export const lang: any;
export const settings: any;
......
/*
* 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;
......@@ -10,58 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Module: TYPO3/CMS/Backend/Tooltip
* API for tooltip windows powered by Twitter Bootstrap.
*/
define(['jquery', 'bootstrap'], function($) {
'use strict';
/**
* The main tooltip object
*
* @type {{}}
* @exports TYPO3/CMS/Backend/Tooltip
*/
var Tooltip = {};
/**
* Initialize
*/
Tooltip.initialize = function(selector, options) {
options = options || {};
$(selector).tooltip(options);
};
/**
* Show tooltip on $element
*
* @param {Object} $element
* @param {String} title
*/
Tooltip.show = function($element, title) {
$element
.attr('data-placement', 'auto')
.attr('data-title', title)
.tooltip('show');
};
/**
* Hide tooltip on $element
*
* @param {Object} $element
*/
Tooltip.hide = function($element) {
$element.tooltip('hide');
};
$(function() {
Tooltip.initialize('[data-toggle="tooltip"]');
});
// expose as global object
TYPO3.Tooltip = Tooltip;
return Tooltip;
});
define(["require","exports","jquery","bootstrap"],function(t,o,i){"use strict";var e=new(function(){function t(){var t=this;i(function(){t.initialize('[data-toggle="tooltip"]')})}return t.prototype.initialize=function(t,o){o=o||{},i(t).tooltip(o)},t.prototype.show=function(t,o){t.attr("data-placement","auto").attr("data-title",o).tooltip("show")},t.prototype.hide=function(t){t.tooltip("hide")},t}());return TYPO3.Tooltip=e,e});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment