Diskuse k MediaWiki:Common.js

Podpora pro navboxy editovat

Pustil jsem se do zprovozňování šablon pro navigační šablony převzatý z en. Potřeboval bych upravit Common.js po vzoru en. Bohužel si nejsem úplně jistý, co všechno je třeba přejmout. Myslím, že jsou to zejména následující kód:

 
/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *               [[Wikipedia:NavFrame]].
 *  Maintainers: [[User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = "hide";
var expandCaption = "show";
 
function collapseTable( tableIndex )
{
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
 
    if ( Button.firstChild.data == collapseCaption ) {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createCollapseButtons()
{
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );
 
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
            if (!HeaderRow) continue;
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
            if (!Header) continue;
 
            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
            var Button     = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
 
            Button.className = "collapseButton";  //Styles are declared in Common.css
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
 
            Header.insertBefore( Button, Header.childNodes[0] );
            tableIndex++;
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        } 
        else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
            var element = NavigationBoxes[i];
            while (element = element.parentNode) {
                if ( hasClass( element, "outercollapse" ) ) {
                    collapseTable ( i );
                    break;
                }
            }
        }
    }
}

Na en je zakončený ještě řádkem:

addOnloadHook( createCollapseButtons );

ale jestli to chápu dobře, na cs se tohle řeší přidáním řádku do function CustomizeCsWikipedia ():

createCollapseButtons();

Samozřejmě bude třeba ještě několik úprav. Kromě přepsání zakomentované hlavičky (klidně můžu být uveden jako maintainer; z popisu je třeba vyhodit odkaz na Wikipedia:NavFrame, který je stejně zastaralý, neboť systém využívá "collapsible tables" popsaný na en:Help:Collapsing), bude třeba přeložit collapseCaption a expandCaption, tedy měly by mít hodnotu "skryj" a "ukaž", resp. "skrýt" a "ukázat", pokud by se rozkazovací způsob nelíbil.

No a pak bude potřeba upravit MediaWiki:Common.css, tam bude potřeba vložit kód:

/* Default skin for navigation boxes */
table.navbox {            /* Navbox container style */
  border: 1px solid #aaa;
  width: 100%; 
  margin: auto;
  clear: both;
  font-size: 88%;
  text-align: center;
  padding: 1px;
}
table.navbox + table.navbox {  /* Single pixel border between adjacent navboxes */
  margin-top: -1px;            /* (doesn't work for IE6, but that's okay)       */
}
.navbox-title,
.navbox-abovebelow,
table.navbox th {
  text-align: center;      /* Title and above/below styles */
  padding-left: 1em;
  padding-right: 1em;
}
.navbox-group {            /* Group style */
  white-space: nowrap;
  text-align: right;
  font-weight: bold;
  padding-left: 1em;
  padding-right: 1em;
}
.navbox, .navbox-subgroup {
  background: #fdfdfd;     /* Background color */
}
.navbox-list {
  border-color: #fdfdfd;   /* Must match background color */
}
.navbox-title,
table.navbox th {
  background: #ccccff;     /* Level 1 color */
}
.navbox-abovebelow,
.navbox-group,
.navbox-subgroup .navbox-title {
  background: #ddddff;     /* Level 2 color */
}
.navbox-subgroup .navbox-group, .navbox-subgroup .navbox-abovebelow {
  background: #e6e6ff;     /* Level 3 color */
}
.navbox-even {
  background: #f7f7f7;     /* Even row striping */
}
.navbox-odd {
  background: transparent; /* Odd row striping */
}
 
.collapseButton {          /* 'show'/'hide' buttons created dynamically */
    float: right;          /* by the CollapsibleTables javascript in    */
    font-weight: normal;   /* [[MediaWiki:Common.js]]are styled here    */
    text-align: right;     /* so they can be customised.                */
    width: auto;
}
.navbox .collapseButton {  /* In navboxes, the show/hide button balances */
    width: 6em;            /* the vde links from [[Template:Tnavbar]],   */
}                          /* so they need to be the same width.         */

Může mi s tím někdo pomoci a tyto věci přidat? Díky. Miraceti 26. 6. 2009, 12:42 (UTC)

For the record: já rozhodně ne. --Mormegil 26. 6. 2009, 12:53 (UTC)
Tvoje řešení jsem neznal, AJAX by byl v lecčems lepší. Ale po té, co jsem dneska ráno sledoval, jak se tu mění navigační šablony jedna podruhé, jsem si řekl, že je třeba s tím něco udělat. Tohle sice není s AJAXem, ale k tomu nebude zas takový problém se časem propracovat. Mým hlavním cílem je dneska sjednotit přístupy vytváření navboxů jednotlivými uživateli, když už se ty navboxy používají (taky bych je tu radši neměl). V této chvíli je podle mě nejrozumější převzít fungující systém z jiného projektu a rozchodit ho zde (což se mi zatím nepodařilo). Miraceti 26. 6. 2009, 13:25 (UTC)

Infinitiv místo rozkazovacího způsobu editovat

Navrhuji změnit řetězec "skryj" na "skrýt" a "ukaž" na "ukázat". Jak jsem již zmínil na Nástěnce správců infinitiv je v uživatelských rozhraních v češtině na PC a i na Wikipedii (Editovat, Ukázat náhled) používanější a dle mého názoru lépe zní. Rovněž by došlo ke sjednocení pokynů v rámci české Wikipedie. Píšu to i jsem, když to souvisí s touto stránkou a jsem ten, komu se rozkazovací způsob nelíbí (viz výše). Děkuji --Phobulos 8. 9. 2011, 16:43 (UTC)

Hotovo, předěláno na skrýt/zobrazit. --Mormegil 8. 9. 2011, 19:53 (UTC)
Zobrazit je ještě lepší než ukázat. Ještě jednou díky. --Phobulos 9. 9. 2011, 17:41 (UTC)

Give search results even when page doesn't exist editovat

 
Screenshot of the Earth test search, with this script adding links to Wikidata, Reasonator, Commons, and Wikipedia.

Hello, I propose to enable the tool created by Magnus Manske (creator of MediaWiki) to provide results from other languages and Commons (via Wikidata) when a page doesn't exist here: links are added to Special:Search and noarticletext. This helps to encourage translation and to make readers use your wiki more, because they can be sure to find something even if it's not local (rather than searching directly on the biggest wiki). The Italian and Polish Wikipedias, among others already enabled it by default.
Examples: [1] [2] [3]. More information: Magnus blog.
How to: just add the following line at the end of Common.js.

// Results from Wikidata
// [[File:Wdsearch_script_screenshot.png]]
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
	importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}

--Nemo 12. 12. 2013, 12:04 (UTC) (comments, translations and last instructions)

Nice (and sorry for the lost </pre> above), seems to be working well on Special:Search. For missing articles, they'll need to tweak the script a bit, I hope you don't need to change anything here but I'll let you know. --Nemo bis (diskuse) 13. 12. 2013, 06:30 (UTC)

Updates editovat

Hi!

I started migrating the English Wikipedia code into a ResourceLoader-compatible gadget, and this requires a few pages to be moved, so the maintainer of this local gadget (Michal Bělka? Vojtěch Dostál?) might want to watch en:Wikipedia:RefToolbar/2.0/porting for future changes. For now, the only page moved was en:MediaWiki:RefToolbarBase.js to en:MediaWiki:Gadget-refToolbarBase.js, but there are a few more to come. Helder.wiki 1. 5. 2014, 21:14 (UTC)

Announced JavaScript change for badges implementation editovat

Hi! I want to let you know that in near future badges will be deployed on Wikidata and the Wikipedias. They help us with displaying the good and featured article icons next to the sitelinks and will replace the javascript hack which is used at the moment together with the Link GA and Link FA templates. To avoid an overlap where the current system and the new feature conflict, I will add a minor fix to your Common.js which adds the class names to the interwiki links. This is part of my task as a global edit interface editor for the Wikidata team. Thanks, Bene* (diskuse) 18. 8. 2014, 20:25 (UTC)

Zpět na stránku „Common.js“.