[MediaWiki-commits] [Gerrit] Reduce the code duplication in applyTranslationTemplate method - change (mediawiki...ContentTranslation)

2015-07-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Reduce the code duplication in applyTranslationTemplate method
..


Reduce the code duplication in applyTranslationTemplate method

Change-Id: If38aa7cf381cb72a136a038724d29bf38e7b6fd4
---
M modules/translation/ext.cx.translation.js
1 file changed, 11 insertions(+), 23 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index f7081ea..41e5247 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -265,39 +265,27 @@
'data-cx-state': 'source'
} );
 
-   if ( origin === 'mt-user-disabled' ) {
+   if ( origin === 'mt-user-disabled' || origin === 
'clear' ) {
$clone.attr( 'data-cx-state', 'empty' );
-   if ( $sourceSection.prop( 'tagName' ) === 
'FIGURE' ) {
-   // Clear figure caption alone.
-   $clone.find( 'figcaption' ).empty();
+   if ( $sourceSection.is( 'figure' ) ) {
+   if ( origin === 'clear' ) {
+   // When clearing figures, 
replace it with placeholder.
+   $clone = getPlaceholder( 
sourceId ).attr( 'data-cx-section-type', 'figure' );
+   } else {
+   // Clear figure caption alone.
+   $clone.find( 'figcaption' 
).empty();
+   }
} else if ( $sourceSection.is( 'ul, ol' ) ) {
-   $clone = $sourceSection.clone();
// Explicit contenteditable attribute 
helps to place the cursor
-   // in empty UL.
+   // in empty  or .
$clone.prop( 'contenteditable', true 
).find( 'li' ).empty();
} else {
$clone.empty();
}
}
-
-   if ( origin === 'clear' ) {
-   $clone.attr( 'data-cx-state', 'empty' );
-   if ( $sourceSection.prop( 'tagName' ) === 
'FIGURE' ) {
-   // When clearing figures, replace it 
with placeholder.
-   $clone = getPlaceholder( sourceId )
-   .attr( 'data-cx-section-type', 
$sourceSection.prop( 'tagName' ) );
-   } else if ( $sourceSection.is( 'ul, ol' ) ) {
-   $clone = $sourceSection.clone();
-   // Explicit contenteditable attribute 
helps to place the cursor
-   // in empty UL.
-   $clone.prop( 'contenteditable', true 
).find( 'li' ).empty();
-   } else {
-   $clone.empty();
-   }
-   } // else: service-failure, non-editable, 
mt-not-available
+   // else: service-failure, non-editable, mt-not-available
// Replace the placeholder with a translatable element
$section.replaceWith( $clone );
-
// $section was replaced. Get the updated instance.
$section = mw.cx.getTranslationSection( sourceId );
mw.hook( 'mw.cx.translation.postMT' ).fire( $section );

-- 
To view, visit https://gerrit.wikimedia.org/r/227203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If38aa7cf381cb72a136a038724d29bf38e7b6fd4
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh 
Gerrit-Reviewer: Amire80 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Reduce the code duplication in applyTranslationTemplate method - change (mediawiki...ContentTranslation)

2015-07-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227203

Change subject: Reduce the code duplication in applyTranslationTemplate method
..

Reduce the code duplication in applyTranslationTemplate method

Change-Id: If38aa7cf381cb72a136a038724d29bf38e7b6fd4
---
M modules/translation/ext.cx.translation.js
1 file changed, 11 insertions(+), 22 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/03/227203/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index f7081ea..c4365b6 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -265,39 +265,28 @@
'data-cx-state': 'source'
} );
 
-   if ( origin === 'mt-user-disabled' ) {
+   if ( origin === 'mt-user-disabled' || origin === 
'clear' ) {
$clone.attr( 'data-cx-state', 'empty' );
-   if ( $sourceSection.prop( 'tagName' ) === 
'FIGURE' ) {
-   // Clear figure caption alone.
-   $clone.find( 'figcaption' ).empty();
+   if ( $sourceSection.is( 'figure' ) ) {
+   if ( origin === 'clear' ) {
+   // When clearing figures, 
replace it with placeholder.
+   $clone = getPlaceholder( 
sourceId ).attr( 'data-cx-section-type', 'figure' );
+   } else {
+   // Clear figure caption alone.
+   $clone.find( 'figcaption' 
).empty();
+   }
} else if ( $sourceSection.is( 'ul, ol' ) ) {
$clone = $sourceSection.clone();
// Explicit contenteditable attribute 
helps to place the cursor
-   // in empty UL.
+   // in empty  or .
$clone.prop( 'contenteditable', true 
).find( 'li' ).empty();
} else {
$clone.empty();
}
}
-
-   if ( origin === 'clear' ) {
-   $clone.attr( 'data-cx-state', 'empty' );
-   if ( $sourceSection.prop( 'tagName' ) === 
'FIGURE' ) {
-   // When clearing figures, replace it 
with placeholder.
-   $clone = getPlaceholder( sourceId )
-   .attr( 'data-cx-section-type', 
$sourceSection.prop( 'tagName' ) );
-   } else if ( $sourceSection.is( 'ul, ol' ) ) {
-   $clone = $sourceSection.clone();
-   // Explicit contenteditable attribute 
helps to place the cursor
-   // in empty UL.
-   $clone.prop( 'contenteditable', true 
).find( 'li' ).empty();
-   } else {
-   $clone.empty();
-   }
-   } // else: service-failure, non-editable, 
mt-not-available
+   // else: service-failure, non-editable, mt-not-available
// Replace the placeholder with a translatable element
$section.replaceWith( $clone );
-
// $section was replaced. Get the updated instance.
$section = mw.cx.getTranslationSection( sourceId );
mw.hook( 'mw.cx.translation.postMT' ).fire( $section );

-- 
To view, visit https://gerrit.wikimedia.org/r/227203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If38aa7cf381cb72a136a038724d29bf38e7b6fd4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits