MediaWiki:Common.js

/* */

/* ######################################################################## */ /* ### JavaScript here is loaded for all users and all skins. ### */ /* ######################################################################## */

/* ######################################################################## */ /* ### SHARED CODE                                                     ### */ /* ### ### */ /* ### Description: Used by multiple modules                            ### */ /* ### Credit:     various                                             ### */ /* ######################################################################## */

/** * Removes lazy loading from all images contained in `lazyIcon`. * * By User:Sakaratte. */ function removeLazyLoad(lazyIcon) { var lazyIconImages = lazyIcon.getElementsByTagName("img"); for (var i = 0; i < lazyIconImages.length; i++) { var iconSrc = lazyIconImages[i].getAttribute("data-src"); if (iconSrc !== null) lazyIconImages[i].setAttribute("src", iconSrc); lazyIconImages[i].className = ""; } }

/* ######################################################################## */ /* ### TITLE ICONS (Template:Games)                                    ### */ /* ### ### */ /* ### Description: Add icons to article title                          ### */ /* ### Credit:     User:Porter21                                       ### */ /* ######################################################################## */

$(function {   if (window.wgIsMainpage)        return;    if (wgNamespaceNumber !== 0 && wgNamespaceNumber !== 4 && wgNamespaceNumber !== 110 && wgNamespaceNumber !== 502)        return;    if (skin !== "oasis" && skin !== "wikia")        return;

var wrapper = $("#va-titleicons-wrapper"); var iconBar = $("#va-titleicons"); var previewBar = $("#va-titleicons-preview"); if (wrapper.length === 0 || iconBar.length === 0 || $("a", previewBar).length === 0) return;

var articleDiv = $(".WikiaArticle"); if (articleDiv.length > 0) { iconBar.css("display", "block"); wrapper.prependTo(articleDiv); }

$("#va-titleicons-more").append("");

iconBar.hover(       function { $(this).addClass("va-titleicons-hover"); },        function { $(this).removeClass("va-titleicons-hover"); }    ); removeLazyLoad(document.getElementById("va-titleicons-preview")); removeLazyLoad(document.getElementById("va-titleicons-fullsize")); });

