/*!
- * OOUI v0.27.5
+ * OOUI v0.28.0
* https://www.mediawiki.org/wiki/OOUI
*
* Copyright 2011–2018 OOUI Team and other contributors.
* Released under the MIT license
* http://oojs.mit-license.org
*
- * Date: 2018-07-11T18:13:04Z
+ * Date: 2018-08-14T23:16:18Z
*/
( function ( OO ) {
this.toolFactory = toolFactory;
this.toolGroupFactory = toolGroupFactory;
this.groupsByName = {};
+ this.activeToolGroups = 0;
this.tools = {};
this.position = config.position || 'top';
this.$bar = $( '<div>' );
* @param {...Mixed} data Application-defined parameters
*/
+/**
+ * @event active
+ *
+ * An 'active' event is emitted when the number of active toolgroups increases from 0, or
+ * returns to 0.
+ *
+ * @param {boolean} There are active toolgroups in this toolbar
+ */
+
/* Methods */
/**
// Groups without name are deprecated
OO.ui.warnDeprecation( 'Toolgroups must have a \'name\' property' );
}
+ toolGroup.connect( this, { active: 'onToolGroupActive' } );
}
this.addItems( items );
};
+/**
+ * Handle active events from tool groups
+ *
+ * @param {boolean} active Tool group has become active, inactive if false
+ * @fires active
+ */
+OO.ui.Toolbar.prototype.onToolGroupActive = function ( active ) {
+ if ( active ) {
+ this.activeToolGroups++;
+ if ( this.activeToolGroups === 1 ) {
+ this.emit( 'active', true );
+ }
+ } else {
+ this.activeToolGroups--;
+ if ( this.activeToolGroups === 0 ) {
+ this.emit( 'active', false );
+ }
+ }
+};
+
/**
* Get a toolgroup by name
*
* @event update
*/
+/**
+ * @event active
+ *
+ * An 'active' event is emitted when any popup is shown/hidden.
+ *
+ * @param {boolean} The popup is visible
+ */
+
/* Static Properties */
/**
*/
OO.ui.PopupTool.prototype.onPopupToggle = function ( isVisible ) {
this.setActive( isVisible );
+ this.toolGroup.emit( 'active', isVisible );
};
/**
this.innerToolGroup = this.createGroup( this.constructor.static.groupConfig );
// Events
- this.innerToolGroup.connect( this, { disable: 'onToolGroupDisable' } );
+ this.innerToolGroup.connect( this, {
+ disable: 'onToolGroupDisable',
+ // Re-emit active events from the innerToolGroup on the parent toolGroup
+ active: this.toolGroup.emit.bind( this.toolGroup, 'active' )
+ } );
// Initialization
this.$link.remove();
* deactivation.
*
* @param {boolean} value The active state to set
+ * @fires active
*/
OO.ui.PopupToolGroup.prototype.setActive = function ( value ) {
var containerWidth, containerLeft;
this.togglePositioning( false );
this.toggleClipping( false );
}
+ this.emit( 'active', this.active );
this.updateThemeClasses();
}
};