mediawiki-extensions-Visual.../modules/ve-mw/ui/contextitems/ve.ui.MWMagicLinkNodeContextItem.js
C. Scott Ananian 7cc23367f6 Specialized inspector for ISBN magic links
Implement a special node type, context item, and inspector for
ISBN/PMID/RFC magic links.  Add buttons to the link inspectors
to convert back and forth between "simple" links, and magic links.

Depends on I5d000d8b63dafdfe0a2753069d3f0ac5b03b8829 in Parsoid
for clean round-tripping of localized ISBN magic links.

Bug: T63558
Change-Id: Id5b7a2ae3c80b0e5eed598f0bd024d3e94f7e9aa
2015-09-01 14:25:59 -04:00

56 lines
1.5 KiB
JavaScript

/*!
* VisualEditor MWMagicLinkNodeContextItem class.
*
* @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org
*/
/**
* Context item for a MWMagicLinkNode.
*
* @class
* @extends ve.ui.LinkContextItem
*
* @constructor
* @param {ve.ui.Context} context Context item is in
* @param {ve.dm.MWMagicLinkNode} model Model item is related to
* @param {Object} config Configuration options
*/
ve.ui.MWMagicLinkNodeContextItem = function VeUiMWMagicLinkNodeContextItem() {
// Parent constructor
ve.ui.MWMagicLinkNodeContextItem.super.apply( this, arguments );
// Initialization
this.$element.addClass( 've-ui-mwMagicLinkNodeContextItem' );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWMagicLinkNodeContextItem, ve.ui.LinkContextItem );
/* Static Properties */
ve.ui.MWMagicLinkNodeContextItem.static.name = 'link/mwMagic';
ve.ui.MWMagicLinkNodeContextItem.static.label = null; // see #setup()
ve.ui.MWMagicLinkNodeContextItem.static.modelClasses = [ ve.dm.MWMagicLinkNode ];
/* Methods */
ve.ui.MWMagicLinkNodeContextItem.prototype.setup = function () {
// Set up label
var msg = 'visualeditor-magiclinknodeinspector-title-' +
this.model.getMagicType().toLowerCase();
this.setLabel( OO.ui.deferMsg( msg ) );
// Invoke superclass method.
return ve.ui.MWMagicLinkNodeContextItem.super.prototype.setup.call( this );
};
ve.ui.MWMagicLinkNodeContextItem.prototype.getDescription = function () {
return this.model.getAttribute( 'content' );
};
/* Registration */
ve.ui.contextItemFactory.register( ve.ui.MWMagicLinkNodeContextItem );