Difference between revisions of "MediaWiki:EditTemplates.js"

From Donate
Jump to navigation Jump to search
(update)
Line 5: Line 5:
 
importStylesheet( 'MediaWiki:EditTemplates.css' );
 
importStylesheet( 'MediaWiki:EditTemplates.css' );
   
$( 'body' ).append( '<div id="toolBox"><span id="toolText">Tools</span><img id="toolArrow" width="8" src="//upload.wikimedia.org/wikipedia/commons/thumb/1/10/ArrowRightNavbox.svg/32px-ArrowRightNavbox.svg.png"/></div>' );
+
$( 'body' ).append( '<div id="toolBox">Tools <img width="8" src="//upload.wikimedia.org/wikipedia/commons/thumb/1/10/ArrowRightNavbox.svg/32px-ArrowRightNavbox.svg.png"/></div>' );
   
 
var toolListHTML = ' \
$( 'body' ).append( '<div id="toolList"></div>' );
 
  +
<div id="toolList"> \
 
$( '#toolList' ).append( '<h4>Edit templates</h4>' );
+
<h4>Edit templates</h4> \
 
<ul> \
 
<li><a href="/wiki/Template:Lp-layout-default?action=edit">Overall Layout</a></li> \
 
<li><a href="/wiki/Template:2011FR/Appeal-template-default?action=edit">Appeal Template</a></li> \
 
<li>- <a href="/wiki/Template:2011FR/Appeal-default/text/@language?action=edit">Appeal Text</a></li> \
 
<li>- <a href="/wiki/Template:2011FR/Appeal-default/title/@language?action=edit">Appeal Title</a></li> \
 
<li><a href="/wiki/Template:2012FR/Form-template-whereyourdonation?action=edit">Form Template</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-countryspecific-control/@country?action=edit">Form Content</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/title/@language?action=edit">Infobox Title</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/text/@language?action=edit">Infobox Text</a></li> \
 
</ul> \
 
<h4>Files</h4> \
 
<ul> \
 
<li><a href="/wiki/Special:AllPages?namespace=6">All files</a></li> \
 
<li><a href="/wiki/Special:Upload">Upload file</a></li> \
 
</ul> \
 
<h4>Lists</h4> \
 
<ul> \
 
<li><a href="/wiki/Special:AllPages">All pages</a></li> \
 
<li><a href="/wiki/Special:PrefixIndex">All pages with prefix</a></li> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=2011FR/Appeal-&namespace=10">All appeals</a> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=2012FR/Form-&namespace=10">All forms</a> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=Styles&namespace=10">All styles</a></li> \
 
</ul> \
 
<h4>Other</h4> \
 
<ul> \
 
<li><a href="/wiki/Template:2012FR/Form-section/Paymentmethods">Payment methods</a></li> \
 
<li><a href="/wiki/MediaWiki:Common.js">Site JavaScript</a></li> \
 
<li><a href="/wiki/Special:MyContributions">My contributions</a></li> \
 
<li><a href="/wiki/MediaWiki:toolBox.js">This toolbox</a></li> \
 
</ul> \
  +
</div>';
   
 
var country = mw.util.getParamValue( 'country' ) || 'XX';
 
var country = mw.util.getParamValue( 'country' ) || 'XX';
 
var language = mw.util.getParamValue( 'uselang' ) || 'en';
 
var language = mw.util.getParamValue( 'uselang' ) || 'en';
 
var toolListHTML = ' \
 
<ul> \
 
<li><a href="/wiki/Template:Lp-layout-default?action=edit">Overall Layout</a></li> \
 
<li><a href="/wiki/Template:2011FR/Appeal-template-default?action=edit">Appeal Template</a></li> \
 
<li>- <a href="/wiki/Template:2011FR/Appeal-default/text/@language?action=edit">Appeal Text</a></li> \
 
<li>- <a href="/wiki/Template:2011FR/Appeal-default/title/@language?action=edit">Appeal Title</a></li> \
 
<li><a href="/wiki/Template:2012FR/Form-template-whereyourdonation?action=edit">Form Template</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-countryspecific-control/@country?action=edit">Form Content</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/title/@language?action=edit">Infobox Title</a></li> \
 
<li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/text/@language?action=edit">Infobox Text</a></li> \
 
</ul> \
 
<h4>Files</h4> \
 
<ul> \
 
<li><a href="/wiki/Special:AllPages?namespace=6">All files</a></li> \
 
<li><a href="/wiki/Special:Upload">Upload file</a></li> \
 
</ul> \
 
<h4>Lists</h4> \
 
<ul> \
 
<li><a href="/wiki/Special:AllPages">All pages</a></li> \
 
<li><a href="/wiki/Special:PrefixIndex">All pages with prefix</a></li> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=2011FR/Appeal-&namespace=10">All appeals</a> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=2012FR/Form-&namespace=10">All forms</a> \
 
