Forskel mellem versioner af "MediaWiki:Common.js"

Skift til: navigering, søgning
m
m
Linje 758: Linje 758:
 
         } );
 
         } );
 
}
 
}
 +
 +
 +
 +
 +
 +
 +
 +
 +
/** 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);
 +
};
 +
})();

Versionen fra 5. dec 2018, 12:25

/* Javascript inkluderet her vil være aktivt for alle brugere. */

/* Tilføjer Edittools-skrivetavle for neden med rul-ned menu og knapper, kræver CharInsert-extension */
importScript( 'MediaWiki:Gadget-Edittools.js' );

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

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

/* Overflødige knapper og tegnsæt under Specialtegn fjernes her */
/* eller brug en javascript/php editor og ret i jquery.wikiEditor.toolbar.config.js  (i \extensions\WikiEditor\modules mappen)*/
/* og tilføj nye specialtegn-sæt i WikiEditor.php og WikiEditor.i18n.php (i \extensions\WikiEditor mappen)*/

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

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

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

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

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

/* Indsæt knapper i topbjælke sektion  */

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'format',
        tools: {
                "sprog": {
                        label: 'Link til sproget.dk',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/3a/Toolbaricon_bold_S.png',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{",
                                        peri: "o",
                                        post: "}}"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'format',
        tools: {
                "ods": {
                        label: 'Link til Ordbog over det danske Sprog',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/4d/Toolbaricon_bold_O.png',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{",
                                        peri: "ods",
                                        post: "}}"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'format',
        tools: {
                "ddo": {
                        label: 'Link til Den Danske Ordbog',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Toolbaricon_bold_D.png',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{",
                                        peri: "ddo",
                                        post: "}}"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'format',
        tools: {
                "numero": {
                        label: 'Indsæt nummer-tegn',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/45/U%2B2116.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "№ ",
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "template": {
                        label: 'Indsæt henvisning med ændret navn',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/32/Toolbaricon_vertical_bar.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[",
                                        post: "|]]\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "template": {
                        label: 'Indsæt skabelon',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{",
                                        post: "}}\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "individ": {
                        label: 'Individ i slægtstræ',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/2/2c/Toolbaricon_regular_i.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{i|",
                                        post: "}}\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "redirect to category": {
                        label: 'Bøjnings-link til et kategoriord',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        post: "]]\n[[kategori:kategoriord]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "catego": {
                        label: 'Link til en kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/b/bb/Toolbaricon_italic_C.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        periMsg: 'wikieditor-toolbar-tool-redirect-example',
                                        post: "]]\n[[kategori:]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "new category": {
                        label: 'Indsæt skabelon og kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/e/eb/Toolbaricon_regular_C.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{",
                                        post: "|-|}}\n\n[[kategori:]]"
                                }
                        }
                }
        }
} );

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

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'main',
        group: 'insert',
        tools: {
                "catego": {
                        label: 'Link til en underoverskrift generelt',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/7/76/Insert_redirect.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[#",
                                        periMsg: 'wikieditor-toolbar-tool-redirect-example',
                                        post: "]]\n[[kategori:]]"
                                }
                        }
                }
        }
} );

/* 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: 'Venstrestil 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: 'Centrér tekst',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/7/76/Format-justify-center.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<center>",
                                        post: "</center>"
                                }
                        }
                }
        }
} );

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


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


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Citat-afsnit',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/2/2f/Toolbaricon_quote_1.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<blockquote>",
                                        post: "</blockquote>\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Opdel i 2 kolonner',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/4f/Trigramme2637_☷.svg',
                        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: 'Miniature-billede til højre',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/6/6f/Toolbar_insert_file.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[Fil:",
                                        periMsg: 'wikieditor-toolbar-tool-file-example',
                                        post: "|thumb|100px]]\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "nav-cat": {
                        label: 'Indsæt kategori-link og prik',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/05/Toolbar_microstub.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[:kategori:",
                                        post: "|]]{{*}} "
                                }
                        }
                }
        }
} );

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


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "village": {
                        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: 'Link til bebyggelse-kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/5/52/Toolbaricon_regular_b.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        post: "]]\n[[kategori:bebyggelse]]"
                                }
                        }
                }
        }
} );

$( '#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: {
                "disambig": {
                        label: 'Byopslag i wikipedia',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/3e/Disambiguate_charset_button.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{w}}\n{{",
                                        post: " Sogn|-|}}\n[[kategori:landsby]]\n[[kategori: Sogn]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Skibsinfoboks',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/41/Toolbaricon_regular_s.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{sk\n| bia= | bals= | mart= | nok= | shsp= | IMO=",
                                        post: "\n| k=\n| før=\n| navn=\n| hjem=\n| værft=\n| år=19 | sbib= | leno=\n| jma=\n| wrs=\n| ms= | rosd=\n| {{gpss|}}\n| død= ♥\n}}"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Søfartsulykke',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/49/Toolbaricon_regular_S.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<noinclude>\n[[kategori:]]\n[[kategori:]]\n[[kategori:",
                                        post: "| 19--]]\n</noinclude>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "navb": {
                        label: 'Avanceret navigationsboks',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/9/96/Interpage_icon.png',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{Navboks \n| navn   = \n| titel  = {{{2|}}} [[:kategori:",
                                        post: "|]]\n\n| over  = \n\n| gruppe3 = [[:kategori:Ejerlav|Ejerlav]]\n| liste3 = {{Navboks | child\n| gruppe1 = [[:kategori: Ejerlav, | ]]\n| liste1 = \n\n| gruppe2 = [[:kategori: Ejerlav, | ]]\n| liste2 = \n\n| gruppe3 = [[:kategori: Ejerlav, | ]]\n| liste3 = \n\n}}\n\n| liste20 = {{Navboks | child\n| gruppe1 = [[:kategori:Vej i  Sogn|Vej]]\n| liste1 = {{Navboks | child\n| gruppe1 = [[:kategori:6760| ]]\n| liste1 = \n\n}}\n}}\n|status={{{1|}}}|navbar=<includeonly>{{{2|plain}}}</includeonly>}}<noinclude>{{s}}</noinclude>"
                                }
                        }
                }
        }
} );

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


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Fodnote-reference',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/81/Wikieditor-reference.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<ref>[",
                                        periMsg: 'wikieditor-toolbar-tool-reference-example',
                                        post: "] - </ref>\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Fodnoter vises her',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/8d/Wikieditor-references.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<references/>\n",
                                }
                        }
                }
        }
} );


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Noter og dokumentation',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/cf/Toolbar_insert_reference.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "\n== Noter ==\n{{Doku||",
                                        post: "|}}\n\n"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "comment": {
                        label: 'Signatur og tid ved diskussion',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "\n~~",
                                        post: "~~"
                                }
                        }
                }
        }
} );

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