MediaWiki:Common.js: Forskelle mellem versioner

Spring til navigation Spring til søgning
mNo edit summary
mNo edit summary
Linje 533: Linje 533:
} );
} );


$( '#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', {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
Linje 557: Linje 576:
         group: 'insert',
         group: 'insert',
         tools: {
         tools: {
                 "category": {
                 "nav-cat": {
                         label: 'Indsæt kategori',
                         label: 'Indsæt kode til fold-ud',
                         type: 'button',
                         type: 'button',
                         icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
                         icon: '//upload.wikimedia.org/wikipedia/commons/0/05/Toolbar_microstub.png',
                         action: {
                         action: {
                                 type: 'encapsulate',
                                 type: 'encapsulate',
                                 options: {
                                 options: {
                                         pre: "[[kategori:",
                                         pre: "{{q|{{{1|}}}|",
                                         post: "]]\n"
                                         post: "}}\n"
                                 }
                                 }
                         }
                         }

Versionen fra 5. feb. 2022, 16:34

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

/* WikiEditor er defineret i extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js */
/* men bør tilpasses, se mediawiki:Extension:WikiEditor/Toolbar Customization */

var customizeToolbar = function () {

/*  fjerner bold og italic fra main sektionen */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	  'section': 'main',
	  'group': 'format',
});

/*  fjerner Overskrift i Avanceret sektionen */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	  'section': 'advanced',
	  'group': 'heading',
});

/*  fjerner Format elementer i Avanceret sektionen */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	  'section': 'advanced',
	  'group': 'format',
	  'tool': 'ulist',
});

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

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

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


/*  fjerner Indsæt elementer i Avanceret sektionen */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	  'section': 'advanced',
	  'group': 'insert',
	  'tool': 'redirect',
});



/* fjerner characters-elementer i Specialtegn sektionen  */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	  'section': 'characters',
	  'page': 'symbols',
});


/* tilføjelser til Specialtegn */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
  'section': 'characters',
  'pages': {
	'section-specialtegn1': {
	  'label': 'Anførselstegn og brøk',
	  'layout': 'characters',
	  'characters': [
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '„',
                  'peri': '',
                  'post': '“'
                }
              },
              'label': '„…“'
            },
		'№', ['1/3', '⅓'], ['2/3', '⅔'], ['1/4', '¼'], ['3/4', '¾'], ['1/8', '⅛'], ['3/8', '⅜'], ['5/8', '⅝'], ['7/8', '⅞'], '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '‰', '²', '³', '°',
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '»',
                  'peri': '',
                  'post': '«'
                }
              },
              'label': '»…«'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '«',
                  'peri': '',
                  'post': '»'
                }
              },
              'label': '«…»'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '’',
                  'peri': '',
                  'post': '‘'
                }
              },
              'label': '’…‘'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '‟',
                  'peri': '',
                  'post': '”'
                }
              },
              'label': '‟…”'
            }
         ]
      },
	'section-specialtegn2': {
	  'label': 'Særlige bogstaver',
	  'layout': 'characters',
	  'characters': [ 'ß', 'Ð', 'ð', 'Þ', 'þ', 'Ł', 'ł', 'Œ', 'œ', 'Ç', 'ç', 'Æ', 'æ', 'Ø', 'ø', 'Å', 'å', '⅍', '℃', '©', '®' ]
    },
	'section-specialtegn3': {
	  'label': 'Ikoner mm.',
	  'layout': 'characters',
	  'characters': [ '⛵', '⛴', '⚓', '✇', '✈', '✼', '⚔', '☹', '†', '✝', '✠', '←', '→', '–', '—', '…', '·', '•', '∗', '✯', '×', '÷', '≈', '□' ]
    },
	'section-specialtegn4': {
	  'label': 'Kode',
	  'layout': 'characters',
	  'characters': [
            {
              'action': {
                'type': 'replace',
                'options': {
                  'pre': '<br>\n',
                }
              },
              'label': 'br'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<code>',
                  'peri': '',
                  'post': '</code>'
                }
              },
              'label': 'code'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<blockquote>',
                  'peri': '',
                  'post': '</blockquote>'
                }
              },
              'label': 'blockquote'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<includeonly>',
                  'peri': '',
                  'post': '</includeonly>'
                }
              },
              'label': 'includeonly'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<noinclude>',
                  'peri': '',
                  'post': '</noinclude>'
                }
              },
              'label': 'noinclude'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<nowiki>',
                  'peri': '',
                  'post': '</nowiki>'
                }
              },
              'label': 'nowiki'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<ref>',
                  'peri': '',
                  'post': '</ref>'
                }
              },
              'label': 'ref'
            },
            {
              'action': {
                'type': 'encapsulate',
                'options': {
                  'pre': '<!--',
                  'peri': ' ',
                  'post': '-->'
                }
              },
              'label': '<!-- -->'
            }
         ]
      }
  }
} );


