MediaWiki:Common.js:修订间差异
创建页面,内容为“→这里的任何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 = {};…” |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
$( function () { | $( function () { | ||
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { | |||
mw. | var colors = [ '红', '绿', '蓝', '橙', '高亮' ]; | ||
var tools = {}; | |||
colors.forEach( function ( name ) { | |||
tools[ name ] = { | |||
label: name, | |||
type: 'button', | |||
action: { | |||
type: 'encapsulate', | |||
options: { pre: '{{' + name + '|', peri: '文字', post: '}}' } | |||
} | |||
}; | }; | ||
} ); | |||
$textarea.wikiEditor( 'addToToolbar', { | |||
section: 'main', | |||
group: 'format', | |||
tools: tools | |||
} ); | |||
} ); | } ); | ||
} ); | } ); | ||