Difference between revisions of "Template:Tt/sandbox"

From Detective Conan Wiki
m
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly><span class="tt-target">{{{1}}}<span class="tt-container tt-container-above" style="display: none;"><span class="tt-tooltip">{{{2}}}<span class="tt-chevron"></span></span></span></span>{{code
+
<includeonly><span class="ttt-target">{{{1}}}<span class="ttt-container ttt-container-above" style="display: none;"><span class="ttt-tooltip">{{{2}}}<span class="ttt-chevron"></span></span></span></span>{{code
 
|css=
 
|css=
 
     /* Target word for the tooltip to focus on */
 
     /* Target word for the tooltip to focus on */
     .tt-target {
+
     .ttt-target {
 
         position: relative;
 
         position: relative;
 
         display: inline-block;
 
         display: inline-block;
Line 12: Line 12:
 
     /* CONTAINER CLASSES */
 
     /* CONTAINER CLASSES */
 
     /* A so-called 'container' for the tooltip to work around in */
 
     /* A so-called 'container' for the tooltip to work around in */
     .tt-container {
+
     .ttt-container {
 
         position: absolute;
 
         position: absolute;
 
         left: 50%;
 
         left: 50%;
Line 29: Line 29:
 
      
 
      
 
     /* Container appear above target */
 
     /* Container appear above target */
     .tt-container-above {
+
     .ttt-container-above {
 
         bottom: 90%;
 
         bottom: 90%;
 
         transform: translate(-50%, 3px);
 
         transform: translate(-50%, 3px);
Line 35: Line 35:
 
      
 
      
 
     /* Container appear below target */
 
     /* Container appear below target */
     .tt-container-below {
+
     .ttt-container-below {
 
         top: 90%;
 
         top: 90%;
 
         transform: translate(-50%, -3px);
 
         transform: translate(-50%, -3px);
Line 43: Line 43:
 
      
 
      
 
     /* The TOOLTIP itself */
 
     /* The TOOLTIP itself */
     .tt-tooltip {
+
     .ttt-tooltip {
 
         background: #fff;
 
         background: #fff;
 
         border-radius: 4px;
 
         border-radius: 4px;
Line 58: Line 58:
 
     /* CHEVRON CLASSES */
 
     /* CHEVRON CLASSES */
 
     /* Shared class */
 
     /* Shared class */
     .tt-chevron {
+
     .ttt-chevron {
 
         position: absolute;
 
         position: absolute;
 
         left: 50%;
 
         left: 50%;
Line 69: Line 69:
 
      
 
      
 
     /* When tooltip is above */
 
     /* When tooltip is above */
     .tt-container-above .tt-chevron {
+
     .ttt-container-above .ttt-chevron {
 
         top: calc(100% - 2px);
 
         top: calc(100% - 2px);
 
         border-width: 9px 9px 0 9px;
 
         border-width: 9px 9px 0 9px;
Line 76: Line 76:
 
      
 
      
 
     /* When tooltip is below */
 
     /* When tooltip is below */
     .tt-container-below .tt-chevron {
+
     .ttt-container-below .ttt-chevron {
 
         bottom: calc(100% - 2px);
 
         bottom: calc(100% - 2px);
 
         border-width: 0 9px 9px 9px;
 
         border-width: 0 9px 9px 9px;
Line 86: Line 86:
 
     /* HOVER ANIMATION CLASSES */
 
     /* HOVER ANIMATION CLASSES */
 
     /* Tooltip fade-in */
 
     /* Tooltip fade-in */
     .tt-target:hover .tt-container {
+
     .ttt-target:hover .ttt-container {
 
         opacity: 1;
 
         opacity: 1;
 
         transform: translate(-50%, 0);
 
         transform: translate(-50%, 0);
Line 96: Line 96:
  
 
     /* Text bold on hover */
 
     /* Text bold on hover */
     .tt-target:hover {
+
     .ttt-target:hover {
 
         border-bottom: 0.0625em dashed;
 
         border-bottom: 0.0625em dashed;
 
     }
 
     }
 
     /* END OF HOVER ANIMATION CLASSES */
 
     /* END OF HOVER ANIMATION CLASSES */
   
+
}}</includeonly><noinclude>
}}</includeonly><noinclude>We love {{tt/sandbox|DC|Detective Conan<ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
+
<code>tt/sandbox </code> We love {{tt/sandbox|DC|Detective Conan<ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
 +
 
 +
<code>tt/sandbox </code> We love {{tt/sandbox|DC|Detective Conan<ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
 +
 
 +
<code>tt/sandbox </code> We love {{tt/sandbox|DC|Detective Conan<ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
 +
 
 +
<code>tt</code> {{tt|DC|Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan <ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
  
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.
+
<code>tt</code> {{tt|DC|Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan <ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
  
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy augue.
+
<code>tt</code> {{tt|DC|Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan Detective Conan <ref>wjdid</ref>}}<ref>qwoidjqwoi</ref><ref>e9qjr</ref>
  
Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy. Fusce aliquet pede non pede. Suspendisse dapibus lorem pellentesque magna. Integer nulla.
 
  
Donec blandit feugiat ligula. Donec hendrerit, felis et imperdiet euismod, purus ipsum pretium metus, in lacinia nulla nisl eget sapien. Donec ut est in lectus consequat consequat. Etiam eget dui. Aliquam erat volutpat. Sed at lorem in nunc porta tristique.
+
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
 +
<br>
  
Proin nec augue. Quisque aliquam tempor magna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc ac magna. Maecenas odio dolor, vulputate vel, auctor ac, accumsan id, felis. Pellentesque cursus sagittis felis.
+
<pre>
 +
// IMPORTANT: When testing using the browser console, remove the DOMContentLoaded event listener
 +
    document.addEventListener("DOMContentLoaded", function () {
 +
    var tooltips = document.querySelectorAll(".ttt-container");
 +
   
 +
    function adjustTooltipPositions() {
 +
        Array.prototype.forEach.call(tooltips, function (tooltipContainer) {
 +
            var tooltip = tooltipContainer.querySelector(".ttt-tooltip");
 +
            var chevron = tooltip.querySelector(".ttt-chevron");
 +
           
 +
            // 1. Temporarily show tooltip to measure size
 +
            tooltipContainer.style.opacity = "0";
 +
            tooltipContainer.style.display = "flex";
 +
            tooltip.style.transform = "";
 +
           
 +
            var tooltipRect = tooltip.getBoundingClientRect();
 +
            var targetRect = tooltipContainer.parentElement.getBoundingClientRect();
 +
           
 +
            // 2. Measure how much the tooltip is outside the viewport
 +
            var overflowTop = tooltipRect.top < 1;
 +
            var spaceTop = targetRect.top > tooltipRect.height + 10;
 +
            var overflowLeft = Math.min(Math.max(0, -tooltipRect.left), 0.5 * tooltipRect.width - 15);
 +
            var overflowRight = Math.min(Math.max(0, tooltipRect.right - document.documentElement.clientWidth), 0.5 * tooltipRect.width - 15);
 +
           
 +
            // 3. Shift tooltip into view if needed and move chevron accordingly
 +
            if (overflowTop) {
 +
                tooltipContainer.classList.remove("ttt-container-above");
 +
                tooltipContainer.classList.add("ttt-container-below");
 +
            } else if (spaceTop) {
 +
                tooltipContainer.classList.add("ttt-container-above");
 +
                tooltipContainer.classList.remove("ttt-container-below");
 +
            }
 +
           
 +
            if (overflowLeft > 0) {
 +
                tooltip.style.transform = "translateX(calc(" + overflowLeft + "px + 4px))";
 +
                chevron.style.transform = "translateX(calc(-50% - " + overflowLeft + "px - 4px))";
 +
            } else if (overflowRight > 0) {
 +
                tooltip.style.transform = "translateX(calc(-" + overflowRight + "px - 4px))";
 +
                chevron.style.transform = "translateX(calc(-50% + " + overflowRight + "px + 4px))";
 +
            } else {
 +
                tooltip.style.transform = "";
 +
                chevron.style.transform = "";
 +
            }
 +
           
 +
            // 4. Hide it again until hover
 +
            tooltipContainer.style.opacity = "";
 +
            tooltipContainer.style.display = "";
 +
        });
 +
    }
 +
   
 +
    // Run on page load, resize, and scroll
 +
    adjustTooltipPositions();
 +
    window.addEventListener("resize", adjustTooltipPositions);
 +
    window.addEventListener("scroll", adjustTooltipPositions, true);
 +
});
 +
</pre>
 
</noinclude>
 
</noinclude>

Latest revision as of 12:50, 11 June 2025

tt/sandbox We love DC[2][3]

tt/sandbox We love DC[5][6]

tt/sandbox We love DC[8][9]

tt DC[11][12]

tt DC[14][15]

tt DC[17][18]



































































// IMPORTANT: When testing using the browser console, remove the DOMContentLoaded event listener
    document.addEventListener("DOMContentLoaded", function () {
    var tooltips = document.querySelectorAll(".ttt-container");
    
    function adjustTooltipPositions() {
        Array.prototype.forEach.call(tooltips, function (tooltipContainer) {
            var tooltip = tooltipContainer.querySelector(".ttt-tooltip");
            var chevron = tooltip.querySelector(".ttt-chevron");
            
            // 1. Temporarily show tooltip to measure size
            tooltipContainer.style.opacity = "0";
            tooltipContainer.style.display = "flex";
            tooltip.style.transform = "";
            
            var tooltipRect = tooltip.getBoundingClientRect();
            var targetRect = tooltipContainer.parentElement.getBoundingClientRect();
            
            // 2. Measure how much the tooltip is outside the viewport
            var overflowTop = tooltipRect.top < 1;
            var spaceTop = targetRect.top > tooltipRect.height + 10;
            var overflowLeft = Math.min(Math.max(0, -tooltipRect.left), 0.5 * tooltipRect.width - 15);
            var overflowRight = Math.min(Math.max(0, tooltipRect.right - document.documentElement.clientWidth), 0.5 * tooltipRect.width - 15);
            
            // 3. Shift tooltip into view if needed and move chevron accordingly
            if (overflowTop) {
                tooltipContainer.classList.remove("ttt-container-above");
                tooltipContainer.classList.add("ttt-container-below");
            } else if (spaceTop) {
                tooltipContainer.classList.add("ttt-container-above");
                tooltipContainer.classList.remove("ttt-container-below");
            }
            
            if (overflowLeft > 0) {
                tooltip.style.transform = "translateX(calc(" + overflowLeft + "px + 4px))";
                chevron.style.transform = "translateX(calc(-50% - " + overflowLeft + "px - 4px))";
            } else if (overflowRight > 0) {
                tooltip.style.transform = "translateX(calc(-" + overflowRight + "px - 4px))";
                chevron.style.transform = "translateX(calc(-50% + " + overflowRight + "px + 4px))";
            } else {
                tooltip.style.transform = "";
                chevron.style.transform = "";
            }
            
            // 4. Hide it again until hover
            tooltipContainer.style.opacity = "";
            tooltipContainer.style.display = "";
        });
    }
    
    // Run on page load, resize, and scroll
    adjustTooltipPositions();
    window.addEventListener("resize", adjustTooltipPositions);
    window.addEventListener("scroll", adjustTooltipPositions, true);
});
  1. ^ wjdid
  2. ^ qwoidjqwoi
  3. ^ e9qjr
  4. ^ wjdid
  5. ^ qwoidjqwoi
  6. ^ e9qjr
  7. ^ wjdid
  8. ^ qwoidjqwoi
  9. ^ e9qjr
  10. ^ wjdid
  11. ^ qwoidjqwoi
  12. ^ e9qjr
  13. ^ wjdid
  14. ^ qwoidjqwoi
  15. ^ e9qjr
  16. ^ wjdid
  17. ^ qwoidjqwoi
  18. ^ e9qjr