MediaWiki:KevinWordBubble.js

$(function {   $("#WikiaPage").ready(function { if ($(".kevin-wb").length > -1) { kevinWBLoad; }   });    if (wgAction == "edit") {        var editPreviewObserver = new MutationObserver(function(editPreviewMutations) { editPreviewMutations.forEach(function(editPreviewMutation) {               Array.prototype.forEach.call(editPreviewMutation.addedNodes, function(editPreviewNode) { if (editPreviewNode.id == "EditPageDialog") { function kevinWBPreview { if ($(".kevin-wb").length >= 1) { kevinWBLoad; } else { setTimeout(kevinWBPreview, 0); }                       }

kevinWBPreview; }               });            });        });        editPreviewObserverTarget = document.body,        editPreviewObserverConfig = {            childList: true        };        editPreviewObserver.observe(editPreviewObserverTarget, editPreviewObserverConfig);    }

var kevinWBObserver = new MutationObserver(function(kevinWBMutations) {		kevinWBMutations.forEach(function(kevinWBMutation) { Array.prototype.forEach.call(kevinWBMutation.addedNodes, function(kevinWBNode) {				if (kevinWBNode.nodeType == 1) {					if (kevinWBNode.id == "article-comments") {                       if ($(".kevin-wb").length > -1) {                            kevinWBLoad;                        }					}				}			}); });	}),	kevinWBObserverTargetComment = document.querySelector("#WikiaArticleComments"), kevinWBObserverConfig = { childList: true, subtree: true };   if ($("#WikiaArticleComments").length >= 1) { kevinWBObserver.observe(kevinWBObserverTargetComment, kevinWBObserverConfig); }   function kevinWBCommentHeight { var kevinWBCommentCurrentHeight = $("div.article-comments").height;

function kevinWBCommentHeightChange { var kevinWBCommentNewHeight = $("div.article-comments").height;

if ($("div.article-comments").length >= 1 && $(".kevin-wb").length >= 1 && kevinWBCommentCurrentHeight !== kevinWBCommentNewHeight) { kevinWBCommentCurrentHeight = $("div.article-comments").height; kevinWBLoad; }       }        kevinWBCommentHeightChange; setInterval(kevinWBCommentHeightChange, 1000); }

kevinWBCommentHeight; $(window).on("unload", function {       if (wgAction == "edit") {            if ($(".kevin-wb").length > -1) {                kevinWBObserver.disconnect;                editPreviewObserver.disconnect;            }        } else if ($("#article-comments").length > -1) {            if ($(".kevin-wb").length > -1) {                kevinWBObserver.disconnect;                clearInterval(kevinWBCommentHeightChange);            }        }    }); });

