MWLinkInspectorTool: Add parent method call to #updateState

Bonus: No need to check if fragment is a SurfaceFragment.

Bug: T111099
Change-Id: Ieaa3ee979477175d0f129e30838853bc04937fad
This commit is contained in:
Ed Sanders 2015-09-01 21:41:50 +01:00 committed by Jforrester
parent 2462889843
commit 471df53aaf

View file

@ -22,8 +22,12 @@ ve.ui.MWLinkInspectorTool = function VeUiMwLinkInspectorTool() {
ve.ui.MWLinkInspectorTool.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWLinkInspectorTool, ve.ui.LinkInspectorTool );
/* Static Properties */
ve.ui.MWLinkInspectorTool.static.modelClasses =
ve.ui.MWLinkInspectorTool.super.static.modelClasses.concat( [
ve.dm.MWNumberedExternalLinkNode,
@ -32,20 +36,32 @@ ve.ui.MWLinkInspectorTool.static.modelClasses =
ve.ui.MWLinkInspectorTool.static.associatedWindows = [ 'link', 'linkNode', 'linkMagicNode' ];
/* Methods */
/**
* @inheritdoc
*/
ve.ui.MWLinkInspectorTool.prototype.onUpdateState = function ( fragment ) {
var node, type, title;
// Parent method
ve.ui.MWLinkInspectorTool.super.prototype.onUpdateState.apply( this, arguments );
// Vary title based on link type.
var node = fragment instanceof ve.dm.SurfaceFragment ?
fragment.getSelectedNode() : null,
type = node instanceof ve.dm.MWMagicLinkNode ?
'magiclinknode-tooltip-' + node.getMagicType().toLowerCase() :
node instanceof ve.dm.MWNumberedExternalLinkNode ?
'linknode-tooltip' : null,
title = type ?
OO.ui.deferMsg( 'visualeditor-annotationbutton-' + type ) :
ve.ui.MWLinkInspectorTool.static.title;
node = fragment && fragment.getSelectedNode();
type = node instanceof ve.dm.MWMagicLinkNode ?
'magiclinknode-tooltip-' + node.getMagicType().toLowerCase() :
node instanceof ve.dm.MWNumberedExternalLinkNode ?
'linknode-tooltip' : null;
title = type ?
OO.ui.deferMsg( 'visualeditor-annotationbutton-' + type ) :
ve.ui.MWLinkInspectorTool.static.title;
this.setTitle( title );
};
/* Registration */
ve.ui.toolFactory.register( ve.ui.MWLinkInspectorTool );
ve.ui.commandRegistry.register(