Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/201105
Change subject: Improve automatic adding of reference list ...................................................................... Improve automatic adding of reference list * Handle the case of multiple reference lists in the page. For example, Notes and References Example: enwiki:Hydrogen * The reference list itself may not be the CX translation section if wrapped inside a section tag like divs Example: enwiki:Emily+Warren+Roebling has reference list as section while enwiki:Hydrogen has it wrapped Change-Id: I807ba3510a76b7c186a1738f0b78d3cdd8eaa7e2 --- M modules/tools/ext.cx.tools.reference.js 1 file changed, 20 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/05/201105/1 diff --git a/modules/tools/ext.cx.tools.reference.js b/modules/tools/ext.cx.tools.reference.js index 13b34fc..3360de5 100644 --- a/modules/tools/ext.cx.tools.reference.js +++ b/modules/tools/ext.cx.tools.reference.js @@ -109,18 +109,32 @@ }; /** - * Add the reference list, usually at the end of translation + * Add the reference list(s), usually at the end of translation */ ReferenceCard.prototype.addReferenceList = function () { - var $referenceList; + var $referenceLists, $parentSection; - $referenceList = $( '[typeof*="mw:Extension/references"]' ); + // There can be multiple reference lists grouped for notes and references + // For example see enwiki:Hydrogen + $referenceLists = $( '[typeof*="mw:Extension/references"]' ); - if ( $referenceList.length === 1 ) { - // Only one reference list - means the target reference list not added yet. - mw.hook( 'mw.cx.translation.add' ).fire( $referenceList.parent().attr( 'id' ), 'click' ); + if ( !$( '.cx-column--translation [typeof*="mw:Extension/references"]' ).length ) { + // Target reference list not added yet. + $referenceLists.each( function ( key, referenceList ) { + var $referenceList = $( referenceList ); + + if ( $referenceList.parent().is( '.cx-column__content' ) ) { + // Reference list is the section, + $parentSection = $referenceList; + } else { + // Reference list not the section, it is wrapped inside. + $parentSection = $referenceList.parent(); + } + mw.hook( 'mw.cx.translation.add' ).fire( $parentSection.attr( 'id' ), 'click' ); + } ); } }; + /** * Start presenting the reference card * @param {string} referenceId The reference element Identifier. -- To view, visit https://gerrit.wikimedia.org/r/201105 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I807ba3510a76b7c186a1738f0b78d3cdd8eaa7e2 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