<li><a href="/wiki/Special:PrefixIndex?prefix=Styles&namespace=10">All styles</a></li> \
 
</ul> \
 
<h4>Other</h4> \
 
<ul> \
 
<li><a href="/wiki/Template:2012FR/Form-section/Paymentmethods">Payment methods</a></li> \
 
<li><a href="/wiki/MediaWiki:Common.js">Site JavaScript</a></li> \
 
<li><a href="/wiki/Special:MyContributions">My contributions</a></li> \
 
<li><a href="/wiki/MediaWiki:toolBox.js">This toolbox</a></li> \
 
</ul>';
 
   
 
toolListHTML = toolListHTML.replace( /@country/g, country );
 
toolListHTML = toolListHTML.replace( /@country/g, country );
 
toolListHTML = toolListHTML.replace( /@language/g, language );
 
toolListHTML = toolListHTML.replace( /@language/g, language );
   
$( '#toolList' ).append( toolListHTML );
+
$( 'body' ).append( toolListHTML );
   
 
var showEditBox = function(){
 
var showEditBox = function(){

Revision as of 17:23, 25 August 2017

$(document).ready(function() {

    if ( mw.config.get('wgPageName') == "Special:LandingPage" ) {

        importStylesheet( 'MediaWiki:EditTemplates.css' );

        $( 'body' ).append( '<div id="toolBox">Tools <img width="8" src="//upload.wikimedia.org/wikipedia/commons/thumb/1/10/ArrowRightNavbox.svg/32px-ArrowRightNavbox.svg.png"/></div>' );

        var toolListHTML = ' \
<div id="toolList"> \
    <h4>Edit templates</h4> \
    <ul> \
        <li><a href="/wiki/Template:Lp-layout-default?action=edit">Overall Layout</a></li> \
        <li><a href="/wiki/Template:2011FR/Appeal-template-default?action=edit">Appeal Template</a></li> \
        <li>- <a href="/wiki/Template:2011FR/Appeal-default/text/@language?action=edit">Appeal Text</a></li> \
        <li>- <a href="/wiki/Template:2011FR/Appeal-default/title/@language?action=edit">Appeal Title</a></li> \
        <li><a href="/wiki/Template:2012FR/Form-template-whereyourdonation?action=edit">Form Template</a></li> \
        <li>- <a href="/wiki/Template:2012FR/Form-countryspecific-control/@country?action=edit">Form Content</a></li> \
        <li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/title/@language?action=edit">Infobox Title</a></li> \
        <li>- <a href="/wiki/Template:2012FR/Form-section/Infobox/Default/text/@language?action=edit">Infobox Text</a></li> \
    </ul> \
    <h4>Files</h4> \
    <ul> \
        <li><a href="/wiki/Special:AllPages?namespace=6">All files</a></li> \
        <li><a href="/wiki/Special:Upload">Upload file</a></li> \
    </ul> \
    <h4>Lists</h4> \
    <ul> \
        <li><a href="/wiki/Special:AllPages">All pages</a></li> \
        <li><a href="/wiki/Special:PrefixIndex">All pages with prefix</a></li> \
        <li><a href="/wiki/Special:PrefixIndex?prefix=2011FR/Appeal-&namespace=10">All appeals</a> \
        <li><a href="/wiki/Special:PrefixIndex?prefix=2012FR/Form-&namespace=10">All forms</a> \
        <li><a href="/wiki/Special:PrefixIndex?prefix=Styles&namespace=10">All styles</a></li> \
    </ul> \
    <h4>Other</h4> \
    <ul> \
        <li><a href="/wiki/Template:2012FR/Form-section/Paymentmethods">Payment methods</a></li> \
        <li><a href="/wiki/MediaWiki:Common.js">Site JavaScript</a></li> \
        <li><a href="/wiki/Special:MyContributions">My contributions</a></li> \
        <li><a href="/wiki/MediaWiki:toolBox.js">This toolbox</a></li> \
    </ul> \
</div>';

        var country = mw.util.getParamValue( 'country' ) || 'XX';
        var language = mw.util.getParamValue( 'uselang' ) || 'en';

        toolListHTML = toolListHTML.replace( /@country/g, country );
        toolListHTML = toolListHTML.replace( /@language/g, language );

        $( 'body' ).append( toolListHTML );

        var showEditBox = function(){
            $( '#toolList' ).css( 'display', 'inline-block' );
            $( '#toolBox' ).click( function(){ hideEditBox(); } );
        };
        var hideEditBox = function(){
            $( '#toolList' ).css( 'display', 'none' );
            $( '#toolBox' ).click( function(){ showEditBox(); } );
        };

        hideEditBox();
    }
    
});