mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 23:05:35 +00:00
59c67e1e94
demos/ve/demo.css, demos/ve/index.php * Style changes for utilities and dump output * Initially disable the log range button, activate when there's a range to log * Make range inputs read-only * Rename some widget variables * Add extra structure and classes to dump output ve.ui.Widget.css * Remove left/right margin for buttons * Simplify opaque white color * Modify selector for disabled buttons - see changes in ve.ui.Widget.js * Added styles for text input widget's readonly and disabled states ve.ui.Widget.js * Added disabled state ve.ui.ButtonWidget.js * Moved click event handler to method ve.ui.InputLabelWidget.js * Moved click event handler to method ve.ui.InputWidget.js * Moved input change event handler to method * Added readOnly state ve.ui.LinkTargetInputWidget.js * Corrected documentation ve.ui.MenuWidget.js * Blocked interaction while widget is disabled ve.ui.MWLinkTargetInputWidget.js * Corrected documentation * Blocked interaction while widget is disabled ve.ui.TextInputMenuWidget.js * Blocked interaction while widget is disabled Change-Id: I7ea89873b50a98d058d1dd1e309e3e8b7c8e7b2e
89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
/*!
|
|
* VisualEditor user interface LinkTargetInputWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.LinkTargetInputWidget object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends ve.ui.TextInputWidget
|
|
* @param {Function} $$ jQuery for the frame the widget is in
|
|
* @param {jQuery} $overlay DOM element to add menu to
|
|
* @param {string} [name] Input name, used by HTML forms
|
|
* @param {string} [value] Input value
|
|
*/
|
|
ve.ui.LinkTargetInputWidget = function VeUiLinkTargetInputWidget( $$, $overlay, name, value ) {
|
|
// Parent constructor
|
|
ve.ui.TextInputWidget.call( this, $$, name, value );
|
|
|
|
// Properties
|
|
this.annotation = null;
|
|
|
|
// Events
|
|
this.addListenerMethod( this, 'change', 'onChange' );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-linkTargetInputWidget' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.LinkTargetInputWidget, ve.ui.TextInputWidget );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles change events.
|
|
*
|
|
* @method
|
|
* @param {string} value New value
|
|
*/
|
|
ve.ui.LinkTargetInputWidget.prototype.onChange = function ( value ) {
|
|
if ( value === '' ) {
|
|
this.annotation = null;
|
|
} else {
|
|
this.setAnnotation( new ve.dm.LinkAnnotation( { 'href': value } ) );
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Sets the annotation value.
|
|
*
|
|
* The input value will automatically be updated.
|
|
*
|
|
* @method
|
|
* @param {ve.dm.LinkAnnotation} annotation Link annotation
|
|
*/
|
|
ve.ui.LinkTargetInputWidget.prototype.setAnnotation = function ( annotation ) {
|
|
this.annotation = annotation;
|
|
this.setValue( this.getTargetFromAnnotation( annotation ), 'annotation' );
|
|
};
|
|
|
|
/**
|
|
* Gets the annotation value.
|
|
*
|
|
* @method
|
|
* @returns {ve.dm.LinkAnnotation} Link annotation
|
|
*/
|
|
ve.ui.LinkTargetInputWidget.prototype.getAnnotation = function () {
|
|
return this.annotation;
|
|
};
|
|
|
|
/**
|
|
* Gets a target from an annotation.
|
|
*
|
|
* @method
|
|
* @param {ve.dm.LinkAnnotation} annotation Link annotation
|
|
* @returns {string} Target
|
|
*/
|
|
ve.ui.LinkTargetInputWidget.prototype.getTargetFromAnnotation = function ( annotation ) {
|
|
if ( annotation instanceof ve.dm.LinkAnnotation ) {
|
|
return annotation.data.href;
|
|
}
|
|
return '';
|
|
};
|