MediaWiki:Gadget-AddProgrammingToolbar.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(mw.loader.using( 'ext.wikiEditor' )) |
(fix localisation) |
||
Zeile 23: | Zeile 23: | ||
//<source lang="javascript"> | //<source lang="javascript"> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
if (!messagePT) { | if (!messagePT) { | ||
Zeile 38: | Zeile 33: | ||
if (!messagePT) { | if (!messagePT) { | ||
var messagePT = { | var messagePT = { | ||
− | label : { | + | label: { |
− | blockquote:'block quote', | + | blockquote: 'block quote', |
− | strikethrough:'strike through', | + | strikethrough: 'strike through', |
− | syntaxhighlight:'syntax highlighting' | + | syntaxhighlight: 'syntax highlighting' |
}, | }, | ||
− | periText :{ | + | periText: { |
− | comment:'comment:', | + | comment: 'comment:', |
− | defInlineTerm:'Parameter', | + | defInlineTerm: 'Parameter', |
− | defInlineDefinition:'Explanation', | + | defInlineDefinition: 'Explanation', |
− | ref:'Reference/Citation', | + | ref: 'Reference/Citation', |
− | tvar:'content, text, link etc.' | + | tvar: 'content, text, link etc.' |
}, | }, | ||
− | sectionLabel : { | + | sectionLabel: { |
− | programming :'Programming', | + | programming: 'Programming', |
− | template :'Templates', | + | template: 'Templates', |
− | wikiTags : 'Wiki/HTML Tags' | + | wikiTags: 'Wiki/HTML Tags' |
} | } | ||
− | } | + | } |
} | } | ||
+ | |||
+ | /** | ||
+ | * override messages by wgUserLanguage | ||
+ | */ | ||
+ | mw.loader.load( | ||
+ | mw.config.get('wgScriptPath') + '/index.php?title=' + | ||
+ | 'MediaWiki:Gadget-AddProgrammingToolbar.js/' + mw.config.get('wgUserLanguage') + | ||
+ | '&action=raw&ctype=text/javascript' | ||
+ | ); | ||
+ | |||
var customizeThisUserWikiEditorToolbar = function () { | var customizeThisUserWikiEditorToolbar = function () { | ||
− | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | + | $('#wpTextbox1').wikiEditor('addToToolbar', { |
'section': 'advanced', | 'section': 'advanced', | ||
'group': 'format', | 'group': 'format', | ||
Zeile 75: | Zeile 80: | ||
}, | }, | ||
'syntaxhighlight': { | 'syntaxhighlight': { | ||
− | label: messagePT.label. | + | label: messagePT.label.syntaxhighlight, |
type: 'button', | type: 'button', | ||
icon: 'http://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png', | icon: 'http://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png', | ||
Zeile 99: | Zeile 104: | ||
} | } | ||
} | } | ||
− | }) | + | }) |
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
'sections': { | 'sections': { | ||
Zeile 107: | Zeile 112: | ||
} | } | ||
} | } | ||
− | }) | + | }) |
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
Zeile 120: | Zeile 125: | ||
type: 'encapsulate', options: {pre: " ", post: ""} | type: 'encapsulate', options: {pre: " ", post: ""} | ||
} | } | ||
− | },{ | + | }, { |
label: "()", | label: "()", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "(", post: ")"} | type: 'encapsulate', options: {pre: "(", post: ")"} | ||
} | } | ||
− | },{ | + | }, { |
label: "[]", | label: "[]", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "[", post: "]"} | type: 'encapsulate', options: {pre: "[", post: "]"} | ||
} | } | ||
− | },{ | + | }, { |
label: "[[]]", | label: "[[]]", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "[[", post: "]]"} | type: 'encapsulate', options: {pre: "[[", post: "]]"} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{}}", | label: "{{}}", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '{{', post: '}}'} | type: 'encapsulate', options: {pre: '{{', post: '}}'} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{{}}}", | label: "{{{}}}", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "{{{", 'peri': '1', post: "}}}"} | type: 'encapsulate', options: {pre: "{{{", 'peri': '1', post: "}}}"} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{{|}}}", | label: "{{{|}}}", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "{{{|", 'peri': '1', post: "}}}"} | type: 'encapsulate', options: {pre: "{{{|", 'peri': '1', post: "}}}"} | ||
} | } | ||
− | },{ | + | }, { |
label: "[[Kategorie:]]", | label: "[[Kategorie:]]", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '[[Kategorie: ', post: ']]'} | type: 'encapsulate', options: {pre: '[[Kategorie: ', post: ']]'} | ||
} | } | ||
− | },{ | + | }, { |
label: "[[Category:]]", | label: "[[Category:]]", | ||
action: { | action: { | ||
Zeile 169: | Zeile 174: | ||
post: "]]", | post: "]]", | ||
/* a selection */ | /* a selection */ | ||
− | regex:/\s*(.+)\s*/, | + | regex: /\s*(.+)\s*/, |
− | regexReplace:"[[Attribut: \$1 |\$1]]" | + | regexReplace: "[[Attribut: \$1 |\$1]]" |
} | } | ||
} | } | ||
Zeile 182: | Zeile 187: | ||
post: "]]", | post: "]]", | ||
/* a selection */ | /* a selection */ | ||
− | regex:/\s*(.+)\s*/, | + | regex: /\s*(.+)\s*/, |
− | regexReplace:"[[property: \$1 |\$1]]" | + | regexReplace: "[[property: \$1 |\$1]]" |
} | } | ||
} | } | ||
− | },{ | + | }, { |
label: "#WEITERLEITUNG [[]]", | label: "#WEITERLEITUNG [[]]", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "#WEITERLEITUNG [[", post: "]]"} | type: 'encapsulate', options: {pre: "#WEITERLEITUNG [[", post: "]]"} | ||
} | } | ||
− | },{ | + | }, { |
label: "#REDIRECT [[]]", | label: "#REDIRECT [[]]", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "#REDIRECT [[", post: "]]"} | type: 'encapsulate', options: {pre: "#REDIRECT [[", post: "]]"} | ||
} | } | ||
− | },{ | + | }, { |
label: "ref", | label: "ref", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '<ref name="">', peri: messagePT.periText.ref, post: '</ref>'} | type: 'encapsulate', options: {pre: '<ref name="">', peri: messagePT.periText.ref, post: '</ref>'} | ||
} | } | ||
− | },{ | + | }, { |
label: "references", | label: "references", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '<references/>', post: ''} | type: 'encapsulate', options: {pre: '<references/>', post: ''} | ||
} | } | ||
− | },{ | + | }, { |
label: "noinclude", | label: "noinclude", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<noinclude>", post: "</noinclude>"} | type: 'encapsulate', options: {pre: "<noinclude>", post: "</noinclude>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "includeonly", | label: "includeonly", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<includeonly>", post: "</includeonly>"} | type: 'encapsulate', options: {pre: "<includeonly>", post: "</includeonly>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "onlyinclude", | label: "onlyinclude", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<onlyinclude>", post: "</onlyinclude>"} | type: 'encapsulate', options: {pre: "<onlyinclude>", post: "</onlyinclude>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "translate", | label: "translate", | ||
action: { | action: { | ||
Zeile 233: | Zeile 238: | ||
options: {pre: "<tvar|name>", peri: messagePT.periText.tvar, post: "</>"} | options: {pre: "<tvar|name>", peri: messagePT.periText.tvar, post: "</>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "code", | label: "code", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<code>", post: "</code>"} | type: 'encapsulate', options: {pre: "<code>", post: "</code>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "nowiki", | label: "nowiki", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<nowiki>", post: "</nowiki>"} | type: 'encapsulate', options: {pre: "<nowiki>", post: "</nowiki>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "code nowiki code", | label: "code nowiki code", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<code><nowiki>", post: "</nowiki></code>"} | type: 'encapsulate', options: {pre: "<code><nowiki>", post: "</nowiki></code>"} | ||
} | } | ||
− | },{ | + | }, { |
label: "comment", | label: "comment", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"} | type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"} | ||
} | } | ||
− | },{ | + | }, { |
label: "comment lt--gt", | label: "comment lt--gt", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"} | type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"} | ||
} | } | ||
− | },{ | + | }, { |
label: "span", | label: "span", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '<span style="">', post: '</span>'} | type: 'encapsulate', options: {pre: '<span style="">', post: '</span>'} | ||
} | } | ||
− | },{ | + | }, { |
label: "span.plainlinks", | label: "span.plainlinks", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '<span class="plainlinks">', post: '</span>'} | type: 'encapsulate', options: {pre: '<span class="plainlinks">', post: '</span>'} | ||
} | } | ||
− | },{ | + | }, { |
label: "div", | label: "div", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: '<div style="">', post: '</div>'} | type: 'encapsulate', options: {pre: '<div style="">', post: '</div>'} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{SORTIERUNG:}}", | label: "{{SORTIERUNG:}}", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "{{SORTIERUNG: ", post: "}}"} | type: 'encapsulate', options: {pre: "{{SORTIERUNG: ", post: "}}"} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{DEFAULTSORT:}}", | label: "{{DEFAULTSORT:}}", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "{{DEFAULTSORT: ", post: "}}"} | type: 'encapsulate', options: {pre: "{{DEFAULTSORT: ", post: "}}"} | ||
} | } | ||
− | },{ | + | }, { |
'label': "div.definition-inline", | 'label': "div.definition-inline", | ||
'action': { | 'action': { | ||
Zeile 293: | Zeile 298: | ||
} | } | ||
} | } | ||
− | },{ | + | }, { |
label: "{{#arraymap:}}", | label: "{{#arraymap:}}", | ||
action: { | action: { | ||
− | type: 'encapsulate', options: {pre: "{{#arraymap: ", peri: | + | type: 'encapsulate', |
+ | options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: '|;|§|[[My property::§]] | • }}'} | ||
} | } | ||
− | },{ | + | }, { |
label: "{{#arraymap:long}}", | label: "{{#arraymap:long}}", | ||
action: { | action: { | ||
− | type: 'encapsulate', options: {pre: "{{#arraymap: ", peri: | + | type: 'encapsulate', |
+ | options: { | ||
+ | pre: "{{#arraymap: ", | ||
+ | peri: '{{{field|}}}', | ||
+ | post: '<!-- values\n-->|;<!-- split on ;\n-->|§<!-- assign temporary variable\n-->|[[My property::§]] <!-- output\n-->| • <!-- new output separator\n-->}}' | ||
+ | } | ||
} | } | ||
− | },{ | + | }, { |
label: "if", | label: "if", | ||
action: { | action: { | ||
type: 'encapsulate', options: {pre: "{{#if: ", post: "| | }}"} | type: 'encapsulate', options: {pre: "{{#if: ", post: "| | }}"} | ||
} | } | ||
− | },{ | + | }, { |
label: "if long", | label: "if long", | ||
action: { | action: { | ||
− | type: 'encapsulate', options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- if end\n-->"} | + | type: 'encapsulate', |
+ | options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- if end\n-->"} | ||
} | } | ||
− | },{ | + | }, { |
label: "switch CONTENTLANGUAGE", | label: "switch CONTENTLANGUAGE", | ||
action: { | action: { | ||
− | type: 'encapsulate', options: {pre: "{{#switch: {{CONTENTLANGUAGE}}", post: "<!--\n-->|de|de-formal= deutsch <!--\n-->| #default = english<!--\n-->}}<!-- switch end\n-->"} | + | type: 'encapsulate', |
+ | options: { | ||
+ | pre: "{{#switch: {{CONTENTLANGUAGE}}", | ||
+ | post: "<!--\n-->|de|de-formal= deutsch <!--\n-->| #default = english<!--\n-->}}<!-- switch end\n-->" | ||
+ | } | ||
} | } | ||
− | },{ | + | }, { |
label: "switch", | label: "switch", | ||
action: { | action: { | ||
− | type: 'encapsulate', options: {pre: "{{#switch: ", post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- switch end\n-->"} | + | type: 'encapsulate', |
+ | options: { | ||
+ | pre: "{{#switch: ", | ||
+ | post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- switch end\n-->" | ||
+ | } | ||
} | } | ||
}, { | }, { | ||
Zeile 327: | Zeile 347: | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
− | options: {pre: '<table>',peri: '<!--\n--><tr><!--\n --><td></td><!--\n--></tr><!--\n-->', post: '</table>'} | + | options: { |
+ | pre: '<table>', | ||
+ | peri: '<!--\n--><tr><!--\n --><td></td><!--\n--></tr><!--\n-->', | ||
+ | post: '</table>' | ||
+ | } | ||
} | } | ||
}, { | }, { | ||
Zeile 333: | Zeile 357: | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
− | options: {pre: '<tr>',peri: '<!--\n --><td></td><!--\n-->', post: '</tr>'} | + | options: {pre: '<tr>', peri: '<!--\n --><td></td><!--\n-->', post: '</tr>'} |
} | } | ||
}, { | }, { | ||
Zeile 365: | Zeile 389: | ||
'layout': 'characters', | 'layout': 'characters', | ||
label: messagePT.sectionLabel.template, | label: messagePT.sectionLabel.template, | ||
− | 'characters': [{ | + | 'characters': [ |
− | + | /* | |
− | + | { | |
− | + | label: "Keyboard", | |
− | + | action: { | |
− | + | type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "Zitat", | |
− | + | action: { | |
− | + | type: 'encapsulate', options: {pre: '{{Zitat |', post: '}}'} | |
− | + | } | |
− | + | }, { | |
− | + | label: "Zitat versteckt", | |
− | + | action: { | |
− | + | type: 'encapsulate', options: {pre: '{{Zitat versteckt|', post: '}}'} | |
− | label: "nbsp;", | + | } |
− | + | }, | |
− | + | */ | |
− | + | { | |
− | + | label: "nbsp;", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: " ", post: ""} | |
− | + | } | |
− | + | }, { | |
− | + | label: "()", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "(", post: ")"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "[]", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "[", post: "]"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "[[]]", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "[[", post: "]]"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{", post: "}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{{}}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{{", post: "}}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{{|}}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{{", post: "|}}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "noinclude", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<noinclude>", post: "</noinclude>"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "includeonly", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<includeonly>", post: "</includeonly>"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "onlyinclude", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<onlyinclude>", post: "</onlyinclude>"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "nowiki", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<nowiki>", post: "</nowiki>"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "comment", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<!-- ", post: " -->"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#arraymap:}} long", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: { | |
− | + | pre: "{{#arraymap: ", | |
− | + | peri: '{{{field|}}}', | |
− | + | post: "<!--\n-->|;<!-- sep\n-->|§<!-- assign temporary var\n-->|[[My property::§]] <!--output\n-->| • <!--output sep\n-->}}<!-- end arraymap \n-->" | |
− | + | } | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#arraymap:}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: "|;|§|[[My property::§]] | • }}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#ask:table}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: { | |
− | + | pre: "{{#ask: ", | |
− | + | peri: '[[PAGE]] [[property::+]]', | |
− | + | post: " | ?displayprop |? | mainlabel=- | link=none | format = table | limit = 500}}" | |
− | + | } | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#ask:list}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: { | |
− | + | pre: "{{#ask: ", | |
− | + | peri: '[[PAGE]] [[property::+]]', | |
− | + | post: " | ?displayprop | mainlabel=- | link=none | format = list | sep= •  | limit = 500}}" | |
− | + | } | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#vardefine:}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#vardefine: ", peri: 'myVar', post: "| }}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#varexist:}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#varexist: ", peri: 'myVar', post: "}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#var:}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#var: ", peri: 'myVar', post: "}}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "if", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#if: ", post: "| | }}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "if long", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end if\n-->"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "ifexist", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#ifexist: ", post: "| | }}"} | |
− | + | } | |
− | + | }, { | |
− | + | label: "ifexist long", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: { | |
− | + | pre: "<!--\n-->{{#ifexist: ", | |
− | + | post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end ifexist\n-->" | |
− | + | } | |
− | + | } | |
− | + | }, { | |
− | + | label: "{{#expr:}}", | |
− | + | action: { | |
− | + | type: 'encapsulate', | |
− | + | options: {pre: "{{#expr: ", peri: '1 + 6', post: "}}"} | |
− | + | } | |
+ | }, { | ||
+ | label: "switch", | ||
+ | action: { | ||
+ | type: 'encapsulate', | ||
+ | options: { | ||
+ | pre: "{{#switch: ", | ||
+ | post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- end switch\n-->" | ||
+ | } | ||
+ | } | ||
+ | }, { | ||
+ | label: "{{DEFAULTSORT:}}", | ||
+ | action: { | ||
+ | type: 'encapsulate', | ||
+ | options: {pre: "{{DEFAULTSORT:", post: "}}"} | ||
+ | } | ||
+ | }, { | ||
+ | label: "{{DISPLAYTITLE:}}", | ||
+ | action: { | ||
+ | type: 'encapsulate', | ||
+ | options: {pre: "{{DISPLAYTITLE:", post: "}}"} | ||
+ | } | ||
+ | }, | ||
'{{PAGENAME}}', | '{{PAGENAME}}', | ||
'{{PAGENAMEE}}', | '{{PAGENAMEE}}', | ||
Zeile 550: | Zeile 596: | ||
} | } | ||
} | } | ||
− | }) | + | }) |
} | } | ||
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ | /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ | ||
− | if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { | + | if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) { |
− | mw.loader.using( 'user.options', function () { | + | mw.loader.using('user.options', function () { |
− | if ( mw.user.options.get('usebetatoolbar') ) { | + | if (mw.user.options.get('usebetatoolbar')) { |
− | mw.loader.using( 'ext.wikiEditor', function () { | + | mw.loader.using('ext.wikiEditor', function () { |
− | $(document).ready( customizeThisUserWikiEditorToolbar ) | + | $(document).ready(customizeThisUserWikiEditorToolbar) |
− | }) | + | }) |
} | } | ||
− | }) | + | }) |
} | } | ||
// </source> | // </source> | ||
// </pre> | // </pre> |
Version vom 21. März 2018, 17:28 Uhr
//<pre>
/*
o ptions: { *
pre:'{|'+classStr+"\n",
peri:table,
post:'|}',
ownline:true
type: "booklet"
label string: non-localizable label string
labelMsg string: key for localizable message string
deferLoad boolean
pages object: map of name keys to further objects:
layout string required: 'table' or 'characters'
label string: non-localizable label string
labelMsg string: key for localizable message string
headings string[]: array of objects? {textMsg: key} ??
rows object[] optional?: array of objects? {'row key name': {message object?}}
characters string[] optional?: array of strings of little character bits for insertion (???!)
*/
//<source lang="javascript">
if (!messagePT) {
mw.loader.load(
mw.config.get('wgScriptPath') + '/index.php?title=' +
'MediaWiki:Gadget-AddProgrammingToolbar.js/local_defaults' +
'&action=raw&ctype=text/javascript'
);
}
if (!messagePT) {
var messagePT = {
label: {
blockquote: 'block quote',
strikethrough: 'strike through',
syntaxhighlight: 'syntax highlighting'
},
periText: {
comment: 'comment:',
defInlineTerm: 'Parameter',
defInlineDefinition: 'Explanation',
ref: 'Reference/Citation',
tvar: 'content, text, link etc.'
},
sectionLabel: {
programming: 'Programming',
template: 'Templates',
wikiTags: 'Wiki/HTML Tags'
}
}
}
/**
* override messages by wgUserLanguage
*/
mw.loader.load(
mw.config.get('wgScriptPath') + '/index.php?title=' +
'MediaWiki:Gadget-AddProgrammingToolbar.js/' + mw.config.get('wgUserLanguage') +
'&action=raw&ctype=text/javascript'
);
var customizeThisUserWikiEditorToolbar = function () {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'strikethrough': {
label: messagePT.label.strikethrough,
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
action: {
type: 'encapsulate',
options: {
pre: "<s>",
post: "</s>"
}
}
},
'syntaxhighlight': {
label: messagePT.label.syntaxhighlight,
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png',
action: {
type: 'encapsulate',
options: {
pre: "<source lang=\"html4strict\">\n",
post: "\n</source>"
}
}
},
'blockquote': {
label: messagePT.label.blockquote,
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png',
action: {
type: 'encapsulate',
options: {
pre: "<blockquote>\n",
post: "\n</blockquote>"
}
}
}
}
})
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections': {
'programming': {
type: 'booklet',
label: messagePT.sectionLabel.programming
}
}
})
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'programming',
'pages': {
'tags': {
'layout': 'characters',
label: messagePT.sectionLabel.wikiTags,
'characters': [{
label: "nbsp;",
action: {
type: 'encapsulate', options: {pre: " ", post: ""}
}
}, {
label: "()",
action: {
type: 'encapsulate', options: {pre: "(", post: ")"}
}
}, {
label: "[]",
action: {
type: 'encapsulate', options: {pre: "[", post: "]"}
}
}, {
label: "[[]]",
action: {
type: 'encapsulate', options: {pre: "[[", post: "]]"}
}
}, {
label: "{{}}",
action: {
type: 'encapsulate', options: {pre: '{{', post: '}}'}
}
}, {
label: "{{{}}}",
action: {
type: 'encapsulate', options: {pre: "{{{", 'peri': '1', post: "}}}"}
}
}, {
label: "{{{|}}}",
action: {
type: 'encapsulate', options: {pre: "{{{|", 'peri': '1', post: "}}}"}
}
}, {
label: "[[Kategorie:]]",
action: {
type: 'encapsulate', options: {pre: '[[Kategorie: ', post: ']]'}
}
}, {
label: "[[Category:]]",
action: {
type: 'encapsulate', options: {pre: '[[Category: ', post: ']]'}
}
}, {
label: "[[Attribut:]]",
action: {
type: 'encapsulate',
options: {
/* no selection */
pre: "[[Attribut: ",
post: "]]",
/* a selection */
regex: /\s*(.+)\s*/,
regexReplace: "[[Attribut: \$1 |\$1]]"
}
}
}, {
label: "[[property:]]",
action: {
type: 'encapsulate',
options: {
/* no selection */
pre: "[[property: ",
post: "]]",
/* a selection */
regex: /\s*(.+)\s*/,
regexReplace: "[[property: \$1 |\$1]]"
}
}
}, {
label: "#WEITERLEITUNG [[]]",
action: {
type: 'encapsulate', options: {pre: "#WEITERLEITUNG [[", post: "]]"}
}
}, {
label: "#REDIRECT [[]]",
action: {
type: 'encapsulate', options: {pre: "#REDIRECT [[", post: "]]"}
}
}, {
label: "ref",
action: {
type: 'encapsulate', options: {pre: '<ref name="">', peri: messagePT.periText.ref, post: '</ref>'}
}
}, {
label: "references",
action: {
type: 'encapsulate', options: {pre: '<references/>', post: ''}
}
}, {
label: "noinclude",
action: {
type: 'encapsulate', options: {pre: "<noinclude>", post: "</noinclude>"}
}
}, {
label: "includeonly",
action: {
type: 'encapsulate', options: {pre: "<includeonly>", post: "</includeonly>"}
}
}, {
label: "onlyinclude",
action: {
type: 'encapsulate', options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
}
}, {
label: "translate",
action: {
type: 'encapsulate',
options: {pre: "<translate>", post: "</translate>"}
}
}, {
label: "tvar",
action: {
type: 'encapsulate',
options: {pre: "<tvar|name>", peri: messagePT.periText.tvar, post: "</>"}
}
}, {
label: "code",
action: {
type: 'encapsulate', options: {pre: "<code>", post: "</code>"}
}
}, {
label: "nowiki",
action: {
type: 'encapsulate', options: {pre: "<nowiki>", post: "</nowiki>"}
}
}, {
label: "code nowiki code",
action: {
type: 'encapsulate', options: {pre: "<code><nowiki>", post: "</nowiki></code>"}
}
}, {
label: "comment",
action: {
type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"}
}
}, {
label: "comment lt--gt",
action: {
type: 'encapsulate', options: {pre: "<!-- ", 'peri': messagePT.periText.comment, post: " -->"}
}
}, {
label: "span",
action: {
type: 'encapsulate', options: {pre: '<span style="">', post: '</span>'}
}
}, {
label: "span.plainlinks",
action: {
type: 'encapsulate', options: {pre: '<span class="plainlinks">', post: '</span>'}
}
}, {
label: "div",
action: {
type: 'encapsulate', options: {pre: '<div style="">', post: '</div>'}
}
}, {
label: "{{SORTIERUNG:}}",
action: {
type: 'encapsulate', options: {pre: "{{SORTIERUNG: ", post: "}}"}
}
}, {
label: "{{DEFAULTSORT:}}",
action: {
type: 'encapsulate', options: {pre: "{{DEFAULTSORT: ", post: "}}"}
}
}, {
'label': "div.definition-inline",
'action': {
'type': 'encapsulate',
'options': {
'pre': '<div class="definition-inline">\n; ',
'peri': messagePT.periText.defInlineTerm,
'post': ' : ' + messagePT.periText.defInlineDefinition + '\n</div>'
}
}
}, {
label: "{{#arraymap:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: '|;|§|[[My property::§]] | • }}'}
}
}, {
label: "{{#arraymap:long}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#arraymap: ",
peri: '{{{field|}}}',
post: '<!-- values\n-->|;<!-- split on ;\n-->|§<!-- assign temporary variable\n-->|[[My property::§]] <!-- output\n-->| • <!-- new output separator\n-->}}'
}
}
}, {
label: "if",
action: {
type: 'encapsulate', options: {pre: "{{#if: ", post: "| | }}"}
}
}, {
label: "if long",
action: {
type: 'encapsulate',
options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- if end\n-->"}
}
}, {
label: "switch CONTENTLANGUAGE",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: {{CONTENTLANGUAGE}}",
post: "<!--\n-->|de|de-formal= deutsch <!--\n-->| #default = english<!--\n-->}}<!-- switch end\n-->"
}
}
}, {
label: "switch",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: ",
post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- switch end\n-->"
}
}
}, {
label: "table",
action: {
type: 'encapsulate',
options: {
pre: '<table>',
peri: '<!--\n--><tr><!--\n --><td></td><!--\n--></tr><!--\n-->',
post: '</table>'
}
}
}, {
label: "tr",
action: {
type: 'encapsulate',
options: {pre: '<tr>', peri: '<!--\n --><td></td><!--\n-->', post: '</tr>'}
}
}, {
label: "th",
action: {
type: 'encapsulate',
options: {pre: '<th>', post: '</th>'}
}
}, {
label: "td",
action: {
type: 'encapsulate',
options: {pre: '<td>', post: '</td>'}
}
},
'┌',
'┬',
'┐',
'└',
'┴',
'┘',
'│',
'─',
'├',
'┼',
'┤'
/* <s></s> <sup></sup> <sub></sub> */
]
},
'templates': {
'layout': 'characters',
label: messagePT.sectionLabel.template,
'characters': [
/*
{
label: "Keyboard",
action: {
type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"}
}
}, {
label: "Zitat",
action: {
type: 'encapsulate', options: {pre: '{{Zitat |', post: '}}'}
}
}, {
label: "Zitat versteckt",
action: {
type: 'encapsulate', options: {pre: '{{Zitat versteckt|', post: '}}'}
}
},
*/
{
label: "nbsp;",
action: {
type: 'encapsulate',
options: {pre: " ", post: ""}
}
}, {
label: "()",
action: {
type: 'encapsulate',
options: {pre: "(", post: ")"}
}
}, {
label: "[]",
action: {
type: 'encapsulate',
options: {pre: "[", post: "]"}
}
}, {
label: "[[]]",
action: {
type: 'encapsulate',
options: {pre: "[[", post: "]]"}
}
}, {
label: "{{}}",
action: {
type: 'encapsulate',
options: {pre: "{{", post: "}}"}
}
}, {
label: "{{{}}}",
action: {
type: 'encapsulate',
options: {pre: "{{{", post: "}}}"}
}
}, {
label: "{{{|}}}",
action: {
type: 'encapsulate',
options: {pre: "{{{", post: "|}}}"}
}
}, {
label: "noinclude",
action: {
type: 'encapsulate',
options: {pre: "<noinclude>", post: "</noinclude>"}
}
}, {
label: "includeonly",
action: {
type: 'encapsulate',
options: {pre: "<includeonly>", post: "</includeonly>"}
}
}, {
label: "onlyinclude",
action: {
type: 'encapsulate',
options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
}
}, {
label: "nowiki",
action: {
type: 'encapsulate',
options: {pre: "<nowiki>", post: "</nowiki>"}
}
}, {
label: "comment",
action: {
type: 'encapsulate',
options: {pre: "<!-- ", post: " -->"}
}
}, {
label: "{{#arraymap:}} long",
action: {
type: 'encapsulate',
options: {
pre: "{{#arraymap: ",
peri: '{{{field|}}}',
post: "<!--\n-->|;<!-- sep\n-->|§<!-- assign temporary var\n-->|[[My property::§]] <!--output\n-->| • <!--output sep\n-->}}<!-- end arraymap \n-->"
}
}
}, {
label: "{{#arraymap:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#arraymap: ", peri: '{{{field|}}}', post: "|;|§|[[My property::§]] | • }}"}
}
}, {
label: "{{#ask:table}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#ask: ",
peri: '[[PAGE]] [[property::+]]',
post: " | ?displayprop |? | mainlabel=- | link=none | format = table | limit = 500}}"
}
}
}, {
label: "{{#ask:list}}",
action: {
type: 'encapsulate',
options: {
pre: "{{#ask: ",
peri: '[[PAGE]] [[property::+]]',
post: " | ?displayprop | mainlabel=- | link=none | format = list | sep= •  | limit = 500}}"
}
}
}, {
label: "{{#vardefine:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#vardefine: ", peri: 'myVar', post: "| }}"}
}
}, {
label: "{{#varexist:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#varexist: ", peri: 'myVar', post: "}}"}
}
}, {
label: "{{#var:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#var: ", peri: 'myVar', post: "}}"}
}
}, {
label: "if",
action: {
type: 'encapsulate',
options: {pre: "{{#if: ", post: "| | }}"}
}
}, {
label: "if long",
action: {
type: 'encapsulate',
options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end if\n-->"}
}
}, {
label: "ifexist",
action: {
type: 'encapsulate',
options: {pre: "{{#ifexist: ", post: "| | }}"}
}
}, {
label: "ifexist long",
action: {
type: 'encapsulate',
options: {
pre: "<!--\n-->{{#ifexist: ",
post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end ifexist\n-->"
}
}
}, {
label: "{{#expr:}}",
action: {
type: 'encapsulate',
options: {pre: "{{#expr: ", peri: '1 + 6', post: "}}"}
}
}, {
label: "switch",
action: {
type: 'encapsulate',
options: {
pre: "{{#switch: ",
post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- end switch\n-->"
}
}
}, {
label: "{{DEFAULTSORT:}}",
action: {
type: 'encapsulate',
options: {pre: "{{DEFAULTSORT:", post: "}}"}
}
}, {
label: "{{DISPLAYTITLE:}}",
action: {
type: 'encapsulate',
options: {pre: "{{DISPLAYTITLE:", post: "}}"}
}
},
'{{PAGENAME}}',
'{{PAGENAMEE}}',
'{{FULLPAGENAME}}',
'{{FULLPAGENAMEE}}'
]
}
}
})
}
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
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', function () {
$(document).ready(customizeThisUserWikiEditorToolbar)
})
}
})
}
// </source>
// </pre>