mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
a2e59f7c86
*.php * Updated links to files ve.ui.MetaDialog * Added stack panel that now contains category and language editor panels * Attached outline widget to stack panel ve.ui.FlaggableWidget -> ve.ui.FlaggableElement * Moved to elements ve.ui.GroupWidget -> ve.ui.GroupElement * Moved to elements * Removed invalid event documentation ve.ui.LabledWidget -> ve.ui.LabledElement * Moved to elements ve.ui.StackPanelLayout.js * New class, mutually exclusive panel container ve.ui.TitledPanelLayout * Remvoed, using labeled element instead ve.ui.Element.css * Added for elements * Moved label style here, from widget styles *.css, ve.ui.ButtonWidget.js, ve.ui.InputLabelWidget, ve.ui.OptionWidget, ve.ui.SelectWidget * Adjusted class names to reflect widget -> element migration Change-Id: I32f504c844dba7aae1b286eef06ca046627bdc8d
119 lines
2.4 KiB
JavaScript
119 lines
2.4 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface StackPanelLayout class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Stack panel layout.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.PanelLayout
|
|
* @mixins ve.ui.GroupElement
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Config options
|
|
* @cfg {string} [icon=''] Symbolic icon name
|
|
*/
|
|
ve.ui.StackPanelLayout = function VeUiStackPanelLayout( config ) {
|
|
// Config initialization
|
|
config = ve.extendObject( config, { 'scroll': true } );
|
|
|
|
// Parent constructor
|
|
ve.ui.PanelLayout.call( this, config );
|
|
|
|
// Mixin constructors
|
|
ve.ui.GroupElement.call( this, this.$, config );
|
|
|
|
// Properties
|
|
this.currentItem = null;
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-stackPanelLayout' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.StackPanelLayout, ve.ui.PanelLayout );
|
|
|
|
ve.mixinClass( ve.ui.StackPanelLayout, ve.ui.GroupElement );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Add items.
|
|
*
|
|
* Adding an existing item (by value) will move it.
|
|
*
|
|
* @method
|
|
* @param {ve.ui.PanelLayout[]} items Items to add
|
|
* @chainable
|
|
*/
|
|
ve.ui.StackPanelLayout.prototype.addItems = function ( items ) {
|
|
var i, len;
|
|
|
|
for ( i = 0, len = items.length; i < len; i++ ) {
|
|
if ( !this.currentItem ) {
|
|
items[i].$.show();
|
|
} else {
|
|
items[i].$.hide();
|
|
}
|
|
}
|
|
ve.ui.GroupElement.prototype.addItems.call( this, items );
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Remove items.
|
|
*
|
|
* Items will be detached, not removed, so they can be used later.
|
|
*
|
|
* @method
|
|
* @param {ve.ui.PanelLayout[]} items Items to remove
|
|
* @chainable
|
|
*/
|
|
ve.ui.StackPanelLayout.prototype.removeItems = function ( items ) {
|
|
ve.ui.GroupElement.prototype.removeItems.call( this, items );
|
|
if ( items.indexOf( this.currentItem ) !== -1 ) {
|
|
this.currentItem = null;
|
|
if ( !this.currentItem && this.items.length ) {
|
|
this.showItem( this.items[0] );
|
|
}
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Clear all items.
|
|
*
|
|
* Items will be detached, not removed, so they can be used later.
|
|
*
|
|
* @method
|
|
* @chainable
|
|
*/
|
|
ve.ui.StackPanelLayout.prototype.clearItems = function () {
|
|
this.currentItem = null;
|
|
ve.ui.GroupElement.prototype.clearItems.call( this );
|
|
|
|
return this;
|
|
};
|
|
|
|
/**
|
|
* Show item.
|
|
*
|
|
* Any currently shown item will be hidden.
|
|
*
|
|
* @method
|
|
* @param {ve.ui.PanelLayout} item Item to show
|
|
* @chainable
|
|
*/
|
|
ve.ui.StackPanelLayout.prototype.showItem = function ( item ) {
|
|
this.$items.hide();
|
|
item.$.show();
|
|
|
|
return this;
|
|
};
|