mediawiki-extensions-Visual.../modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
Trevor Parscal efafed3231 Remove ve.{inheritClass,mixinClass} and use OO instead
Change-Id: I8df9226a358a76b661eab6e967ff0d63d361f691
2013-10-18 18:58:08 +02:00

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;
};