mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
ac26f5fc69
Objectives: * Allow reordering items in outline widgets using an outline control widget * Use an outline control widget to reorder transclusion parts Changes: ve.ui.SelectWidget.js * Emit add and remove events ve.ui.OutlineItemWidget.js * Add movable config options * Add isMovable method ve.ui.OutlineControlsWidget.js * New class * Displays move up/down buttons which are synchronized with an outline widget * Doesn't actually move items (since an outline widget is probably data-driven) just emits events ve.ui.Widget.css * Add disabled style for icon button widgets * Add styles for outline controls widget ve.ui.Icons*.css * Add missing icon styles ve.ui.Dialog.css * Add styles for outline and controls in editable paged dialogs ve.ui.GroupElement.js * Fix bug where items are insertions are in the wrong place when "moving" them ve.ui.PagedDialog.js * Add editable config option which shows outline controls under the outline * Pass through movable config option when creating pages ve.ui.MWTranclusionDialog.js * Configure paged dialog outline as editable * Add initialize method to connect outline controls widget events * Make addPart method automatically add parameters when templates are added * Add handler for outline controls move event which re-orders parts * Make parts movable (params are automatically ordered, so they aren't movable) ve.dm.MWTransclusionModel.js * Add addPart method and use it within the addContent and addTemplate methods * Fix documentation lies * Add getPartFromId method *.php * Add links to new files and messages Change-Id: I919d4c3e9b85d07a97a99c0b2e8739a859bdf2b1
97 lines
2.2 KiB
JavaScript
97 lines
2.2 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface OutlineItemWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.OutlineItemWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.OptionWidget
|
|
*
|
|
* @constructor
|
|
* @param {Mixed} data Item data
|
|
* @param {Object} [config] Config options
|
|
* @cfg {string} [icon] Symbolic name of icon
|
|
* @cfg {number} [level] Indentation level
|
|
* @cfg {boolean} [moveable] Allow modification from outline controls
|
|
*/
|
|
ve.ui.OutlineItemWidget = function VeUiOutlineItemWidget( data, config ) {
|
|
// Config intialization
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
ve.ui.OptionWidget.call( this, data, config );
|
|
|
|
// Properties
|
|
this.level = 0;
|
|
this.moveable = !!config.moveable;
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-outlineItemWidget' );
|
|
if ( config.icon ) {
|
|
this.$.addClass( 've-ui-icon-' + config.icon );
|
|
}
|
|
this.setLevel( config.level );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.OutlineItemWidget, ve.ui.OptionWidget );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.OutlineItemWidget.static.highlightable = false;
|
|
|
|
ve.ui.OutlineItemWidget.static.levelClass = 've-ui-outlineItemWidget-level-';
|
|
|
|
ve.ui.OutlineItemWidget.static.levels = 3;
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Check if item is moveable.
|
|
*
|
|
* Moveablilty is used by outline controls.
|
|
*
|
|
* @returns {boolean} Item is moveable
|
|
*/
|
|
ve.ui.OutlineItemWidget.prototype.isMoveable = function () {
|
|
return this.moveable;
|
|
};
|
|
|
|
/**
|
|
* Get indentation level.
|
|
*
|
|
* @returns {number} Indentation level
|
|
*/
|
|
ve.ui.OutlineItemWidget.prototype.getLevel = function () {
|
|
return this.level;
|
|
};
|
|
|
|
/**
|
|
* Set indentation level.
|
|
*
|
|
* @method
|
|
* @param {number} [level=0] Indentation level, in the range of [0,#maxLevel]
|
|
* @chainable
|
|
*/
|
|
ve.ui.OutlineItemWidget.prototype.setLevel = function ( level ) {
|
|
var levels = this.constructor.static.levels,
|
|
levelClass = this.constructor.static.levelClass,
|
|
i = levels;
|
|
|
|
this.level = level ? Math.max( 0, Math.min( levels - 1, level ) ) : 0;
|
|
while ( i-- ) {
|
|
if ( this.level === i ) {
|
|
this.$.addClass( levelClass + i );
|
|
} else {
|
|
this.$.removeClass( levelClass + i );
|
|
}
|
|
}
|
|
|
|
return this;
|
|
};
|