mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Minor code cleanups in forked BookletLayout and related"
This commit is contained in:
commit
6422e69821
|
@ -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
|
||||
var promise = this.transclusionModel.addPart( part, newPlace );
|
||||
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() ) );
|
||||
}
|
||||
};
|
||||
|
@ -109,8 +109,8 @@ ve.ui.MWTransclusionDialog.prototype.onOutlineControlsRemove = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var itemId = this.bookletLayout.getSelectedTopLevelPartId(),
|
||||
part = this.transclusionModel.getPartFromId( itemId );
|
||||
var partId = this.bookletLayout.getSelectedTopLevelPartId(),
|
||||
part = this.transclusionModel.getPartFromId( partId );
|
||||
if ( part ) {
|
||||
this.transclusionModel.removePart( part );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* Specialized layout similar to BookletLayout, but to synchronize the sidebar
|
||||
* and content pane of the transclusion dialog
|
||||
* Specialized layout forked from and similar to {@see OO.ui.BookletLayout}, but to synchronize the
|
||||
* sidebar and content pane of the transclusion dialog.
|
||||
*
|
||||
* Also owns the outline controls.
|
||||
*
|
||||
|
@ -22,9 +22,6 @@
|
|||
* pane, but has no corresponding item in the sidebar.
|
||||
*/
|
||||
ve.ui.MWTwoPaneTransclusionDialogLayout = function VeUiMWTwoPaneTransclusionDialogLayout( config ) {
|
||||
// Configuration initialization
|
||||
config = config || {};
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTwoPaneTransclusionDialogLayout.super.call( this, config );
|
||||
|
||||
|
@ -159,12 +156,12 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.onSidebarItemSelected = functi
|
|||
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.toggleOutline = function ( show ) {
|
||||
this.toggleMenu( show );
|
||||
if ( show ) {
|
||||
var booklet = this;
|
||||
var self = this;
|
||||
// HACK: Kill dumb scrollbars when the sidebar stops animating, see T161798.
|
||||
// Only necessary when outline controls are present, delay matches transition on
|
||||
// `.oo-ui-menuLayout-menu`.
|
||||
setTimeout( function () {
|
||||
OO.ui.Element.static.reconsiderScrollbars( booklet.outlinePanel.$element[ 0 ] );
|
||||
OO.ui.Element.static.reconsiderScrollbars( self.outlinePanel.$element[ 0 ] );
|
||||
}, OO.ui.theme.getDialogTransitionDuration() );
|
||||
}
|
||||
};
|
||||
|
@ -345,18 +342,15 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.setPage = function ( name ) {
|
|||
*/
|
||||
ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.refreshControls = function () {
|
||||
var partId = this.getSelectedTopLevelPartId(),
|
||||
pages = this.stackLayout.getItems(),
|
||||
page = this.getPage( partId ),
|
||||
index = pages.indexOf( page ),
|
||||
isPart = !!partId,
|
||||
canMoveUp, canMoveDown = false,
|
||||
canBeDeleted = isPart;
|
||||
canBeDeleted = !!partId;
|
||||
|
||||
/* check if this is the first element and no parameter */
|
||||
canMoveUp = isPart && index > 0;
|
||||
|
||||
/* check if this is the last element and no parameter */
|
||||
if ( isPart ) {
|
||||
if ( partId ) {
|
||||
var pages = this.stackLayout.getItems(),
|
||||
page = this.getPage( partId ),
|
||||
index = pages.indexOf( page );
|
||||
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++ ) {
|
||||
if ( !( pages[ i ] instanceof ve.ui.MWParameterPage || pages[ i ] instanceof ve.ui.MWAddParameterPage ) ) {
|
||||
canMoveDown = true;
|
||||
|
|
|
@ -157,7 +157,7 @@ ve.ui.MWTransclusionOutlineWidget.prototype.setSelectionByPageName = function (
|
|||
* @param {boolean} hasValue
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineWidget.prototype.toggleHasValueByPageName = function ( pageName, hasValue ) {
|
||||
var idParts = pageName.split( '/' ),
|
||||
var idParts = pageName.split( '/', 2 ),
|
||||
templatePartWidget = this.partWidgets[ idParts[ 0 ] ];
|
||||
|
||||
templatePartWidget.toggleHasValue( idParts[ 1 ], hasValue );
|
||||
|
|
Loading…
Reference in a new issue