mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b8ca16
commit 810f4aa
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Tooltip functionality for WordPress. | ||
* | ||
* @version 6.5.0 | ||
* @output wp-includes/js/wp-tooltip.js | ||
*/ | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
// Select all tooltip containers on the page | ||
const tooltipContainers = document.querySelectorAll('.tooltip-container'); | ||
|
||
tooltipContainers.forEach(function (tooltipContainer) { | ||
const tooltipButton = tooltipContainer.querySelector('.tooltip-button'); | ||
const tooltipContent = tooltipContainer.querySelector('.tooltip-content'); | ||
|
||
tooltipButton.addEventListener('click', function () { | ||
// Toggle the display of the tooltip content | ||
tooltipContent.style.display = tooltipContent.style.display === 'block' ? 'none' : 'block'; | ||
}); | ||
|
||
document.addEventListener('keydown', function (event) { | ||
if (event.key === 'Escape' && tooltipContent.style.display === 'block') { | ||
// Hide the tooltip on Escape key press | ||
tooltipContent.style.display = 'none'; | ||
tooltipButton.focus(); | ||
} | ||
}); | ||
|
||
document.body.addEventListener('click', function (event) { | ||
// Check if the clicked element is not within the tooltip container | ||
if (!tooltipContent.contains(event.target) && !tooltipButton.contains(event.target)) { | ||
tooltipContent.style.display = 'none'; | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.tooltip-container { | ||
position: relative; | ||
display: inline-block; | ||
} | ||
|
||
.tooltip-button { | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
} | ||
|
||
.tooltip-content { | ||
display: none; | ||
position: absolute; | ||
background-color: #fff; | ||
border: 1px solid #ccc; | ||
padding: 5px; | ||
z-index: 1000; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
border-radius: 5px; | ||
width: 150px; | ||
text-align: center; | ||
top: auto; | ||
bottom: 140%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
margin-top: -10px; | ||
} | ||
|
||
.tooltip-arrow { | ||
position: absolute; | ||
top: 100%; | ||
left: 50%; | ||
margin-left: -10px; | ||
width: 0; | ||
height: 0; | ||
border-left: 10px solid transparent; | ||
border-right: 10px solid transparent; | ||
border-bottom: 10px solid #fff; | ||
transform: rotate(180deg) scaleX(-1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters