All files / src/ui/tools ve.ui.AnnotationTool.js

87.85% Statements 94/107
0% Branches 0/2
0% Functions 0/12
87.85% Lines 94/107

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281                                1x             1x                       1x   1x             1x                                   1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x 1x 1x                     1x     1x 1x 1x 1x 1x   1x                   1x  
/*!
 * VisualEditor UserInterface AnnotationTool classes.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * UserInterface annotation tool.
 *
 * @class
 * @abstract
 * @extends ve.ui.Tool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.AnnotationTool = function VeUiAnnotationTool() {
	// Parent constructor
	ve.ui.AnnotationTool.super.apply( this, arguments );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ui.AnnotationTool, ve.ui.Tool );
 
/* Static Properties */
 
/**
 * Annotation name and data the tool applies.
 *
 * @abstract
 * @static
 * @property {Object}
 * @inheritable
 */
ve.ui.AnnotationTool.static.annotation = { name: '' };
 
ve.ui.AnnotationTool.static.deactivateOnSelect = false;
 
/* Methods */
 
/**
 * @inheritdoc
 */
ve.ui.AnnotationTool.prototype.onUpdateState = function ( fragment ) {
	// Parent method
	ve.ui.AnnotationTool.super.prototype.onUpdateState.apply( this, arguments );
 
	this.setActive(
		fragment && fragment.getAnnotations().hasAnnotationWithName( this.constructor.static.annotation.name )
	);
};
 
