MediaWiki:Common.js

From xat wiki
Jump to: navigation, search
This page contains changes which are not marked for translation.

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */

var customizeToolbar = function() {

/* TEMPLATE SECTION */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'templates': {
			'type': 'booklet', // Can also be 'booklet'
			'label': 'Templates'
			// or 'labelMsg': 'section-emoticons-label' for a localized label
		}
	}
} );
/* TEMPLATE SECTION END */

/* TEMPLATE SECTION ENTRIES */
// Template:Category
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'templates',
	'pages': {
		'category': {
			'layout': 'table',
			'label': 'Category',
			'headings': [
				{ text: 'Template' },
				{ text: 'Documentation' }
			],
			'rows': [
				{
					'name': { html: '{{category|<b>nameofcategory</b>}}' },
					'doc': { html: 'In almost all situations the template will be used instead of [[Category:Name]] to avoid the main article along with its translations to be included under the same category.<br /><br />Attributes&#58;<br /><b>langcat</b> - Value <b>yes</b> to create a separate category for each translation of an article (optional).<br /><b>dir</b> - Value <b>3</b> if an article translation resides in the third part of the directory e.g trans/smilies/<b>et</b> (optional).' }
				}
			]
		}
	}
} );

// Template:Gallery
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'templates',
	'pages': {
		'gallery': {
			'layout': 'table',
			'label': 'Gallery',
			'headings': [
				{ text: 'Template' },
				{ text: 'Documentation' }
			],
			'rows': [
				{
					'name': { html: '{{Gallery<br />|<b>https://</b>|1d=<br />|<b>https://</b>|2d=<br />}}' },
					'doc': { html: 'Display a gallery of up to 10 images.<br /><br />Attributes&#58;<br /><b>1d-10d</b> - Image descriptions (optional).<br /><b>width</b> - Width of each thumbnail in pixels (optional, defaults to 275).<br /><b>scalable</b> - Value <b>no</b> to prevent images from scaling.' }
				}
			]
		}
	}
} );

// Template:Img
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'templates',
	'pages': {
		'img': {
			'layout': 'table',
			'label': 'Img',
			'headings': [
				{ text: 'Template' },
				{ text: 'Documentation' }
			],
			'rows': [
				{
					'name': { text: '{{img|image=|description=}}' },
					'doc': { html: 'Image thumbnails for external images.<br /><br />Attributes&#58;<br /><b>image</b> - Direct link to an image you&#39re going to use.<br /><b>width</b> - Sets the width of an image thumb in pixels, defaults to 275px and should be kept that way, unless the image is smaller than that.<br /><b>float</b> - Value <b>right</b> or <b>left</b>, defaults to right (optional).<br /><b>description</b> - Short description of the image.<br /><b>link</b> - Where the thumbnail links to, should not be set for regular thumbnails (optional).<br /><b>scalable</b> - Value no to prevent image from scaling.' }
				}
			]
		}
	}
} );

// Template:Trans
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'templates',
	'pages': {
		'trans': {
			'layout': 'table',
			'label': 'Translatable templates',
			'headings': [
				{ text: '' },
				{ text: '' }
			],
			'rows': [
				{
					'name': { html: '<b>Various</b>' },
					'doc': { html: '' }
				},
				{
					'name': { text: '{{ {{tt|Trans/examples}} }}' },
					'doc': { html: '&#39== Examples ==&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/newin}} }}' },
					'doc': { html: '&#39New in&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/pawns}} }}' },
					'doc': { html: '&#39Limited Pawns&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/smilies}} }}' },
					'doc': { html: '&#39Smilies&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/ts}} }}' },
					'doc': { html: '&#39themed smilies&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/usage}} }}' },
					'doc': { html: '&#39== Usage ==&#39' }
				},
				{
					'name': { html: '<b>Hug</b>' },
					'doc': { html: '' }
				},
				{
					'name': { text: '{{ {{tt|Trans/hug}} }}' },
					'doc': { html: '<i>Hug description.</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/hugm}} }}' },
					'doc': { html: '&#39Your message here#optional color code&#39' }
				},
				{
					'name': { html: '<b>Jinx</b>' },
					'doc': { html: '' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxallnote}} }}' },
					'doc': { html: '<i>How much it costs and how often can you send.</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxexamples}} }}' },
					'doc': { html: '&#39Examples&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxgcontrol}} }}' },
					'doc': { html: '<i>Configuring jinx using Gcontrol</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxnote1}} }}' },
					'doc': { html: '<i>Cannot jinx in main chat</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxprobability}} }}' },
					'doc': { html: '&#39probability%&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxtime}} }}' },
					'doc': { html: '&#39time in minutes&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxusage1}} }}' },
					'doc': { html: '&#39To jinx_name the user in private chat only&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxusage2}} }}' },
					'doc': { html: '&#39To jinx_name the user in main chat&#39' }
				},
				{
					'name': { text: '{{ {{tt|Trans/jinxusagenotes}} }}' },
					'doc': { html: '<i>Jinx usage notes</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/unjinx}} }}' },
					'doc': { html: '<i>Info on unjinxing.</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/unjinxmain}} }}' },
					'doc': { html: '<i>Info on how to unjinx in main chat.</i>' }
				},
				{
					'name': { text: '{{ {{tt|Trans/unjinxpc}} }}' },
					'doc': { html: '<i>Info on how to unjinx in private chat.' }
				}
			]
		}
	}
} );

// Template:Shortcut
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'templates',
	'pages': {
		'shortcut': {
			'layout': 'table',
			'label': 'Shortcut',
			'headings': [
				{ text: 'Template' },
				{ text: 'Documentation' }
			],
			'rows': [
				{
					'name': { text: '{{shortcut}}' },
					'doc': { html: 'To display a xat.wiki short link with the same name as the article, all you need to do, is add <b>{{shortcut}}</b> on the very first line of an article. In case you find the name of an article too long and complicated you can create a redirect and define the redirect on an article, e.g <b>{{shortcut|og}}</b> for Owners_Guide, which has og redirecting to it.' }
				}
			]
		}
	}
} );
/* TEMPLATE SECTION ENTRIES END */

/* TRANSLATE GROUP */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'main',
	'groups': {
		'translate': {
			'label': 'Translate' // or use labelMsg for a localized label, see above
		}
	}
} );
/* TRANSLATE GROUP END */

/* LANGUAGES BUTTON */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'main',
	group: 'translate',
	tools: {
		"languages": {
			label: 'Languages',
			type: 'button',
			icon: '//util.xat.com/wiki/images/2/29/Button_languages.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<languages/>",
					post: ""
				}
			}
		}
	}
});
/* LANGUAGES BUTTON END */

/* TRANSLATE BUTTON */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'main',
	group: 'translate',
	tools: {
		"translate": {
			label: 'Translate',
			type: 'button',
			icon: '//util.xat.com/wiki/images/5/5c/Button_translate.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<translate>",
					post: "</translate>"
				}
			}
		}
	}
});
/* TRANSLATE BUTTON END */

/* TRANS TEMPLATE BUTTON */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'main',
	group: 'translate',
	tools: {
		"tt": {
			label: 'Translatable template',
			type: 'button',
			icon: '//util.xat.com/wiki/images/f/f6/Button_tt.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{ {{tt|trans/",
					post: "}} }}"
				}
			}
		}
	}
});
/* TRANS TEMPLATE BUTTON END */

/* TVAR BUTTON */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'main',
	group: 'translate',
	tools: {
		"tvar": {
			label: 'Variable',
			type: 'button',
			icon: '//util.xat.com/wiki/images/e/e4/Button_tvar.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<tvar|1>",
					post: "</>"
				}
			}
		}
	}
});
/* TVAR BUTTON END */

/* MYLANGUAGE BUTTON */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'main',
	group: 'translate',
	tools: {
		"tvar": {
			label: 'MyLanguage',
			type: 'button',
			icon: '//util.xat.com/wiki/images/8/84/Button_ml.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "[[<tvar|1>Special:MyLanguage/</>|",
					post: "]]"
				}
			}
		}
	}
});
/* MYLANGUAGE BUTTON END */

/* REMOVED BUTTONS */
/* Remove Search & Replace */
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	'section': 'main',
	'group': 'insert',
	'tool': 'file'
});

$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
	'section': 'main',
	'group': 'insert',
	'tool': 'reference'
});
/* REMOVED BUTTONS END */

};

/* TOOLBAR CONFIG */
/* 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 ) {
	mw.loader.using( 'user.options', 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.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
/* TOOLBAR CONFIG END */