summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/resources/js/ext.translate.messagetable.js')
-rw-r--r--MLEB/Translate/resources/js/ext.translate.messagetable.js98
1 files changed, 68 insertions, 30 deletions
diff --git a/MLEB/Translate/resources/js/ext.translate.messagetable.js b/MLEB/Translate/resources/js/ext.translate.messagetable.js
index f2ac9a0f..ba139bed 100644
--- a/MLEB/Translate/resources/js/ext.translate.messagetable.js
+++ b/MLEB/Translate/resources/js/ext.translate.messagetable.js
@@ -22,7 +22,8 @@
mcfilter: filter,
mcprop: 'definition|translation|tags|properties',
rawcontinue: 1,
- errorformat: 'html'
+ errorformat: 'html',
+ formatversion: 2
} );
}
} );
@@ -91,7 +92,7 @@
messageTable.switchMode( 'page' );
} );
- this.$proofreadOwnTranslations.click( function () {
+ this.$proofreadOwnTranslations.on( 'click', function () {
var $this = $( this ),
hideMessage = mw.msg( 'tux-editor-proofreading-hide-own-translations' ),
showMessage = mw.msg( 'tux-editor-proofreading-show-own-translations' );
@@ -124,7 +125,7 @@
*/
add: function ( message ) {
// Prepare the message for display
- mw.translateHooks.run( 'formatMessageBeforeTable', message );
+ mw.hook( 'mw.translate.messagetable.formatMessageBeforeTable' ).fire( message );
if ( this.mode === 'translate' ) {
this.addTranslate( message );
@@ -163,7 +164,7 @@
// Fuzzy translations need warning class
if ( status === 'fuzzy' ) {
- statusClass = statusClass + ' tux-warning';
+ statusClass = statusClass + ' tux-notice';
}
// Label the status if it is not untranslated
@@ -200,7 +201,7 @@
// unicode-bidi: isolate
// is supported everywhere
$( '<span>' )
- .html( $( 'body' ).hasClass( 'rtl' ) ? '&rlm;' : '&lrm;' ),
+ .html( $( document.body ).hasClass( 'rtl' ) ? '&rlm;' : '&lrm;' ),
$( '<span>' )
.addClass( 'tux-list-translation' )
.attr( {
@@ -214,6 +215,13 @@
.append(
$( '<span>' )
.addClass( statusClass )
+ // The following messages are used here:
+ // * tux-status-optional
+ // * tux-status-fuzzy
+ // * tux-status-proofread
+ // * tux-status-translated
+ // * tux-status-saving
+ // * tux-status-unsaved
.text( statusMsg ? mw.msg( statusMsg ) : '' )
),
$( '<div>' )
@@ -283,7 +291,7 @@
}
offset = $icon.offset();
- tooltip.$element.appendTo( 'body' );
+ tooltip.$element.appendTo( document.body );
tooltip.toggle( true ).toggleClipping( false ).togglePositioning( false );
tooltip.$element.css( {
top: offset.top + $icon.outerHeight() + 5,
@@ -375,10 +383,14 @@
},
resize: function () {
- var actualWidth = 0;
+ var actualWidth = 0, $messageSelector = $( '.row.tux-message-selector' );
+
+ if ( $messageSelector.is( ':hidden' ) ) {
+ return;
+ }
// Calculate the total width required for the filters
- $( '.row.tux-message-selector > li' ).each( function () {
+ $messageSelector.children( 'li' ).each( function () {
actualWidth += $( this ).outerWidth( true );
} );
@@ -412,6 +424,9 @@
mw.msg( 'tux-messagetable-loading-messages', this.$loader.data( 'pagesize' ) )
);
+ // Update the target language
+ this.$container.data( 'targetlangcode', this.settings.language );
+
// Reset the statsbar
this.$statsBar
.empty()
@@ -470,13 +485,23 @@
this.settings.filter
).done( function ( result ) {
var messages = result.query.messagecollection,
- state;
+ state, i;
if ( !self.loading ) {
// reject. This was cancelled.
return;
}
+ if ( result.warnings ) {
+ for ( i = 0; i !== result.warnings.length; i++ ) {
+ if ( result.warnings[ i ].code === 'translate-language-disabled-source' ) {
+ self.handleLoadErrors( [ result.warnings[ i ] ] );
+ break;
+ }
+ }
+ return;
+ }
+
if ( messages.length === 0 ) {
// And this is the first load for the filter...
if ( self.$container.children().length === 0 ) {
@@ -499,7 +524,7 @@
self.settings.group,
self.settings.language,
state
- );
+ ).removeClass( 'hide' );
// Dynamically loaded messages should pass the search filter if present.
query = $( '.tux-message-filter-box' ).val();
@@ -515,7 +540,7 @@
// Helpfully open the first message in show mode
// TODO: Refactor to avoid direct DOM access
- $( '.tux-message-item' ).first().click();
+ $( '.tux-message-item' ).first().trigger( 'click' );
} else {
self.$loader.data( 'offset', result[ 'query-continue' ].messagecollection.mcoffset );
@@ -532,18 +557,7 @@
self.updateHideOwnInProofreadingToggleVisibility();
self.updateLastMessage();
} ).fail( function ( errorCode, response ) {
- var $warningContainer = $( '.tux-editor-header .group-warning' );
-
- if ( response.errors ) {
- $.map( response.errors, function ( error ) {
- $warningContainer.append( error[ '*' ] );
- } );
- } else {
- $warningContainer.text( mw.msg( 'api-error-unknownerror', errorCode ) );
- }
- self.$loader.data( 'offset', -1 ).addClass( 'hide' );
- self.$actionBar.addClass( 'hide' );
- self.$header.addClass( 'hide' );
+ self.handleLoadErrors( response.errors, errorCode );
} ).always( function () {
self.$loaderIcon.addClass( 'tux-loading-indicator--stopped' );
self.loading = false;
@@ -622,7 +636,7 @@
.attr( 'href', '#' )
.text( mw.msg( 'tux-empty-show-optional-messages' ) )
.on( 'click', function ( e ) {
- $( '#tux-option-optional' ).click();
+ $( '#tux-option-optional' ).trigger( 'click' );
e.preventDefault();
} )
);
@@ -632,7 +646,7 @@
$actions.append( messageTable.otherActionButton(
'tux-empty-list-other-action',
function () {
- $( '.tux-tab-unproofread' ).click();
+ $( '.tux-tab-unproofread' ).trigger( 'click' );
// @todo untranslated
} )
);
@@ -652,7 +666,7 @@
$actions.append( messageTable.otherActionButton(
'tux-empty-you-can-review-already-proofread',
function () {
- $( '.tux-tab-translated' ).click();
+ $( '.tux-tab-translated' ).trigger( 'click' );
} )
);
}
@@ -666,7 +680,7 @@
$actions.append( messageTable.otherActionButton(
'tux-empty-list-translated-action',
function () {
- mw.translate.changeFilter( $( '.tux-tab-untranslated' ).click() );
+ mw.translate.changeFilter( $( '.tux-tab-untranslated' ).trigger( 'click' ) );
} )
);
} else {
@@ -684,8 +698,8 @@
$actions.append( $( '<a>' )
.text( mw.msg( 'tux-empty-list-other-link' ) )
- .click( function () {
- $( '.tux-tab-all' ).click();
+ .on( 'click', function () {
+ $( '.tux-tab-all' ).trigger( 'click' );
} )
);
}
@@ -768,7 +782,7 @@
$.each( messageTable.messages, function ( index, message ) {
messageTable.add( message );
} );
- } else if ( messageTable.initialized ) {
+ } else if ( messageTable.initialized && !messageTable.loading ) {
messageTable.displayEmptyListHelp();
}
@@ -828,6 +842,30 @@
} else if ( isActionBarFloating && needsActionBarFloat ) {
this.$actionBar.width( messageListWidth );
}
+ },
+
+ /**
+ * Handles errors encountered during the loading state.
+ * Displays the errors and updates the state of the table.
+ *
+ * @param {Array} errors
+ * @param {string} errorCode
+ */
+ handleLoadErrors: function ( errors, errorCode ) {
+ var $warningContainer = $( '.tux-editor-header .group-warning' );
+
+ if ( errors ) {
+ $.map( errors, function ( error ) {
+ $warningContainer.append( error.html );
+ } );
+ } else {
+ $warningContainer.text( mw.msg( 'api-error-unknownerror', errorCode ) );
+ }
+
+ $( '.tux-workflow' ).addClass( 'hide' );
+ this.$loader.data( 'offset', -1 ).addClass( 'hide' );
+ this.$actionBar.addClass( 'hide' );
+ this.$header.addClass( 'hide' );
}
};