/**
 * UserInterface bold tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.BoldAnnotationTool = function VeUiBoldAnnotationTool() {
	ve.ui.BoldAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.BoldAnnotationTool, ve.ui.AnnotationTool );
ve.ui.BoldAnnotationTool.static.name = 'bold';
ve.ui.BoldAnnotationTool.static.group = 'textStyle';
ve.ui.BoldAnnotationTool.static.icon = 'bold';
ve.ui.BoldAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-bold-tooltip' );
ve.ui.BoldAnnotationTool.static.annotation = { name: 'textStyle/bold' };
ve.ui.BoldAnnotationTool.static.commandName = 'bold';
ve.ui.toolFactory.register( ve.ui.BoldAnnotationTool );
 
/**
 * UserInterface italic tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.ItalicAnnotationTool = function VeUiItalicAnnotationTool() {
	ve.ui.ItalicAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.ItalicAnnotationTool, ve.ui.AnnotationTool );
ve.ui.ItalicAnnotationTool.static.name = 'italic';
ve.ui.ItalicAnnotationTool.static.group = 'textStyle';
ve.ui.ItalicAnnotationTool.static.icon = 'italic';
ve.ui.ItalicAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-italic-tooltip' );
ve.ui.ItalicAnnotationTool.static.annotation = { name: 'textStyle/italic' };
ve.ui.ItalicAnnotationTool.static.commandName = 'italic';
ve.ui.toolFactory.register( ve.ui.ItalicAnnotationTool );
 
/**
 * UserInterface code tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.CodeAnnotationTool = function VeUiCodeAnnotationTool() {
	ve.ui.CodeAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.CodeAnnotationTool, ve.ui.AnnotationTool );
ve.ui.CodeAnnotationTool.static.name = 'code';
ve.ui.CodeAnnotationTool.static.group = 'textStyle';
ve.ui.CodeAnnotationTool.static.icon = 'code';
ve.ui.CodeAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-code-tooltip' );
ve.ui.CodeAnnotationTool.static.annotation = { name: 'textStyle/code' };
ve.ui.CodeAnnotationTool.static.commandName = 'code';
ve.ui.toolFactory.register( ve.ui.CodeAnnotationTool );
 
/**
 * UserInterface strikethrough tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.StrikethroughAnnotationTool = function VeUiStrikethroughAnnotationTool() {
	ve.ui.StrikethroughAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.StrikethroughAnnotationTool, ve.ui.AnnotationTool );
ve.ui.StrikethroughAnnotationTool.static.name = 'strikethrough';
ve.ui.StrikethroughAnnotationTool.static.group = 'textStyle';
ve.ui.StrikethroughAnnotationTool.static.icon = 'strikethrough';
ve.ui.StrikethroughAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-strikethrough-tooltip' );
ve.ui.StrikethroughAnnotationTool.static.annotation = { name: 'textStyle/strikethrough' };
ve.ui.StrikethroughAnnotationTool.static.commandName = 'strikethrough';
ve.ui.toolFactory.register( ve.ui.StrikethroughAnnotationTool );
 
/**
 * UserInterface underline tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.UnderlineAnnotationTool = function VeUiUnderlineAnnotationTool() {
	ve.ui.UnderlineAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.UnderlineAnnotationTool, ve.ui.AnnotationTool );
ve.ui.UnderlineAnnotationTool.static.name = 'underline';
ve.ui.UnderlineAnnotationTool.static.group = 'textStyle';
ve.ui.UnderlineAnnotationTool.static.icon = 'underline';
ve.ui.UnderlineAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-underline-tooltip' );
ve.ui.UnderlineAnnotationTool.static.annotation = { name: 'textStyle/underline' };
ve.ui.UnderlineAnnotationTool.static.commandName = 'underline';
ve.ui.toolFactory.register( ve.ui.UnderlineAnnotationTool );
 
/**
 * UserInterface superscript tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.SuperscriptAnnotationTool = function VeUiSuperscriptAnnotationTool() {
	ve.ui.SuperscriptAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.SuperscriptAnnotationTool, ve.ui.AnnotationTool );
ve.ui.SuperscriptAnnotationTool.static.name = 'superscript';
ve.ui.SuperscriptAnnotationTool.static.group = 'textStyle';
ve.ui.SuperscriptAnnotationTool.static.icon = 'superscript';
ve.ui.SuperscriptAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-superscript-tooltip' );
ve.ui.SuperscriptAnnotationTool.static.annotation = { name: 'textStyle/superscript' };
ve.ui.SuperscriptAnnotationTool.static.commandName = 'superscript';
ve.ui.toolFactory.register( ve.ui.SuperscriptAnnotationTool );
 
/**
 * UserInterface subscript tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.SubscriptAnnotationTool = function VeUiSubscriptAnnotationTool() {
	ve.ui.SubscriptAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.SubscriptAnnotationTool, ve.ui.AnnotationTool );
ve.ui.SubscriptAnnotationTool.static.name = 'subscript';
ve.ui.SubscriptAnnotationTool.static.group = 'textStyle';
ve.ui.SubscriptAnnotationTool.static.icon = 'subscript';
ve.ui.SubscriptAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-subscript-tooltip' );
ve.ui.SubscriptAnnotationTool.static.annotation = { name: 'textStyle/subscript' };
ve.ui.SubscriptAnnotationTool.static.commandName = 'subscript';
ve.ui.toolFactory.register( ve.ui.SubscriptAnnotationTool );
 
/**
 * UserInterface big tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.BigAnnotationTool = function VeUiBigAnnotationTool() {
	ve.ui.BigAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.BigAnnotationTool, ve.ui.AnnotationTool );
ve.ui.BigAnnotationTool.static.name = 'big';
ve.ui.BigAnnotationTool.static.group = 'textStyle';
ve.ui.BigAnnotationTool.static.icon = 'bigger';
ve.ui.BigAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-big-tooltip' );
ve.ui.BigAnnotationTool.static.annotation = { name: 'textStyle/big' };
ve.ui.BigAnnotationTool.static.commandName = 'big';
ve.ui.toolFactory.register( ve.ui.BigAnnotationTool );
 
/**
 * UserInterface small tool.
 *
 * @class
 * @extends ve.ui.AnnotationTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.SmallAnnotationTool = function VeUiSmallAnnotationTool() {
	ve.ui.SmallAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.SmallAnnotationTool, ve.ui.AnnotationTool );
ve.ui.SmallAnnotationTool.static.name = 'small';
ve.ui.SmallAnnotationTool.static.group = 'textStyle';
ve.ui.SmallAnnotationTool.static.icon = 'smaller';
ve.ui.SmallAnnotationTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-small-tooltip' );
ve.ui.SmallAnnotationTool.static.annotation = { name: 'textStyle/small' };
ve.ui.SmallAnnotationTool.static.commandName = 'small';
ve.ui.toolFactory.register( ve.ui.SmallAnnotationTool );
 
/**
 * UserInterface more text styles tool.
 *
 * @class
 * @extends OO.ui.ToolGroupTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.MoreTextStyleTool = function VeUiMoreTextStyleTool() {
	ve.ui.MoreTextStyleTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.MoreTextStyleTool, OO.ui.ToolGroupTool );
ve.ui.MoreTextStyleTool.static.autoAddToCatchall = false;
ve.ui.MoreTextStyleTool.static.name = 'moreTextStyle';
ve.ui.MoreTextStyleTool.static.group = 'textStyleExpansion';
ve.ui.MoreTextStyleTool.static.title =
	OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' );
ve.ui.MoreTextStyleTool.static.groupConfig = {
	header: OO.ui.deferMsg( 'visualeditor-toolbar-text-style' ),
	icon: 'textStyle',
	indicator: 'down',
	title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),
	label: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),
	invisibleLabel: true,
	include: [ { group: 'textStyle' }, 'language', 'clear' ],
	demote: [ 'strikethrough', 'code', 'underline', 'language', 'big', 'small', 'clear' ]
};
ve.ui.toolFactory.register( ve.ui.MoreTextStyleTool );