mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/6466] Remove createElement function from tooltip.js
PHPBB3-6466
This commit is contained in:
parent
89cb8a3217
commit
2e46bef2ec
1 changed files with 31 additions and 28 deletions
|
@ -25,10 +25,13 @@ var tooltips = [];
|
||||||
phpbb.enableTooltipsSelect = function (id, headline, subId) {
|
phpbb.enableTooltipsSelect = function (id, headline, subId) {
|
||||||
var $links, hold;
|
var $links, hold;
|
||||||
|
|
||||||
hold = document.createElement('span');
|
hold = $('<span />', {
|
||||||
hold.id = '_tooltip_container';
|
id: '_tooltip_container',
|
||||||
hold.setAttribute('id', '_tooltip_container');
|
css: {
|
||||||
hold.style.position = 'absolute';
|
position: 'absolute'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('body').append(hold);
|
$('body').append(hold);
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
@ -57,7 +60,7 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
|
||||||
* @param {string} headText Text heading to display
|
* @param {string} headText Text heading to display
|
||||||
*/
|
*/
|
||||||
phpbb.prepareTooltips = function ($element, headText) {
|
phpbb.prepareTooltips = function ($element, headText) {
|
||||||
var tooltip, text, desc, title;
|
var $tooltip, text, $desc, $title;
|
||||||
|
|
||||||
text = $element.attr('data-title');
|
text = $element.attr('data-title');
|
||||||
|
|
||||||
|
@ -65,17 +68,32 @@ phpbb.prepareTooltips = function ($element, headText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
title = phpbb.createElement('span', 'top');
|
$title = $('<span />', {
|
||||||
title.appendChild(document.createTextNode(headText));
|
class: 'top',
|
||||||
|
css: {
|
||||||
|
display: 'block'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.append(document.createTextNode(headText));
|
||||||
|
|
||||||
desc = phpbb.createElement('span', 'bottom');
|
$desc = $('<span />', {
|
||||||
desc.innerHTML = text;
|
class: 'bottom',
|
||||||
|
html: text,
|
||||||
|
css: {
|
||||||
|
display: 'block'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tooltip = phpbb.createElement('span', 'tooltip');
|
$tooltip = $('<span />', {
|
||||||
tooltip.appendChild(title);
|
class: 'tooltip',
|
||||||
tooltip.appendChild(desc);
|
css: {
|
||||||
|
display: 'block'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.append($title)
|
||||||
|
.append($desc);
|
||||||
|
|
||||||
tooltips[$element.attr('data-id')] = tooltip;
|
tooltips[$element.attr('data-id')] = $tooltip;
|
||||||
$element.on('mouseover', phpbb.showTooltip);
|
$element.on('mouseover', phpbb.showTooltip);
|
||||||
$element.on('mouseout', phpbb.hideTooltip);
|
$element.on('mouseout', phpbb.hideTooltip);
|
||||||
};
|
};
|
||||||
|
@ -101,21 +119,6 @@ phpbb.hideTooltip = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new element
|
|
||||||
*
|
|
||||||
* @param {string} tag HTML tag
|
|
||||||
* @param {string} c Element's class
|
|
||||||
*
|
|
||||||
* @return {object} Created element
|
|
||||||
*/
|
|
||||||
phpbb.createElement = function (tag, c) {
|
|
||||||
var x = document.createElement(tag);
|
|
||||||
x.className = c;
|
|
||||||
x.style.display = 'block';
|
|
||||||
return x;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Correct positioning of tooltip container
|
* Correct positioning of tooltip container
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue