MediaWiki:Common.js

Skift til: navigering, søgning

Bemærk: Efter at have gemt er du måske nødt til at tømme din browsers cache for at kunne se ændringerne.

  • Firefox / Safari: Hold Shift nede og klik på Reload, eller tryk enten Ctrl-F5 eller Ctrl-R (⌘-R på en Mac).
  • Google Chrome: Tryk Ctrl-Shift-R (⌘-Shift-R på en Mac).
  • Internet Explorer: Hold Ctrl nede og klik på Refresh, eller tryk på Ctrl-F5.
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files
/* Javascript inkluderet her vil være aktivt for alle brugere. */

/* Tilføjer WikiEditor-extension med knapper og rulned-menu */
/* Skal aktiveres i indstillinger eller i LocalSettings som standard  */

importScript( 'MediaWiki:Gadget-Edittools.js' );

var customizeToolbar = function() {
        /* Koden indsættes her */

/* Overflødige knapper og tegnsæt under Specialtegn fjernes her */
/* eller i jquery.wikiEditor.toolbar.config.js */

$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
        'section': 'main',
        'group': 'insert',
        'tool': 'signature'
});

$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tool': 'newline'
});

$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
        'section': 'characters',
        'page': 'latin',
});

/* Indsæt knapper i Avanceret-'Format'  */

$('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "strikethrough": {
                        label: 'Gennemstreget',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/6/6d/Vector_strikeout.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<s>",
                                        post: "</s>"
                                }
                        }
                }
        }
});

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "på dansk": {
                        label: 'Understreget',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/1/13/Toolbaricon_regular_U_underline.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<u>",
                                        post: "</u>"
                                }
                        }
                }
        }
});


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Venstrestillet kursiv tekst med mellemrum',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/81/Toolbaricon_justify-left.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<div style='white-space:pre'>''",
                                        post: "''</div>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Centreret kursiv tekst med mellemrum',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/34/Toolbar_miss_signature.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<center style='white-space:pre'>''",
                                        post: "''</center>"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Centrér tekst',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<center>",
                                        post: "</center>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Højrestillet tekst',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<div align=right>",
                                        post: "</div>"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Opdeler i 2 kolonner',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/04/Button_multicol.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<table width=100%>\n<tr valign=top>\n<td width=50%>\n",
                                        post: "\n<td>\n\n</tr>\n</table>"
                                }
                        }
                }
        }
} );

/* Indsæt knapper i Avanceret-'Indsæt'  */

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Bøjningsform til ekstern link',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/7/7b/Tilde_button.PNG',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[da:",
                                        post: "]]\n[[kategori:Bøjning]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "wikipedia": {
                        label: 'Omdirigér til dansk Wikipedia',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/33/Toolbar_welcome.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[wp:",
                                        post: "]]\n[[kategori:wikipedia]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Omdirigér til engelsk Wiktionary',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/e/e5/Toolbar_wikt_new.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[wikt:",
                                        post: "#Latin]]\n[[kategori:wiktionary]]\n[[kategori:latin]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Omdirigér til sproget.dk',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/49/Toolbaricon_regular_S.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[sprog:",
                                        post: "]]\n[[kategori:sproget]]\n[[kategori:Den Danske Ordbog]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Omdirigér til Den Danske Ordbog',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/41/Toolbaricon_regular_D.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[ddo:",
                                        post: "]]\n[[kategori:Den Danske Ordbog]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Omdirigér til Ordbog over det Danske Sprog',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/7/71/Toolbaricon_regular_O.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[ods:",
                                        post: "]]\n[[kategori:Ordbog over det Danske Sprog]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Link til landsby-kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/db/Toolbaricon_regular_L.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        post: "]]\n[[kategori:landsby]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Omdefinér navn',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/85/Toolbaricon_regular_N.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[da:",
                                        post: "]]\n[[kategori:]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Flertydigt navn',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/3d/Toolbar_desambig.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{flere}}\n*",
                                        post: "\n*\n\n[[kategori:]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "navb": {
                        label: 'Indsætter en navigationsboks',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/4c/Button_interprojet.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{Navboks\n| navn   = \n| titel  = [[:kategori:",
                                        post: "|]]\n| billede-venstre = \n| billede = \n\n| liste1  = \n\n|status=<noinclude>uncollapsed</noinclude>{{{1|}}}||navbar=<includeonly>{{{2|plain}}}</includeonly>}}"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Intern link til kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/0c/Vector_toolbar_category_uk_button.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        post: "]]\n[[kategori:kategoriord]]"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "category": {
                        label: 'Indsæt kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[kategori:",
                                        post: "]]\n"
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Indsætter dokumentation',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/dd/P_writing_icon.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "\n== Noter ==\n{{Doku||",
                                        post: "|}}\n\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Usynlig kommentar',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Norwegian_quote_sign.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<!-- ",
                                        post: " -->"
                                }
                        }
                }
        }
} );

/* Tilpasser værktøjslinjen hvis man er i redigeringstilstand og de nødvendige moduler er til rådighed */
};

if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
}


/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *               [[Wikipedia:NavFrame]].
 *  Maintainers: [[User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = "skjul";
var expandCaption = "vis";
 
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.style.styleFloat = "right";
            Button.style.cssFloat = "right";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "right";
            Button.style.width = "6em";
 
            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 );
        }
    }
}
 
addOnloadHook( createCollapseButtons );

/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
 
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();


/*
F11 - fjerner søjlen til venstre [[mw:Manual:FAQ#How_do_I_hide_the_left_vertical_navigation_toolbar]]
*/

document.onkeydown = function( e ) {
	if( e == null ) e = event
	if( testKey( e, 122 ) ) { //F11
		appendCSS('#column-content {margin: 0 0 .6em 0;} #content {margin: 2.8em 0 0 0;} #p-logo, .generated-sidebar, #p-lang, #p-tb, #p-search {display:none;} #p-cactions {left: .1em;} #footer {display:none;}');
		return false;
	}
}
 
function testKey( e, intKeyCode ) {
	if( window.createPopup )
		return e.keyCode == intKeyCode
	else
		return e.which == intKeyCode
}