Difference between revisions of "MediaWiki:Common.js"

From GATE
Line 34: Line 34:
 
         group: 'text',
 
         group: 'text',
 
tools: {
 
tools: {
"head": {
+
"add": {
label: 'Header',
+
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',
 
type: 'button',
icon: 'File:TEI_head.png',
+
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/b/bf/TEI_Button_lb.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: '<head>',
+
pre: '<lb/>',
post: "</head>"
+
ownline: true
 
}
 
}
 
}
 
}
Line 53: Line 91:
 
         group: 'text',
 
         group: 'text',
 
tools: {
 
tools: {
"add": {
+
"pb": {
label: 'Addition',
+
label: 'Page-break',
 
type: 'button',
 
type: 'button',
icon: 'https://upload.wikimedia.org/wikipedia/commons/3/34/22px_icon_512.png',
+
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/4/4d/TEI_Button_pb.png',
 
action: {
 
action: {
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: '<add>',
+
pre: '<pb/>',
post: "</add>"
+
ownline: true
 
}
 
}
 
}
 
}

Revision as of 18:13, 15 January 2017

/* Any JavaScript here will be loaded for 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 );
		}
	} );
}