MediaWiki:Common.js:修订间差异

Baneq留言 | 贡献
创建页面,内容为“这里的任何JavaScript将为所有用户在每次页面加载时加载。:​ // 给源码编辑器工具栏加"颜色/高亮"按钮 $( function () { if ( typeof mw === 'undefined' || !mw.loader ) { return; } mw.loader.using( 'user.options' ).then( function () { if ( $( '#wpTextbox1' ).length && $.fn.wikiEditor ) { var buttons = { '红': '红', '绿': '绿', '蓝': '蓝', '橙': '橙', '高亮': '高亮' }; var tools = {};…”
 
Baneq留言 | 贡献
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// 给源码编辑器工具栏加"颜色/高亮"按钮
$( function () {
$( function () {
if ( typeof mw === 'undefined' || !mw.loader ) { return; }
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
mw.loader.using( 'user.options' ).then( function () {
var colors = [ '红', '绿', '蓝', '橙', '高亮' ];
if ( $( '#wpTextbox1' ).length && $.fn.wikiEditor ) {
var tools = {};
var buttons = {
colors.forEach( function ( name ) {
'红': '红',
tools[ name ] = {
'绿': '绿',
label: name,
'蓝': '',
type: 'button',
'': '',
action: {
'高亮': '高亮'
type: 'encapsulate',
options: { pre: '{{' + name + '|', peri: '文字', post: '}}' }
}
};
};
var tools = {};
} );
Object.keys( buttons ).forEach( function ( label ) {
$textarea.wikiEditor( 'addToToolbar', {
tools[ label ] = {
section: 'main',
label: label,
group: 'format',
type: 'button',
tools: tools
action: {
} );
type: 'encapsulate',
options: {
pre: '{{' + buttons[ label ] + '|',
peri: '文字',
post: '}}'
}
}
};
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'main',
group: 'format',
tools: tools
} );
}
} );
} );
} );
} );