mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
d2dfb9ac4f
* Move and rename generic parts of ve.ui to OO.ui * We now have a UI test suite because ve.Element (outside ve.ui) is now part of oojs-ui, so it needs a test suite. * Added to the MW test run (just like we do for unicodejs). * Updated csslint config (also added ve-mw and syntaxhighlight which were missing). oojs-ui still depends on the TriggerRegistry in VE, this is addressed in a follow-up commit. Change-Id: Iec147155c1ddf20b73a4d15d87b8742207032312
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
/*!
|
|
* ObjectOriented UserInterface PopupButtonWidget class.
|
|
*
|
|
* @copyright 2011-2013 OOJS Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Button that shows and hides a popup.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.IconButtonWidget
|
|
* @mixins OO.ui.PopuppableElement
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
OO.ui.PopupButtonWidget = function OoUiPopupButtonWidget( config ) {
|
|
// Parent constructor
|
|
OO.ui.IconButtonWidget.call( this, config );
|
|
|
|
// Mixin constructors
|
|
OO.ui.PopuppableElement.call( this, config );
|
|
|
|
// Initialization
|
|
this.$
|
|
.addClass( 'oo-ui-popupButtonWidget' )
|
|
.append( this.popup.$ );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( OO.ui.PopupButtonWidget, OO.ui.IconButtonWidget );
|
|
|
|
OO.mixinClass( OO.ui.PopupButtonWidget, OO.ui.PopuppableElement );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handles mouse click events.
|
|
*
|
|
* @method
|
|
* @param {jQuery.Event} e Mouse click event
|
|
*/
|
|
OO.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();
|
|
}
|
|
OO.ui.IconButtonWidget.prototype.onClick.call( this );
|
|
}
|
|
return false;
|
|
};
|