Difference between revisions of "MediaWiki:Common.js"

From GATE
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
+
/* Any JavaScript here will be <add>loaded</add>
 +
<lb/>
 +
<lb/>for
 +
<lb/>
 +
<pb/>
 +
all users on every page load. */
 
var customizeToolbar = function () {
 
var customizeToolbar = function () {
  

Revision as of 18:20, 15 January 2017

/* Any JavaScript here will be <add>loaded</add> 
<lb/>
<lb/>for
<lb/>
<pb/>
 all users on every page load. */
var customizeToolbar = function () {

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'annotation': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Annotation'
			// or 'labelMsg': 'section-emoticons-label' for a localized label
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'annotation',
	groups: {
		'text': {
			'label': 'TEI'
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'annotation',
	groups: {
		'entities': {
			'label': 'Entities'
		}
	}
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'text',
	tools: {
		"add": {
			label: 'Addition',
			type: 'button',
			icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/9/9c/TEI_Button_add_01.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<add>',
					post: "</add>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'text',
	tools: {
		"del": {
			label: 'Deletion',
			type: 'button',
			icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/c/cf/TEI_Button_del.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<del>',
					post: "</del>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'text',
	tools: {
		"lb": {
			label: 'Line-break',
			type: 'button',
			icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/b/bf/TEI_Button_lb.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<lb/>',
					ownline: true
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'text',
	tools: {
		"pb": {
			label: 'Page-break',
			type: 'button',
			icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/4/4d/TEI_Button_pb.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<pb/>',
					ownline: true
				}
			}
		}
	}
});
};

/* 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' ).then( 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 );
		}
	} );
}