MediaWiki:Gadget-extra-toolbar-buttons-core.js

出自維基百科,自由嘅百科全書

注意:儲存之後,你可能要兜過你嘅瀏覽器快取至睇到更改。Internet Explorer: 撳住Ctrl掣再撳重新整理掣。 Firefox: 撳住Shift掣再撳重新載入(又或者撳Ctrl-Shift-R)。 Google Chrome同埋Safari用戶就噉撳個重載掣。

/*global mw */
/*jshint strict: false, browser: true, jquery: true */
/**
 * Extra toolbar options
 *  
 *  Description: Adds extra buttons to the old (non-enhanced) editing toolbar.
 *  
 *  Maintainers: [[User:MarkS]], [[User:Voice of All]], [[User:R. Koot]]
 */

function addExtraButtons () {
	mw.toolbar.addButtons(
	{
		imageId: 'button-redirect',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/c/c8/Button_redirect.png',
		speedTip: '彈去',
		tagOpen: '#REDIRECT[[',
		tagClose: ']]',
		sampleText: '目標版名'
	},
	{
		imageId: 'button-strike',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png',
		speedTip: '刪除綫',
		tagOpen: '<s>',
		tagClose: '</s>',
		sampleText: '要刪除嘅字'
	},
	{
		imageId: 'button-enter',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png',
		speedTip: '斷行',
		tagOpen: '<br/>',
		tagClose: '',
		sampleText: ''
	},
	{
		imageId: 'button-subscript',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/a/aa/Button_sub_letter.png',
		speedTip: '下標',
		tagOpen: '<sub>',
		tagClose: '</sub>',
		sampleText: '下標字'
	},
	{
		imageId: 'button-superscript',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/6/6a/Button_sup_letter.png',
		speedTip: '上標',
		tagOpen: '<sup>',
		tagClose: '</sup>',
		sampleText: '上標字'
	},
	{
		imageId: 'button-small',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/5/58/Button_small.png',
		speedTip: '細字',
		tagOpen: '<small>',
		tagClose: '</small>',
		sampleText: '細字'
	},
	{
		imageId: 'button-hide-comment',
		imageFile: '//upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png',
		speedTip: '插入隱藏註解',
		tagOpen: '<!-- ',
		tagClose: ' -->',
		sampleText: '註解'
	},
	{
		imageId: 'button-gallery',
		imageFile: '//upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png',
		speedTip: '插入一個畫廊',
		tagOpen: '\n<gallery>\n',
		tagClose: '\n</gallery>',
		sampleText: 'File:Example.svg|標題1\nFile:Example.jpg|標題2'
	},
	{
		imageId: 'button-blockquote',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/f/fd/Button_blockquote.png',
		speedTip: '插入一舊引用字',
		tagOpen: '<blockquote>\n',
		tagClose: '\n</blockquote>',
		sampleText: '一舊引用'
	},
	{
		imageId: 'button-insert-table',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png',
		speedTip: '插入一個表',
		tagOpen: '{| class="wikitable"\n|',
		tagClose: '\n|}',
		sampleText: '-\n! 標題 1\n! 標題 2\n! 標題 3\n|-\n| 列 1, 格 1\n| 列 1, 格 2\n| 列 1, 格 3\n|-\n| 列 2, 格 1\n| 列 2, 格 2\n| 列 2, 格 3'
	},
	{
		imageId: 'button-insert-reflink',
		imageFile: '//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png',
		speedTip: '插入一個引用',
		tagOpen: '<ref>',
		tagClose: '</ref>',
		sampleText: '響呢度插入底文'
	}
	);
}

mw.loader.using( 'user.options', function () {
	// This can be the string "0" if the user disabled the preference ([[bugzilla:52542#c3]])
	if ( mw.user.options.get( 'usebetatoolbar' ) != 1 && mw.user.options.get( 'showtoolbar' ) == 1 ) {
		$.when(
			mw.loader.using( 'mediawiki.toolbar' ),
			$.ready
		).then( addExtraButtons );
	}
} );

/**
 * Fix edit summary prompt for undo
 *
 *  Fixes the fact that the undo function combined with the "no edit summary prompter"
 *  causes problems if leaving the edit summary unchanged.
 *  Added by [[User:Deskana]], code by [[User:Tra]].
 *  See also [[bugzilla:8912]].
 */
$(function () {
    if (document.location.search.indexOf('undo=') !== -1 && document.getElementsByName('wpAutoSummary')[0]) {
        document.getElementsByName('wpAutoSummary')[0].value = '1';
    }
});