function kevinWBLoad { $(".kevin-wb").each(function {       $(this).find("a").each(function { $(this).removeAttr("title"); });

$(this).find(".kevin-wb-hover-bar").html("H O V E R");

$(this).find(".kevin-wb-header").css({           "background": "url('" + $(this).find(".kevin-wb-header").data("kevin-wb-header-background") + "')"        });

$(this).find(".kevin-wb-middle").css({           "background": "url('" + $(this).find(".kevin-wb-middle").data("kevin-wb-middle-background") + "')"        });

$(this).find(".kevin-wb-bottom-header").css({           "background": "url('" + $(this).find(".kevin-wb-top-header").data("kevin-wb-bottom-header-background") + "')"        });

function kevinWBHexToRGBA(hex, alpha) { hex = hex.replace("#", ""); var r = parseInt(hex.substring(0, 2), 16), g = parseInt(hex.substring(2, 4), 16), b = parseInt(hex.substring(4, 6), 16), rgba = "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")"; return rgba; }

mw.util.addCSS(' \           .kevin-wb a:hover { \                text-decoration: underline !important; \                text-decoration-color:' + kevinWBHexToRGBA($(this).find(".kevin-wb-other-header").data("kevin-wb-header-bottom-gradient"), 0.75) + ' !important; \            } \            .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-primary-header-text { \                display: inline-block; \                position: relative; \                background: -webkit-linear-gradient(' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-top-gradient") + ', ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-bottom-gradient") + '); \                -webkit-background-clip: text; \                -webkit-text-fill-color: transparent; \                font-family: ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-font") + '; \ font-style: italic; \ font-size: 250%; \ } \           .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-secondary-header-text { \ display: inline-block; \ position: relative; \ background: -webkit-linear-gradient(' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-top-gradient") + ', ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-bottom-gradient") + '); \ -webkit-background-clip: text; \ -webkit-text-fill-color: transparent; \ font-family: ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-font") + '; \ font-style: italic; \ font-size: 150%; \ } \           .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-tertiary-header-text { \ display: inline-block; \ position: relative; \ background: -webkit-linear-gradient(' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-top-gradient") + ', ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-bottom-gradient") + '); \ -webkit-background-clip: text; \ -webkit-text-fill-color: transparent; \ font-family: ' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-font") + '; \ font-style: italic; \ font-size: 100%; \ } \           .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-primary-header-text:before { \ content: attr(data-primary-header-text); \ display: inline-block; \ position: absolute; \ z-index: -1; \ left: 0; \ background: none; \ text-shadow: 1px 1px' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-text-shadow-color") + '; \ } \           .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-secondary-header-text:before { \ content: attr(data-secondary-header-text); \ display: inline-block; \ position: absolute; \ z-index: -1; \ left: 0; \ background: none; \ text-shadow: 1px 1px' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-text-shadow-color") + '; \ } \           .' + $(this).find(".kevin-wb-other-header").data("kevin-wb-name") + '-tertiary-header-text:before { \ content: attr(data-tertiary-header-text); \ display: inline-block; \ position: absolute; \ z-index: -1; \ left: 0; \ background: none; \ text-shadow: 1px 1px' + $(this).find(".kevin-wb-other-header").data("kevin-wb-header-text-shadow-color") + '; \ } \       ');    });

$(".kevin-wb-hover").on("mouseenter", function {       $(this).siblings(".kevin-wb-image").hide;

if ($(this).hasClass("kevin-wb-biography")) { $(this).show; } else { $(this).siblings(".kevin-wb-biography").show; }   });

$(".kevin-wb-hover").on("mouseleave", function {       $(this).siblings(".kevin-wb-image").show;

if ($(this).hasClass("kevin-wb-biography")) { $(this).hide; } else { $(this).siblings(".kevin-wb-biography").hide; }   });

$(".kevin-wb-biography").hide; var detectIE = IEBrowser, detectIEEdge = IEEdgeBrowser, detectPre49Firefox = pre49FirefoxBrowser; function IEBrowser { var userAgent = window.navigator.userAgent, MSIEUserAgent = userAgent.indexOf('MSIE'), tridentUserAgent = userAgent.indexOf('Trident/');

if (MSIEUserAgent > -1 || tridentUserAgent > -1) { return true; } else { return false; }   }

function IEEdgeBrowser { var userAgent = window.navigator.userAgent, edgeUserAgent = userAgent.indexOf('Edge/');

if (edgeUserAgent > -1) { return true; } else { return false; }   }    function pre49FirefoxBrowser { var userAgent = window.navigator.userAgent, firefoxUserAgent = userAgent.indexOf('Firefox/');

if (firefoxUserAgent > -1) { var firefoxVersion = userAgent.split("Firefox/")[1].split(".")[0]; if (firefoxVersion < 49) { return true; }       } else { return false; }   }    if (detectIE === true) { $(".kevin-wb-other-header").hide; $(".kevin-wb-other-biography").hide; } else if (detectIEEdge === true) { $(".kevin-wb-firefox-ie-header").hide; $(".kevin-wb-other-biography").hide; } else if (detectPre49Firefox === true) { $(".kevin-wb-other-header").hide; $(".kevin-wb-ie-biography").hide; } else { $(".kevin-wb-firefox-ie-header").hide; $(".kevin-wb-ie-biography").hide; }   $(".kevin-wb-text").on("click", function {        var kevinWBTextSelection = getSelection.toString;        if (!kevinWBTextSelection) {            var kevinWBTextClick = new Date,                kevinWBTextLastClick = $(this).data("kevin-wb-text-last-clicked") || 0;            if ((kevinWBTextClick - kevinWBTextLastClick) >= 450) {                if (!$(this).hasClass("kevin-wb-expanded")) {                    $(this).queue("animations", function(nextAnimation) { $(this).closest(".kevin-wb-middle").children.fadeOut(350, function {                           nextAnimation;                        }); }).queue("animations", function(nextAnimation) { $(this).css({                           height: 300,                            marginBottom: 0                        }); $(this).parent.prependTo($(this).closest(".kevin-wb-middle")); $(this).parent.fadeIn(350); nextAnimation; }).dequeue("animations");                   $(this).addClass("kevin-wb-expanded");                } else {                    $(this).queue("animations", function(nextAnimation) { $(this).parent.fadeOut(350, function {                           nextAnimation;                        }); }).queue("animations", function(nextAnimation) { $(this).closest(".kevin-wb-middle").children.fadeIn(350); nextAnimation; }).queue("animations", function(nextAnimation) { $(this).css({                           height: 145,                            marginBottom: 10                        }); $(this).parent.insertBefore($(this).closest(".kevin-wb-middle").find(".kevin-wb-scroll3")); $(this).parent.fadeIn(350); nextAnimation; }).dequeue("animations");                   $(this).removeClass("kevin-wb-expanded");                }                $(this).data("kevin-wb-text-last-clicked", new Date);            }        }    }); }