User:Shizhao/Edittools-vector.js

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
			'section': 'main',
			'group': 'insert',
			'tools': {
				'category': {
					label: '分类',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/0/00/Structure_du_site_ic%C3%B4ne.svg/23px-Structure_du_site_ic%C3%B4ne.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "[[Category:",
							post: "]]"
						}
					}
				}
			}
		} );
		$('#wpTextbox1').wikiEditor('addToToolbar', {
			'section': 'advanced',
			'group': 'format',
			'tools': {
				'bolditalic': {
					label: '粗斜体',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/b/be/Toolbaricon_bolditalic_A.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "'''''",
                                                        periMsg: '粗斜体文字', 
							post: "'''''"
						}
					}
				},

				'strikethrough': {
					label: '删除线',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/1/1a/Toolbaricon_strike.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<s>",
							post: "</s>"
						}
					}
				},

				'underline': {
					label: '下划线',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/9/99/Gnome-format-text-underline.svg/22px-Gnome-format-text-underline.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<u>",
							post: "</u>"
						}
					}
				},
				'quote': {
					label: '块引用',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/2/2f/Toolbaricon_quote_1.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<blockquote>",
							post: "</blockquote>"
						}
					}
				},

				'justify-left': {
					label: '左对齐',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/8/81/Toolbaricon_justify-left.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<div style=\"text-align: left;\">",
							post: "</div>"
						}
					}
				},

				'justify-center': {
					label: '居中',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Gnome-format-justify-center.svg/23px-Gnome-format-justify-center.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<div style=\"text-align: center;\">",
							post: "</div>"
						}
					}
				},

				'justify-right': {
					label: '右对齐',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Gnome-format-justify-right.svg/23px-Gnome-format-justify-right.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<div style=\"text-align: right;\">",
							post: "</div>"
						}
					}
				},

				'indent-more': {
					label: '定义',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/8/84/Gnome-format-indent-more.svg/23px-Gnome-format-indent-more.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: ";"
						}
					}
				},
				'source': {
					label: '源代码',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Toolbaricon_source.svg/22px-Toolbaricon_source.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<source lang=\"text\">",
							post: '</source>'
						}
					}
				}
			}
		} );

		$('#wpTextbox1').wikiEditor('addToToolbar', {
			'section': 'advanced',
			'group': 'insert',
			'tools': {
				'math': {
					label: '数学公式',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/c2/Nuvola_apps_edu_mathematics-p.svg/22px-Nuvola_apps_edu_mathematics-p.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<math>",
                                                        periMsg: '插入数学公式', 
							post: "</math>"
						}
					}
				},

				'template': {
					label: '模板',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Curly_Brackets.svg/22px-Curly_Brackets.svg.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "{{",
                                                        periMsg: '模板名称', 
							post: "}}"
						}
					}
				},

				'hidden': {
					label: '注释或隐藏文字',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "<!-- ",
							post: " -->"
						}
					}
				},

				'hline': {
					label: '水平线',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/2/2c/Norwegian_ndash_sign.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "----",
							ownline: true
						}
					}
				},

				'hans-hant': {
					label: '繁简转换',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/9/9d/Toolbaricon_sr.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "-{",
                                                        periMsg: '转换文字', 
							post: "}-"
						}
					}
				},

				'mediafile': {
					label: '媒体文件链接',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/6/65/Toolbaricon_media.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "[[Media:",
                                                        periMsg: 'Example.ogg', 
							post: "]]"
						}
					}
				},

				'references': {
					label: '参考文献区',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/8/8d/Wikieditor-references.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: "\n==参考文献==\n<div class=\"references-small\">\n<references></references>\n</div>\n",
						}
					}
				}
			}
		} );

//结束

};

/* Check if we are in edit mode and the required modules are available and 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( customizeToolbar );
                        } );
                }
        } );
}