MediaWiki:LangSelect.js

/** * LangSelectEdit.js * @author Speedit * @file Redirects edit buttons for Template:LangSelect */ (function (window, mw, $) {	'use strict';   // Variable caching and script scoping    var conf = mw.config.get([ 'skin', 'wgAction', 'wgIsArticle', 'wgRelevantPageName', ]);   if ( window.isLangSelectEditEnabled || !conf.wgIsArticle || conf.wgAction !== 'view' ) {       return;    }    window.isLangSelectEditEnabled = true;    /**     * @class LangEdit     * @classdesc The main LangEdit class     */    var LangSelectEdit = {        /**         * @method edit         * @description Method assigns the wikilink variable from the getLang         *              logic to the edit button.         * @param {string} target         * @returns {void}         */        edit: function(target) {            $('#ca-edit, #ca-ve-edit, #ca-viewsource').each(function { var link = (conf.skin === 'oasis') ? this : this.firstElementChild, uri = link.getAttribute('href').split('?'); uri[0] = mw.util.wikiGetlink(target); link.setAttribute(                   'href',                    uri.join('?')                ); });       },        /**         * @method init         * @description Method retrieves language variable from the DOM,         *              and passes the appropriate wikilink to the handler         *              if necessary.         * @param {void}         * @returns {void}         */        init: function {            if ( $('.transclude-notice').exists && !$('.template-documentation').exists ) {               var lang = $('.transclude-notice')                        .attr('data-uselang'),                    link = conf.wgRelevantPageName + '/' + lang;                this.edit(link);            }        }    };    mw.loader.using('mediawiki.util').then( $.proxy(LangSelectEdit.init, LangSelectEdit) ); }(window, mediaWiki, jQuery));