/* Indsæt knapper i topbjælke sektion (main)  */


/* Indsæt knapper i Avanceret-'Format' (advanced) */

$('#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: 'Centrér tekst',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/Text_align_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/3/3f/Text_align_right.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<div align=right>",
                                        post: "</div>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
                "comment": {
                        label: 'Opdel i 2 kolonner',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/5/5b/Text_columns.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: {
                "redirect to category": {
                        label: 'Omdirigering til et kategoriord',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/2/23/OOjs_UI_icon_articleRedirect-ltr-progressive.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        peri: "Indsæt",
                                        post: "]]\n[[kategori:kategoriord]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "catego": {
                        label: 'Omdirigering til en kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/OOjs_UI_icon_articleRedirect-ltr.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        periMsg: 'wikieditor-toolbar-tool-redirect-example',
                                        post: "]]\n[[kategori:]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "landsby": {
                        label: 'Link til landsby-kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c8/OpenMoji-black_1F3D8.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        peri: "Indsæt",
                                        post: "]]\n[[kategori:landsby]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "bebyggelse": {
                        label: 'Link til bebyggelse-kategori',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/08/OpenMoji-black_1F3E1.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "#REDIRECT[[:kategori:",
                                        peri: "Indsæt",
                                        post: "]]\n[[kategori:bebyggelse]]"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        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: "{{",
                                        peri: "",
                                        post: "|}}\n"
                                }
                        }
                }
        }
} );

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

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "navb": {
                        label: 'Indsæt en navboksskabelon',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/81/OOjs_UI_icon_window-progressive.svg',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{Navboks \n| navn  = \n| titel = [[:kategori:",
                                        peri: "",
                                        post: "|]]\n| billede-venstre = \n\n| liste1 = {{q|{{{1|}}}|\n\n}}\n\n<includeonly>|status={{{1|}}}|navbar={{{2|plain}}}</includeonly>}}<noinclude>{{n}}</noinclude>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "boks": {
                        label: 'Indsæt en boksskabelon',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/38/OOjs_UI_icon_window.svg',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "__NOTITLE_\n<div class='toccolours {{#if:{{{1|}}}|mw-collapsible mw-collapsed}}'><center><big class='plainlinks'><b>{{#switch:{{{2|}}}\n|={{{alt|{{PAGENAME}}}}}\n|+=&emsp;&emsp;&emsp;[https://da.wikipedia.org/wiki/{{PAGENAMEE}} {{{alt|{{PAGENAME}}}}}]\n|#default=&emsp;&emsp;&emsp;[https://{{#if:{{#pos:{{{2}}}|:}}|{{#explode:{{{2}}}|:}}|da}}.wikipedia.org/wiki/{{PAGENAMEE:{{#explode:{{{2}}}|:|-1}}}} {{{alt|{{PAGENAME}}}}}]\n}}</b></big> {{næste}}</center>\n{{#if:{{{1|}}}\n|<div class='mw-collapsible-content'>{{#widget:Iframe | height=160 | url=https://da.wikipedia.org/w/index.php?action=render&title={{#ifeq:{{{1}}}|+|{{PAGENAMEE}}|{{PAGENAMEE:{{{1}}}}}}}}}</div>}}\n",
                                        peri: "\n",
                                        post: "</div>\n{{#switch:|=<div class='toccolours' style='border-top:0px'><small><center></center></small></div>\n{{#switch:{{PAGENAME}}|=|[[kategori:]]}}\n}}<noinclude>\n[[kategori:Boksskabelon]]\n</noinclude>"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Skibsinfoboks',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/8d/Pirate_Ship_Black.svg',
                        action: {
                                type: 'replace',
                                options: {
                                        pre: "{{sk\n| k=\n| bia= | bash= | mart= | nok= | shsp= | IMO=",
                                        post: "\n| før=\n| navn=\n| hjem=\n| værft=\n| år=18 | sbib=\n| b= | d= | m=\n| jma=\n| wrs=\n| ms=G-G.pdf\n| {{gps|}}\n| liv= | død=\n}}"
                                }
                        }
                }
        }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
                "disambig": {
                        label: 'Avisartikler og kategorier',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c2/Emojione_BW_1F4F0.svg',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "\n{{a|",
                                        peri: "dato",
                                        post: "}\n\n<noinclude>\n[[kategori:]]\n[[kategori:]]\n[[kategori:]]\n[[kategori:]]\n[[kategori:]]\n</noinclude>"
                                }
                        }
                }
        }
} );


$( '#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: {
                "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: {
                "nav-cat": {
                        label: 'Indsæt kode til fold-ud',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/05/Toolbar_microstub.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{q|{{{1|}}}|",
                                        post: "}}\n"
                                }
                        }
                }
        }
} );


};

/* Tilpasser værktøjslinjen hvis man er i redigeringstilstand og de nødvendige moduler er til rådighed */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}