mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
8409d16f0f
Objective: * Add default sort key field to meta dialog * Replace PagePanelLayout with a generic panel containing one or more FieldsetLayout elements Changes: *.php * Added/removed file links ve.dm.MWDefaultSortMetaItem.js * Added getContent method ve.dm.MetaItem.js * Added replaceWith method ve.dm.MetaList.js * Allow insertion at the end by omitting offset and index ve.dm.MWMetaDialog.js * Added default sort key field * Put category and default sort fields inside fieldsets * Added loading/saving default sort key ve.ui.PagedLayout.js * Changed class used for pages to generic panel layout ve.ui.PagePanelLayout * Moved title/icon stuff to field set ve.ui.FieldsetLayout.js * New class, adds fieldset with legend ve.ui.StackPanelLayout.js * Moved up to the layouts directory ve.ui.Dialog.css * Moved style for paged panel from layout stylesheet ve.ui.Layout.css * Added styles for fieldsets ve.ui.Widget.css * Adjusted margins of input label widgets ve.ui.MWCategoryWidget.js, ve.ui.MWCategoryPopupWidget.js * Added setDefaultSortKey method Change-Id: I979f5e3f08a688790c9f54086206ed1999af13ea
121 lines
2.5 KiB
JavaScript
121 lines
2.5 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
|
|
* @param {number} [index] Index to insert items after
|
|
* @chainable
|
|
*/
|
|
ve.ui.StackPanelLayout.prototype.addItems = function ( items, index ) {
|
|
var i, len;
|
|
|
|
for ( i = 0, len = items.length; i < len; i++ ) {
|
|
if ( !this.currentItem ) {
|
|
this.showItem( items[i] );
|
|
} else {
|
|
items[i].$.hide();
|
|
}
|
|
}
|
|
ve.ui.GroupElement.prototype.addItems.call( this, items, index );
|
|
|
|
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();
|
|
this.currentItem = item;
|
|
|
|
return this;
|
|
};
|