mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 11:46:01 +00:00
e6f48c5c93
Because the former isn't a real word. Change-Id: Ie6ed15f9e390b357bbaa768b57f3c3fd7cf21181
65 lines
1.2 KiB
JavaScript
65 lines
1.2 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface IconButtonWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.IconButtonWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Widget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
* @cfg {string} [icon] Symbolic name of icon
|
|
* @cfg {string} [title=''] Title text
|
|
*/
|
|
ve.ui.IconButtonWidget = function VeUiIconButtonWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.Widget.call( this, config );
|
|
|
|
// Events
|
|
this.$.on( 'click', ve.bind( this.onClick, this ) );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-iconButtonWidget' );
|
|
if ( config.icon ) {
|
|
this.$.addClass( 've-ui-icon-' + config.icon );
|
|
}
|
|
if ( config.title ) {
|
|
this.$.attr( 'title', config.title );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.IconButtonWidget, ve.ui.Widget );
|
|
|
|
/* Events */
|
|
|
|
/**
|
|
* @event click
|
|
*/
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.IconButtonWidget.static.tagName = 'a';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse click event
|
|
* @emits click
|
|
*/
|
|
ve.ui.IconButtonWidget.prototype.onClick = function () {
|
|
if ( !this.disabled ) {
|
|
this.emit( 'click' );
|
|
}
|
|
return false;
|
|
};
|