mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Minor code cleanups in forked BookletLayout and related
E.g. renaming variables and moving code around. No functional change. Change-Id: I39e76356c62a0d1bcdf1d20bc8215f09604ad07d
This commit is contained in:
parent
f67033a82d
commit
741dbe5ccf
|
@ -89,7 +89,7 @@ ve.ui.MWTransclusionDialog.prototype.onOutlineControlsMove = function ( places )
|
||||||
// Move part to new location, and if dialog is loaded switch to new part page
|
// Move part to new location, and if dialog is loaded switch to new part page
|
||||||
var promise = this.transclusionModel.addPart( part, newPlace );
|
var promise = this.transclusionModel.addPart( part, newPlace );
|
||||||
if ( this.loaded && !this.preventReselection ) {
|
if ( this.loaded && !this.preventReselection ) {
|
||||||
// FIXME: Should be handled internally to bookletLayout.
|
// FIXME: Should be handled internally {@see ve.ui.MWTwoPaneTransclusionDialogLayout}
|
||||||
promise.done( this.bookletLayout.focusPart.bind( this.bookletLayout, part.getId() ) );
|
promise.done( this.bookletLayout.focusPart.bind( this.bookletLayout, part.getId() ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -109,8 +109,8 @@ ve.ui.MWTransclusionDialog.prototype.onOutlineControlsRemove = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemId = this.bookletLayout.getSelectedTopLevelPartId(),
|
var partId = this.bookletLayout.getSelectedTopLevelPartId(),
|
||||||
part = this.transclusionModel.getPartFromId( itemId );
|
part = this.transclusionModel.getPartFromId( partId );
|
||||||
if ( part ) {
|
if ( part ) {
|
||||||
this.transclusionModel.removePart( part );
|
this.transclusionModel.removePart( part );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Specialized layout similar to BookletLayout, but to synchronize the sidebar
|
* Specialized layout forked from and similar to {@see OO.ui.BookletLayout}, but to synchronize the
|
||||||
* and content pane of the transclusion dialog
|
* sidebar and content pane of the transclusion dialog.
|
||||||
*
|
*
|
||||||
* Also owns the outline controls.
|
* Also owns the outline controls.
|
||||||
*
|
*
|
||||||
|
@ -22,9 +22,6 @@
|
||||||
* pane, but has no corresponding item in the sidebar.
|
* pane, but has no corresponding item in the sidebar.
|
||||||
*/
|
*/
|
||||||
ve.ui.MWTwoPaneTransclusionDialogLayout = function VeUiMWTwoPaneTransclusionDialogLayout( config ) {
|
ve.ui.MWTwoPaneTransclusionDialogLayout = function VeUiMWTwoPaneTransclusionDialogLayout( config ) {
|
||||||
// Configuration initialization
|
|
||||||
config = config || {};
|
|
||||||
|
|
||||||
// Parent constructor
|
// Parent constructor
|
||||||
ve.ui.MWTwoPaneTransclusionDialogLayout.super.call( this, config );
|
ve.ui.MWTwoPaneTransclusionDialogLayout.super.call( this, config );
|
||||||
|
|
||||||
|
@ -159,12 +156,12 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.onSidebarItemSelected = functi
|
||||||
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.toggleOutline = function ( show ) {
|
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.toggleOutline = function ( show ) {
|
||||||
this.toggleMenu( show );
|
this.toggleMenu( show );
|
||||||
if ( show ) {
|
if ( show ) {
|
||||||
var booklet = this;
|
var self = this;
|
||||||
// HACK: Kill dumb scrollbars when the sidebar stops animating, see T161798.
|
// HACK: Kill dumb scrollbars when the sidebar stops animating, see T161798.
|
||||||
// Only necessary when outline controls are present, delay matches transition on
|
// Only necessary when outline controls are present, delay matches transition on
|
||||||
// `.oo-ui-menuLayout-menu`.
|
// `.oo-ui-menuLayout-menu`.
|
||||||
setTimeout( function () {
|
setTimeout( function () {
|
||||||
OO.ui.Element.static.reconsiderScrollbars( booklet.outlinePanel.$element[ 0 ] );
|
OO.ui.Element.static.reconsiderScrollbars( self.outlinePanel.$element[ 0 ] );
|
||||||
}, OO.ui.theme.getDialogTransitionDuration() );
|
}, OO.ui.theme.getDialogTransitionDuration() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -345,18 +342,15 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.setPage = function ( name ) {
|
||||||
*/
|
*/
|
||||||
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.refreshControls = function () {
|
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.refreshControls = function () {
|
||||||
var partId = this.getSelectedTopLevelPartId(),
|
var partId = this.getSelectedTopLevelPartId(),
|
||||||
pages = this.stackLayout.getItems(),
|
|
||||||
page = this.getPage( partId ),
|
|
||||||
index = pages.indexOf( page ),
|
|
||||||
isPart = !!partId,
|
|
||||||
canMoveUp, canMoveDown = false,
|
canMoveUp, canMoveDown = false,
|
||||||
canBeDeleted = isPart;
|
canBeDeleted = !!partId;
|
||||||
|
|
||||||
/* check if this is the first element and no parameter */
|
if ( partId ) {
|
||||||
canMoveUp = isPart && index > 0;
|
var pages = this.stackLayout.getItems(),
|
||||||
|
page = this.getPage( partId ),
|
||||||
/* check if this is the last element and no parameter */
|
index = pages.indexOf( page );
|
||||||
if ( isPart ) {
|
canMoveUp = index > 0;
|
||||||
|
// Check if there is at least one more top-level part below the current one
|
||||||
for ( var i = index + 1; i < pages.length; i++ ) {
|
for ( var i = index + 1; i < pages.length; i++ ) {
|
||||||
if ( !( pages[ i ] instanceof ve.ui.MWParameterPage || pages[ i ] instanceof ve.ui.MWAddParameterPage ) ) {
|
if ( !( pages[ i ] instanceof ve.ui.MWParameterPage || pages[ i ] instanceof ve.ui.MWAddParameterPage ) ) {
|
||||||
canMoveDown = true;
|
canMoveDown = true;
|
||||||
|
|
|
@ -157,7 +157,7 @@ ve.ui.MWTransclusionOutlineWidget.prototype.setSelectionByPageName = function (
|
||||||
* @param {boolean} hasValue
|
* @param {boolean} hasValue
|
||||||
*/
|
*/
|
||||||
ve.ui.MWTransclusionOutlineWidget.prototype.toggleHasValueByPageName = function ( pageName, hasValue ) {
|
ve.ui.MWTransclusionOutlineWidget.prototype.toggleHasValueByPageName = function ( pageName, hasValue ) {
|
||||||
var idParts = pageName.split( '/' ),
|
var idParts = pageName.split( '/', 2 ),
|
||||||
templatePartWidget = this.partWidgets[ idParts[ 0 ] ];
|
templatePartWidget = this.partWidgets[ idParts[ 0 ] ];
|
||||||
|
|
||||||
templatePartWidget.toggleHasValue( idParts[ 1 ], hasValue );
|
templatePartWidget.toggleHasValue( idParts[ 1 ], hasValue );
|
||||||
|
|
Loading…
Reference in a new issue