Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/241229
Change subject: MWLinkAnnotationInspector: Use TitleSearchWidget instead of TitleInputWidget ...................................................................... MWLinkAnnotationInspector: Use TitleSearchWidget instead of TitleInputWidget Depends on I335bd912d in MediaWiki core. Bug: T101169 Change-Id: I2932c9df5444d1363af5af9b438bb905ed298148 --- M modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js M modules/ve-mw/ui/styles/inspectors/ve.ui.MWLinkAnnotationInspector.css M modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js 3 files changed, 47 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/29/241229/1 diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js index 63e7b64..e58ebbe 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js @@ -46,14 +46,9 @@ * @inheritdoc */ ve.ui.MWLinkAnnotationInspector.prototype.initialize = function () { - var overlay = this.manager.getOverlay(); - // Properties this.allowProtocolInInternal = false; - this.internalAnnotationInput = new ve.ui.MWInternalLinkAnnotationWidget( { - // Sub-classes may want to know where to position overlays - $overlay: overlay ? overlay.$element : this.$frame - } ); + this.internalAnnotationInput = new ve.ui.MWInternalLinkAnnotationWidget(); this.externalAnnotationInput = new ve.ui.MWExternalLinkAnnotationWidget(); this.linkTypeSelect = new OO.ui.TabSelectWidget( { @@ -76,6 +71,12 @@ this.linkTypeSelect.connect( this, { select: 'onLinkTypeSelectSelect' } ); this.internalAnnotationInput.connect( this, { change: 'onInternalLinkChange' } ); this.externalAnnotationInput.connect( this, { change: 'onExternalLinkChange' } ); + + this.internalAnnotationInput.input.results.connect( this, { + add: 'onInternalLinkChangeResultsChange' + // Listening to remove causes a flicker, and is not required + // as 'add' is always trigger on a change too + } ); // Parent method ve.ui.MWLinkAnnotationInspector.super.prototype.initialize.call( this ); @@ -126,6 +127,16 @@ this.linkTypeSelect.selectItemByData( 'external' ); } this.updateActions(); +}; + +/** + * Handle list change events ('add') from the interal link's result widget + * + * @param {OO.ui.OptionWidget[]} items Added items + * @param {number} index Index of insertion point + */ +ve.ui.MWLinkAnnotationInspector.prototype.onInternalLinkChangeResultsChange = function () { + this.updateSize(); }; /** @@ -186,16 +197,6 @@ this.initialAnnotation instanceof ve.dm.MWExternalLinkAnnotation ? 'external' : 'internal' ); this.annotationInput.setAnnotation( this.initialAnnotation ); - }, this ); -}; - -/** - * @inheritdoc - */ -ve.ui.MWLinkAnnotationInspector.prototype.getReadyProcess = function ( data ) { - return ve.ui.MWLinkAnnotationInspector.super.prototype.getReadyProcess.call( this, data ) - .next( function () { - this.internalAnnotationInput.getTextInputWidget().populateLookupMenu(); }, this ); }; @@ -271,10 +272,6 @@ this.annotationInput.getTextInputWidget().setValue( text ).focus(); // Firefox moves the cursor to the beginning this.annotationInput.getTextInputWidget().$input[ 0 ].setSelectionRange( end, end ); - - if ( !isExternal ) { - this.annotationInput.getTextInputWidget().populateLookupMenu(); - } }; /** diff --git a/modules/ve-mw/ui/styles/inspectors/ve.ui.MWLinkAnnotationInspector.css b/modules/ve-mw/ui/styles/inspectors/ve.ui.MWLinkAnnotationInspector.css index 85c2b18..05d1bb2 100644 --- a/modules/ve-mw/ui/styles/inspectors/ve.ui.MWLinkAnnotationInspector.css +++ b/modules/ve-mw/ui/styles/inspectors/ve.ui.MWLinkAnnotationInspector.css @@ -7,4 +7,24 @@ .ve-ui-mwLinkAnnotationInspector-linkTypeSelect { margin: -0.75em -0.75em 0.75em -0.75em; -} \ No newline at end of file +} + +.ve-ui-linkAnnotationWidget .mw-widget-titleSearchWidget { + position: relative; +} + +.ve-ui-linkAnnotationWidget .mw-widget-titleSearchWidget .oo-ui-searchWidget-query { + padding: 0; + height: auto; + border: 0; +} + +.ve-ui-linkAnnotationWidget .mw-widget-titleSearchWidget .oo-ui-searchWidget-query .oo-ui-textInputWidget { + margin: 0; +} + +.ve-ui-linkAnnotationWidget .mw-widget-titleSearchWidget .oo-ui-searchWidget-results { + position: relative; + top: 0; + padding: 3em 0 0 0; +} diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js index 9a86617..dfa5567 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js @@ -53,13 +53,19 @@ * @return {OO.ui.TextInputWidget} Text input widget */ ve.ui.MWInternalLinkAnnotationWidget.prototype.createInputWidget = function ( config ) { - return new mw.widgets.TitleInputWidget( { - $overlay: config.$overlay, + return new mw.widgets.TitleSearchWidget( ve.extendObject( { icon: 'search', showImages: mw.config.get( 'wgVisualEditor' ).usePageImages, showDescriptions: mw.config.get( 'wgVisualEditor' ).usePageDescriptions, cache: ve.init.platform.linkCache - } ); + }, config ) ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWInternalLinkAnnotationWidget.prototype.getTextInputWidget = function () { + return this.input.query; }; /** -- To view, visit https://gerrit.wikimedia.org/r/241229 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2932c9df5444d1363af5af9b438bb905ed298148 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits