Forskel mellem versioner af "MediaWiki:Common.js"

Skift til: navigering, søgning
Linje 68: Linje 68:
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
         group: 'format',
+
         group: 'insert',
 
         tools: {
 
         tools: {
 
                 "comment": {
 
                 "comment": {
 
                         label: 'Usynlig kommentar',
 
                         label: 'Usynlig kommentar',
 
                         type: 'button',
 
                         type: 'button',
                         icon: '//upload.wikimedia.org/wikipedia/commons/0/0c/Vector_toolbar_category_uk_button.png',
+
                         icon: '//upload.',
 
                         action: {
 
                         action: {
 
                                 type: 'encapsulate',
 
                                 type: 'encapsulate',
Linje 87: Linje 87:
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
         group: 'format',
+
         group: 'insert',
 
         tools: {
 
         tools: {
 
                 "navb": {
 
                 "navb": {
Linje 97: Linje 97:
 
                                 options: {
 
                                 options: {
 
                                         pre: "{{Navboks\n| navn  = \n| titel  = [[:kategori:",
 
                                         pre: "{{Navboks\n| navn  = \n| titel  = [[:kategori:",
                                         post: ": '|]]\n| billede-venstre = \n| billede = \n\n| liste1  = \n\n"
+
                                         post: ": '|]]\n| billede-venstre = \n| billede = \n\n| liste1  = \n\n\n|status=<noinclude>uncollapsed</noinclude>{{{1|}}}||navbar=<includeonly>{{{2|plain}}}</includeonly>}}"
 
                                 }
 
                                 }
 
                         }
 
                         }
Linje 136: Linje 136:
 
                                         pre: "<center>",
 
                                         pre: "<center>",
 
                                         post: "</center>"
 
                                         post: "</center>"
                                }
 
                        }
 
                }
 
        }
 
} );
 
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
        section: 'advanced',
 
        group: 'format',
 
        tools: {
 
                "comment": {
 
                        label: 'tekst',
 
                        type: 'button',
 
                        icon: '//upload.',
 
                        action: {
 
                                type: 'encapsulate',
 
                                options: {
 
                                        pre: "",
 
                                        post: ""
 
 
                                 }
 
                                 }
 
                         }
 
                         }
Linje 169: Linje 150:
 
                         label: 'Indsætter dokumentation',
 
                         label: 'Indsætter dokumentation',
 
                         type: 'button',
 
                         type: 'button',
                         icon: '//upload.wikimedia.org/wikipedia/commons/1/1a/Button_fact.png',
+
                         icon: '//upload.wikimedia.org/wikipedia/commons/9/94/Toolbar_copyright.png',
 
                         action: {
 
                         action: {
 
                                 type: 'encapsulate',
 
                                 type: 'encapsulate',
Linje 190: Linje 171:
 
                         label: 'Venstrestillet kursiv tekst med mellemrum',
 
                         label: 'Venstrestillet kursiv tekst med mellemrum',
 
                         type: 'button',
 
                         type: 'button',
                         icon: '//upload.wikimedia.org/wikipedia/commons/3/34/Toolbar_miss_signature.png',
+
                         icon: '//upload.wikimedia.org/wikipedia/commons/8/81/Toolbaricon_justify-left.png',
 
                         action: {
 
                         action: {
 
                                 type: 'encapsulate',
 
                                 type: 'encapsulate',
Linje 225: Linje 206:
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
         group: 'format',
+
         group: 'insert',
 
         tools: {
 
         tools: {
 
                 "comment": {
 
                 "comment": {
 
                         label: 'Omdirigér til engelsk Wiktionary',
 
                         label: 'Omdirigér til engelsk Wiktionary',
 
                         type: 'button',
 
                         type: 'button',
                         icon: '//upload.',
+
                         icon: '//upload.wikimedia.org/wikipedia/commons/e/e5/Toolbar_wikt_new.png',
 
                         action: {
 
                         action: {
 
                                 type: 'encapsulate',
 
                                 type: 'encapsulate',
Linje 327: Linje 308:
 
         group: 'insert',
 
         group: 'insert',
 
         tools: {
 
         tools: {
                 "comment": {
+
                 "category": {
 
                         label: 'Indsæt kategori',
 
                         label: 'Indsæt kategori',
 
                         type: 'button',
 
                         type: 'button',
                         icon: '//upload.wikimedia.org/wikipedia/commons/e/e6/Toolbaricon_italics_K.jpg',
+
                         icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
 
                         action: {
 
                         action: {
 
                                 type: 'encapsulate',
 
                                 type: 'encapsulate',
Linje 345: Linje 326:
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
         group: 'format',
+
         group: 'insert',
 
         tools: {
 
         tools: {
 
                 "comment": {
 
                 "comment": {

Versionen fra 3. jun 2012, 22:46

/* 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 */

$('#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: {
                "hline": {
                        label: 'Vandret linje',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/b/b4/Toolbaricon_rule.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "----",
                                        ownline: true
                                }
                        }
                }
        }
} );

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

$( '#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\n|status=<noinclude>uncollapsed</noinclude>{{{1|}}}||navbar=<includeonly>{{{2|plain}}}</includeonly>}}"
                                }
                        }
                }
        }
} );

$( '#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>"
                                }
                        }
                }
        }
} );

$( '#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: 'insert',
        tools: {
                "comment": {
                        label: 'Indsætter dokumentation',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/9/94/Toolbar_copyright.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "== Noter ==\n{{Doku||",
                                        post: "|}}\n\n"
                                }
                        }
                }
        }
} );



$( '#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: '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.',
                        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.',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT [[ddo:",
                                        post: "]]\n[[kategori:Den Danske Ordbog]]"
                                }
                        }
                }
        }
} );



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


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Bøjningsform af kategoriord',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c6/Button_Kat.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: 'Omdefinér intern link',
                        type: 'button',
                        icon: '//upload.',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[da:",
                                        post: "]]\n[[kategori:]]"
                                }
                        }
                }
        }
} );

/* 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
}