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 1: Line 1:
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.0.min.js"></script>
<span class="marker">
<span class="marker">
<!--{$text}-->
<!--{$text}-->
Line 37: 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 53: Line 64:
     }
     }
};
};
console.log($('span').is(':offscreen'));
</script>
</script>

Revision as of 18:56, 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> 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');

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 = -300;
   }
   for (var i = 0; i < tooltipSpan.length; i++) {
   tooltipSpan[i].style.top = (y + 20) + 'px';
   tooltipSpan[i].style.left = (x + 2 + val) + 'px';
   }

};

console.log($('span').is(':offscreen')); </script>