MediaWiki:Pseudo-Vector.js

/* Pseudo-Vector - turn the MonoBook skin into Vector  */ /*              ************************               */ /*        this is an auxiliary script with a few        */ /*      extra features/options for Pseudo-Vector       */ /*                 by OneTwoThreeFall                  */

/*jslint browser */ /*global window, jQuery, mediaWiki */

(function ($, mw) {   'use strict';

// double-run protection + only run in monobook if (window.pseudoVectorLoaded || mw.config.get('skin') !== 'monobook') { return; }   window.pseudoVectorLoaded = true;

// default prefs + translations var prefs = { addReadTab: true, addContributionsTab: false, disableWatchIcon: false, newDiffStyle: false, blacklist: [], cssArticles: [ 'u:dev:Pseudo-Vector/code.css' ],       readMsg: { // translations from https://translatewiki.net/wiki/Special:Translations?message=MediaWiki:Vector-view-view 'ar': 'اقرأ', 'de': 'Lesen', 'en': 'Read', 'es': 'Leer', 'fr': 'Lire', 'it': 'Leggi', 'ja': '閲覧', 'pl': 'Czytaj', 'pt-br': 'Ler', 'qqx': '(pseudovector-read)', 'ru': 'Читать', 'zh': '阅读' }   };

// load any custom prefs + make global window.pseudoVector = $.extend(true, prefs, window.pseudoVector); prefs = window.pseudoVector;

// use MediaWiki 1.20+ diff style if (prefs.newDiffStyle) { prefs.cssArticles.push('u:dev:NewDiffStyle/code.css'); }

// load CSS if wiki domain not in blacklist if ($.inArray(location.hostname, prefs.blacklist) === -1) { mw.loader.load(           '//dev.wikia.com/load.php' +                    '?debug=' + mw.config.get('debug') +                    '&lang=' + mw.config.get('wgUserLanguage') +                    '&mode=articles' +                    '&articles=' + encodeURIComponent(prefs.cssArticles.join('|')) +                    '&only=styles',            'text/css'        ); }

// JS-based tweaks $(function {        // add 'Search' box placeholder        $('#searchInput').attr('placeholder', $('#mw-searchButton').val);

// add 'Read' tab if (prefs.addReadTab && mw.config.get('wgArticleId')) { // use user language, then wiki language, then English as fallback var readMsg = prefs.readMsg[mw.config.get('wgUserLanguage')] || prefs.readMsg[mw.config.get('wgContentLanguage')] || prefs.readMsg.en;

var $readTab = $('').append(               $('', { 'href': mw.util.getUrl(mw.config.get('wgRelevantPageName')), 'text': readMsg })           );

// is another action tab selected already? if (!$('#p-cactions li.selected').not(':nth-child(1), :nth-child(2)').length) { $readTab.addClass('selected'); }

$('#ca-edit, #ca-viewsource').before($readTab); }

// add 'Contributions' tab on pages in the user namespaces if (prefs.addContributionsTab && $.inArray(mw.config.get('wgNamespaceNumber'), [2, 3, 1200]) !== -1) { var $contribTab = $('#t-contributions').clone.attr('id', 'ca-contribs'); $('#p-cactions li:nth-child(2)').after($contribTab); }

// use text instead of icon on 'Watch'/'Unwatch' tab if (prefs.disableWatchIcon) { $('#ca-watch, #ca-unwatch').addClass('no-watch-icon'); }   }); }(jQuery, mediaWiki));