mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/6466] Improved code in tooltip.js
PHPBB3-6466
This commit is contained in:
parent
4d827b5b99
commit
faa5ab5899
1 changed files with 24 additions and 13 deletions
|
@ -12,7 +12,7 @@ phpBB Development Team:
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
var head_text, tooltip_mode, tooltips;
|
var head_text, tooltip_mode, tooltips;
|
||||||
tooltips = [];
|
tooltips = [];
|
||||||
|
@ -56,7 +56,10 @@ function enable_tooltips_link(id, headline, sub_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable tooltip replacements for selects
|
* Enable tooltip replacements for selects
|
||||||
|
* @param {string} id ID tag of select
|
||||||
|
* @param {string} headline Text that should appear on top of tooltip
|
||||||
|
* @param {string} sub_id Sub ID that should only be using tooltips (optional)
|
||||||
*/
|
*/
|
||||||
function enable_tooltips_select(id, headline, sub_id) {
|
function enable_tooltips_select(id, headline, sub_id) {
|
||||||
var $links, hold;
|
var $links, hold;
|
||||||
|
@ -76,7 +79,7 @@ function enable_tooltips_select(id, headline, sub_id) {
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
$links = $('.roles-options li');
|
$links = $('.roles-options li');
|
||||||
} else {
|
} else {
|
||||||
$links = $('#' + id + ' .roles-options li');
|
$links = $('.roles-options li', '#' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$links.each(function () {
|
$links.each(function () {
|
||||||
|
@ -95,7 +98,9 @@ function enable_tooltips_select(id, headline, sub_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare elements to replace
|
* Prepare elements to replace
|
||||||
|
*
|
||||||
|
* @param {object} $element Element to prepare for tooltips
|
||||||
*/
|
*/
|
||||||
function prepare($element) {
|
function prepare($element) {
|
||||||
var tooltip, text, desc, title;
|
var tooltip, text, desc, title;
|
||||||
|
@ -128,18 +133,22 @@ function prepare($element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show tooltip
|
* Show tooltip
|
||||||
|
*
|
||||||
|
* @param {object} $element Element passed by .on()
|
||||||
*/
|
*/
|
||||||
function show_tooltip(e) {
|
function show_tooltip($element) {
|
||||||
var $this = $(e.target);
|
var $this = $($element.target);
|
||||||
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
|
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
|
||||||
locate($this);
|
locate($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide tooltip
|
* Hide tooltip
|
||||||
|
*
|
||||||
|
* @param {object} $element Element passed by .on()
|
||||||
*/
|
*/
|
||||||
function hide_tooltip(e) {
|
function hide_tooltip($element) {
|
||||||
var d = document.getElementById('_tooltip_container');
|
var d = document.getElementById('_tooltip_container');
|
||||||
if (d.childNodes.length > 0) {
|
if (d.childNodes.length > 0) {
|
||||||
d.removeChild(d.firstChild);
|
d.removeChild(d.firstChild);
|
||||||
|
@ -167,13 +176,15 @@ function create_element(tag, c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Correct positioning of tooltip container
|
* Correct positioning of tooltip container
|
||||||
|
*
|
||||||
|
* @param {object} $element Tooltip element that should be positioned
|
||||||
*/
|
*/
|
||||||
function locate(e) {
|
function locate($element) {
|
||||||
var offset;
|
var offset;
|
||||||
|
|
||||||
e = e.parent();
|
$element = $element.parent();
|
||||||
offset = e.offset();
|
offset = $element.offset();
|
||||||
|
|
||||||
if (tooltip_mode === 'link') {
|
if (tooltip_mode === 'link') {
|
||||||
$('#_tooltip_container').css({
|
$('#_tooltip_container').css({
|
||||||
|
|
Loading…
Add table
Reference in a new issue