Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/206097
Change subject: Avoid page scroll when reference list added automatically ...................................................................... Avoid page scroll when reference list added automatically Avoid setting focus to that section added automatically Bug: T96575 Change-Id: I2a648c8cf448e09d1102bf60681b5eecd339c700 --- M modules/tools/ext.cx.tools.reference.js M modules/translation/ext.cx.translation.js 2 files changed, 15 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/97/206097/1 diff --git a/modules/tools/ext.cx.tools.reference.js b/modules/tools/ext.cx.tools.reference.js index 2b6c631..b604753 100644 --- a/modules/tools/ext.cx.tools.reference.js +++ b/modules/tools/ext.cx.tools.reference.js @@ -132,7 +132,7 @@ // Reference list not the section, it is wrapped inside. $parentSection = $referenceList.parent(); } - mw.hook( 'mw.cx.translation.add' ).fire( $parentSection.attr( 'id' ), 'click' ); + mw.hook( 'mw.cx.translation.add' ).fire( $parentSection.attr( 'id' ), 'reference' ); } ); } }; diff --git a/modules/translation/ext.cx.translation.js b/modules/translation/ext.cx.translation.js index b76b0b3..d57edd4 100644 --- a/modules/translation/ext.cx.translation.js +++ b/modules/translation/ext.cx.translation.js @@ -166,7 +166,7 @@ * @param {jQuery} $section */ ContentTranslationEditor.prototype.postProcessMT = function ( $section ) { - var selection, $sourceSection; + var $sourceSection; if ( !$section || !$section.length ) { // Empty references in some articles cause this. @@ -195,15 +195,6 @@ } else { $section.cxEditor(); } - - // Set the focus on the new section. - // Rely on browser behavior for setting the cursor position. - // Will generally go to the beginning of the section. - $section[ 0 ].focus(); - - // Capture and save the new selection and cursor position - selection = mw.cx.selection.get(); - mw.cx.selection.save( 'translation', selection ); // Search for text that was selected using the mouse. // Delay it to run every 250 ms so it won't fire all the time while typing. @@ -238,7 +229,7 @@ sourceId, origin ) { - var $sourceSection, $section, $clone; + var $sourceSection, $section, $clone, selection; $sourceSection = mw.cx.getSourceSection( sourceId ); $section = mw.cx.getTranslationSection( sourceId ); @@ -284,6 +275,16 @@ $section = mw.cx.getTranslationSection( sourceId ); mw.hook( 'mw.cx.translation.postMT' ).fire( $section ); } + // Set the focus on the new section. + // Rely on browser behavior for setting the cursor position. + // Will generally go to the beginning of the section. + if ( origin !== 'reference' ) { + // Do not focus reference. Page will scroll. + $section.focus(); + // Capture and save the new selection and cursor position + selection = mw.cx.selection.get(); + mw.cx.selection.save( 'translation', selection ); + } }; /** @@ -324,7 +325,7 @@ * Fill in the preceding parent heading, if not yet filled * @param {string} sectionId Source section Id */ - ContentTranslationEditor.prototype.addSectionHeader = function ( sectionId ) { + ContentTranslationEditor.prototype.addSectionHeader = function ( sectionId, origin ) { var $currentSection, $previousSection; $currentSection = mw.cx.getTranslationSection( sectionId ); @@ -337,7 +338,7 @@ $currentSection.data( 'cx-section-type' ) ) ) { - mw.hook( 'mw.cx.translation.add' ).fire( $previousSection.data( 'source' ), 'click' ); + mw.hook( 'mw.cx.translation.add' ).fire( $previousSection.data( 'source' ), origin ); } }; -- To view, visit https://gerrit.wikimedia.org/r/206097 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2a648c8cf448e09d1102bf60681b5eecd339c700 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits