mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
Merge "Highlight corresponding template parameter in new sidebar"
This commit is contained in:
commit
c8e00fb98a
|
@ -488,9 +488,14 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) {
|
||||||
filterParameters: 'onFilterParameters',
|
filterParameters: 'onFilterParameters',
|
||||||
focusPart: 'focusPart'
|
focusPart: 'focusPart'
|
||||||
} );
|
} );
|
||||||
|
// FIXME: Check if we can merge these two "set"/"focusin" event handlers
|
||||||
this.bookletLayout.connect( this, {
|
this.bookletLayout.connect( this, {
|
||||||
set: 'onBookletLayoutSetPage'
|
set: 'onBookletLayoutSetPage'
|
||||||
} );
|
} );
|
||||||
|
this.bookletLayout.stackLayout.$element.on(
|
||||||
|
'focusin',
|
||||||
|
this.onBookletLayoutPageFocused.bind( this )
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.pocSidebar.clear();
|
this.pocSidebar.clear();
|
||||||
}
|
}
|
||||||
|
@ -636,6 +641,22 @@ ve.ui.MWTemplateDialog.prototype.onBookletLayoutSetPage = function ( page ) {
|
||||||
this.pocSidebar.selectPartById( partId );
|
this.pocSidebar.selectPartById( partId );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modeled after {@see OO.ui.BookletLayout.onStackLayoutFocus}.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {jQuery.Event} e
|
||||||
|
*/
|
||||||
|
ve.ui.MWTemplateDialog.prototype.onBookletLayoutPageFocused = function ( e ) {
|
||||||
|
var $focusedPage = $( e.target ).closest( '.oo-ui-pageLayout' );
|
||||||
|
for ( var pageName in this.bookletLayout.pages ) {
|
||||||
|
if ( this.bookletLayout.getPage( pageName ).$element[ 0 ] === $focusedPage[ 0 ] ) {
|
||||||
|
this.pocSidebar.highlightSubItemByPageName( pageName );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -143,6 +143,19 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.selectPartById = function (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} pageName
|
||||||
|
*/
|
||||||
|
ve.ui.MWTransclusionOutlineContainerWidget.prototype.highlightSubItemByPageName = function ( pageName ) {
|
||||||
|
var ids = pageName.split( '/', 2 ),
|
||||||
|
partId = ids[ 0 ],
|
||||||
|
paramName = ids[ 1 ];
|
||||||
|
// Note this code-path (currently) doesn't care about top-level parts
|
||||||
|
if ( partId in this.partWidgets && paramName !== undefined ) {
|
||||||
|
this.partWidgets[ partId ].highlightParameter( paramName );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is inspired by {@see OO.ui.SelectWidget.findSelectedItem}, but isn't one.
|
* This is inspired by {@see OO.ui.SelectWidget.findSelectedItem}, but isn't one.
|
||||||
*
|
*
|
||||||
|
|
|
@ -68,6 +68,18 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.addItems = function (
|
||||||
return ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.addItems.call( this, items, index );
|
return ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.addItems.call( this, items, index );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} paramName
|
||||||
|
*/
|
||||||
|
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightParameter = function ( paramName ) {
|
||||||
|
var item = this.findItemFromData( paramName );
|
||||||
|
// Intentionally drop any highlighting if the parameter can't be found
|
||||||
|
this.highlightItem( item );
|
||||||
|
if ( item ) {
|
||||||
|
this.scrollItemIntoView( item );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} paramName
|
* @param {string} paramName
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -118,6 +118,13 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.findCanonicalPosition = func
|
||||||
return insertAt;
|
return insertAt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} paramName
|
||||||
|
*/
|
||||||
|
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.highlightParameter = function ( paramName ) {
|
||||||
|
this.parameters.highlightParameter( paramName );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ve.dm.MWParameterModel} param
|
* @param {ve.dm.MWParameterModel} param
|
||||||
|
|
Loading…
Reference in a new issue