mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 12:16:51 +00:00
Merge "Detangle triggers from OOUI"
This commit is contained in:
commit
678102c7fd
|
@ -103,7 +103,8 @@
|
|||
"ve.ui.TargetToolbar",
|
||||
"ve.ui.SurfaceWindowSet",
|
||||
"ve.ui.Action",
|
||||
"ve.ui.Trigger"
|
||||
"ve.ui.Trigger",
|
||||
"ve.ui.Command"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -520,6 +520,7 @@ $wgResourceModules += array(
|
|||
've/ui/ve.ui.SurfaceToolbar.js',
|
||||
've/ui/ve.ui.TargetToolbar.js',
|
||||
've/ui/ve.ui.ToolFactory.js',
|
||||
've/ui/ve.ui.Command.js',
|
||||
've/ui/ve.ui.CommandRegistry.js',
|
||||
've/ui/ve.ui.Trigger.js',
|
||||
've/ui/ve.ui.TriggerRegistry.js',
|
||||
|
|
|
@ -15,12 +15,10 @@
|
|||
* @mixins OO.ui.LabeledElement
|
||||
*
|
||||
* @constructor
|
||||
* @param {OO.ui.Toolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
OO.ui.Tool = function OoUiTool( toolbar, config ) {
|
||||
var titleMessage = this.constructor.static.titleMessage;
|
||||
|
||||
OO.ui.Tool = function OoUiTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Widget.call( this, config );
|
||||
|
||||
|
@ -29,7 +27,8 @@ OO.ui.Tool = function OoUiTool( toolbar, config ) {
|
|||
OO.ui.LabeledElement.call( this, this.$$( '<span>' ) );
|
||||
|
||||
// Properties
|
||||
this.toolbar = toolbar;
|
||||
this.toolGroup = toolGroup;
|
||||
this.toolbar = this.toolGroup.getToolbar();
|
||||
this.active = false;
|
||||
|
||||
// Events
|
||||
|
@ -43,8 +42,8 @@ OO.ui.Tool = function OoUiTool( toolbar, config ) {
|
|||
this.constructor.static.name.replace( /^([^\/]+)\/([^\/]+).*$/, '$1-$2' )
|
||||
)
|
||||
.append( this.$icon, this.$label );
|
||||
this.setLabel( titleMessage ? OO.ui.msg( titleMessage ) : '' );
|
||||
this.setIcon( this.constructor.static.icon );
|
||||
this.updateLabel();
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -118,7 +117,7 @@ OO.ui.Tool.static.icon = '';
|
|||
OO.ui.Tool.static.titleMessage = '';
|
||||
|
||||
/**
|
||||
* Tool can be automatically added to toolgroups.
|
||||
* Tool can be automatically added to tool groups.
|
||||
*
|
||||
* @static
|
||||
* @property {boolean}
|
||||
|
@ -195,19 +194,50 @@ OO.ui.Tool.prototype.setActive = function ( state ) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Sets the tool title attribute in the DOM.
|
||||
* Get the tool's symbolic name.
|
||||
*
|
||||
* @method
|
||||
* @param {string} [title] Title text, omit to remove title
|
||||
* @chainable
|
||||
* @returns {string} Symbolic name of tool
|
||||
*/
|
||||
OO.ui.Tool.prototype.setTitle = function ( title ) {
|
||||
if ( typeof title === 'string' && title.length ) {
|
||||
this.$.attr( 'title', title );
|
||||
OO.ui.Tool.prototype.getName = function () {
|
||||
return this.constructor.static.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the label.
|
||||
*
|
||||
* @method
|
||||
*/
|
||||
OO.ui.Tool.prototype.updateLabel = function () {
|
||||
var titleMessage = this.constructor.static.titleMessage,
|
||||
labelTooltips = this.toolGroup.constructor.static.labelTooltips,
|
||||
accelTooltips = this.toolGroup.constructor.static.accelTooltips,
|
||||
title = titleMessage ? OO.ui.msg( titleMessage ) : '',
|
||||
accel = this.toolbar.getToolAccelerator( this.constructor.static.name ),
|
||||
tooltipParts = [];
|
||||
|
||||
this.setLabel(
|
||||
this.$$( '<span>' )
|
||||
.addClass( 'oo-ui-tool-title' )
|
||||
.text( title )
|
||||
.add(
|
||||
this.$$( '<span>' )
|
||||
.addClass( 'oo-ui-tool-accel' )
|
||||
.text( accel )
|
||||
)
|
||||
);
|
||||
|
||||
if ( labelTooltips && typeof title === 'string' && title.length ) {
|
||||
tooltipParts.push( title );
|
||||
}
|
||||
if ( accelTooltips && typeof accel === 'string' && accel.length ) {
|
||||
tooltipParts.push( accel );
|
||||
}
|
||||
if ( tooltipParts.length ) {
|
||||
this.$.attr( 'title', tooltipParts.join( ' ' ) );
|
||||
} else {
|
||||
this.$.removeAttr( 'title' );
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,6 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) {
|
|||
'mouseout': OO.ui.bind( this.onMouseOut, this )
|
||||
} );
|
||||
this.toolbar.getToolFactory().connect( this, { 'register': 'onToolFactoryRegister' } );
|
||||
ve.ui.triggerRegistry.connect( this, { 'register': 'onTriggerRegistryRegister' } );
|
||||
|
||||
// Initialization
|
||||
this.$group.addClass( 'oo-ui-toolGroup-tools' );
|
||||
|
@ -79,22 +78,22 @@ OO.mixinClass( OO.ui.ToolGroup, OO.ui.GroupElement );
|
|||
/* Static Properties */
|
||||
|
||||
/**
|
||||
* Show title in tooltip.
|
||||
* Show labels in tooltips.
|
||||
*
|
||||
* @static
|
||||
* @property {string}
|
||||
* @property {boolean}
|
||||
* @inheritable
|
||||
*/
|
||||
OO.ui.ToolGroup.static.showTitle = false;
|
||||
OO.ui.ToolGroup.static.labelTooltips = false;
|
||||
|
||||
/**
|
||||
* Show trigger in tooltip.
|
||||
* Show acceleration labels in tooltips.
|
||||
*
|
||||
* @static
|
||||
* @property {string}
|
||||
* @property {boolean}
|
||||
* @inheritable
|
||||
*/
|
||||
OO.ui.ToolGroup.static.showTrigger = false;
|
||||
OO.ui.ToolGroup.static.accelTooltips = false;
|
||||
|
||||
/* Methods */
|
||||
|
||||
|
@ -203,51 +202,6 @@ OO.ui.ToolGroup.prototype.onToolFactoryRegister = function () {
|
|||
this.populate();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle trigger registry register events.
|
||||
*
|
||||
* If a trigger is registered after the tool is loaded, this handler will ensure matching tools'
|
||||
* titles are updated to reflect the available key command for the tool.
|
||||
*
|
||||
* @param {string} name Symbolic name of trigger
|
||||
*/
|
||||
OO.ui.ToolGroup.prototype.onTriggerRegistryRegister = function ( name ) {
|
||||
if ( this.tools[name] ) {
|
||||
this.updateToolTitle( name );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the title of a tool.
|
||||
*
|
||||
* @param {string} name Tool name
|
||||
* @chainable
|
||||
*/
|
||||
OO.ui.ToolGroup.prototype.updateToolTitle = function ( name ) {
|
||||
var tool, trigger, labelMessage, labelText,
|
||||
showTitle = this.constructor.static.showTitle,
|
||||
showTrigger = this.constructor.static.showTrigger;
|
||||
|
||||
tool = this.tools[name];
|
||||
if ( tool ) {
|
||||
labelText = '';
|
||||
if ( showTitle ) {
|
||||
labelMessage = tool.constructor.static.titleMessage;
|
||||
if ( labelMessage ) {
|
||||
labelText += OO.ui.msg( labelMessage );
|
||||
}
|
||||
}
|
||||
if ( showTrigger ) {
|
||||
trigger = ve.ui.triggerRegistry.lookup( tool.constructor.static.name );
|
||||
if ( trigger ) {
|
||||
labelText += ' [' + trigger.getMessage() + ']';
|
||||
}
|
||||
}
|
||||
tool.setTitle( labelText );
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the toolbar this group is in.
|
||||
*
|
||||
|
@ -279,10 +233,10 @@ OO.ui.ToolGroup.prototype.populate = function () {
|
|||
if ( !tool ) {
|
||||
// Auto-initialize tools on first use
|
||||
this.tools[name] = tool =
|
||||
this.toolbar.getToolFactory().create( name, this.toolbar );
|
||||
this.updateToolTitle( name );
|
||||
this.toolbar.getToolFactory().create( name, this );
|
||||
tool.updateLabel();
|
||||
}
|
||||
this.toolbar.reserveTool( name );
|
||||
this.toolbar.reserveTool( tool );
|
||||
add.push( tool );
|
||||
names[name] = true;
|
||||
}
|
||||
|
@ -291,7 +245,7 @@ OO.ui.ToolGroup.prototype.populate = function () {
|
|||
for ( name in this.tools ) {
|
||||
if ( !names[name] ) {
|
||||
this.tools[name].destroy();
|
||||
this.toolbar.releaseTool( name );
|
||||
this.toolbar.releaseTool( this.tools[name] );
|
||||
remove.push( this.tools[name] );
|
||||
delete this.tools[name];
|
||||
}
|
||||
|
@ -320,7 +274,7 @@ OO.ui.ToolGroup.prototype.destroy = function () {
|
|||
this.clearItems();
|
||||
this.toolbar.getToolFactory().disconnect( this );
|
||||
for ( name in this.tools ) {
|
||||
this.toolbar.releaseTool( name );
|
||||
this.toolbar.releaseTool( this.tools[name] );
|
||||
this.tools[name].disconnect( this ).destroy();
|
||||
delete this.tools[name];
|
||||
}
|
||||
|
|
|
@ -124,6 +124,13 @@ OO.ui.Toolbar.prototype.setup = function ( groups ) {
|
|||
'menu': OO.ui.MenuToolGroup
|
||||
};
|
||||
|
||||
// Cleanup previous groups
|
||||
for ( i = 0, len = this.items.length; i < len; i++ ) {
|
||||
this.items[i].destroy();
|
||||
}
|
||||
this.clearItems();
|
||||
|
||||
// Build out new groups
|
||||
for ( i = 0, len = groups.length; i < len; i++ ) {
|
||||
group = groups[i];
|
||||
if ( group.include === '*' ) {
|
||||
|
@ -136,7 +143,9 @@ OO.ui.Toolbar.prototype.setup = function ( groups ) {
|
|||
}
|
||||
}
|
||||
type = constructors[group.type] ? group.type : defaultType;
|
||||
items.push( new constructors[type]( this, OO.ui.extendObject( { '$$': this.$$ }, group ) ) );
|
||||
items.push(
|
||||
new constructors[type]( this, OO.ui.extendObject( { '$$': this.$$ }, group ) )
|
||||
);
|
||||
}
|
||||
this.addItems( items );
|
||||
};
|
||||
|
@ -149,21 +158,49 @@ OO.ui.Toolbar.prototype.setup = function ( groups ) {
|
|||
OO.ui.Toolbar.prototype.destroy = function () {
|
||||
var i, len;
|
||||
|
||||
this.clearItems();
|
||||
for ( i = 0, len = this.items.length; i < len; i++ ) {
|
||||
this.items[i].destroy();
|
||||
}
|
||||
this.clearItems();
|
||||
this.$.remove();
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if tool has not been used yet.
|
||||
*
|
||||
* @param {string} name Symbolic name of tool
|
||||
* @return {boolean} Tool is available
|
||||
*/
|
||||
OO.ui.Toolbar.prototype.isToolAvailable = function ( name ) {
|
||||
return !this.tools[name];
|
||||
};
|
||||
|
||||
OO.ui.Toolbar.prototype.reserveTool = function ( name ) {
|
||||
this.tools[name] = true;
|
||||
/**
|
||||
* Prevent tool from being used again.
|
||||
*
|
||||
* @param {OO.ui.Tool} tool Tool to reserve
|
||||
*/
|
||||
OO.ui.Toolbar.prototype.reserveTool = function ( tool ) {
|
||||
this.tools[tool.getName()] = tool;
|
||||
};
|
||||
|
||||
OO.ui.Toolbar.prototype.releaseTool = function ( name ) {
|
||||
delete this.tools[name];
|
||||
/**
|
||||
* Allow tool to be used again.
|
||||
*
|
||||
* @param {OO.ui.Tool} tool Tool to release
|
||||
*/
|
||||
OO.ui.Toolbar.prototype.releaseTool = function ( tool ) {
|
||||
delete this.tools[tool.getName()];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get accelerator label for tool.
|
||||
*
|
||||
* This is a stub that should be overridden to provide access to accelerator information.
|
||||
*
|
||||
* @param {string} name Symbolic name of tool
|
||||
* @returns {string|undefined} Tool accelerator label if available
|
||||
*/
|
||||
OO.ui.Toolbar.prototype.getToolAccelerator = function () {
|
||||
return undefined;
|
||||
};
|
||||
|
|
|
@ -61,15 +61,6 @@ OO.ui.LabeledElement.prototype.setLabel = function ( value ) {
|
|||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get label value as plain text.
|
||||
*
|
||||
* @return {string} Label text
|
||||
*/
|
||||
OO.ui.LabeledElement.prototype.getLabelText = function () {
|
||||
return this.$label.text();
|
||||
};
|
||||
|
||||
/**
|
||||
* Fit the label.
|
||||
*
|
||||
|
|
|
@ -107,6 +107,11 @@
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
.oo-ui-barToolGroup .oo-ui-tool-title,
|
||||
.oo-ui-barToolGroup .oo-ui-tool-accel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* OO.ui.PopupToolGroup */
|
||||
|
||||
.oo-ui-popupToolGroup {
|
||||
|
@ -181,6 +186,10 @@
|
|||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.oo-ui-popupToolGroup .oo-ui-tool-accel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* OO.ui.ListToolGroup */
|
||||
|
||||
.oo-ui-listToolGroup .oo-ui-toolGroup-tools {
|
||||
|
|
|
@ -30,6 +30,6 @@ OO.inheritClass( OO.ui.BarToolGroup, OO.ui.ToolGroup );
|
|||
|
||||
/* Static Properties */
|
||||
|
||||
OO.ui.BarToolGroup.static.showTitle = true;
|
||||
OO.ui.BarToolGroup.static.labelTooltips = true;
|
||||
|
||||
OO.ui.BarToolGroup.static.showTrigger = true;
|
||||
OO.ui.BarToolGroup.static.accelTooltips = true;
|
||||
|
|
|
@ -30,4 +30,4 @@ OO.inheritClass( OO.ui.ListToolGroup, OO.ui.PopupToolGroup );
|
|||
|
||||
/* Static Properties */
|
||||
|
||||
OO.ui.ListToolGroup.static.showTrigger = true;
|
||||
OO.ui.ListToolGroup.static.accelTooltips = true;
|
||||
|
|
|
@ -33,7 +33,7 @@ OO.inheritClass( OO.ui.MenuToolGroup, OO.ui.PopupToolGroup );
|
|||
|
||||
/* Static Properties */
|
||||
|
||||
OO.ui.MenuToolGroup.static.showTrigger = true;
|
||||
OO.ui.MenuToolGroup.static.accelTooltips = true;
|
||||
|
||||
/* Methods */
|
||||
|
||||
|
@ -51,7 +51,7 @@ OO.ui.MenuToolGroup.prototype.onUpdateState = function () {
|
|||
|
||||
for ( name in this.tools ) {
|
||||
if ( this.tools[name].isActive() ) {
|
||||
labelTexts.push( this.tools[name].getLabelText() );
|
||||
labelTexts.push( this.tools[name].$label.find( '.oo-ui-tool-title' ).text() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
* @class
|
||||
* @extends ve.ui.DialogTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Config options
|
||||
*/
|
||||
ve.ui.MWSyntaxHighlightTool = function VeUiMWSyntaxHighlightTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightTool = function VeUiMWSyntaxHighlightTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -44,9 +44,9 @@ ve.ui.syntaxHighlightEditorToolFactory = new OO.ui.ToolFactory();
|
|||
|
||||
/* SyntaxHighlight Editor Tools */
|
||||
|
||||
ve.ui.MWSyntaxHighlightEditorTool = function VeUiMWSyntaxHighlightEditorTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool = function VeUiMWSyntaxHighlightEditorTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWSyntaxHighlightEditorTool, OO.ui.Tool );
|
||||
|
||||
|
@ -63,8 +63,8 @@ ve.ui.MWSyntaxHighlightEditorTool.prototype.onUpdateState = function () {
|
|||
}
|
||||
};
|
||||
|
||||
ve.ui.MWSynHiUndoTool = function VeUiMWSynhiUndoTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolbar, config );
|
||||
ve.ui.MWSynHiUndoTool = function VeUiMWSynhiUndoTool( toolGroup, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWSynHiUndoTool, ve.ui.MWSyntaxHighlightEditorTool );
|
||||
ve.ui.MWSynHiUndoTool.static.name = 'synhiUndo';
|
||||
|
@ -75,8 +75,8 @@ ve.ui.MWSynHiUndoTool.static.titleMessage = 'visualeditor-historybutton-undo-too
|
|||
ve.ui.MWSynHiUndoTool.static.autoAdd = false;
|
||||
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiUndoTool );
|
||||
|
||||
ve.ui.MWSynHiRedoTool = function VeUiMWSynHiRedoTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolbar, config );
|
||||
ve.ui.MWSynHiRedoTool = function VeUiMWSynHiRedoTool( toolGroup, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWSynHiRedoTool, ve.ui.MWSyntaxHighlightEditorTool );
|
||||
ve.ui.MWSynHiRedoTool.static.name = 'synhiRedo';
|
||||
|
@ -87,8 +87,8 @@ ve.ui.MWSynHiRedoTool.static.titleMessage = 'visualeditor-historybutton-redo-too
|
|||
ve.ui.MWSynHiRedoTool.static.autoAdd = false;
|
||||
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiRedoTool );
|
||||
|
||||
ve.ui.MWSynHiIndentTool = function VeUiMWSynHiIndentTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolbar, config );
|
||||
ve.ui.MWSynHiIndentTool = function VeUiMWSynHiIndentTool( toolGroup, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWSynHiIndentTool, ve.ui.MWSyntaxHighlightEditorTool );
|
||||
ve.ui.MWSynHiIndentTool.static.name = 'synhiIndent';
|
||||
|
@ -99,8 +99,8 @@ ve.ui.MWSynHiIndentTool.static.titleMessage = '';
|
|||
ve.ui.MWSynHiIndentTool.static.autoAdd = false;
|
||||
ve.ui.syntaxHighlightEditorToolFactory.register( ve.ui.MWSynHiIndentTool );
|
||||
|
||||
ve.ui.MWSynHiBeautifyTool = function VeUiMWSynHiBeautifyTool( toolbar, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolbar, config );
|
||||
ve.ui.MWSynHiBeautifyTool = function VeUiMWSynHiBeautifyTool( toolGroup, config ) {
|
||||
ve.ui.MWSyntaxHighlightEditorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWSynHiBeautifyTool, ve.ui.MWSyntaxHighlightEditorTool );
|
||||
ve.ui.MWSynHiBeautifyTool.static.name = 'synhiBeautify';
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* @class
|
||||
* @extends ve.ui.InspectorTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWAlienExtensionInspectorTool = function VeUiMWAlienExtensionInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolbar, config );
|
||||
ve.ui.MWAlienExtensionInspectorTool = function VeUiMWAlienExtensionInspectorTool( toolGroup, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWAlienExtensionInspectorTool, ve.ui.InspectorTool );
|
||||
ve.ui.MWAlienExtensionInspectorTool.static.name = 'alienExtension';
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* @class
|
||||
* @extends ve.ui.DialogTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWMediaEditDialogTool = function VeUiMWMediaEditDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.MWMediaEditDialogTool = function VeUiMWMediaEditDialogTool( toolGroup, config ) {
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWMediaEditDialogTool, ve.ui.DialogTool );
|
||||
ve.ui.MWMediaEditDialogTool.static.name = 'mediaEdit';
|
||||
|
@ -34,11 +34,11 @@ ve.ui.toolFactory.register( ve.ui.MWMediaEditDialogTool );
|
|||
* @extends ve.ui.DialogTool
|
||||
*
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWMediaInsertDialogTool = function VeUiMWMediaInsertDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.MWMediaInsertDialogTool = function VeUiMWMediaInsertDialogTool( toolGroup, config ) {
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWMediaInsertDialogTool, ve.ui.DialogTool );
|
||||
ve.ui.MWMediaInsertDialogTool.static.name = 'mediaInsert';
|
||||
|
@ -55,11 +55,11 @@ ve.ui.toolFactory.register( ve.ui.MWMediaInsertDialogTool );
|
|||
* @extends ve.ui.DialogTool
|
||||
*
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWReferenceDialogTool = function VeUiMWReferenceDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.MWReferenceDialogTool = function VeUiMWReferenceDialogTool( toolGroup, config ) {
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWReferenceDialogTool, ve.ui.DialogTool );
|
||||
ve.ui.MWReferenceDialogTool.static.name = 'reference';
|
||||
|
@ -76,11 +76,11 @@ ve.ui.toolFactory.register( ve.ui.MWReferenceDialogTool );
|
|||
* @class
|
||||
* @extends ve.ui.DialogTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWReferenceListDialogTool = function VeUiMWReferenceListDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.MWReferenceListDialogTool = function VeUiMWReferenceListDialogTool( toolGroup, config ) {
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWReferenceListDialogTool, ve.ui.DialogTool );
|
||||
ve.ui.MWReferenceListDialogTool.static.name = 'referenceList';
|
||||
|
@ -98,11 +98,11 @@ ve.ui.toolFactory.register( ve.ui.MWReferenceListDialogTool );
|
|||
* @class
|
||||
* @extends ve.ui.DialogTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWTransclusionDialogTool = function VeUiMWTransclusionDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool.call( this, toolbar, config );
|
||||
ve.ui.MWTransclusionDialogTool = function VeUiMWTransclusionDialogTool( toolGroup, config ) {
|
||||
ve.ui.DialogTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWTransclusionDialogTool, ve.ui.DialogTool );
|
||||
ve.ui.MWTransclusionDialogTool.static.name = 'transclusion';
|
||||
|
|
|
@ -11,17 +11,17 @@
|
|||
* @class
|
||||
* @extends ve.ui.Heading1FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading1FormatTool = function VeUiMWHeading1FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading1FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading1FormatTool = function VeUiMWHeading1FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading1FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading1FormatTool, ve.ui.Heading1FormatTool );
|
||||
ve.ui.MWHeading1FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading1';
|
||||
ve.ui.MWHeading1FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 1 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading1FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading1', 'format', 'convert', 'mwHeading', { 'level': 1 } );
|
||||
ve.ui.commandRegistry.register( 'heading1', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 1 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface heading 2 tool.
|
||||
|
@ -29,17 +29,17 @@ ve.ui.commandRegistry.register( 'heading1', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.Heading2FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading2FormatTool = function VeUiMWHeading2FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading2FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading2FormatTool = function VeUiMWHeading2FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading2FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading2FormatTool, ve.ui.Heading2FormatTool );
|
||||
ve.ui.MWHeading2FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading2';
|
||||
ve.ui.MWHeading2FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 2 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading2FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading2', 'format', 'convert', 'mwHeading', { 'level': 2 } );
|
||||
ve.ui.commandRegistry.register( 'heading2', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 2 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface heading 3 tool.
|
||||
|
@ -47,17 +47,17 @@ ve.ui.commandRegistry.register( 'heading2', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.Heading3FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading3FormatTool = function VeUiMWHeading3FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading3FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading3FormatTool = function VeUiMWHeading3FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading3FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading3FormatTool, ve.ui.Heading3FormatTool );
|
||||
ve.ui.MWHeading3FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading3';
|
||||
ve.ui.MWHeading3FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 3 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading3FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading3', 'format', 'convert', 'mwHeading', { 'level': 3 } );
|
||||
ve.ui.commandRegistry.register( 'heading3', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 3 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface heading 4 tool.
|
||||
|
@ -65,17 +65,17 @@ ve.ui.commandRegistry.register( 'heading3', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.Heading4FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading4FormatTool = function VeUiMWHeading4FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading4FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading4FormatTool = function VeUiMWHeading4FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading4FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading4FormatTool, ve.ui.Heading4FormatTool );
|
||||
ve.ui.MWHeading4FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading4';
|
||||
ve.ui.MWHeading4FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 4 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading4FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading4', 'format', 'convert', 'mwHeading', { 'level': 4 } );
|
||||
ve.ui.commandRegistry.register( 'heading4', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 4 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface heading 5 tool.
|
||||
|
@ -83,17 +83,17 @@ ve.ui.commandRegistry.register( 'heading4', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.Heading5FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading5FormatTool = function VeUiMWHeading5FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading5FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading5FormatTool = function VeUiMWHeading5FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading5FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading5FormatTool, ve.ui.Heading5FormatTool );
|
||||
ve.ui.MWHeading5FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading5';
|
||||
ve.ui.MWHeading5FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 5 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading5FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading5', 'format', 'convert', 'mwHeading', { 'level': 5 } );
|
||||
ve.ui.commandRegistry.register( 'heading5', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 5 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface heading 6 tool.
|
||||
|
@ -101,17 +101,17 @@ ve.ui.commandRegistry.register( 'heading5', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.Heading6FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHeading6FormatTool = function VeUiMWHeading6FormatTool( toolbar, config ) {
|
||||
ve.ui.Heading6FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWHeading6FormatTool = function VeUiMWHeading6FormatTool( toolGroup, config ) {
|
||||
ve.ui.Heading6FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHeading6FormatTool, ve.ui.Heading6FormatTool );
|
||||
ve.ui.MWHeading6FormatTool.static.titleMessage = 'visualeditor-formatdropdown-format-mw-heading6';
|
||||
ve.ui.MWHeading6FormatTool.static.format = { 'type' : 'mwHeading', 'attributes': { 'level': 6 } };
|
||||
ve.ui.toolFactory.register( ve.ui.MWHeading6FormatTool );
|
||||
ve.ui.commandRegistry.register( 'heading6', 'format', 'convert', 'mwHeading', { 'level': 6 } );
|
||||
ve.ui.commandRegistry.register( 'heading6', new ve.ui.Command( 'format', 'convert', 'mwHeading', { 'level': 6 } ) );
|
||||
|
||||
/**
|
||||
* MediaWiki UserInterface preformatted tool.
|
||||
|
@ -119,13 +119,13 @@ ve.ui.commandRegistry.register( 'heading6', 'format', 'convert', 'mwHeading', {
|
|||
* @class
|
||||
* @extends ve.ui.PreformattedFormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWPreformattedFormatTool = function VeUiMWPreformattedFormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.MWPreformattedFormatTool = function VeUiMWPreformattedFormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWPreformattedFormatTool, ve.ui.PreformattedFormatTool );
|
||||
ve.ui.MWPreformattedFormatTool.static.format = { 'type' : 'mwPreformatted' };
|
||||
ve.ui.toolFactory.register( ve.ui.MWPreformattedFormatTool );
|
||||
ve.ui.commandRegistry.register( 'preformatted', 'format', 'convert', 'mwPreformatted' );
|
||||
ve.ui.commandRegistry.register( 'preformatted', new ve.ui.Command( 'format', 'convert', 'mwPreformatted' ) );
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* @class
|
||||
* @extends ve.ui.InspectorTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWHieroInspectorTool = function VeUiMWHieroInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolbar, config );
|
||||
ve.ui.MWHieroInspectorTool = function VeUiMWHieroInspectorTool( toolGroup, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWHieroInspectorTool, ve.ui.InspectorTool );
|
||||
ve.ui.MWHieroInspectorTool.static.name = 'hiero';
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* @class
|
||||
* @extends ve.ui.InspectorTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWMathInspectorTool = function VeUiMWMathInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolbar, config );
|
||||
ve.ui.MWMathInspectorTool = function VeUiMWMathInspectorTool( toolGroup, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.MWMathInspectorTool, ve.ui.InspectorTool );
|
||||
ve.ui.MWMathInspectorTool.static.name = 'math';
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
* @extends OO.ui.Tool
|
||||
*
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.AnnotationTool = function VeUiAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool = function VeUiAnnotationTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -68,11 +68,11 @@ ve.ui.AnnotationTool.prototype.onUpdateState = function ( nodes, full ) {
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.BoldAnnotationTool = function VeUiBoldAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.BoldAnnotationTool = function VeUiBoldAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.BoldAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.BoldAnnotationTool.static.name = 'bold';
|
||||
|
@ -113,11 +113,11 @@ ve.ui.toolFactory.register( ve.ui.BoldAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.ItalicAnnotationTool = function VeUiItalicAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.ItalicAnnotationTool = function VeUiItalicAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.ItalicAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.ItalicAnnotationTool.static.name = 'italic';
|
||||
|
@ -158,11 +158,11 @@ ve.ui.toolFactory.register( ve.ui.ItalicAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.CodeAnnotationTool = function VeUiCodeAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.CodeAnnotationTool = function VeUiCodeAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.CodeAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.CodeAnnotationTool.static.name = 'code';
|
||||
|
@ -178,11 +178,11 @@ ve.ui.toolFactory.register( ve.ui.CodeAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.StrikethroughAnnotationTool = function VeUiStrikethroughAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.StrikethroughAnnotationTool = function VeUiStrikethroughAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.StrikethroughAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.StrikethroughAnnotationTool.static.name = 'strikethrough';
|
||||
|
@ -202,11 +202,11 @@ ve.ui.toolFactory.register( ve.ui.StrikethroughAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.UnderlineAnnotationTool = function VeUiUnderlineAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.UnderlineAnnotationTool = function VeUiUnderlineAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.UnderlineAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.UnderlineAnnotationTool.static.name = 'underline';
|
||||
|
@ -226,11 +226,11 @@ ve.ui.toolFactory.register( ve.ui.UnderlineAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.SubscriptAnnotationTool = function VeUiSubscriptAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.SubscriptAnnotationTool = function VeUiSubscriptAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.SubscriptAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.SubscriptAnnotationTool.static.name = 'subscript';
|
||||
|
@ -247,11 +247,11 @@ ve.ui.toolFactory.register( ve.ui.SubscriptAnnotationTool );
|
|||
* @class
|
||||
* @extends ve.ui.AnnotationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.SuperscriptAnnotationTool = function VeUiSuperscriptAnnotationTool( toolbar, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolbar, config );
|
||||
ve.ui.SuperscriptAnnotationTool = function VeUiSuperscriptAnnotationTool( toolGroup, config ) {
|
||||
ve.ui.AnnotationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.SuperscriptAnnotationTool, ve.ui.AnnotationTool );
|
||||
ve.ui.SuperscriptAnnotationTool.static.name = 'superscript';
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.ClearAnnotationTool = function VeUiClearAnnotationTool( toolbar, config ) {
|
||||
ve.ui.ClearAnnotationTool = function VeUiClearAnnotationTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
|
||||
// Initialization
|
||||
this.setDisabled( true );
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.DialogTool = function VeUiDialogTool( toolbar, config ) {
|
||||
ve.ui.DialogTool = function VeUiDialogTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.FormatTool = function VeUiFormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool = function VeUiFormatTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
|
||||
// Properties
|
||||
this.convertible = false;
|
||||
|
@ -83,11 +83,11 @@ ve.ui.FormatTool.prototype.onUpdateState = function ( nodes ) {
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.ParagraphFormatTool = function VeUiParagraphFormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.ParagraphFormatTool = function VeUiParagraphFormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.ParagraphFormatTool, ve.ui.FormatTool );
|
||||
ve.ui.ParagraphFormatTool.static.name = 'paragraph';
|
||||
|
@ -102,11 +102,11 @@ ve.ui.toolFactory.register( ve.ui.ParagraphFormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading1FormatTool = function VeUiHeading1FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading1FormatTool = function VeUiHeading1FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading1FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading1FormatTool.static.name = 'heading1';
|
||||
|
@ -121,11 +121,11 @@ ve.ui.toolFactory.register( ve.ui.Heading1FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading2FormatTool = function VeUiHeading2FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading2FormatTool = function VeUiHeading2FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading2FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading2FormatTool.static.name = 'heading2';
|
||||
|
@ -140,11 +140,11 @@ ve.ui.toolFactory.register( ve.ui.Heading2FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading3FormatTool = function VeUiHeading3FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading3FormatTool = function VeUiHeading3FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading3FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading3FormatTool.static.name = 'heading3';
|
||||
|
@ -159,11 +159,11 @@ ve.ui.toolFactory.register( ve.ui.Heading3FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading4FormatTool = function VeUiHeading4FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading4FormatTool = function VeUiHeading4FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading4FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading4FormatTool.static.name = 'heading4';
|
||||
|
@ -178,11 +178,11 @@ ve.ui.toolFactory.register( ve.ui.Heading4FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading5FormatTool = function VeUiHeading5FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading5FormatTool = function VeUiHeading5FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading5FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading5FormatTool.static.name = 'heading5';
|
||||
|
@ -197,11 +197,11 @@ ve.ui.toolFactory.register( ve.ui.Heading5FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.Heading6FormatTool = function VeUiHeading6FormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.Heading6FormatTool = function VeUiHeading6FormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.Heading6FormatTool, ve.ui.FormatTool );
|
||||
ve.ui.Heading6FormatTool.static.name = 'heading6';
|
||||
|
@ -216,11 +216,11 @@ ve.ui.toolFactory.register( ve.ui.Heading6FormatTool );
|
|||
* @class
|
||||
* @extends ve.ui.FormatTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.PreformattedFormatTool = function VeUiPreformattedFormatTool( toolbar, config ) {
|
||||
ve.ui.FormatTool.call( this, toolbar, config );
|
||||
ve.ui.PreformattedFormatTool = function VeUiPreformattedFormatTool( toolGroup, config ) {
|
||||
ve.ui.FormatTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.PreformattedFormatTool, ve.ui.FormatTool );
|
||||
ve.ui.PreformattedFormatTool.static.name = 'preformatted';
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.HistoryTool = function VeUiHistoryTool( toolbar, config ) {
|
||||
ve.ui.HistoryTool = function VeUiHistoryTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
|
||||
// Events
|
||||
this.toolbar.getSurface().getModel().connect( this, { 'history': 'onUpdateState' } );
|
||||
|
@ -89,11 +89,11 @@ ve.ui.HistoryTool.prototype.destroy = function () {
|
|||
* @class
|
||||
* @extends ve.ui.HistoryTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.UndoHistoryTool = function VeUiUndoHistoryTool( toolbar, config ) {
|
||||
ve.ui.HistoryTool.call( this, toolbar, config );
|
||||
ve.ui.UndoHistoryTool = function VeUiUndoHistoryTool( toolGroup, config ) {
|
||||
ve.ui.HistoryTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.UndoHistoryTool, ve.ui.HistoryTool );
|
||||
ve.ui.UndoHistoryTool.static.name = 'undo';
|
||||
|
@ -110,11 +110,11 @@ ve.ui.toolFactory.register( ve.ui.UndoHistoryTool );
|
|||
* @class
|
||||
* @extends ve.ui.HistoryTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.RedoHistoryTool = function VeUiRedoHistoryTool( toolbar, config ) {
|
||||
ve.ui.HistoryTool.call( this, toolbar, config );
|
||||
ve.ui.RedoHistoryTool = function VeUiRedoHistoryTool( toolGroup, config ) {
|
||||
ve.ui.HistoryTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.RedoHistoryTool, ve.ui.HistoryTool );
|
||||
ve.ui.RedoHistoryTool.static.name = 'redo';
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.IndentationTool = function VeUiIndentationTool( toolbar, config ) {
|
||||
ve.ui.IndentationTool = function VeUiIndentationTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -73,11 +73,11 @@ ve.ui.IndentationTool.prototype.onUpdateState = function ( nodes ) {
|
|||
* @class
|
||||
* @extends ve.ui.IndentationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.IncreaseIndentationTool = function VeUiIncreaseIndentationTool( toolbar, config ) {
|
||||
ve.ui.IndentationTool.call( this, toolbar, config );
|
||||
ve.ui.IncreaseIndentationTool = function VeUiIncreaseIndentationTool( toolGroup, config ) {
|
||||
ve.ui.IndentationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.IncreaseIndentationTool, ve.ui.IndentationTool );
|
||||
ve.ui.IncreaseIndentationTool.static.name = 'indent';
|
||||
|
@ -95,11 +95,11 @@ ve.ui.toolFactory.register( ve.ui.IncreaseIndentationTool );
|
|||
* @class
|
||||
* @extends ve.ui.IndentationTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.DecreaseIndentationTool = function VeUiDecreaseIndentationTool( toolbar, config ) {
|
||||
ve.ui.IndentationTool.call( this, toolbar, config );
|
||||
ve.ui.DecreaseIndentationTool = function VeUiDecreaseIndentationTool( toolGroup, config ) {
|
||||
ve.ui.IndentationTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.DecreaseIndentationTool, ve.ui.IndentationTool );
|
||||
ve.ui.DecreaseIndentationTool.static.name = 'outdent';
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.InspectorTool = function VeUiInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool = function VeUiInspectorTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -85,11 +85,11 @@ ve.ui.InspectorTool.prototype.onUpdateState = function ( nodes, full ) {
|
|||
* @class
|
||||
* @extends ve.ui.InspectorTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.LinkInspectorTool = function VeUiLinkInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolbar, config );
|
||||
ve.ui.LinkInspectorTool = function VeUiLinkInspectorTool( toolGroup, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.LinkInspectorTool, ve.ui.InspectorTool );
|
||||
ve.ui.LinkInspectorTool.static.name = 'link';
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* @class
|
||||
* @extends ve.ui.InspectorTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.LanguageInspectorTool = function VeUiLanguageInspectorTool( toolbar, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolbar, config );
|
||||
ve.ui.LanguageInspectorTool = function VeUiLanguageInspectorTool( toolGroup, config ) {
|
||||
ve.ui.InspectorTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.LanguageInspectorTool, ve.ui.InspectorTool );
|
||||
ve.ui.LanguageInspectorTool.static.name = 'language';
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
* @class
|
||||
* @extends OO.ui.Tool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.ListTool = function VeUiListTool( toolbar, config ) {
|
||||
ve.ui.ListTool = function VeUiListTool( toolGroup, config ) {
|
||||
// Parent constructor
|
||||
OO.ui.Tool.call( this, toolbar, config );
|
||||
OO.ui.Tool.call( this, toolGroup, config );
|
||||
|
||||
// Properties
|
||||
this.method = null;
|
||||
|
@ -81,11 +81,11 @@ ve.ui.ListTool.prototype.onUpdateState = function ( nodes ) {
|
|||
* @class
|
||||
* @extends ve.ui.ListTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.BulletListTool = function VeUiBulletListTool( toolbar, config ) {
|
||||
ve.ui.ListTool.call( this, toolbar, config );
|
||||
ve.ui.BulletListTool = function VeUiBulletListTool( toolGroup, config ) {
|
||||
ve.ui.ListTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.BulletListTool, ve.ui.ListTool );
|
||||
ve.ui.BulletListTool.static.name = 'bullet';
|
||||
|
@ -101,11 +101,11 @@ ve.ui.toolFactory.register( ve.ui.BulletListTool );
|
|||
* @class
|
||||
* @extends ve.ui.ListTool
|
||||
* @constructor
|
||||
* @param {ve.ui.SurfaceToolbar} toolbar
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.NumberListTool = function VeUiNumberListTool( toolbar, config ) {
|
||||
ve.ui.ListTool.call( this, toolbar, config );
|
||||
ve.ui.NumberListTool = function VeUiNumberListTool( toolGroup, config ) {
|
||||
ve.ui.ListTool.call( this, toolGroup, config );
|
||||
};
|
||||
OO.inheritClass( ve.ui.NumberListTool, ve.ui.ListTool );
|
||||
ve.ui.NumberListTool.static.name = 'number';
|
||||
|
|
69
modules/ve/ui/ve.ui.Command.js
Normal file
69
modules/ve/ui/ve.ui.Command.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*!
|
||||
* VisualEditor UserInterface Command class.
|
||||
*
|
||||
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Command that executes an action.
|
||||
*
|
||||
* @class
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} action Action to execute when command is triggered
|
||||
* @param {string} method Method to call on action when executing
|
||||
* @param {Mixed...} [data] Additional data to pass to the action when executing
|
||||
* @throws {Error} Action must be a string
|
||||
* @throws {Error} Method must be a string
|
||||
*/
|
||||
ve.ui.Command = function VeUiCommand( action, method ) {
|
||||
if ( typeof action !== 'string' ) {
|
||||
throw new Error( 'action must be a string, cannot be a ' + typeof action );
|
||||
}
|
||||
if ( typeof method !== 'string' ) {
|
||||
throw new Error( 'method must be a string, cannot be a ' + typeof method );
|
||||
}
|
||||
this.action = action;
|
||||
this.method = method;
|
||||
this.data = Array.prototype.slice.call( arguments, 2 );
|
||||
};
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Execute command on a surface.
|
||||
*
|
||||
* @param {ve.ui.Surface} surface Surface to execute command on
|
||||
* @returns {Mixed} Result of command execution.
|
||||
*/
|
||||
ve.ui.Command.prototype.execute = function ( surface ) {
|
||||
return surface.execute.apply( surface, [ this.action, this.method ].concat( this.data ) );
|
||||
};
|
||||
|
||||
/**
|
||||
* Get command action.
|
||||
*
|
||||
* @returns {string} action Action to execute when command is triggered
|
||||
*/
|
||||
ve.ui.Command.prototype.getAction = function () {
|
||||
return this.action;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get command method.
|
||||
*
|
||||
* @returns {string} method Method to call on action when executing
|
||||
*/
|
||||
ve.ui.Command.prototype.getMethod = function () {
|
||||
return this.method;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get command data.
|
||||
*
|
||||
* @returns {Array} data Additional data to pass to the action when executing
|
||||
*/
|
||||
ve.ui.Command.prototype.getData = function () {
|
||||
return this.data;
|
||||
};
|
|
@ -28,25 +28,18 @@ OO.inheritClass( ve.ui.CommandRegistry, OO.Registry );
|
|||
*
|
||||
* @method
|
||||
* @param {string|string[]} name Symbolic name or list of symbolic names
|
||||
* @param {string} action Action to execute when command is triggered
|
||||
* @param {string} method Method to call on action when executing
|
||||
* @param {Mixed...} [data] Additional data to pass to the action when executing
|
||||
* @throws {Error} Action must be a string
|
||||
* @throws {Error} Method must be a string
|
||||
* @param {ve.ui.Command} command Command object
|
||||
* @throws {Error} If command is not an instance of ve.ui.Command
|
||||
*/
|
||||
ve.ui.CommandRegistry.prototype.register = function ( name, action, method ) {
|
||||
if ( typeof name !== 'string' && !ve.isArray( name ) ) {
|
||||
throw new Error( 'name must be a string or array, cannot be a ' + typeof name );
|
||||
ve.ui.CommandRegistry.prototype.register = function ( name, command ) {
|
||||
// Validate arguments
|
||||
if ( !( command instanceof ve.ui.Command ) ) {
|
||||
throw new Error(
|
||||
'command must be an instance of ve.ui.Command, cannot be a ' + typeof command
|
||||
);
|
||||
}
|
||||
if ( typeof action !== 'string' ) {
|
||||
throw new Error( 'action must be a string, cannot be a ' + typeof action );
|
||||
}
|
||||
if ( typeof method !== 'string' ) {
|
||||
throw new Error( 'method must be a string, cannot be a ' + typeof method );
|
||||
}
|
||||
OO.Registry.prototype.register.call(
|
||||
this, name, { 'action': Array.prototype.slice.call( arguments, 1 ) }
|
||||
);
|
||||
|
||||
OO.Registry.prototype.register.call( this, name, command );
|
||||
};
|
||||
|
||||
/* Initialization */
|
||||
|
@ -55,25 +48,69 @@ ve.ui.commandRegistry = new ve.ui.CommandRegistry();
|
|||
|
||||
/* Registrations */
|
||||
|
||||
ve.ui.commandRegistry.register( 'bold', 'annotation', 'toggle', 'textStyle/bold' );
|
||||
ve.ui.commandRegistry.register( 'italic', 'annotation', 'toggle', 'textStyle/italic' );
|
||||
ve.ui.commandRegistry.register( 'code', 'annotation', 'toggle', 'textStyle/code' );
|
||||
ve.ui.commandRegistry.register( 'strikethrough', 'annotation', 'toggle', 'textStyle/strike' );
|
||||
ve.ui.commandRegistry.register( 'underline', 'annotation', 'toggle', 'textStyle/underline' );
|
||||
ve.ui.commandRegistry.register( 'subscript', 'annotation', 'toggle', 'textStyle/subscript' );
|
||||
ve.ui.commandRegistry.register( 'superscript', 'annotation', 'toggle', 'textStyle/superscript' );
|
||||
ve.ui.commandRegistry.register( 'clear', 'annotation', 'clearAll' );
|
||||
ve.ui.commandRegistry.register( 'indent', 'indentation', 'increase' );
|
||||
ve.ui.commandRegistry.register( 'outdent', 'indentation', 'decrease' );
|
||||
ve.ui.commandRegistry.register( 'link', 'inspector', 'open', 'link' );
|
||||
ve.ui.commandRegistry.register( 'language', 'inspector', 'open', 'language' );
|
||||
ve.ui.commandRegistry.register( 'redo', 'history', 'redo' );
|
||||
ve.ui.commandRegistry.register( 'undo', 'history', 'undo' );
|
||||
ve.ui.commandRegistry.register( 'paragraph', 'format', 'convert', 'paragraph' );
|
||||
ve.ui.commandRegistry.register( 'heading1', 'format', 'convert', 'heading', { 'level': 1 } );
|
||||
ve.ui.commandRegistry.register( 'heading2', 'format', 'convert', 'heading', { 'level': 2 } );
|
||||
ve.ui.commandRegistry.register( 'heading3', 'format', 'convert', 'heading', { 'level': 3 } );
|
||||
ve.ui.commandRegistry.register( 'heading4', 'format', 'convert', 'heading', { 'level': 4 } );
|
||||
ve.ui.commandRegistry.register( 'heading5', 'format', 'convert', 'heading', { 'level': 5 } );
|
||||
ve.ui.commandRegistry.register( 'heading6', 'format', 'convert', 'heading', { 'level': 6 } );
|
||||
ve.ui.commandRegistry.register( 'preformatted', 'format', 'convert', 'preformatted' );
|
||||
ve.ui.commandRegistry.register(
|
||||
'bold', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/bold' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'italic', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/italic' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'code', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/code' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'strikethrough', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/strike' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'underline', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/underline' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'subscript', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/subscript' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'superscript', new ve.ui.Command( 'annotation', 'toggle', 'textStyle/superscript' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'clear', new ve.ui.Command( 'annotation', 'clearAll' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'indent', new ve.ui.Command( 'indentation', 'increase' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'outdent', new ve.ui.Command( 'indentation', 'decrease' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'link', new ve.ui.Command( 'inspector', 'open', 'link' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'language', new ve.ui.Command( 'inspector', 'open', 'language' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'redo', new ve.ui.Command( 'history', 'redo' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'undo', new ve.ui.Command( 'history', 'undo' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'paragraph', new ve.ui.Command( 'format', 'convert', 'paragraph' )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading1', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 1 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading2', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 2 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading3', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 3 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading4', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 4 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading5', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 5 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'heading6', new ve.ui.Command( 'format', 'convert', 'heading', { 'level': 6 } )
|
||||
);
|
||||
ve.ui.commandRegistry.register(
|
||||
'preformatted', new ve.ui.Command( 'format', 'convert', 'preformatted' )
|
||||
);
|
||||
|
|
|
@ -35,6 +35,7 @@ ve.ui.Surface = function VeUiSurface( dataOrDoc, config ) {
|
|||
this.context = new ve.ui.Context( this, { '$$': this.$$ } );
|
||||
this.dialogs = new ve.ui.SurfaceWindowSet( this, ve.ui.dialogFactory, { '$$': this.$$ } );
|
||||
this.commands = {};
|
||||
this.triggers = {};
|
||||
this.enabled = true;
|
||||
|
||||
// Initialization
|
||||
|
@ -71,9 +72,22 @@ OO.mixinClass( ve.ui.Surface, OO.EventEmitter );
|
|||
* @event position
|
||||
*/
|
||||
|
||||
/**
|
||||
* When a command is added to the surface.
|
||||
*
|
||||
* @event addCommand
|
||||
* @param {string} name Symbolic name of command and trigger
|
||||
* @param {ve.ui.Command} command Command that's been registered
|
||||
* @param {ve.ui.Trigger} trigger Trigger to associate with command
|
||||
*/
|
||||
|
||||
/* Methods */
|
||||
|
||||
/** */
|
||||
/**
|
||||
* Initialize surface.
|
||||
*
|
||||
* This must be called after the surface has been attached to the DOM.
|
||||
*/
|
||||
ve.ui.Surface.prototype.initialize = function () {
|
||||
this.view.$.after( this.$localOverlay );
|
||||
$( 'body' ).append( this.$globalOverlay );
|
||||
|
@ -137,15 +151,25 @@ ve.ui.Surface.prototype.getDialogs = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Get the context menu.
|
||||
* Get list of commands keyed by trigger string.
|
||||
*
|
||||
* @method
|
||||
* @returns {ve.ui.Context} Context user interface
|
||||
* @returns {Object.<string,ve.ui.Command>} Commands
|
||||
*/
|
||||
ve.ui.Surface.prototype.getCommands = function () {
|
||||
return this.commands;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get list of triggers keyed by symbolic name.
|
||||
*
|
||||
* @method
|
||||
* @returns {Object.<string,ve.ui.Trigger>} Triggers
|
||||
*/
|
||||
ve.ui.Surface.prototype.getTriggers = function () {
|
||||
return this.triggers;
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the surface, releasing all memory and removing all DOM elements.
|
||||
*
|
||||
|
@ -199,9 +223,11 @@ ve.ui.Surface.prototype.execute = function ( action, method ) {
|
|||
}
|
||||
|
||||
if ( action instanceof ve.ui.Trigger ) {
|
||||
// Lookup command by trigger
|
||||
trigger = action.toString();
|
||||
if ( trigger in this.commands ) {
|
||||
return this.execute.apply( this, this.commands[trigger] );
|
||||
// Have command call execute with action arguments
|
||||
return this.commands[trigger].execute( this );
|
||||
}
|
||||
} else if ( typeof action === 'string' && typeof method === 'string' ) {
|
||||
// Validate method
|
||||
|
@ -218,39 +244,35 @@ ve.ui.Surface.prototype.execute = function ( action, method ) {
|
|||
/**
|
||||
* Add all commands from initialization options.
|
||||
*
|
||||
* @method
|
||||
* @param {string[]|Object[]} commands List of symbolic names of commands in the command registry
|
||||
*/
|
||||
ve.ui.Surface.prototype.addCommands = function ( commands ) {
|
||||
var i, len, command;
|
||||
|
||||
for ( i = 0, len = commands.length; i < len; i++ ) {
|
||||
command = ve.ui.commandRegistry.lookup( commands[i] );
|
||||
if ( !command ) {
|
||||
throw new Error( 'No command registered by that name: ' + commands[i] );
|
||||
}
|
||||
this.addTriggers( [ve.ui.triggerRegistry.lookup( commands[i] )], command );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add triggers to surface.
|
||||
* Commands and triggers must be registered under the same name prior to adding them to the surface.
|
||||
*
|
||||
* @method
|
||||
* @param {ve.ui.Trigger[]} triggers Triggers to associate with command
|
||||
* @param {Object} command Command to trigger
|
||||
* @param {string[]} names List of symbolic names of commands in the command registry
|
||||
* @throws {Error} If command has not been registered
|
||||
* @throws {Error} If trigger has not been registered
|
||||
* @throws {Error} If trigger is not complete
|
||||
*/
|
||||
ve.ui.Surface.prototype.addTriggers = function ( triggers, command ) {
|
||||
var i, len, trigger;
|
||||
ve.ui.Surface.prototype.addCommands = function ( names ) {
|
||||
var i, len, key, command, trigger;
|
||||
|
||||
for ( i = 0, len = triggers.length; i < len; i++ ) {
|
||||
// Normalize
|
||||
trigger = triggers[i].toString();
|
||||
// Validate
|
||||
if ( trigger.length === 0 ) {
|
||||
throw new Error( 'Incomplete trigger: ' + triggers[i] );
|
||||
for ( i = 0, len = names.length; i < len; i++ ) {
|
||||
command = ve.ui.commandRegistry.lookup( names[i] );
|
||||
if ( !command ) {
|
||||
throw new Error( 'No command registered by that name: ' + names[i] );
|
||||
}
|
||||
this.commands[trigger] = command.action;
|
||||
// Normalize trigger key
|
||||
trigger = ve.ui.triggerRegistry.lookup( names[i] );
|
||||
if ( !trigger ) {
|
||||
throw new Error( 'No trigger registered by that name: ' + names[i] );
|
||||
}
|
||||
key = trigger.toString();
|
||||
// Validate trigger
|
||||
if ( key.length === 0 ) {
|
||||
throw new Error( 'Incomplete trigger: ' + trigger );
|
||||
}
|
||||
this.commands[key] = command;
|
||||
this.triggers[names[i]] = trigger;
|
||||
this.emit( 'addCommand', names[i], command, trigger );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ ve.ui.SurfaceToolbar = function VeUiSurfaceToolbar( surface, options ) {
|
|||
|
||||
// Events
|
||||
this.surface.getModel().connect( this, { 'contextChange': 'onContextChange' } );
|
||||
this.surface.connect( this, { 'addCommand': 'onSurfaceAddCommand' } );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -145,15 +146,6 @@ ve.ui.SurfaceToolbar.prototype.onSurfaceViewKeyUp = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the surface which the toolbar controls.
|
||||
*
|
||||
* @returns {ve.ui.Surface} Surface being controlled
|
||||
*/
|
||||
ve.ui.SurfaceToolbar.prototype.getSurface = function () {
|
||||
return this.surface;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle context changes on the surface.
|
||||
*
|
||||
|
@ -173,6 +165,37 @@ ve.ui.SurfaceToolbar.prototype.onContextChange = function () {
|
|||
this.emit( 'updateState', nodes, fragment.getAnnotations(), fragment.getAnnotations( true ) );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle command being added to surface.
|
||||
*
|
||||
* If a matching tool is present, it's label will be updated.
|
||||
*
|
||||
* @param {string} name Symbolic name of command and trigger
|
||||
* @param {ve.ui.Command} command Command that's been registered
|
||||
* @param {ve.ui.Trigger} trigger Trigger to associate with command
|
||||
*/
|
||||
ve.ui.SurfaceToolbar.prototype.onSurfaceAddCommand = function ( name ) {
|
||||
if ( this.tools[name] ) {
|
||||
this.tools[name].updateLabel();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.SurfaceToolbar.prototype.getToolAccelerator = function ( name ) {
|
||||
var trigger = this.surface.getTriggers()[name];
|
||||
return trigger instanceof ve.ui.Trigger ? trigger.getMessage() : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the surface which the toolbar controls.
|
||||
*
|
||||
* @returns {ve.ui.Surface} Surface being controlled
|
||||
*/
|
||||
ve.ui.SurfaceToolbar.prototype.getSurface = function () {
|
||||
return this.surface;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets up handles and preloads required information for the toolbar to work.
|
||||
|
|
|
@ -39,9 +39,6 @@ ve.ui.TriggerRegistry.prototype.register = function ( name, trigger ) {
|
|||
platformKey = platform === 'mac' ? 'mac' : 'pc';
|
||||
|
||||
// Validate arguments
|
||||
if ( typeof name !== 'string' && !ve.isArray( name ) ) {
|
||||
throw new Error( 'name must be a string or array, cannot be a ' + typeof name );
|
||||
}
|
||||
if ( !( trigger instanceof ve.ui.Trigger ) && !ve.isPlainObject( trigger ) ) {
|
||||
throw new Error(
|
||||
'trigger must be an instance of ve.ui.Trigger or an object containing instances of ' +
|
||||
|
@ -64,6 +61,8 @@ ve.ui.TriggerRegistry.prototype.register = function ( name, trigger ) {
|
|||
|
||||
ve.ui.triggerRegistry = new ve.ui.TriggerRegistry();
|
||||
|
||||
/* Registrations */
|
||||
|
||||
ve.ui.triggerRegistry.register(
|
||||
'bold', { 'mac': new ve.ui.Trigger( 'cmd+b' ), 'pc': new ve.ui.Trigger( 'ctrl+b' ) }
|
||||
);
|
||||
|
@ -73,8 +72,12 @@ ve.ui.triggerRegistry.register(
|
|||
ve.ui.triggerRegistry.register(
|
||||
'clear', { 'mac': new ve.ui.Trigger( 'cmd+\\' ), 'pc': new ve.ui.Trigger( 'ctrl+\\' ) }
|
||||
);
|
||||
ve.ui.triggerRegistry.register( 'indent', new ve.ui.Trigger( 'tab' ) );
|
||||
ve.ui.triggerRegistry.register( 'outdent', new ve.ui.Trigger( 'shift+tab' ) );
|
||||
ve.ui.triggerRegistry.register(
|
||||
'indent', new ve.ui.Trigger( 'tab' )
|
||||
);
|
||||
ve.ui.triggerRegistry.register(
|
||||
'outdent', new ve.ui.Trigger( 'shift+tab' )
|
||||
);
|
||||
ve.ui.triggerRegistry.register(
|
||||
'link', { 'mac': new ve.ui.Trigger( 'cmd+k' ), 'pc': new ve.ui.Trigger( 'ctrl+k' ) }
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue