diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js')
-rw-r--r-- | vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js b/vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js new file mode 100644 index 00000000..5643b77c --- /dev/null +++ b/vendor/oojs/oojs-ui/src/widgets/PopupButtonWidget.js @@ -0,0 +1,57 @@ +/** + * PopupButtonWidgets toggle the visibility of a contained {@link OO.ui.PopupWidget PopupWidget}, + * which is used to display additional information or options. + * + * @example + * // Example of a popup button. + * var popupButton = new OO.ui.PopupButtonWidget( { + * label: 'Popup button with options', + * icon: 'menu', + * popup: { + * $content: $( '<p>Additional options here.</p>' ), + * padded: true, + * align: 'force-left' + * } + * } ); + * // Append the button to the DOM. + * $( 'body' ).append( popupButton.$element ); + * + * @class + * @extends OO.ui.ButtonWidget + * @mixins OO.ui.PopupElement + * + * @constructor + * @param {Object} [config] Configuration options + */ +OO.ui.PopupButtonWidget = function OoUiPopupButtonWidget( config ) { + // Parent constructor + OO.ui.PopupButtonWidget.super.call( this, config ); + + // Mixin constructors + OO.ui.PopupElement.call( this, config ); + + // Events + this.connect( this, { click: 'onAction' } ); + + // Initialization + this.$element + .addClass( 'oo-ui-popupButtonWidget' ) + .attr( 'aria-haspopup', 'true' ) + .append( this.popup.$element ); +}; + +/* Setup */ + +OO.inheritClass( OO.ui.PopupButtonWidget, OO.ui.ButtonWidget ); +OO.mixinClass( OO.ui.PopupButtonWidget, OO.ui.PopupElement ); + +/* Methods */ + +/** + * Handle the button action being triggered. + * + * @private + */ +OO.ui.PopupButtonWidget.prototype.onAction = function () { + this.popup.toggle(); +}; |