Widget:Tooltip: Difference between revisions
From Unforgotten Realms Wiki
Jump to navigationJump to search
imported>Pillowkeeper No edit summary |
imported>Pillowkeeper No edit summary |
||
| Line 8: | Line 8: | ||
<style> | <style> | ||
.marker | .marker:hover .tooltip, .hovered .tooltip { | ||
display:block !important; | display:block !important; | ||
position:fixed; | position:fixed; | ||
overflow: | overflow:auto; | ||
background: rgba(33,33,33,1); | background: rgba(33,33,33,1); | ||
border-radius:5px; | border-radius:5px; | ||
| Line 20: | Line 20: | ||
font-size: 14px; | font-size: 14px; | ||
max-width: 400px; | max-width: 400px; | ||
max-height: 500px; | |||
white-space:pre-line; | white-space:pre-line; | ||
} | } | ||
Revision as of 12:21, 10 August 2017
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.0.min.js"></script>
<style>
.marker:hover .tooltip, .hovered .tooltip {
display:block !important; position:fixed; overflow:auto; background: rgba(33,33,33,1); border-radius:5px; border: 2px solid #8b4513; padding: 5px 8px; color: white; font-family: sans-serif; font-size: 14px; max-width: 400px; max-height: 500px; white-space:pre-line;
}
.marker {
color: #f4f26b;
}
.marker:hover{
color:#c3c155; cursor:default;
}
.marker .tooltip {
display:none;
} </style>
<script> var tooltipSpan = document.getElementsByClassName('tooltip');
$(".marker").click(function(evt) { if(!$(this).hasClass("hovered")){ $(this).addClass("hovered"); } else { $(this).removeClass("hovered"); } evt.stopImmediatePropagation();
});
function reset(e){
if ($(e.currentTarget).parent().hasClass("marker")){
$(".marker").each(function() {
$(this).removeClass("hovered"); }); } }
function move(e) { if (!$(e.currentTarget).hasClass("hovered")){
var x = e.clientX,
y = e.clientY;
var xoffset = 0;
if(screen.width - e.clientX < 550){
xoffset = -350;
}
var yoffset = 0;
if(screen.height - e.clientY < 250){
yoffset = -40;
}
for (var i = 0; i < tooltipSpan.length; i++) {
tooltipSpan[i].style.top = (y + 15 + yoffset) + 'px';
tooltipSpan[i].style.left = (x + 2 + xoffset) + 'px';
}
} }
</script>


