mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
efafed3231
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface PopupButtonWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Button that shows and hides a popup.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.IconButtonWidget
|
|
* @mixins ve.ui.PopuppableElement
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.PopupButtonWidget = function VeUiPopupButtonWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.IconButtonWidget.call( this, config );
|
|
|
|
// Mixin constructors
|
|
ve.ui.PopuppableElement.call( this, config );
|
|
|
|
// Initialization
|
|
this.$
|
|
.addClass( 've-ui-popupButtonWidget' )
|
|
.append( this.popup.$ );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.PopupButtonWidget, ve.ui.IconButtonWidget );
|
|
|
|
OO.mixinClass( ve.ui.PopupButtonWidget, ve.ui.PopuppableElement );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse click event
|
|
*/
|
|
ve.ui.PopupButtonWidget.prototype.onClick = function ( e ) {
|
|
// Skip clicks within the popup
|
|
if ( $.contains( this.popup.$[0], e.target ) ) {
|
|
return;
|
|
}
|
|
|
|
if ( !this.disabled ) {
|
|
if ( this.popup.isVisible() ) {
|
|
this.hidePopup();
|
|
} else {
|
|
this.showPopup();
|
|
}
|
|
ve.ui.IconButtonWidget.prototype.onClick.call( this );
|
|
}
|
|
return false;
|
|
};
|