MediaWiki:Gadget-EditAddButton.js:修订间差异
来自康健生活
无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的14个中间版本) | |||
| 第1行: | 第1行: | ||
var customizeToolbar = function () { | var customizeToolbar = function () { | ||
/* Your code goes here */ | /* Your code goes here */ | ||
jQuery( document ).ready( function ( $ ) { | jQuery( document ).ready( function ( $ ) { | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
section: 'advanced', | |||
group: 'format', | |||
tools: { | |||
reqular_s_stroke: { | |||
label: 'Comment visible only for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Toolbaricon_regular_S_stroke.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<!-- ', | |||
peri: 'Insert comment here', | |||
post: ' -->' | |||
} | } | ||
} | |||
}, | |||
toolbar_css_tag: { | |||
} | label: 'CSS tag for editors', | ||
type: 'button', | |||
icon: 'images/toolbar_img/CSS.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<syntaxhighlight lang="css">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>' | |||
} | |||
} | |||
}, | |||
toolbar_html_tag: { | |||
label: 'HTML tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/HTML-Button.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<syntaxhighlight lang="html5">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>' | |||
} | |||
} | |||
}, | |||
toolbar_bash_tag: { | |||
label: 'BASH tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/BASH.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{shc|<syntaxhighlight lang="bash">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>|$|/home/kwy}}' | |||
} | |||
} | |||
}, | |||
toolbar_js_tag: { | |||
label: 'JAVASCRIPT tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/JSbutton.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<syntaxhighlight lang="javascript">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>' | |||
} | |||
} | |||
}, | |||
toolbar_blockquote_tag: { | |||
label: 'Blockquote tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_blockquote.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<blockquote>\n', | |||
peri: 'Insert comment here\n', | |||
post: '</blockquote>' | |||
} | |||
} | |||
}, | |||
toolbar_pre_tag: { | |||
label: 'PRE tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_insert_table.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<pre>\n', | |||
peri: 'Insert comment here\n', | |||
post: '</pre>' | |||
} | |||
} | |||
}, | |||
toolbar_bq_pre_tag: { | |||
label: 'Blockquote > PRE tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/BQ_PRE.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<blockquote><pre>\n', | |||
peri: 'Insert comment here\n', | |||
post: '</pre></blockquote>' | |||
} | |||
} | |||
}, | |||
toolbar_button_reflink: { | |||
label: 'Button reflink tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_reflink.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<ref>', | |||
peri: 'Insert comment here', | |||
post: '</ref>' | |||
} | |||
} | |||
}, | |||
toolbar_button_strong: { | |||
label: 'strong tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_bold.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: "'''", | |||
peri: 'Insert comment here', | |||
post: "'''" | |||
} | |||
} | |||
}, | |||
toolbar_button_strike: { | |||
label: 'Button_strike tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_strike.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<s>', | |||
peri: 'Insert comment here', | |||
post: '</s>' | |||
} | |||
} | |||
}, | |||
toolbar_button_email: { | |||
label: 'Button email tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_spam2.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '[mailto:', | |||
peri: 'Insert comment here', | |||
post: ']' | |||
} | |||
} | |||
}, | |||
toolbar_button_outLink: { | |||
label: 'Button outLink tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_Link_DifferentName.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '[[|', | |||
peri: 'Insert comment here', | |||
post: ']]' | |||
} | |||
} | |||
}, | |||
toolbar_button_redNote: { | |||
label: 'Button redNote tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Marco1.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{Warning|', | |||
peri: 'Insert comment here', | |||
post: '}}' | |||
} | |||
} | |||
}, | |||
toolbar_button_greenNote: { | |||
label: 'Button greenNote tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_chapitre.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<div class="pageBoxGreen">', | |||
peri: 'Insert comment here', | |||
post: '</div>' | |||
} | |||
} | |||
}, | |||
toolbar_button_hrTag: { | |||
label: 'Button hr tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_hr.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<hr>\n', | |||
peri: '', | |||
post: '' | |||
} | |||
} | |||
}, | |||
toolbar_button_noToc: { | |||
label: 'Button noToc tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Button_stop.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '__NOTOC__\n', | |||
peri: '', | |||
post: '' | |||
} | |||
} | |||
}, | |||
toolbar_code_tag: { | |||
label: 'code tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/Btn_toolbar_commentaire.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<code>', | |||
peri: 'Insert comment here', | |||
post: '</code>' | |||
} | |||
} | |||
}, | |||
div_300px_tag: { | |||
label: 'Div 300px tag for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/width300px.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<div style="width:300px;">', | |||
peri: 'Insert comment here', | |||
post: '</div>' | |||
} | |||
} | |||
}, | |||
js_out_tag: { | |||
label: 'Js and console for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/js_out.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{Double-columns|<syntaxhighlight lang="javascript">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>|{{consoleout|<pre>\n</pre>}}}}' | |||
} | |||
} | |||
}, | |||
bash_out_tag: { | |||
label: 'bash and console for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/bash_out.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{Shc_out|<syntaxhighlight lang="bash">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>|<syntaxhighlight lang="bash">\n</syntaxhighlight>|$|/home/kwy}}' | |||
} | |||
} | |||
}, | |||
file_text_tag: { | |||
label: 'file text for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/file_text.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{hc|head=|output=<syntaxhighlight lang="bash">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>}}' | |||
} | |||
} | |||
}, | |||
file_text_diff_tag: { | |||
label: 'file text diff for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/file_text_diff.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{hcdiff|head=|output=<syntaxhighlight lang="bash">\n', | |||
peri: 'Insert comment here\n', | |||
post: '</syntaxhighlight>|output2=<syntaxhighlight lang="bash">\n</syntaxhighlight>}}' | |||
} | |||
} | |||
}, | |||
code_tabs_tag: { | |||
label: 'code tabs for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/codetab.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{codetab|tabs=<tabs><tab name="html"><syntaxhighlight lang="html5">\n', | |||
peri: 'Insert comment here', | |||
post: '</syntaxhighlight></tab><tab name="css"><syntaxhighlight lang="css">\n</syntaxhighlight></tab><tab name="js"><syntaxhighlight lang="javascript">\n</syntaxhighlight></tab></tabs>}}' | |||
} | |||
} | |||
}, | |||
code_pen_tag: { | |||
label: 'codepen iframe for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/codepen.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '{{codepen|tabs=<tabs><tab name="html"><syntaxhighlight lang="html5">\n', | |||
peri: 'Insert comment here', | |||
post: '</syntaxhighlight></tab><tab name="css"><syntaxhighlight lang="css">\n</syntaxhighlight></tab><tab name="js"><syntaxhighlight lang="javascript">\n</syntaxhighlight></tab></tabs>|iframe=<html><iframe src="//iframe.kangkk.cn/" name="kangkk.com"></iframe></html>}}' | |||
} | |||
} | |||
}, | |||
html_iframe_tag: { | |||
label: 'html iframe for editors', | |||
type: 'button', | |||
icon: 'images/toolbar_img/iframe.png', | |||
action: { | |||
type: 'encapsulate', | |||
options: { | |||
pre: '<html><iframe width="100%" height="300" src="//iframe.kangkk.cn/', | |||
peri: 'Insert comment here', | |||
post: '" frameborder="0" name="kangkk.com"></iframe></html>' | |||
} | |||
} | |||
}, | |||
} | |||
} ); | } ); | ||
} ); | } ); | ||
| 第294行: | 第356行: | ||
/* 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' ).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 ); | |||
} | |||
} ); | |||
} | } | ||