diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /vendor/oojs/oojs-ui/src/tools/PopupTool.js | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'vendor/oojs/oojs-ui/src/tools/PopupTool.js')
-rw-r--r-- | vendor/oojs/oojs-ui/src/tools/PopupTool.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/oojs/oojs-ui/src/tools/PopupTool.js b/vendor/oojs/oojs-ui/src/tools/PopupTool.js new file mode 100644 index 00000000..98f93d75 --- /dev/null +++ b/vendor/oojs/oojs-ui/src/tools/PopupTool.js @@ -0,0 +1,59 @@ +/** + * Tool that shows a popup when selected. + * + * @abstract + * @class + * @extends OO.ui.Tool + * @mixins OO.ui.PopupElement + * + * @constructor + * @param {OO.ui.ToolGroup} toolGroup + * @param {Object} [config] Configuration options + */ +OO.ui.PopupTool = function OoUiPopupTool( toolGroup, config ) { + // Allow passing positional parameters inside the config object + if ( OO.isPlainObject( toolGroup ) && config === undefined ) { + config = toolGroup; + toolGroup = config.toolGroup; + } + + // Parent constructor + OO.ui.PopupTool.super.call( this, toolGroup, config ); + + // Mixin constructors + OO.ui.PopupElement.call( this, config ); + + // Initialization + this.$element + .addClass( 'oo-ui-popupTool' ) + .append( this.popup.$element ); +}; + +/* Setup */ + +OO.inheritClass( OO.ui.PopupTool, OO.ui.Tool ); +OO.mixinClass( OO.ui.PopupTool, OO.ui.PopupElement ); + +/* Methods */ + +/** + * Handle the tool being selected. + * + * @inheritdoc + */ +OO.ui.PopupTool.prototype.onSelect = function () { + if ( !this.isDisabled() ) { + this.popup.toggle(); + } + this.setActive( false ); + return false; +}; + +/** + * Handle the toolbar state being updated. + * + * @inheritdoc + */ +OO.ui.PopupTool.prototype.onUpdateState = function () { + this.setActive( false ); +}; |