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 | 1x 1x 1x 1x | /*!
* VisualEditor Context Item widget class.
*
* @copyright See AUTHORS.txt
*/
/**
* Proxy for a tool, displaying information about the current context.
*
* Use with ve.ui.ContextSelectWidget.
*
* @class
* @extends OO.ui.DecoratedOptionWidget
*
* @constructor
* @param {Function} tool Tool item is a proxy for
* @param {ve.dm.Node|ve.dm.Annotation} model Node or annotation item is related to
* @param {Object} [config] Configuration options
*/
ve.ui.ContextOptionWidget = function VeUiContextOptionWidget( tool, model, config = {} ) {
// Parent constructor
ve.ui.ContextOptionWidget.super.call( this, config );
// Properties
this.tool = tool;
this.model = model;
// Initialization
this.$element.addClass( 've-ui-contextOptionWidget' );
this.setIcon( this.tool.static.icon );
this.setLabel( this.getDescription() );
};
/* Setup */
OO.inheritClass( ve.ui.ContextOptionWidget, OO.ui.DecoratedOptionWidget );
/* Methods */
/**
* Get a description of the model.
*
* @return {string} Description of model
*/
ve.ui.ContextOptionWidget.prototype.getDescription = function () {
let description;
if ( this.model instanceof ve.dm.Annotation ) {
description = ve.ce.annotationFactory.getDescription( this.model );
} else if ( this.model instanceof ve.dm.Node ) {
description = ve.ce.nodeFactory.getDescription( this.model );
}
if ( !description ) {
description = this.tool.static.title;
}
return description;
};
/**
* Get the command for this item.
*
* @return {ve.ui.Command}
*/
ve.ui.ContextOptionWidget.prototype.getCommand = function () {
return this.tool.static.getCommand( this.context.getSurface() );
};
|