MediaWiki:Placement.js

/** * @Name           Placement * @Version        v0.1 * @Author         TheGoldenPatrik1 * @Description    Library for script placement. * @Status         Experimental - Do Not Use */   if (window.dev && window.dev.placement) { return; }   window.placement = window.placement || {}; var config = mw.config.get([       'wgUserLanguage',        'wgContentLanguage'    ]); function createToolsMenu { // No I18n-js Here var i18n = { en: 'My Tools' };       i18n = i18n[config.wgUserLanguage] || i18n[config.wgUserLanguage.split('-')[0]] || i18n[config.wgContentLanguage] || i18n[config.wgContentLanguage.split('-')[0]]; $('#WikiaBar .toolbar .tools').prepend(           $('', { 'class': 'mytools menu' }).append( $(' ', {                   'class': 'arrow-icon-ctr'                }).append(                    $(' ', { 'class': 'arrow-icon arrow-icon-single' })               ),                $('', {                    href: '#',                    text: i18n                }), $('', {                   'class': 'tools-menu',                    id: 'my-tools-menu'                }) )       );        // If you have a better way of getting this to work... WikiaFooterApp.init; }   function generate (element) { var place; switch (element) { case 'editdropdown': place = '.page-header__contribution-buttons .wds-dropdown__content .wds-list'; break; case 'globalnav': place = '.wds-global-navigation__user-menu .wds-dropdown__content > .wds-list'; break; case 'toolbar': place = '#WikiaBar .toolbar .tools'; break; case 'tools': place = '#my-tools-menu'; break; case 'wikinav': place = '.wds-community-header__wiki-buttons .wds-dropdown__content .wds-list'; break; default: place = null; console.error('Element does not exist!'); }       return place; }   function main (element) { var config = window.placement[element]; var standard = generate(element); if (standard === null) { return; }       if ($(config).exists) { return config; } else if ($(standard).exists) { return standard; } else if (element === 'tools') { createToolsMenu; return element; }   }    window.dev = window.dev || {}; window.dev.placement = main; mw.hook('dev.placement').fire(window.dev.placement); }(this, jQuery, mediaWiki));
 * (function (window, $, mw) {