mediawiki-extensions-Visual.../modules/ve/ui/tools/buttons/ve.ui.LinkButtonTool.js
Trevor Parscal 6b5310c562 ve.ui.ViewRegistry annihilation
Objectives:
* Associate models with tools, rather than dialogs and inspectors
* Move tool/model association utilities to ve.ui.ToolFactory
* Obliterate the view registry

Notes:

The only special case for leaving modelClasses definitions in place is
for the linkInspector. It uses these for selection expansion.
Because tools can now override the static canEditModel method, we can
dynamically evaluate a model, rather than be restricted to only
comparing classes. This will be useful for disabling editors for models
that are for some reason incomplete or otherwise broken and cannot be
safely edited.

Change-Id: I7adf254990112d90f1f808593a9111afc7a116b5
2013-06-26 16:52:10 -07:00

47 lines
1.2 KiB
JavaScript

/*!
* VisualEditor UserInterface LinkButtonTool class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface link button tool.
*
* @class
* @extends ve.ui.InspectorButtonTool
* @constructor
* @param {ve.ui.Toolbar} toolbar
* @param {Object} [config] Config options
*/
ve.ui.LinkButtonTool = function VeUiLinkButtonTool( toolbar, config ) {
// Parent constructor
ve.ui.InspectorButtonTool.call( this, toolbar, config );
};
/* Inheritance */
ve.inheritClass( ve.ui.LinkButtonTool, ve.ui.InspectorButtonTool );
/* Static Properties */
ve.ui.LinkButtonTool.static.name = 'link';
ve.ui.LinkButtonTool.static.icon = 'link';
ve.ui.LinkButtonTool.static.titleMessage = 'visualeditor-annotationbutton-link-tooltip';
ve.ui.LinkButtonTool.static.inspector = 'link';
ve.ui.LinkButtonTool.static.modelClasses = [ ve.dm.LinkAnnotation ];
/* Registration */
ve.ui.toolFactory.register( 'link', ve.ui.LinkButtonTool );
ve.ui.commandRegistry.register( 'link', 'inspector', 'open', 'link' );
ve.ui.triggerRegistry.register(
'link', { 'mac': new ve.ui.Trigger( 'cmd+k' ), 'pc': new ve.ui.Trigger( 'ctrl+k' ) }
);