mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
4e64187beb
* Document them consistently between secetions Inheritance and Static Properties under their own (new) section Events. * Removed any quotes or brackets around the event name in existing @emit annotations Search: @emit.*['"{}(){}] * For every call to this.emit() anywhere, added @emits. * Fixed all warnings for references to undefined events (introduced as a result of the previous point). Event handler parameter documented based on the emit() call and actual handlers using the event. Usually the latter is more elaborate. * Extend coverage of jQuery as needed (copied from mwcore/maintenance/jsduck/external.js written by me, hereby implicitly and explicitly released under MIT). Specifics * ve.ce.Surface#onContentChange: Fixed type of range from Object to ve.Range. * ve.ce.SurfaceObserver#poll: Fix syntax for code from {} to `backticks`. * ve.ui.Toolbar#onContextChange: Doesn't actually emit "clearState" event. Removed #onClearState in Tool, ButtonTool and DropdownTool. Bug: 45872 Change-Id: Id879aa769b2c72d86a0322e75dddeb868211ce28
68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface 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.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Widget
|
|
* @mixins ve.ui.FlaggableWidget
|
|
* @mixins ve.ui.LabeledWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Config options
|
|
*/
|
|
ve.ui.ButtonWidget = function VeUiButtonWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.Widget.call( this, config );
|
|
|
|
// Mixin constructors
|
|
ve.ui.FlaggableWidget.call( this, config );
|
|
ve.ui.LabeledWidget.call( this, this.$$( '<span>' ), config );
|
|
|
|
// Events
|
|
this.$.on( 'click', ve.bind( this.onClick, this ) );
|
|
|
|
// Initialization
|
|
this.$label.addClass( 've-ui-buttonWidget-label' );
|
|
this.$.addClass( 've-ui-buttonWidget' ).append( this.$label );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.ButtonWidget, ve.ui.Widget );
|
|
|
|
ve.mixinClass( ve.ui.ButtonWidget, ve.ui.FlaggableWidget );
|
|
|
|
ve.mixinClass( ve.ui.ButtonWidget, ve.ui.LabeledWidget );
|
|
|
|
/* Events */
|
|
|
|
/**
|
|
* @event click
|
|
*/
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.ButtonWidget.static.tagName = 'div';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse click event
|
|
* @emits click
|
|
*/
|
|
ve.ui.ButtonWidget.prototype.onClick = function () {
|
|
if ( !this.disabled ) {
|
|
this.emit( 'click' );
|
|
}
|
|
return false;
|
|
};
|