2013-08-27 23:28:29 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface AnnotationTool classes.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface annotation tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
2013-10-09 20:09:59 +00:00
|
|
|
* @extends OO.ui.Tool
|
2013-08-27 23:28:29 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-27 23:28:29 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.AnnotationTool = function VeUiAnnotationTool( toolGroup, config ) {
|
2013-08-27 23:28:29 +00:00
|
|
|
// Parent constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
OO.ui.Tool.call( this, toolGroup, config );
|
2013-08-27 23:28:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( ve.ui.AnnotationTool, OO.ui.Tool );
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Annotation name and data the tool applies.
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @static
|
|
|
|
* @property {Object}
|
|
|
|
* @inheritable
|
|
|
|
*/
|
|
|
|
ve.ui.AnnotationTool.static.annotation = { 'name': '' };
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the tool being selected.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ui.AnnotationTool.prototype.onSelect = function () {
|
|
|
|
this.toolbar.getSurface().execute(
|
|
|
|
'annotation', 'toggle', this.constructor.static.annotation.name
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the toolbar state being updated.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {ve.dm.Node[]} nodes List of nodes covered by the current selection
|
|
|
|
* @param {ve.dm.AnnotationSet} full Annotations that cover all of the current selection
|
|
|
|
* @param {ve.dm.AnnotationSet} partial Annotations that cover some or all of the current selection
|
|
|
|
*/
|
|
|
|
ve.ui.AnnotationTool.prototype.onUpdateState = function ( nodes, full ) {
|
|
|
|
this.setActive( full.hasAnnotationWithName( this.constructor.static.annotation.name ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface bold tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-27 23:28:29 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.BoldAnnotationTool = function VeUiBoldAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-08-27 23:28:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.BoldAnnotationTool, ve.ui.AnnotationTool );
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.BoldAnnotationTool.static.name = 'bold';
|
|
|
|
ve.ui.BoldAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.BoldAnnotationTool.static.icon = {
|
|
|
|
'default': 'bold-a',
|
2013-09-12 18:41:58 +00:00
|
|
|
'be': 'bold-cyrl-te',
|
2013-08-27 23:28:29 +00:00
|
|
|
'cs': 'bold-b',
|
|
|
|
'da': 'bold-f',
|
|
|
|
'de': 'bold-f',
|
|
|
|
'en': 'bold-b',
|
|
|
|
'es': 'bold-n',
|
|
|
|
'eu': 'bold-l',
|
|
|
|
'fr': 'bold-g',
|
|
|
|
'gl': 'bold-n',
|
|
|
|
'he': 'bold-b',
|
|
|
|
'hu': 'bold-f',
|
|
|
|
'it': 'bold-g',
|
|
|
|
'ka': 'bold-geor-man',
|
|
|
|
'ky': 'bold-cyrl-zhe',
|
|
|
|
'ml': 'bold-b',
|
|
|
|
'nl': 'bold-v',
|
|
|
|
'nn': 'bold-f',
|
|
|
|
'no': 'bold-f',
|
|
|
|
'os': 'bold-cyrl-be',
|
|
|
|
'pl': 'bold-b',
|
|
|
|
'pt': 'bold-n',
|
|
|
|
'ru': 'bold-cyrl-zhe',
|
|
|
|
'sv': 'bold-f'
|
|
|
|
};
|
|
|
|
ve.ui.BoldAnnotationTool.static.titleMessage = 'visualeditor-annotationbutton-bold-tooltip';
|
|
|
|
ve.ui.BoldAnnotationTool.static.annotation = { 'name': 'textStyle/bold' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.BoldAnnotationTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface italic tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-27 23:28:29 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.ItalicAnnotationTool = function VeUiItalicAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-08-27 23:28:29 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.ItalicAnnotationTool, ve.ui.AnnotationTool );
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.ItalicAnnotationTool.static.name = 'italic';
|
|
|
|
ve.ui.ItalicAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.ItalicAnnotationTool.static.icon = {
|
|
|
|
'default': 'italic-a',
|
2013-09-12 18:41:58 +00:00
|
|
|
'be': 'italic-cyrl-ka',
|
2013-08-27 23:28:29 +00:00
|
|
|
'cs': 'italic-i',
|
|
|
|
'da': 'italic-k',
|
|
|
|
'de': 'italic-k',
|
|
|
|
'en': 'italic-i',
|
|
|
|
'es': 'italic-c',
|
|
|
|
'eu': 'italic-e',
|
|
|
|
'fr': 'italic-i',
|
|
|
|
'gl': 'italic-c',
|
|
|
|
'he': 'italic-i',
|
|
|
|
'hu': 'italic-d',
|
|
|
|
'it': 'italic-c',
|
|
|
|
'ka': 'italic-geor-kan',
|
|
|
|
'ky': 'italic-cyrl-ka',
|
|
|
|
'ml': 'italic-i',
|
|
|
|
'nl': 'italic-c',
|
|
|
|
'nn': 'italic-k',
|
|
|
|
'no': 'italic-k',
|
|
|
|
'os': 'italic-cyrl-ka',
|
|
|
|
'pl': 'italic-i',
|
|
|
|
'pt': 'italic-i',
|
|
|
|
'ru': 'italic-cyrl-ka',
|
|
|
|
'sv': 'italic-k'
|
|
|
|
};
|
|
|
|
ve.ui.ItalicAnnotationTool.static.titleMessage = 'visualeditor-annotationbutton-italic-tooltip';
|
|
|
|
ve.ui.ItalicAnnotationTool.static.annotation = { 'name': 'textStyle/italic' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.ItalicAnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface code tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-09-12 02:41:14 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.CodeAnnotationTool = function VeUiCodeAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-09-12 02:41:14 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.CodeAnnotationTool, ve.ui.AnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
ve.ui.CodeAnnotationTool.static.name = 'code';
|
|
|
|
ve.ui.CodeAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.CodeAnnotationTool.static.icon = 'code';
|
|
|
|
ve.ui.CodeAnnotationTool.static.titleMessage = 'visualeditor-annotationbutton-code-tooltip';
|
|
|
|
ve.ui.CodeAnnotationTool.static.annotation = { 'name': 'textStyle/code' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.CodeAnnotationTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface strikethrough tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-09-12 02:41:14 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.StrikethroughAnnotationTool = function VeUiStrikethroughAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-09-12 02:41:14 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.StrikethroughAnnotationTool, ve.ui.AnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
ve.ui.StrikethroughAnnotationTool.static.name = 'strikethrough';
|
|
|
|
ve.ui.StrikethroughAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.StrikethroughAnnotationTool.static.icon = {
|
|
|
|
'default': 'strikethrough-a',
|
|
|
|
'en': 'strikethrough-s'
|
|
|
|
};
|
|
|
|
ve.ui.StrikethroughAnnotationTool.static.titleMessage =
|
|
|
|
'visualeditor-annotationbutton-strikethrough-tooltip';
|
|
|
|
ve.ui.StrikethroughAnnotationTool.static.annotation = { 'name': 'textStyle/strike' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.StrikethroughAnnotationTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface underline tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-09-12 02:41:14 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.UnderlineAnnotationTool = function VeUiUnderlineAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-09-12 02:41:14 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.UnderlineAnnotationTool, ve.ui.AnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
ve.ui.UnderlineAnnotationTool.static.name = 'underline';
|
|
|
|
ve.ui.UnderlineAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.UnderlineAnnotationTool.static.icon = {
|
|
|
|
'default': 'underline-a',
|
|
|
|
'en': 'underline-u'
|
|
|
|
};
|
|
|
|
ve.ui.UnderlineAnnotationTool.static.titleMessage =
|
|
|
|
'visualeditor-annotationbutton-underline-tooltip';
|
|
|
|
ve.ui.UnderlineAnnotationTool.static.annotation = { 'name': 'textStyle/underline' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.UnderlineAnnotationTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface subscript tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-09-12 02:41:14 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.SubscriptAnnotationTool = function VeUiSubscriptAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-09-12 02:41:14 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.SubscriptAnnotationTool, ve.ui.AnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
ve.ui.SubscriptAnnotationTool.static.name = 'subscript';
|
|
|
|
ve.ui.SubscriptAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.SubscriptAnnotationTool.static.icon = 'subscript';
|
|
|
|
ve.ui.SubscriptAnnotationTool.static.titleMessage =
|
|
|
|
'visualeditor-annotationbutton-subscript-tooltip';
|
|
|
|
ve.ui.SubscriptAnnotationTool.static.annotation = { 'name': 'textStyle/subscript' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.SubscriptAnnotationTool );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UserInterface superscript tool.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.AnnotationTool
|
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-09-12 02:41:14 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.SuperscriptAnnotationTool = function VeUiSuperscriptAnnotationTool( toolGroup, config ) {
|
|
|
|
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
2013-09-12 02:41:14 +00:00
|
|
|
};
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.SuperscriptAnnotationTool, ve.ui.AnnotationTool );
|
2013-09-12 02:41:14 +00:00
|
|
|
ve.ui.SuperscriptAnnotationTool.static.name = 'superscript';
|
|
|
|
ve.ui.SuperscriptAnnotationTool.static.group = 'textStyle';
|
|
|
|
ve.ui.SuperscriptAnnotationTool.static.icon = 'superscript';
|
|
|
|
ve.ui.SuperscriptAnnotationTool.static.titleMessage =
|
|
|
|
'visualeditor-annotationbutton-superscript-tooltip';
|
|
|
|
ve.ui.SuperscriptAnnotationTool.static.annotation = { 'name': 'textStyle/superscript' };
|
|
|
|
ve.ui.toolFactory.register( ve.ui.SuperscriptAnnotationTool );
|