mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Update new sidebar when moving template parts up/down"
This commit is contained in:
commit
f161868e6a
|
@ -26,9 +26,8 @@ ve.ui.MWTransclusionOutlineContainerWidget = function VeUiMWTransclusionOutlineC
|
|||
|
||||
// Events
|
||||
this.transclusionModel.connect( this, {
|
||||
replace: 'onReplacePart'
|
||||
// TODO
|
||||
// change: 'onTransclusionModelChange'
|
||||
replace: 'onReplacePart',
|
||||
change: 'onTransclusionModelChange'
|
||||
} );
|
||||
|
||||
this.$element.addClass( 've-ui-mwTransclusionOutlineContainerWidget' );
|
||||
|
@ -56,6 +55,24 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.onReplacePart = function (
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineContainerWidget.prototype.onTransclusionModelChange = function () {
|
||||
var newOrder = this.transclusionModel.getParts();
|
||||
|
||||
for ( var i = 0; i < newOrder.length; i++ ) {
|
||||
var expectedWidget = this.partWidgets[ newOrder[ i ].getId() ],
|
||||
$expectedElement = expectedWidget && expectedWidget.$element,
|
||||
$currentElement = this.$element.children().eq( i );
|
||||
|
||||
if ( !$currentElement.is( $expectedElement ) ) {
|
||||
// Move each widget to the correct position if it wasn't there before
|
||||
$currentElement.before( $expectedElement );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
* @extends OO.ui.Widget
|
||||
*
|
||||
* @constructor
|
||||
* @param {ve.dm.MWTransclusionPartModel} part
|
||||
* @param {Object} [config]
|
||||
* @cfg {string} [icon='']
|
||||
* @cfg {string} [label]
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( config ) {
|
||||
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( part, config ) {
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, config );
|
||||
|
||||
|
@ -25,11 +26,15 @@ ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWi
|
|||
OO.ui.mixin.IconElement.call( this, config );
|
||||
OO.ui.mixin.LabelElement.call( this, config );
|
||||
|
||||
this.id = part.getId();
|
||||
|
||||
this.$header = $( '<div>' )
|
||||
.addClass( 've-ui-mwTransclusionOutlinePartWidget-header' )
|
||||
.prepend( this.$icon, this.$label );
|
||||
this.$element
|
||||
.addClass( 've-ui-mwTransclusionOutlinePartWidget' )
|
||||
// Note: There is no code that uses this. It just helps when manually inspecting the HTML.
|
||||
.attr( 'data-transclusion-part-id', part.getId() )
|
||||
.prepend( this.$header );
|
||||
};
|
||||
|
||||
|
@ -40,3 +45,10 @@ OO.mixinClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.mixin.IconElement );
|
|||
OO.mixinClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.mixin.LabelElement );
|
||||
// TODO: Add OO.ui.mixin.AccessKeyedElement?
|
||||
// TODO: Add OO.ui.mixin.TitledElement?
|
||||
|
||||
/**
|
||||
* @return {string} Identifier of the {@see ve.dm.MWTransclusionPartModel} this widget represents
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlinePartWidget.prototype.getId = function () {
|
||||
return this.id;
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ ve.ui.MWTransclusionOutlinePlaceholderWidget = function VeUiMWTransclusionOutlin
|
|||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlinePlaceholderWidget.super.call( this, config );
|
||||
ve.ui.MWTransclusionOutlinePlaceholderWidget.super.call( this, placeholder, config );
|
||||
|
||||
this.placeholder = placeholder;
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTe
|
|||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.super.call( this, config );
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.super.call( this, template, config );
|
||||
|
||||
// Initialization
|
||||
this.templateModel = template.connect( this, {
|
||||
|
|
|
@ -14,7 +14,7 @@ ve.ui.MWTransclusionOutlineWikitextWidget = function VeUiMWTransclusionOutlineWi
|
|||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlineWikitextWidget.super.call( this, config );
|
||||
ve.ui.MWTransclusionOutlineWikitextWidget.super.call( this, content, config );
|
||||
|
||||
this.content = content;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue