2013-10-02 00:00:57 +00:00
|
|
|
/*!
|
2013-10-09 20:09:59 +00:00
|
|
|
* ObjectOriented UserInterface PopupButtonWidget class.
|
2013-10-02 00:00:57 +00:00
|
|
|
*
|
2013-10-09 20:09:59 +00:00
|
|
|
* @copyright 2011-2013 OOJS Team and others; see AUTHORS.txt
|
2013-10-02 00:00:57 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Button that shows and hides a popup.
|
|
|
|
*
|
|
|
|
* @class
|
2013-10-09 20:09:59 +00:00
|
|
|
* @extends OO.ui.IconButtonWidget
|
|
|
|
* @mixins OO.ui.PopuppableElement
|
2013-10-02 00:00:57 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.PopupButtonWidget = function OoUiPopupButtonWidget( config ) {
|
2013-10-02 00:00:57 +00:00
|
|
|
// Parent constructor
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.IconButtonWidget.call( this, config );
|
2013-10-02 00:00:57 +00:00
|
|
|
|
2013-10-17 17:21:03 +00:00
|
|
|
// Mixin constructors
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.PopuppableElement.call( this, config );
|
2013-10-02 00:00:57 +00:00
|
|
|
|
|
|
|
// Initialization
|
2013-10-17 17:21:03 +00:00
|
|
|
this.$
|
2013-10-09 20:09:59 +00:00
|
|
|
.addClass( 'oo-ui-popupButtonWidget' )
|
2013-10-17 17:21:03 +00:00
|
|
|
.append( this.popup.$ );
|
2013-10-02 00:00:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( OO.ui.PopupButtonWidget, OO.ui.IconButtonWidget );
|
2013-10-02 00:00:57 +00:00
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.mixinClass( OO.ui.PopupButtonWidget, OO.ui.PopuppableElement );
|
2013-10-17 17:21:03 +00:00
|
|
|
|
2013-10-02 00:00:57 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles mouse click events.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {jQuery.Event} e Mouse click event
|
|
|
|
*/
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.PopupButtonWidget.prototype.onClick = function ( e ) {
|
2013-10-02 00:00:57 +00:00
|
|
|
// 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();
|
|
|
|
}
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.IconButtonWidget.prototype.onClick.call( this );
|
2013-10-02 00:00:57 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|