/* ############################################################################# */ /* ### TICKER                                                               ### */ /* ###  ### */ /* ### Description: Displays a ticker, as in Template:Ticker             ### */ /* ### Credit:     unknown                                                  ### */ /* ###             User:FDekker                                             ### */ /* ############################################################################# */ $(function {

$(".ticker").each(function(_, ticker) {       var step = 10;  // How many pixels to move text each tick        var tickerSpeed = 200;        ticker = $(ticker);        if (ticker.attr('data-speed') !== undefined)            tickerSpeed = parseInt(ticker.attr('data-speed'));        if (ticker.attr('data-step') !== undefined)            step = parseInt(ticker.attr('data-step'));        ticker.css("display", "block");

var wrapper = $(".tickerWrapper", ticker); wrapper.css("left", (step + ticker.width) + "px");

var text = $(".tickerText", ticker); var textWidth = text.outerWidth;

setInterval(function {           var offset =                (wrapper.position.left > -(textWidth + step))                    ? (wrapper.position.left - step) + "px"  // Move left                    : (ticker.width + step) + "px";  // Reset            wrapper.css("left", offset);        }, tickerSpeed); }); });

/* ###################################################################################### */ /* ### Staff Images                                                                  ### */ /* ###           ### */ /* ### Description: Loads all of the latest staff images on the staff page. ### */ /* ### URL: https://fallout.wikia.com/wiki/Fallout_Wiki:Administrators_and_moderators ### */ /* ### Credit:     User:TwoBearsHigh-Fiving                                          ### */ /* ###             User:FDekker                                                      ### */ /* ###################################################################################### */ $(function {   var placeholderClass = "user-image-placeholder";

var placeholders = $("." + placeholderClass); if (placeholders.length === 0) return;

var users = placeholders .map(function(_, placeholder) {            return $(placeholder).attr("data-user");        }) .map(function(_, user) {       	return user.replace(/@/g, "\"")        })        .toArray;    $.ajax({        url: "https://" + window.location.hostname + "/api/v1/User/Details",        data: { "ids": users.join(",") },        success: function(response) {            response.items.forEach(function(item) {            	var escapedName = item.name.replace(/"/g, "@")

$("." + placeholderClass + "[data-user]") // Separate filter to support quotes in usernames .filter(function {           			return $(this).data("user") === escapedName;            		}) .each(function(_, placeholder) {                       placeholder = $(placeholder);

var width = placeholder.attr("data-width"); var height = placeholder.attr("data-height"); if (width === undefined && height === undefined) { width = "100px"; height = "100px"; } else if (width === undefined || height === undefined) { width = width || height; height = width || height; }

placeholder.html(                           ""                        ); });           });        },        dataType: "json" }); });

/* ##################################################################################### */ /* ### Notable content                                                              ### */ /* ###          ### */ /* ### Description: Create a collapsible template where mw-collapsable is not        ### */ /* ###             suitable to use. ### */ /* ### URL: https://fallout.fandom.com/wiki/Fallout_Wiki:Notable_content/draft      ### */ /* ### Credit:     User:Sakaratte                                                   ### */ /* ##################################################################################### */

$(function {   var collapseCaption = "Less";    var expandCaption = "More";

document.querySelectorAll(".np-collapsible").forEach(function(collapsible) {       removeLazyLoad(collapsible);

var collapsed = collapsible.querySelector("#np-collapsed"); var helip = collapsible.querySelector("#np-helip"); helip.innerHTML = expandCaption; helip.addEventListener("click", function(e) {           var navState = helip.innerHTML;            var navClassList = collapsed.classList;

if (navState == expandCaption) { navClassList.add("np-visible"); navClassList.remove("np-hidden"); helip.innerHTML = collapseCaption; } else { navClassList.remove("np-visible"); navClassList.add("np-hidden"); helip.innerHTML = expandCaption; }       });    }); });

/* ##################################################################################### */ /* ### Main page                                                                    ### */ /* ###          ### */ /* ### Description: Styling all portal template                                      ### */ /* ###                                                                              ### */ /* ### URL: https://fallout.fandom.com/wiki/Template:Portal/Welcome                  ### */ /* ### Credit:     User:Old Man Leon                                                ### */ /* ##################################################################################### */

.portal { width: 100%; padding: 30px; box-sizing: border-box; background-size: cover; font-weight: 300; position: relative; margin-bottom: 15px; }

.portal__header { color: var(--theme-text-color); border-bottom: .05em solid var(--theme-text-color); margin-bottom: 20px; padding: 0.3em .2em; } .portal:before, .portal:after { content: ''; height: 85px; width: 100%; position: absolute; left: 0; z-index: 0; } .portal.welcome { background-size: 100%; background-position: center; font-weight: normal; padding: 0px; } .portal.welcome a { color: rgba(255, 255, 255, 0.8); }

.portal.welcome .portal__content { padding: 60px 0 40px 0; max-width: 650px; text-align: center; margin: auto; }

.portal__welcome__text { margin-top: 1.7em; margin-bottom: -1em; }

.portal__overlay { background: linear-gradient(180deg, var(--theme-gradient)); /*background-color: rgba(0, 0, 0, 0.5);*/ position: absolute; top: 0; right: 0; bottom: 0; left: 0; backdrop-filter: blur(2px) } .portal a, .portal a.visited { color: #fff !important; font-weight: bold; } .portal.navigation a { font-weight: 300; }

.portal__content { text-shadow: 1px 1px black; }

.portal__content .preloader { background-repeat: no-repeat; background-position: 1px 1px; } .portal__wrapper { position: relative; z-index: 1; } .portal__wrapper span { display: block; text-align: center; } .portal__header { font-size: 25px; }

.portal__header a { color: #12bfff; } .portal__content__aux { display: inline-block; position: relative; width: 150px; height: auto; margin: 5px 0; } .portal__content__aux:hover img { filter: drop-shadow(1px 1px 5px #fff); } .portal__content__aux a { cursor: pointer; }

/* ##################################################################################### */ /* ### Main page 1.1                                                                   ### */ /* ###          ### */ /* ### Description: Template styling and background images                                      ### */ /* ###                                                                              ### */ /* ### URL: https://fallout.fandom.com/wiki/Template:Portal/Welcome                  ### */ /* ### Credit:     User:Old Man Leon                                                ### */ /* ##################################################################################### */

.portal.welcome.bg--1 { background-image: url('//static.wikia.nocookie.net/fallout/images/3/33/11880458_465040637011449_7394173790093005597_n.jpg/revision/latest/scale-to-width-down/400'); } .portal.welcome.bg--2 { background-image: url('//static.wikia.nocookie.net/fallout/images/e/e3/KUfLmRR.jpg/revision/latest/scale-to-width-down/400'); } .portal.welcome.bg--3 { background-image: url('//static.wikia.nocookie.net/fallout/images/7/72/DgOAomHUEAAWKY-.jpg_large.jpg/revision/latest/scale-to-width-down/400'); }

.portal.navigation #hub .portal__overlay { background: transparent; }

.portal__categories { display: grid; grid-template-columns: auto auto auto auto auto; }

.portal__categories .category { box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8); width: 100px; height: 100px; margin: 15px auto; position: relative; }

.portal__categories .category .icon { width: 100px; height: 100px; background-position: center; background-repeat: no-repeat; background-size: 90%; transition: all .15s ease-in; margin: auto; position: relative; filter: grayscale(100%); } .portal__categories .category .icon:hover { filter: drop-shadow(1px 1px 5px #fff); }

.portal__categories .category .link-text { position: absolute; left: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); border-top-right-radius: 5px; padding: 0 5px 0 5px; font-family: Roboto,arial; font-size: 1em; font-weight:800; }

.portal__categories .category .link-text a, .portal__categories .category .link-text a:visited { color: white; }

.portal__categories .category .icon.Games { background-image: url('//static.wikia.nocookie.net/fallout/images/6/63/FO76_Atomic_Command.webp/revision/latest/scale-to-width-down/722'); } .portal__categories .category .icon.Characters { background-image: url('//'); } .portal__categories .category .icon.Creatures { background-image: url('//'); } .portal__categories .category .icon.Locations { background-image: url('//'); } .portal__categories .category .icon.Creation Club { background-image: url('//'); } .portal__categories .category .icon.Atomic Shop { background-image: url('//'); } .portal__categories .category .icon.Perks { background-image: url('//'); } .portal__categories .category .icon.Traits { background-image: url('//'); } .portal__categories .category .icon.Factions { background-image: url('//'); } .portal__categories .category .icon.Events { background-image: url('//'); } .portal__categories .category .icon.Lore { background-image: url('//'); } .portal__categories .category .icon.Music { background-image: url('//'); } .portal__categories .category .icon.Transcripts { background-image: url('//'); } .portal__categories .category .icon.Prima Guides { background-image: url('//'); } .portal__categories .category .icon.More { background-image: url('//'); }