mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 20:26:46 +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
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
/*!
|
|
* VisualEditor user interface ButtonWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.ButtonWidget object.
|
|
*
|
|
* CSS classes will be added to the button for each flag, each prefixed with 've-ui-buttonWidget-'
|
|
*
|
|
* @abstract
|
|
* @class
|
|
* @constructor
|
|
* @extends ve.ui.Widget
|
|
* @param {Function} $$ jQuery for the frame the widget is in
|
|
* @param {string} label Button label
|
|
* @param {string[]} [flags] List of styling flags, e.g. 'primary', 'destructive' or 'constructive'
|
|
*/
|
|
ve.ui.ButtonWidget = function VeUiButtonWidget( $$, label, flags ) {
|
|
// Parent constructor
|
|
ve.ui.Widget.call( this, $$, $( '<a>' ) );
|
|
|
|
// Properties
|
|
this.$label = this.$$( '<span>' );
|
|
|
|
// Events
|
|
this.$.on( 'click', ve.bind( this.onClick, this ) );
|
|
|
|
// Initialization
|
|
this.$label
|
|
.addClass( 've-ui-buttonWidget-label' )
|
|
.text( label );
|
|
this.$
|
|
.addClass( 've-ui-buttonWidget' )
|
|
.append( this.$label );
|
|
if ( ve.isArray( flags ) ) {
|
|
this.$.addClass( 've-ui-buttonWidget-' + flags.join( ' ve-ui-buttonWidget-' ) );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.ButtonWidget, ve.ui.Widget );
|
|
|
|
/**
|
|
* @event click
|
|
*/
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Event
|
|
*/
|
|
ve.ui.ButtonWidget.prototype.onClick = function ( e ) {
|
|
if ( !this.disabled ) {
|
|
this.emit( 'click' );
|
|
}
|
|
e.preventDefault();
|
|
return false;
|
|
};
|