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 39: Line 39:


<script>
<script>
jQuery.expr.filters.offscreen = function(el) {
  var rect = el.getBoundingClientRect();
  return (
          (rect.x + rect.width) < 0
            || (rect.y + rect.height) < 0
            || (rect.x > window.innerWidth || rect.y > window.innerHeight)
        );
};


var tooltipSpan = document.getElementsByClassName('tooltip');
var tooltipSpan = document.getElementsByClassName('tooltip');
Line 57: Line 49:
var val = 0;
var val = 0;
     if(screen.width - e.screenX < 500){
     if(screen.width - e.screenX < 500){
     val = -300;
     val = -350;
     }
     }
console.log($('span').is(':offscreen'));


     for (var i = 0; i < tooltipSpan.length; i++) {
     for (var i = 0; i < tooltipSpan.length; i++) {

Revision as of 18:59, 9 August 2017

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.0.min.js"></script>

<style> .marker:hover .tooltip {

   display:block;
   position:fixed;
   overflow:hidden;
   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;
   white-space:pre-line;

}

.marker {

color: #f4f26b;

}

.marker:hover{

 color:#c3c155;
 cursor:default;

}

.marker .tooltip {

 display:none;

} </style>

<script>

var tooltipSpan = document.getElementsByClassName('tooltip');

window.onmousemove = function (e) {

   var x = e.clientX,
       y = e.clientY;
 /*  console.log(screen.width - e.screenX) */

var val = 0;

   if(screen.width - e.screenX < 500){
   val = -350;
   }
   for (var i = 0; i < tooltipSpan.length; i++) {
   tooltipSpan[i].style.top = (y + 20) + 'px';
   tooltipSpan[i].style.left = (x + 2 + val) + 'px';
   }

};

</script>