mediawiki-extensions-Visual.../modules/ve-mw/ui/widgets/ve.ui.MWExternalLinkAnnotationWidget.js
Ed Sanders ff9bf1fcb3 Update VE core submodule to master (2c0224d)
New changes:
68959f2 Localisation updates from https://translatewiki.net.
2c0224d [BREAKING CHANGE] Link widget refactor
f81eefa [BREAKING CHANGE] Rename LinkInspector to LinkAnnotationInspector

Local changes:
Adjust for link inspector refactor

Create separate widgets for internal and external link
annotations. Remove annotation specific logic from link
target input widget.

Change-Id: I054c3fe7ac9c61fbc3302471abd58cab89fed5a4
2015-05-08 09:56:11 +01:00

59 lines
1.4 KiB
JavaScript

/*!
* VisualEditor UserInterface MWExternalLinkAnnotationWidget class.
*
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.MWExternalLinkAnnotationWidget object.
*
* @class
* @extends ve.ui.LinkAnnotationWidget
*
* @constructor
* @param {Object} [config] Configuration options
*/
ve.ui.MWExternalLinkAnnotationWidget = function VeUiMWExternalLinkAnnotationWidget() {
// Parent constructor
ve.ui.MWExternalLinkAnnotationWidget.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWExternalLinkAnnotationWidget, ve.ui.LinkAnnotationWidget );
/* Methods */
/**
* Create a text input widget to be used by the annotation widget
*
* @param {Object} [config] Configuration options
* @return {OO.ui.TextInputWidget} Text input widget
*/
ve.ui.MWExternalLinkAnnotationWidget.prototype.createInputWidget = function () {
return new OO.ui.TextInputWidget( {
icon: 'linkExternal',
validate: ve.init.platform.getExternalLinkUrlProtocolsRegExp()
} );
};
/**
* @inheritdoc
*/
ve.ui.MWExternalLinkAnnotationWidget.prototype.getAnnotationFromText = function ( value ) {
var href = value.trim();
// Keep annotation in sync with value
if ( href === '' ) {
return null;
} else {
return new ve.dm.MWExternalLinkAnnotation( {
type: 'link/mwExternal',
attributes: {
href: href
}
} );
}
};