Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("DOMContentLoaded", function () {
- var _fallbackImage = "";
- function _imageError() {
- image.src = _fallbackImage;
- }
- function hover(event) {
- if (this.hasAttribute("data-no-balloon")) return;
- balloon.style.display = "";
- var src = this.getAttribute("data-img");
- if (src) image.src = src; else _imageError();
- description.innerText = this.getAttribute("data-description");
- var bcr = this.getBoundingClientRect();
- var x = bcr.left + window.scrollX + bcr.width;
- var y = bcr.top + window.scrollY + bcr.height / 2.0;
- balloon.style.left = x + "px";
- balloon.style.top = y + "px";
- var container = this.parentElement;
- while (container && !container.getAttribute("data-img")) {
- container = container.parentElement;
- }
- if (container) _fallbackImage = container.getAttribute("data-img");
- }
- function leave(event) {
- balloon.style.display = "none";
- image.removeAttribute("src");
- }
- var links = document.querySelectorAll(".module.price .pricing a");
- for (var i = 0; i < links.length; i++) {
- links[i].onmouseover = hover;
- links[i].onmouseleave = leave;
- }
- var balloon = $gsm.tag("div", {"class": "price-balloon", "style": "display: none;"}, "", document.body);
- var imageContainer = $gsm.tag("div", {"class": "image"}, "", balloon);
- var image = $gsm.tag("img", {}, "", imageContainer);
- var description = $gsm.tag("span", {}, "", balloon);
- image.onerror = _imageError;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement