MediaWiki:BrockyWB.js

/* Autumnal - Brocky Character Page */ var brockyCharacterPage = { eventHandlers: function { $(".brocky-character-page #blogroll").on("click", function {           $(this).closest(".brocky-character-page").find("img.lzy.lzyPlcHld").each(function { if (typeof ImgLzy === "object") { ImgLzy.load(this); }           });        });        $(".brocky-character-page #slide-toggle").on("click", function {            $(this).closest(".brocky-character-page").find("#slide-panel").toggleClass("slide-pushed");            $(this).closest(".brocky-character-page").find("#navigation-panel").toggleClass('navigation-pushed');            $(this).closest(".brocky-character-page").find(".slide-left-icon").toggle(0);            $(this).closest(".brocky-character-page").find(".slide-right-icon").toggle(0);        }); $(".brocky-character-page #about").on("click", function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#about-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".about-icon").toggle(0);        }); $(".brocky-character-page #links").on("click", function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#links-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".links-icon").toggle(0);        }); $(".brocky-character-page #tags").on("click", function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#tags-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".tags-icon").toggle(0);        }); $(".brocky-character-page #faq").click(function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#faq-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".faq-icon").toggle(0);        }); $(".brocky-character-page #blogroll").click(function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#blogroll-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".blogroll-icon").toggle(0);        }); $(".brocky-character-page #extra").click(function {           $(this).closest("#navigation-panel").find(".close").not(this).click;            $(this).closest(".brocky-character-page").find("#extra-panel").toggle(0);            $(this).toggleClass("close");            $(this).closest(".brocky-character-page").find(".extra-icon").toggle(0);        }); },   pageEditor: function(MutationObserver) { if (wgAction == "edit") { if ("MutationObserver" in window) { var brockyCharacterPageEPObserver = new MutationObserver(function(brockyCharacterPageEPObserverMutations) {                   brockyCharacterPageEPObserverMutations.forEach(function(brockyCharacterPageEPObserverMutation) { Array.prototype.forEach.call(brockyCharacterPageEPObserverMutation.addedNodes, function(brockyCharacterPageEPObserverNode) {                           if (brockyCharacterPageEPObserverNode.id == "EditPageDialog") {                                brockyCharacterPage.articlePreview(MutationObserver);                            }                        }); });               });                var brockyCharacterPageEPObserverTarget = document.body, brockyCharacterPageEPObserverConfig = { childList: true, subtree: true };               brockyCharacterPageEPObserver.observe(brockyCharacterPageEPObserverTarget, brockyCharacterPageEPObserverConfig); }       }    },    pageEditorFallback: function { $(document.body).on("DOMNodeInserted", function (event) {           if (event.target.id == "EditPageDialog") {                $("#EditPageDialog").on("DOMNodeInserted", function (event) { if (event.target.className == "WikiaArticle") { if ($(".brocky-character-page").length) { brockyCharacterPage.init; }                   }                });            }        });    },    articlePreview: function(MutationObserver) { var brockyCharacterPageAPObserver = new MutationObserver(function(brockyCharacterPageAPMutations) {           brockyCharacterPageAPMutations.forEach(function(brockyCharacterPageAPMutation) { Array.prototype.forEach.call(brockyCharacterPageAPMutation.addedNodes, function(brockyCharacterPageAPNode) {                   if (brockyCharacterPageAPNode.className == "WikiaArticle") {                        brockyCharacterPageAPObserver.disconnect;                        brockyCharacterPage.init(this);                    }                }); });       });        var brockyCharacterPageAPObserverTarget = document.querySelector("#EditPageDialog"), brockyCharacterPageAPObserverConfig = { childList: true, subtree: true };       brockyCharacterPageAPObserver.observe(brockyCharacterPageAPObserverTarget, brockyCharacterPageAPObserverConfig); },   init: function { if ($(".brocky-character-page").length) { mw.util.addCSS(' \               @import url("https://fonts.googleapis.com/css?family=Poiret+One"); \                \                @font-face { \                    font-family: "saturnicons"; \                    src: url(//dl.dropbox.com/s/c81sfo74jq9g3kg/saturnicons.eot); \                    src:url(//dl.dropbox.com/s/c81sfo74jq9g3kg/saturnicons.eot?#iefix) format("embedded-opentype"), \                    url(//dl.dropbox.com/s/x8trqmytgani1sg/saturnicons.woff) format("woff"), \                    url(//dl.dropbox.com/s/9q3puzxagzaj7pc/saturnicons.ttf) format("truetype"), \                    url(//dl.dropbox.com/s/h9kqhix0ubm7rsf/saturnicons.svg#saturnicons) format("svg");  \                    font-weight:400; \                    font-style:normal; \                } \            '); }       brockyCharacterPage.eventHandlers; } }; $(function {   brockyCharacterPage.init;    if ("MutationObserver" in window) {        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;        brockyCharacterPage.pageEditor(MutationObserver);    } else {        brockyCharacterPage.pageEditorFallback;    } });