mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-25 12:33:19 +00:00
e9384ad9ac
New changes: 9d162ce Restore the selection to a sensible place when closing FindAndReplace 57229ac Only apply annotations if 'done' is clicked bfb17ee Always show cancel button on annotation inspectors 91672cf Disable 'done'/'insert' button when input invalid aef9cbd Only create annotations from text input if it is valid a384b96 [BREAKING CHANGE] Make getTextFromAnnotation/getAnnotationFromText static fa09ab7 Scroll table selection into view when it changes Local changes: Make getTextFromAnnotation/getAnnotationFromText static Change-Id: Id3c2a1efb1f327fa6d5b93d57d90bb5bb8ee88f8
61 lines
1.4 KiB
JavaScript
61 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 );
|
|
|
|
/* Static Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWExternalLinkAnnotationWidget.static.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
|
|
}
|
|
} );
|
|
}
|
|
};
|
|
|
|
/* 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()
|
|
} );
|
|
};
|