BPositive has uploaded a new change for review. https://gerrit.wikimedia.org/r/135415
Change subject: Feature to add a new unit to facilitate manual splitting for Special:PageMigration ...................................................................... Feature to add a new unit to facilitate manual splitting for Special:PageMigration A new '+' icon has been added to add a new empty unit after the current one to allow manual splitting of the translation units. Bug: 65739 Change-Id: I2e794483665e7666117d410c33058550c7dd92cc --- M resources/css/ext.translate.special.pagemigration.css M resources/js/ext.translate.special.pagemigration.js 2 files changed, 52 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/15/135415/1 diff --git a/resources/css/ext.translate.special.pagemigration.css b/resources/css/ext.translate.special.pagemigration.css index 78a35ff..4a4113e 100644 --- a/resources/css/ext.translate.special.pagemigration.css +++ b/resources/css/ext.translate.special.pagemigration.css @@ -31,19 +31,21 @@ border: 2px solid transparent; } -#actions div:last-child .swap { +#actions div:last-child .swap, +#actions div:last-child .add { display: none; } .edit, .save-edit, .delete, -.swap { +.swap, +.add { width: 10%; height: 10%; float: left; - margin-left: 10%; - margin-right: 10%; + margin-left: 5%; + margin-right: 5%; cursor: pointer; } @@ -78,4 +80,11 @@ background: url('../images/label-tick.png') transparent; background-image: linear-gradient(transparent, transparent), url('../images/label-tick.png'); background-image: -webkit-linear-gradient(transparent, transparent), url('../images/label-tick.png'); +} + +.add { + display: inline-block; + background: url('../images/add.png'); + background-image: linear-gradient(transparent, transparent), url('../images/add.png'); + background-image: -webkit-linear-gradient(transparent, transparent), url('../images/add.png'); } \ No newline at end of file diff --git a/resources/js/ext.translate.special.pagemigration.js b/resources/js/ext.translate.special.pagemigration.js index 0915b63..b25419e 100644 --- a/resources/js/ext.translate.special.pagemigration.js +++ b/resources/js/ext.translate.special.pagemigration.js @@ -158,6 +158,23 @@ } /** + * Update the IDs of translation divs and action divs. This function is called + * when a unit is deleted or a new unit is added for manual splitting + */ + function updateIDs() { + var divNumber = 1; + $( '#translationunits div' ).each( function() { + $( this ).attr( 'id', 't' + ( divNumber ) ); + divNumber += 1; + } ); + divNumber = 1; + $( '#actions div' ).each( function() { + $( this ).attr( 'id', 'a' + ( divNumber ) ); + divNumber += 1; + } ); + } + + /** * Add empty RHS blocks to always match with the number of source units */ function addEmptyUnits() { @@ -170,14 +187,12 @@ return; } else { difference = noOfSourceUnits - noOfTranslationUnits; - previousID = Number( $( '#translationunits div:last' ).attr( 'id' ).replace( 't', '' ) ); for ( i = 1; i <= difference; i++ ) { - $( '<div>' ).attr( 'id', 't' + ( previousID + 1 ) ) - .appendTo( divTranslations ); - $( '<div>' ).attr( 'id', 'a' + ( previousID + 1 ) ) - .append( $( '<span>' ).attr( 'class', 'edit' ), + $( '<div>' ).appendTo( divTranslations ); + $( '<div>' ).append( $( '<span>' ).attr( 'class', 'edit' ), $( '<span>' ).attr( 'class', 'delete' ), - $( '<span>' ).attr( 'class', 'swap' ) ) + $( '<span>' ).attr( 'class', 'swap' ), + $( '<span>' ).attr( 'class', 'add' ) ) .appendTo( divActions ); previousID += 1; } @@ -199,7 +214,8 @@ $( '<div>' ).attr( 'id', 'a' + ( i + 1 ) ) .append( $( '<span>' ).attr( 'class', 'edit' ), $( '<span>' ).attr( 'class', 'delete' ), - $( '<span>' ).attr( 'class', 'swap' ) ) + $( '<span>' ).attr( 'class', 'swap' ), + $( '<span>' ).attr( 'class', 'add' ) ) .appendTo( divActions ); } } @@ -276,6 +292,20 @@ $( '#sourceunits, #translationunits, #actions' ).html( '' ); } ); + $( document ).on( 'click', '.add', function() { + var parentID, translationID; + parentID = $( this ).parent().attr( 'id' ); + translationID = 't' + parentID.replace( 'a' , '' ); + $( '<div>' ).insertAfter( '#' + translationID ); + $( '<div>' ).append( $( '<span>' ).attr( 'class', 'edit' ), + $( '<span>' ).attr( 'class', 'delete' ), + $( '<span>' ).attr( 'class', 'swap' ), + $( '<span>' ).attr( 'class', 'add' ) ) + .insertAfter( '#' + parentID ); + noOfTranslationUnits += 1; + updateIDs(); + } ); + $( document ).on( 'click', '.delete', function() { var parentID, translationID; parentID = $( this ).parent().attr( 'id' ); @@ -284,6 +314,7 @@ $( this ).parent().remove(); noOfTranslationUnits -= 1; addEmptyUnits(); + updateIDs(); } ); $( document ).on( 'click', '.save-edit', function() { @@ -336,6 +367,7 @@ showTranslationUnits( translations ); showActionIcons( noOfTranslationUnits ); addEmptyUnits(); + updateIDs(); $( '#buttonSavePages, #buttonCancel').show(); $( '#buttonImport' ).hide(); } ); -- To view, visit https://gerrit.wikimedia.org/r/135415 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2e794483665e7666117d410c33058550c7dd92cc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: BPositive <pr4tiklah...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits