mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
8fc98868c9
ve.ui.Inspector * Removed disabled state and interfaces - this isn't needed * Renamed prepareSelection to onInitialize * Using event emitter to run onInitialize, onOpen and onClose methods * Left removal up to the child class to handle in the onClose method * Replaced calls on context to close inspector to calling close directly * Renamed prepareSelection stub to onInitialize * Emitting initialize event from within the open method * Added recursion guarding to close method * Changed the close method's argument to be remove instead of accept - the more common case is to save changes, and the only time you wouldn't save changes is if you were to remove the annotation * Moved focus restore to close method ve.ui.Context * Moved the majority of the code in openInspector and closeInspector to event handlers for onInspectorOpen and onInspectorClose * Updated calls to closeInspector re: accept->remove argument change ve.ui.LinkInspector * Renamed prepareSelection to onInitialize and rewrote logic and documentation * Removed unused onLocationInputChange method * Moved restore focus (now it's in the inspector base class) ve.dm.SurfaceFragment * Added word mode for expandRange ve.dm.Surface * Added locking/unlocking while processing transactions - this was not an issue before because this was effectively being done manually throughout ce (which needs to be cleaned up) but once we started using the content action to insert content dm and ce started playing off each other and inserting in a loop - we already do this for undo/redo so it makes sense to do it here as well ve.InspectorAction * Updated arguments re: close method's accept->remove argument change Change-Id: I38995d4101fda71bfb2e6fe516603507ce820937
62 lines
1.2 KiB
JavaScript
62 lines
1.2 KiB
JavaScript
/**
|
|
* VisualEditor InspectorAction class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* List action.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.Action}
|
|
* @param {ve.Surface} surface Surface to act on
|
|
*/
|
|
ve.InspectorAction = function VeListAction( surface ) {
|
|
// Parent constructor
|
|
ve.Action.call( this, surface );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.InspectorAction, ve.Action );
|
|
|
|
/* Static Members */
|
|
|
|
/**
|
|
* List of allowed methods for this action.
|
|
*
|
|
* @static
|
|
* @member
|
|
*/
|
|
ve.InspectorAction.static.methods = ['open', 'close'];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Opens an inspector.
|
|
*
|
|
* @method
|
|
* @param {String} name Symbolic name of inspector
|
|
*/
|
|
ve.InspectorAction.prototype.open = function ( name ) {
|
|
this.surface.getContext().openInspector( name );
|
|
};
|
|
|
|
/**
|
|
* Wraps content in a list.
|
|
*
|
|
* If changes are not accepted, the inspector will close without modifying the document.
|
|
*
|
|
* @method
|
|
* @param {Boolean} accept Accept changes
|
|
*/
|
|
ve.InspectorAction.prototype.close = function ( remove ) {
|
|
this.surface.getContext().closeInspector( remove );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.actionFactory.register( 'inspector', ve.InspectorAction );
|