summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2022-09-27 18:53:03 -0400
committerBrian Evans <grknight@gentoo.org>2022-09-27 19:02:02 -0400
commit5ca8d30155e11d97b20f79acec40632c2e06fcd5 (patch)
tree7531fb116791f8328c0bb0cabe42265ca67e6df9 /MLEB/Translate/resources/js
parentMerge branch 'master' into wikitest (diff)
downloadextensions-1.35.2.tar.gz
extensions-1.35.2.tar.bz2
extensions-1.35.2.zip
Update MLEB to 2021.12v1.35.2
This is the final version for MW 1.35 Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'MLEB/Translate/resources/js')
-rw-r--r--MLEB/Translate/resources/js/LanguagesMultiselectWidget.js5
-rw-r--r--MLEB/Translate/resources/js/ext.translate.base.js29
-rw-r--r--MLEB/Translate/resources/js/ext.translate.edit.documentation.js9
-rw-r--r--MLEB/Translate/resources/js/ext.translate.editor.helpers.js84
-rw-r--r--MLEB/Translate/resources/js/ext.translate.editor.js177
-rw-r--r--MLEB/Translate/resources/js/ext.translate.editor.shortcuts.js14
-rw-r--r--MLEB/Translate/resources/js/ext.translate.groupselector.js95
-rw-r--r--MLEB/Translate/resources/js/ext.translate.messagerenamedialog.js27
-rw-r--r--MLEB/Translate/resources/js/ext.translate.messagetable.js116
-rw-r--r--MLEB/Translate/resources/js/ext.translate.navitoggle.js10
-rw-r--r--MLEB/Translate/resources/js/ext.translate.pagemode.js41
-rw-r--r--MLEB/Translate/resources/js/ext.translate.pagetranslation.uls.js4
-rw-r--r--MLEB/Translate/resources/js/ext.translate.parsers.js5
-rw-r--r--MLEB/Translate/resources/js/ext.translate.proofread.js73
-rw-r--r--MLEB/Translate/resources/js/ext.translate.selecttoinput.js5
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.aggregategroups.js65
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.languagestats.js50
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.managegroups.js40
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.managetranslatorsandbox.js68
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.pagemigration.js166
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js88
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.pagetranslation.js23
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js99
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.translate.js70
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.translationstash.js256
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.translationstats.js13
-rw-r--r--MLEB/Translate/resources/js/ext.translate.statsbar.js21
-rw-r--r--MLEB/Translate/resources/js/ext.translate.translationstashstorage.js57
-rw-r--r--MLEB/Translate/resources/js/ext.translate.translationstats.embedded.js7
-rw-r--r--MLEB/Translate/resources/js/ext.translate.translationstats.graphbuilder.js27
-rw-r--r--MLEB/Translate/resources/js/ext.translate.workflowselector.js17
-rw-r--r--MLEB/Translate/resources/js/jquery.ajaxdispatcher.js11
-rw-r--r--MLEB/Translate/resources/js/jquery.textchange.js44
33 files changed, 653 insertions, 1163 deletions
diff --git a/MLEB/Translate/resources/js/LanguagesMultiselectWidget.js b/MLEB/Translate/resources/js/LanguagesMultiselectWidget.js
index 2ec3b0e7..54c2ebc1 100644
--- a/MLEB/Translate/resources/js/LanguagesMultiselectWidget.js
+++ b/MLEB/Translate/resources/js/LanguagesMultiselectWidget.js
@@ -69,9 +69,9 @@ LanguagesMultiselectWidget.prototype.onInputChange = function () {
* @return {OO.ui.MenuOptionWidget[]} Menu items
*/
LanguagesMultiselectWidget.prototype.getOptionsFromData = function ( data ) {
- var languageCode, options = [];
+ var options = [];
- for ( languageCode in data ) {
+ for ( var languageCode in data ) {
if ( this.languages[ languageCode ] !== undefined ) {
options.push( new OO.ui.MenuOptionWidget( {
data: languageCode,
@@ -90,7 +90,6 @@ LanguagesMultiselectWidget.prototype.setValue = function ( valueObject ) {
this.clearItems();
valueObject.forEach( function ( obj ) {
var data;
-
if ( typeof obj === 'string' ) {
data = obj;
} else {
diff --git a/MLEB/Translate/resources/js/ext.translate.base.js b/MLEB/Translate/resources/js/ext.translate.base.js
index cb0e13a5..6756ff90 100644
--- a/MLEB/Translate/resources/js/ext.translate.base.js
+++ b/MLEB/Translate/resources/js/ext.translate.base.js
@@ -54,15 +54,13 @@
* @return {jQuery.Promise} Object containing the requested properties on success.
*/
getMessageGroup: function ( id, props ) {
- var params, api;
-
if ( Array.isArray( props ) ) {
props = props.join( '|' );
} else if ( props === undefined ) {
props = 'id|label|description|icon|priority|prioritylangs|priorityforce|workflowstates';
}
- params = {
+ var params = {
meta: 'messagegroups',
mgformat: 'flat',
mgprop: props,
@@ -70,7 +68,7 @@
formatversion: 2
};
- api = new mw.Api();
+ var api = new mw.Api();
return api.get( params ).then( function ( result ) {
return result.query.messagegroups[ 0 ];
@@ -86,12 +84,11 @@
* @return {Object} Message group object
*/
findGroup: function ( id, groups ) {
- var result;
-
if ( !id ) {
return groups;
}
+ var result;
groups.some( function ( group ) {
if ( group.id === id ) {
result = group;
@@ -156,8 +153,7 @@
* @param {Array} regions Which regions to add the languages.
*/
addExtraLanguagesToLanguageData: function ( languages, regions ) {
- var code;
- for ( code in languages ) {
+ for ( var code in languages ) {
if ( code in $.uls.data.languages ) {
continue;
}
@@ -178,22 +174,17 @@
}
} );
- function pageShowHandler() {
- $( window ).on( 'beforeunload.translate', function () {
- if ( mw.translate.isDirty() ) {
- // Return our message
- return mw.msg( 'translate-js-support-unsaved-warning' );
- }
- } );
- }
-
/**
* A warning to be shown if a user tries to close the page or navigate away
* from it without saving the written translation.
*/
function translateOnBeforeUnloadRegister() {
- pageShowHandler();
- $( window ).on( 'pageshow.translate', pageShowHandler );
+ $( window ).on( 'beforeunload', function () {
+ if ( mw.translate.isDirty() ) {
+ // Return our message
+ return mw.msg( 'translate-js-support-unsaved-warning' );
+ }
+ } );
}
$( function () {
diff --git a/MLEB/Translate/resources/js/ext.translate.edit.documentation.js b/MLEB/Translate/resources/js/ext.translate.edit.documentation.js
index 6404cbb9..45bcc6e7 100644
--- a/MLEB/Translate/resources/js/ext.translate.edit.documentation.js
+++ b/MLEB/Translate/resources/js/ext.translate.edit.documentation.js
@@ -17,6 +17,15 @@
$( 'body' ).append( windowManager.$element );
windowManager.addWindows( [ warningDialog ] );
+ // TODO load ext.translate.ve unconditionally after 1.39 release: T295203
+ // (see gerrit I7a55a09514110fa7d290d6f03ce9c0b7962c9140; this should be
+ // loaded from extension.json, not from here)
+ if ( mw.config.get( 'wgVersion' ) >= '1.38' ) {
+ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
+ mw.libs.ve.targetLoader.addPlugin( 'ext.translate.ve' );
+ } );
+ }
+
$( function () {
mw.hook( 've.activationComplete' ).add( function () {
// eslint-disable-next-line no-undef
diff --git a/MLEB/Translate/resources/js/ext.translate.editor.helpers.js b/MLEB/Translate/resources/js/ext.translate.editor.helpers.js
index f728381e..7bd6c0b8 100644
--- a/MLEB/Translate/resources/js/ext.translate.editor.helpers.js
+++ b/MLEB/Translate/resources/js/ext.translate.editor.helpers.js
@@ -93,22 +93,13 @@
* @param {Object} documentation A documentation object as returned by API.
*/
showMessageDocumentation: function ( documentation ) {
- var $descEditLink,
- documentationDir,
- expand,
- $messageDescViewer,
- $messageDoc,
- readMore,
- langAttr,
- $readMore = null;
-
if ( !mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
return;
}
- $messageDescViewer = this.$editor.find( '.message-desc-viewer' );
- $descEditLink = $messageDescViewer.find( '.message-desc-edit' );
- $messageDoc = $messageDescViewer.find( '.message-desc' );
+ var $messageDescViewer = this.$editor.find( '.message-desc-viewer' );
+ var $descEditLink = $messageDescViewer.find( '.message-desc-edit' );
+ var $messageDoc = $messageDescViewer.find( '.message-desc' );
// Display the documentation only if it's not empty and
// documentation language is configured
@@ -117,13 +108,13 @@
// is heavily hinted at in the UI
return;
} else if ( documentation.value ) {
- documentationDir = $.uls.data.getDir( documentation.language );
+ var documentationDir = $.uls.data.getDir( documentation.language );
// Show the documentation and set appropriate
// lang and dir attributes.
// The message documentation is assumed to be written
// in the content language of the wiki.
- langAttr = {
+ var langAttr = {
lang: documentation.language,
dir: documentationDir
};
@@ -147,12 +138,12 @@
$descEditLink.text( mw.msg( 'tux-editor-edit-desc' ) );
if ( documentation.html.length > 500 ) {
- expand = function () {
+ var expand = function () {
$messageDoc.removeClass( 'compact' );
$readMore.text( mw.msg( 'tux-editor-message-desc-less' ) );
};
- readMore = function () {
+ var readMore = function () {
if ( $messageDoc.hasClass( 'compact' ) ) {
expand();
} else {
@@ -161,7 +152,7 @@
}
};
- $readMore = $( '<span>' )
+ var $readMore = $( '<span>' )
.addClass( 'read-more column' )
.text( mw.msg( 'tux-editor-message-desc-more' ) )
.on( 'click', readMore );
@@ -187,14 +178,15 @@
* @param {Object} documentation A gettext object as returned by API.
*/
showUneditableDocumentation: function ( documentation ) {
- var dir;
-
if ( documentation.error ) {
return;
}
- dir = $.uls.data.getDir( documentation.language );
+ var dir = $.uls.data.getDir( documentation.language );
+ // The following classes are used here:
+ // * mw-content-ltr
+ // * mw-content-rtl
this.$editor.find( '.uneditable-documentation' )
.attr( {
lang: documentation.language,
@@ -211,8 +203,6 @@
* @param {Array} translations An inotherlanguages array as returned by the translation helpers API.
*/
showAssistantLanguages: function ( translations ) {
- var $elements;
-
if ( translations.error ) {
return;
}
@@ -221,15 +211,13 @@
return;
}
- $elements = translations.map( function ( translation ) {
- var $element, langAttr;
-
- langAttr = {
+ var $elements = translations.map( function ( translation ) {
+ var langAttr = {
lang: translation.language,
dir: $.uls.data.getDir( translation.language )
};
- $element = $( '<div>' )
+ var $element = $( '<div>' )
.addClass( 'row in-other-language' )
.append(
$( '<div>' )
@@ -258,26 +246,23 @@
* @param {Array} translations A ttmserver array as returned by API.
*/
showTranslationMemory: function ( translations ) {
- var $heading, $tmSuggestions, $messageList, lang, dir,
- suggestions = {};
-
if ( !translations.length ) {
return;
}
// Container for the suggestions
- $tmSuggestions = $( '<div>' ).addClass( 'tm-suggestions' );
+ var $tmSuggestions = $( '<div>' ).addClass( 'tm-suggestions' );
- $heading = this.$editor.find( '.tm-suggestions-title' );
+ var $heading = this.$editor.find( '.tm-suggestions-title' );
$heading.after( $tmSuggestions );
- $messageList = $( '.tux-messagelist' );
- lang = $messageList.data( 'targetlangcode' );
- dir = $messageList.data( 'targetlangdir' );
+ var $messageList = $( '.tux-messagelist' );
+ var lang = $messageList.data( 'targetlangcode' );
+ var dir = $messageList.data( 'targetlangdir' );
- translations.forEach( function ( translation ) {
- var suggestion;
+ var suggestions = {};
+ translations.forEach( function ( translation ) {
// Remove once formatversion=2
if ( translation.local === '' ) {
translation.local = true;
@@ -291,7 +276,7 @@
}
// Check if suggestion with this value already exists
- suggestion = suggestions[ translation.target ];
+ var suggestion = suggestions[ translation.target ];
if ( suggestion ) {
suggestion.count++;
suggestion.sources.push( translation );
@@ -399,14 +384,13 @@
* @param {Array} suggestions
*/
showMachineTranslations: function ( suggestions ) {
- var $mtSuggestions, $messageList, translationLang, translationDir,
- translateEditor = this;
-
if ( !suggestions.length ) {
return;
}
- $mtSuggestions = this.$editor.find( '.tm-suggestions' );
+ var translateEditor = this;
+
+ var $mtSuggestions = this.$editor.find( '.tm-suggestions' );
if ( !$mtSuggestions.length ) {
$mtSuggestions = $( '<div>' ).addClass( 'tm-suggestions' );
@@ -416,9 +400,9 @@
.removeClass( 'hide' )
.after( $mtSuggestions );
- $messageList = $( '.tux-messagelist' );
- translationLang = $messageList.data( 'targetlangcode' );
- translationDir = $messageList.data( 'targetlangdir' );
+ var $messageList = $( '.tux-messagelist' );
+ var translationLang = $messageList.data( 'targetlangcode' );
+ var translationDir = $messageList.data( 'targetlangdir' );
suggestions.forEach( function ( translation ) {
var $translation;
@@ -452,10 +436,9 @@
* @param {string} suggestion Text to add
*/
suggestionAdder: function ( $source, suggestion ) {
- var inserter,
- $target = this.$editor.find( '.tux-textarea-translation' );
+ var $target = this.$editor.find( '.tux-textarea-translation' );
- inserter = function () {
+ var inserter = function () {
var selection;
if ( window.getSelection ) {
selection = window.getSelection().toString();
@@ -491,13 +474,12 @@
* @param {Object} insertables A insertables object as returned by API.
*/
addInsertables: function ( insertables ) {
- var i,
- count = insertables.length,
+ var count = insertables.length,
$sourceMessage = this.$editor.find( '.sourcemessage' ),
$buttonArea = this.$editor.find( '.tux-editor-insert-buttons' ),
$textarea = this.$editor.find( '.tux-textarea-translation' );
- for ( i = 0; i < count; i++ ) {
+ for ( var i = 0; i < count; i++ ) {
// The dir and lang attributes must be set here,
// because the language of the insertables is the language
// of the source message and not of the translation.
diff --git a/MLEB/Translate/resources/js/ext.translate.editor.js b/MLEB/Translate/resources/js/ext.translate.editor.js
index e4e227c1..2bbfddbb 100644
--- a/MLEB/Translate/resources/js/ext.translate.editor.js
+++ b/MLEB/Translate/resources/js/ext.translate.editor.js
@@ -16,10 +16,9 @@
diff: 'diff',
fuzzy: 'fuzzy',
getAllClasses: function () {
- var prop,
- classes = [];
+ var classes = [];
- for ( prop in this ) {
+ for ( var prop in this ) {
if ( typeof this[ prop ] === 'string' ) {
classes.push( this[ prop ] );
}
@@ -70,6 +69,7 @@
this.listen();
this.storage = this.options.storage || new mw.translate.TranslationApiStorage();
this.canDelete = mw.translate.canDelete();
+ this.editFontClass = 'mw-editfont-' + mw.user.options.get( 'editfont' );
this.delayValidation = delayer();
this.validating = null;
}
@@ -130,6 +130,8 @@
$tuxListStatus.children( '.tux-status-unsaved' ).remove();
$tuxListStatus.children().addClass( 'hide' );
+ // `highlightClass` documented above
+ // eslint-disable-next-line mediawiki/class-doc
$( '<span>' )
.addClass( 'tux-status-unsaved ' + highlightClass )
.text( mw.msg( 'tux-status-unsaved' ) )
@@ -206,12 +208,11 @@
* Save the translation
*/
save: function () {
- var translation, editSummary,
- translateEditor = this;
+ var translateEditor = this;
mw.hook( 'mw.translate.editor.beforeSubmit' ).fire( translateEditor.$editor );
- translation = translateEditor.$editor.find( '.tux-textarea-translation' ).val();
- editSummary = translateEditor.$editor.find( '.tux-input-editsummary' ).val() || '';
+ var translation = translateEditor.$editor.find( '.tux-textarea-translation' ).val();
+ var editSummary = translateEditor.$editor.find( '.tux-input-editsummary' ).val() || '';
translateEditor.saving = true;
@@ -333,6 +334,9 @@
);
this.saving = false;
this.markUnsavedFailure();
+
+ // Enable the save button again
+ this.$editor.find( '.tux-editor-save-button' ).prop( 'disabled', false );
},
/**
@@ -349,12 +353,10 @@
next: function () {
var $next = this.$editTrigger.next( '.tux-message' );
- // Skip if the message is hidden. For example in a filter result.
- if ( $next.length && $next.hasClass( 'hide' ) ) {
- this.$editTrigger = $next;
- this.next();
-
- return;
+ // Determine the next message to show. The immediate next one maybe hidden
+ // for example in case of filtering
+ while ( $next.length && $next.hasClass( 'hide' ) ) {
+ $next = $next.next( '.tux-message' );
}
// If this is the last message, just hide it
@@ -397,7 +399,6 @@
href: uri.toString(),
target: '_blank'
} )
- // eslint-disable-next-line mediawiki/msg-doc
.text( mw.msg( message ) )
);
},
@@ -409,9 +410,7 @@
* @return {jQuery} The new message tools menu element
*/
createMessageTools: function () {
- var $editItem, $historyItem, $deleteItem, $translationsItem, $linkToThisItem;
-
- $editItem = this.createMessageToolsItem(
+ var $editItem = this.createMessageToolsItem(
'message-tools-edit',
{
title: this.message.title,
@@ -424,7 +423,7 @@
$editItem.addClass( 'hide' );
}
- $historyItem = this.createMessageToolsItem(
+ var $historyItem = this.createMessageToolsItem(
'message-tools-history',
{
title: this.message.title,
@@ -433,7 +432,7 @@
'tux-editor-message-tools-history'
);
- $deleteItem = this.createMessageToolsItem(
+ var $deleteItem = this.createMessageToolsItem(
'message-tools-delete',
{
title: this.message.title,
@@ -453,7 +452,7 @@
// A link to Special:Translations,
// with translations of this message to other languages
- $translationsItem = this.createMessageToolsItem(
+ var $translationsItem = this.createMessageToolsItem(
'message-tools-translations',
{
title: 'Special:Translations',
@@ -462,7 +461,7 @@
'tux-editor-message-tools-translations'
);
- $linkToThisItem = this.createMessageToolsItem(
+ var $linkToThisItem = this.createMessageToolsItem(
'message-tools-linktothis',
{
title: 'Special:Translate',
@@ -480,38 +479,15 @@
prepareEditorColumn: function () {
var translateEditor = this,
- sourceString,
- originalTranslation,
- $editorColumn,
- $messageKeyLabel,
- $moreNoticesTab,
- $notices,
- $noticesBlock,
- $editAreaBlock,
- $textarea,
- $controlButtonBlock,
- $editingButtonBlock,
- $pasteOriginalButton,
- $editSummary,
- $editSummaryBlock,
$discardChangesButton = $( [] ),
$saveButton = $( [] ),
- $requestRight,
- $skipButton,
- $cancelButton,
- $sourceString,
- $closeIcon,
- $layoutActions,
- $infoToggleIcon,
- $messageList,
- targetLangAttrib, targetLangDir, targetLangCode, prefix,
$messageTools = translateEditor.createMessageTools(),
canTranslate = mw.translate.canTranslate();
- $editorColumn = $( '<div>' )
+ var $editorColumn = $( '<div>' )
.addClass( 'seven columns editcolumn' );
- $messageKeyLabel = $( '<div>' )
+ var $messageKeyLabel = $( '<div>' )
.addClass( 'ten columns messagekey' )
.text( this.message.title )
.append(
@@ -523,7 +499,7 @@
e.stopPropagation();
} );
- $closeIcon = $( '<span>' )
+ var $closeIcon = $( '<span>' )
.addClass( 'one column close' )
.attr( 'title', mw.msg( 'tux-editor-close-tooltip' ) )
.on( 'click', function ( e ) {
@@ -531,7 +507,7 @@
e.stopPropagation();
} );
- $infoToggleIcon = $( '<span>' )
+ var $infoToggleIcon = $( '<span>' )
// Initially the editor column is contracted,
// so show the expand button first
.addClass( 'one column editor-info-toggle editor-expand' )
@@ -541,7 +517,7 @@
e.stopPropagation();
} );
- $layoutActions = $( '<div>' )
+ var $layoutActions = $( '<div>' )
.addClass( 'two columns layout-actions' )
.append( $closeIcon, $infoToggleIcon );
@@ -550,11 +526,15 @@
.append( $messageKeyLabel, $layoutActions )
);
- $messageList = $( '.tux-messagelist' );
- originalTranslation = this.message.translation;
- sourceString = this.message.definition;
- $sourceString = $( '<span>' )
- .addClass( 'twelve columns sourcemessage' )
+ var $messageList = $( '.tux-messagelist' );
+ var originalTranslation = this.message.translation;
+ var sourceString = this.message.definition;
+ // The following classes are used here:
+ // * mw-editfont-serif
+ // * mw-editfont-sans-serif
+ // * mw-editfont-monospace
+ var $sourceString = $( '<span>' )
+ .addClass( 'twelve columns sourcemessage ' + this.editFontClass )
.attr( {
lang: $messageList.data( 'sourcelangcode' ),
dir: $messageList.data( 'sourcelangdir' )
@@ -575,10 +555,10 @@
.append( $sourceString )
);
- $notices = $( '<div>' )
+ var $notices = $( '<div>' )
.addClass( 'tux-notice hide' );
- $moreNoticesTab = $( '<div>' )
+ var $moreNoticesTab = $( '<div>' )
.addClass( 'tux-more-notices hide' )
.on( 'click', function () {
var $this = $( this ),
@@ -613,7 +593,8 @@
translateEditor.toggleMoreButtonClass();
} );
- targetLangCode = this.message.targetLanguage;
+ var targetLangCode = this.message.targetLanguage;
+ var targetLangAttrib, targetLangDir;
if ( targetLangCode === mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
targetLangAttrib = mw.config.get( 'wgContentLanguage' );
targetLangDir = $.uls.data.getDir( targetLangAttrib );
@@ -622,8 +603,12 @@
targetLangDir = $messageList.data( 'targetlangdir' );
}
- $textarea = $( '<textarea>' )
- .addClass( 'tux-textarea-translation' )
+ // The following classes are used here:
+ // * mw-editfont-serif
+ // * mw-editfont-sans-serif
+ // * mw-editfont-monospace
+ var $textarea = $( '<textarea>' )
+ .addClass( 'tux-textarea-translation ' + this.editFontClass )
.attr( {
lang: targetLangAttrib,
dir: targetLangDir
@@ -678,7 +663,7 @@
}
} );
- $textarea.on( 'textchange', function () {
+ $textarea.on( 'input', function () {
var $pasteSourceButton = translateEditor.$editor.find( '.tux-editor-paste-original-button' ),
original = translateEditor.message.translation || '',
current = $textarea.val() || '';
@@ -717,11 +702,11 @@
}, 500 );
} );
- $noticesBlock = $( '<div>' )
+ var $noticesBlock = $( '<div>' )
.addClass( 'tux-notices-block' )
.append( $moreNoticesTab, $notices );
- $editAreaBlock = $( '<div>' )
+ var $editAreaBlock = $( '<div>' )
.addClass( 'row tux-editor-editarea-block' )
.append( $( '<div>' )
.addClass( 'editarea twelve columns' )
@@ -730,8 +715,9 @@
$editorColumn.append( $editAreaBlock );
+ var $editingButtonBlock, $editSummaryBlock, $requestRight, $skipButton;
if ( canTranslate ) {
- $pasteOriginalButton = $( '<button>' )
+ var $pasteOriginalButton = $( '<button>' )
.addClass( 'tux-editor-paste-original-button' )
.text( mw.msg( 'tux-editor-paste-original-button-label' ) )
.on( 'click', function () {
@@ -743,7 +729,7 @@
$pasteOriginalButton.addClass( 'hide' );
} );
- $editSummary = $( '<input>' )
+ var $editSummary = $( '<input>' )
.addClass( 'tux-input-editsummary' )
.attr( {
maxlength: 255,
@@ -754,7 +740,7 @@
// Enable edit summary if there was a change to translation area
// or disable if there is no text in translation area
- $textarea.on( 'textchange', function () {
+ $textarea.on( 'input', function () {
if ( $editSummary.prop( 'disabled' ) ) {
$editSummary.prop( 'disabled', false );
}
@@ -873,7 +859,7 @@
} );
// This appears instead of "Skip" on the last message on the page
- $cancelButton = $( '<button>' )
+ var $cancelButton = $( '<button>' )
.addClass( 'tux-editor-cancel-button mw-ui-button mw-ui-quiet' )
.text( mw.msg( 'tux-editor-cancel-button-label' ) )
.on( 'click', function ( e ) {
@@ -883,7 +869,7 @@
e.stopPropagation();
} );
- $controlButtonBlock = $( '<div>' )
+ var $controlButtonBlock = $( '<div>' )
.addClass( 'twelve columns tux-editor-control-buttons' )
.append( $requestRight, $saveButton, $skipButton, $cancelButton );
@@ -900,7 +886,7 @@
);
if ( canTranslate ) {
- prefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix();
+ var prefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix();
$editorColumn.append( $( '<div>' )
.addClass( 'row shortcutinfo' )
.text( mw.msg(
@@ -969,10 +955,9 @@
*/
validateTranslation: function () {
var translateEditor = this,
- api,
$textarea = translateEditor.$editor.find( '.tux-textarea-translation' );
- api = new mw.Api();
+ var api = new mw.Api();
this.validating = api.post( {
action: 'translationcheck',
@@ -1029,9 +1014,6 @@
removeNotices: function ( types ) {
var $tuxNotice = this.$editor.find( '.tux-notice' ),
stringTypes = [],
- $currentNotices,
- index,
- errMsg,
allNoticeTypes = noticeTypes.getAllClasses();
if ( typeof types === 'string' ) {
@@ -1040,16 +1022,16 @@
stringTypes = types;
}
- for ( index = 0; index < stringTypes.length; index++ ) {
+ for ( var index = 0; index < stringTypes.length; index++ ) {
if ( allNoticeTypes.indexOf( stringTypes[ index ] ) === -1 ) {
- errMsg = 'tux: Invalid notice type removeNotice - ' + stringTypes[ index ];
+ var errMsg = 'tux: Invalid notice type removeNotice - ' + stringTypes[ index ];
mw.log.error( errMsg );
throw new Error( errMsg );
}
$tuxNotice.find( '.' + stringTypes[ index ] ).remove();
}
- $currentNotices = $tuxNotice.children();
+ var $currentNotices = $tuxNotice.children();
// If a single notice is shown, we can hide the more notice button,
// and display the hidden notice.
if ( $currentNotices.length <= 1 ) {
@@ -1070,9 +1052,10 @@
* @return {jQuery} the new notice element
*/
addNotice: function ( notice, type ) {
- var noticeCount,
- $notices = this.$editor.find( '.tux-notice' ),
+ var $notices = this.$editor.find( '.tux-notice' ),
$moreNoticesTab = this.$editor.find( '.tux-more-notices' ),
+ // `noticeTypes` documented above
+ // eslint-disable-next-line mediawiki/class-doc
$newNotice = $( '<div>' )
.addClass( 'tux-notice-message ' + type )
.html( notice );
@@ -1083,7 +1066,7 @@
.removeClass( 'hide' )
.prepend( $newNotice );
- noticeCount = $notices.find( '.tux-notice-message' ).length;
+ var noticeCount = $notices.find( '.tux-notice-message' ).length;
if ( noticeCount > 1 ) {
$moreNoticesTab
@@ -1121,10 +1104,7 @@
},
prepareInfoColumn: function () {
- var $messageDescEditor, $messageDescTextarea,
- $messageDescSaveButton, $messageDescCancelButton,
- $messageDescViewer,
- $infoColumn = $( '<div>' ).addClass( 'infocolumn' ),
+ var $infoColumn = $( '<div>' ).addClass( 'infocolumn' ),
translateEditor = this;
$infoColumn.append( $( '<div>' )
@@ -1133,7 +1113,7 @@
);
if ( mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
- $messageDescSaveButton = $( '<button>' )
+ var $messageDescSaveButton = $( '<button>' )
.addClass( 'tux-editor-savedoc-button mw-ui-button mw-ui-progressive' )
.prop( 'disabled', true )
.text( mw.msg( 'tux-editor-doc-editor-save' ) )
@@ -1145,16 +1125,16 @@
} );
} );
- $messageDescCancelButton = $( '<button>' )
+ var $messageDescCancelButton = $( '<button>' )
.addClass( 'tux-editor-skipdoc-button mw-ui-button mw-ui-quiet' )
.text( mw.msg( 'tux-editor-doc-editor-cancel' ) )
.on( 'click', function () {
translateEditor.hideDocumentationEditor();
} );
- $messageDescTextarea = $( '<textarea>' )
+ var $messageDescTextarea = $( '<textarea>' )
.addClass( 'tux-textarea-documentation' )
- .on( 'textchange', function () {
+ .on( 'input', function () {
$messageDescSaveButton.prop( 'disabled', false );
} );
@@ -1162,7 +1142,7 @@
$messageDescTextarea.prop( 'placeholder', mw.msg( 'tux-editor-doc-editor-placeholder' ) );
}
- $messageDescEditor = $( '<div>' )
+ var $messageDescEditor = $( '<div>' )
.addClass( 'row message-desc-editor hide' )
.append(
$messageDescTextarea,
@@ -1174,7 +1154,7 @@
)
);
- $messageDescViewer = $( '<div>' )
+ var $messageDescViewer = $( '<div>' )
.addClass( 'message-desc-viewer hide' )
.append(
$( '<div>' )
@@ -1241,13 +1221,11 @@
},
show: function () {
- var $next, $textarea;
-
if ( !this.$editor ) {
this.init();
}
- $textarea = this.$editor.find( '.editcolumn textarea' );
+ var $textarea = this.$editor.find( '.editcolumn textarea' );
// Hide all other open editors in the page
$( '.tux-message.open' ).each( function () {
$( this ).data( 'translateeditor' ).hide();
@@ -1271,7 +1249,7 @@
this.$editTrigger.addClass( 'open' );
// don't waste time, get ready with next message
- $next = this.$editTrigger.next( '.tux-message' );
+ var $next = this.$editTrigger.next( '.tux-message' );
if ( $next.length ) {
$next.data( 'translateeditor' ).init();
@@ -1341,8 +1319,6 @@
* @param {Object} definitiondiff A definitiondiff object as returned by API.
*/
addDefinitionDiff: function ( definitiondiff ) {
- var $trigger;
-
if ( !definitiondiff || definitiondiff.error ) {
mw.log( 'Error loading translation diff ' + definitiondiff && definitiondiff.error );
return;
@@ -1351,7 +1327,7 @@
// Load the diff styles
mw.loader.load( 'mediawiki.diff.styles' );
- $trigger = $( '<span>' )
+ var $trigger = $( '<span>' )
.addClass( 'show-diff-link' )
.text( mw.msg( 'tux-editor-outdated-notice-diff-link' ) )
.on( 'click', function () {
@@ -1384,10 +1360,8 @@
* @param {jQuery} $textarea Text area.
*/
resizeInsertables: function ( $textarea ) {
- var $buttonArea, buttonAreaHeight;
-
- $buttonArea = this.$editor.find( '.tux-editor-insert-buttons' );
- buttonAreaHeight = $buttonArea.height();
+ var $buttonArea = this.$editor.find( '.tux-editor-insert-buttons' );
+ var buttonAreaHeight = $buttonArea.height();
$textarea.css( 'padding-bottom', buttonAreaHeight + 5 );
$buttonArea.css( 'top', -buttonAreaHeight );
autosize.update( $textarea );
@@ -1400,8 +1374,7 @@
* @param {string} noticeType
*/
displayNotices: function ( notices, noticeType ) {
- var index;
- for ( index = 0; index < notices.length; ++index ) {
+ for ( var index = 0; index < notices.length; ++index ) {
this.addNotice( notices[ index ], noticeType );
}
},
diff --git a/MLEB/Translate/resources/js/ext.translate.editor.shortcuts.js b/MLEB/Translate/resources/js/ext.translate.editor.shortcuts.js
index b8d5c4e2..8c56ef94 100644
--- a/MLEB/Translate/resources/js/ext.translate.editor.shortcuts.js
+++ b/MLEB/Translate/resources/js/ext.translate.editor.shortcuts.js
@@ -5,16 +5,14 @@
'use strict';
var translateEditorShortcuts = {
showShortcuts: function () {
- var editorOffset, minTop, maxTop, maxLeft, middle, rtl;
-
// Any better way?
- rtl = $( document.body ).is( '.rtl' );
+ var rtl = $( document.body ).is( '.rtl' );
- editorOffset = this.$editor.offset();
- minTop = editorOffset.top;
- maxTop = minTop + this.$editor.outerHeight();
- middle = minTop + ( maxTop - minTop ) / 2;
- maxLeft = rtl ? editorOffset.left : editorOffset.left + this.$editor.outerWidth();
+ var editorOffset = this.$editor.offset();
+ var minTop = editorOffset.top;
+ var maxTop = minTop + this.$editor.outerHeight();
+ var middle = minTop + ( maxTop - minTop ) / 2;
+ var maxLeft = rtl ? editorOffset.left : editorOffset.left + this.$editor.outerWidth();
this.hideShortcuts();
diff --git a/MLEB/Translate/resources/js/ext.translate.groupselector.js b/MLEB/Translate/resources/js/ext.translate.groupselector.js
index c87f4acf..9b37d908 100644
--- a/MLEB/Translate/resources/js/ext.translate.groupselector.js
+++ b/MLEB/Translate/resources/js/ext.translate.groupselector.js
@@ -56,17 +56,11 @@
* Prepare the selector menu rendering
*/
prepareSelectorMenu: function () {
- var $listFilters,
- $listFiltersGroup,
- $search,
- $searchIcon,
- $searchGroup;
-
this.$menu = $( '<div>' )
.addClass( 'tux-groupselector' )
.addClass( 'grid hide' );
- $searchIcon = $( '<div>' )
+ var $searchIcon = $( '<div>' )
.addClass( 'two columns tux-groupselector__filter__search__icon' );
this.$search = $( '<input>' )
@@ -77,11 +71,11 @@
this.$search.prop( 'placeholder', mw.msg( 'translate-msggroupselector-search-placeholder' ) );
}
- $search = $( '<div>' )
+ var $search = $( '<div>' )
.addClass( 'ten columns' )
.append( this.$search );
- $listFilters = $( '<div>' )
+ var $listFilters = $( '<div>' )
.addClass( 'tux-groupselector__filter__tabs' )
.addClass( 'six columns' )
.append(
@@ -98,12 +92,12 @@
);
}
- $searchGroup = $( '<div>' )
+ var $searchGroup = $( '<div>' )
.addClass( 'tux-groupselector__filter__search' )
.addClass( 'six columns' )
.append( $searchIcon, $search );
- $listFiltersGroup = $( '<div>' )
+ var $listFiltersGroup = $( '<div>' )
.addClass( 'tux-groupselector__filter' )
.addClass( 'row' )
.append( $listFilters, $searchGroup );
@@ -165,8 +159,7 @@
* Attach event listeners
*/
listen: function () {
- var $tabs,
- groupSelector = this;
+ var groupSelector = this;
// Hide the selector panel when clicking outside of it
$( document.documentElement ).on( 'click', this.hide.bind( this ) );
@@ -183,15 +176,14 @@
// Handle click on row item. This selects the group, and in case it has
// subgroups, also opens a new menu to show them.
groupSelector.$menu.on( 'click', '.tux-grouplist__item', function () {
- var $newLink,
- messageGroup = $( this ).data( 'msggroup' );
+ var messageGroup = $( this ).data( 'msggroup' );
groupSelector.hide();
groupSelector.$trigger.nextAll().remove();
if ( !groupSelector.options.preventSelector ) {
- $newLink = $( '<span>' )
+ var $newLink = $( '<span>' )
.addClass( 'grouptitle grouplink' )
.text( messageGroup.label )
.data( 'msggroupid', messageGroup.id );
@@ -216,7 +208,7 @@
} );
// Handle the tabs All | Recent
- $tabs = groupSelector.$menu.find( '.tux-grouptab' );
+ var $tabs = groupSelector.$menu.find( '.tux-grouptab' );
$tabs.on( 'click', function () {
var $this = $( this );
@@ -361,15 +353,14 @@
* @param {Object} foundIDs The array in which the keys are IDs of message groups that were found already.
*/
flattenGroupList: function ( messageGroups, foundIDs ) {
- var i, messageGroupList;
-
+ var messageGroupList;
if ( messageGroups.groups ) {
messageGroupList = messageGroups.groups;
} else {
messageGroupList = messageGroups;
}
- for ( i = 0; i < messageGroupList.length; i++ ) {
+ for ( var i = 0; i < messageGroupList.length; i++ ) {
// Avoid duplicate groups, and add the parent before subgroups
if ( !foundIDs[ messageGroupList[ i ].id ] ) {
this.flatGroupList.push( messageGroupList[ i ] );
@@ -393,11 +384,11 @@
var self = this;
this.loadGroups().done( function ( groups ) {
- var currentGroup, index, matcher, foundGroups = [];
+ var foundGroups = [];
if ( !self.flatGroupList ) {
self.flatGroupList = [];
- currentGroup = mw.translate.findGroup( self.parentGroupId, groups );
+ var currentGroup = mw.translate.findGroup( self.parentGroupId, groups );
if ( self.parentGroupId ) {
currentGroup = currentGroup.groups;
}
@@ -406,9 +397,9 @@
// Optimization, assuming that people search the beginning
// of the group name.
- matcher = new RegExp( '\\b' + escapeRegex( query ), 'i' );
+ var matcher = new RegExp( '\\b' + escapeRegex( query ), 'i' );
- for ( index = 0; index < self.flatGroupList.length; index++ ) {
+ for ( var index = 0; index < self.flatGroupList.length; index++ ) {
if ( matcher.test( self.flatGroupList[ index ].label ) ||
query === self.flatGroupList[ index ].id ) {
foundGroups.push( self.flatGroupList[ index ] );
@@ -427,18 +418,17 @@
* @return {jQuery.Promise}
*/
loadGroups: function () {
- var params;
-
if ( groupsLoader !== undefined ) {
return groupsLoader;
}
- params = {
+ var params = {
action: 'query',
meta: 'messagegroups',
mgformat: 'tree',
- mgprop: 'id|label|icon|priority|prioritylangs|priorityforce',
- mgiconsize: '32'
+ mgprop: 'id|label|icon',
+ mgiconsize: '32',
+ mglanguageFilter: this.options.language
};
groupsLoader = new mw.Api()
@@ -458,32 +448,18 @@
*/
addGroupRows: function ( groups ) {
var groupSelector = this,
- $msgGroupRows = [],
- $parent,
- targetLanguage = this.options.language;
+ $msgGroupRows = [];
if ( !groups ) {
return;
}
groups.forEach( function ( group ) {
- /* Hide from the selector:
- * - discouraged groups (the only priority value currently supported).
- * - groups that are recommended for other languages.
- */
- if ( group.priority === 'discouraged' ||
- ( group.priorityforce &&
- group.prioritylangs &&
- group.prioritylangs.indexOf( targetLanguage ) === -1 )
- ) {
- return;
- }
-
$msgGroupRows.push( groupSelector.prepareMessageGroupRow( group ) );
} );
if ( this.parentGroupId ) {
- $parent = this.$list.find( '.tux-grouplist__item[data-msggroupid="' +
+ var $parent = this.$list.find( '.tux-grouplist__item[data-msggroupid="' +
this.parentGroupId + '"]' );
if ( $parent.length ) {
@@ -502,28 +478,21 @@
* @return {Object} a jQuery object with the groups selector row (<div>).
*/
prepareMessageGroupRow: function ( messagegroup ) {
- var $row,
- $icon,
- $label,
- $statsbar,
- $subGroupsLabel,
- style = '';
-
- $row = $( '<div>' )
+ var $row = $( '<div>' )
.addClass( 'row tux-grouplist__item' )
.attr( 'data-msggroupid', messagegroup.id )
.data( 'msggroup', messagegroup );
- $icon = $( '<div>' )
+ var $icon = $( '<div>' )
.addClass( 'tux-grouplist__item__icon' )
.addClass( 'one column' );
- $statsbar = $( '<div>' ).languagestatsbar( {
+ var $statsbar = $( '<div>' ).languagestatsbar( {
language: this.options.language,
group: messagegroup.id
} );
- $label = $( '<div>' )
+ var $label = $( '<div>' )
.addClass( 'tux-grouplist__item__label' )
.addClass( 'seven columns' )
.append(
@@ -534,6 +503,7 @@
$statsbar
);
+ var style = '';
if ( messagegroup.icon && messagegroup.icon.raster ) {
style += 'background-image: url(--);';
style = style.replace( /--/g, messagegroup.icon.raster );
@@ -548,7 +518,7 @@
$icon.attr( 'style', style );
}
- $subGroupsLabel = $( [] );
+ var $subGroupsLabel = $( [] );
if ( messagegroup.groups && messagegroup.groups.length > 0 ) {
$subGroupsLabel = $( '<div>' )
@@ -577,6 +547,17 @@
}
return isSupported;
+ },
+
+ /**
+ * Only shows message groups translatable to given target language
+ *
+ * @param {string} targetLanguage
+ */
+ updateTargetLanguage: function ( targetLanguage ) {
+ this.options.language = targetLanguage;
+ groupsLoader = undefined;
+ this.firstShow = true;
}
};
diff --git a/MLEB/Translate/resources/js/ext.translate.messagerenamedialog.js b/MLEB/Translate/resources/js/ext.translate.messagerenamedialog.js
index 499e1541..40ad5807 100644
--- a/MLEB/Translate/resources/js/ext.translate.messagerenamedialog.js
+++ b/MLEB/Translate/resources/js/ext.translate.messagerenamedialog.js
@@ -19,8 +19,6 @@ mw.translate = mw.translate || {};
* @param {Function} [onRenameSelect] Function to call when the rename button is pressed
*/
mw.translate.MessageRenameDialog = function ( config, onRenameSelect ) {
- var errMsg;
-
// HTML Elements
this.messageSearch = null;
this.searchButton = null;
@@ -36,7 +34,7 @@ mw.translate.MessageRenameDialog = function ( config, onRenameSelect ) {
this.resetProperties();
if ( !onRenameSelect ) {
- errMsg = 'Must provide the "onRenameSelect" callback function.';
+ var errMsg = 'Must provide the "onRenameSelect" callback function.';
mw.log.error( errMsg );
throw new Error( errMsg );
}
@@ -174,13 +172,12 @@ mw.translate.MessageRenameDialog.prototype.getTeardownProcess = function ( data
* @param {Array} messages
*/
mw.translate.MessageRenameDialog.prototype.displayMessages = function ( messages ) {
- var i;
if ( !messages.length ) {
this.displayNotice( mw.msg( 'translate-smg-rename-no-msg' ), 'info' );
return;
}
- for ( i = 0; i < messages.length; i++ ) {
+ for ( var i = 0; i < messages.length; i++ ) {
this.displayMessage( messages[ i ] );
}
};
@@ -191,9 +188,7 @@ mw.translate.MessageRenameDialog.prototype.displayMessages = function ( messages
* @param {Object} message
*/
mw.translate.MessageRenameDialog.prototype.displayMessage = function ( message ) {
- var $title, $content, $container;
-
- $title = $( '<div>' ).append(
+ var $title = $( '<div>' ).append(
$( '<a>' ).text( message.title ).addClass( 'smg-rename-msg-key' )
.prop( 'href', message.link )
.data( 'msg-key', message.key ),
@@ -202,9 +197,9 @@ mw.translate.MessageRenameDialog.prototype.displayMessage = function ( message )
).addClass( 'smg-rename-similarity' )
);
- $content = $( '<div>' ).text( message.content ).addClass( 'smg-rename-msg-content' );
+ var $content = $( '<div>' ).text( message.content ).addClass( 'smg-rename-msg-content' );
- $container = $( '<div>' ).addClass( 'smg-rename-list' );
+ var $container = $( '<div>' ).addClass( 'smg-rename-list' );
$container.append( $title, $content );
@@ -242,11 +237,10 @@ mw.translate.MessageRenameDialog.prototype.resetProperties = function () {
* @return {jQuery.Promise} Resolves after making call to the onRenameSelect function.
*/
mw.translate.MessageRenameDialog.prototype.rename = function () {
- var deferred, promise, renameData;
- deferred = $.Deferred();
- promise = deferred.promise();
+ var deferred = $.Deferred();
+ var promise = deferred.promise();
- renameData = {
+ var renameData = {
groupId: this.currentGroupId,
targetKey: this.targetKey,
selectedKey: this.selectedMessage
@@ -301,11 +295,14 @@ mw.translate.MessageRenameDialog.prototype.filterMessages = function ( searchVal
* Method use to display a notice on the dialog box
*
* @param {string} msg
- * @param {string} type
+ * @param {string} type Type of notice to display.
*/
mw.translate.MessageRenameDialog.prototype.displayNotice = function ( msg, type ) {
var possibleTypes = [ 'info', 'error', 'warning' ];
+ // `type` classes documented above. Will be one of "possibleTypes".
+ // eslint-disable-next-line mediawiki/class-doc
this.$notice.removeClass( possibleTypes.join( ' ' ) );
+ // eslint-disable-next-line mediawiki/class-doc
this.$notice.text( msg ).addClass( type ).removeClass( 'hide' );
this.updateSize();
};
diff --git a/MLEB/Translate/resources/js/ext.translate.messagetable.js b/MLEB/Translate/resources/js/ext.translate.messagetable.js
index 9bea2c33..20da0930 100644
--- a/MLEB/Translate/resources/js/ext.translate.messagetable.js
+++ b/MLEB/Translate/resources/js/ext.translate.messagetable.js
@@ -76,7 +76,7 @@
$filterInput.prop( 'placeholder', mw.msg( 'tux-message-filter-placeholder' ) );
}
- $filterInput.on( 'textchange', $.debounce( 250, function () {
+ $filterInput.on( 'input', $.debounce( 250, function () {
messageTable.search( $filterInput.val() );
} ) );
@@ -142,9 +142,7 @@
* @param {Object} message
*/
addTranslate: function ( message ) {
- var $message,
- targetLangDir, targetLangAttrib,
- targetLangCode = this.$container.data( 'targetlangcode' ),
+ var targetLangCode = this.$container.data( 'targetlangcode' ),
sourceLangCode = this.$container.data( 'sourcelangcode' ),
sourceLangDir = $.uls.data.getDir( sourceLangCode ),
status = message.properties.status,
@@ -175,6 +173,7 @@
statusMsg = 'tux-status-' + status;
}
+ var targetLangDir, targetLangAttrib;
if ( targetLangCode === mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
targetLangAttrib = mw.config.get( 'wgContentLanguage' );
targetLangDir = $.uls.data.getDir( targetLangAttrib );
@@ -183,7 +182,7 @@
targetLangDir = this.$container.data( 'targetlangdir' );
}
- $message = $( '<div>' )
+ var $message = $( '<div>' )
.addClass( 'row message tux-message-item ' + status )
.append(
$( '<div>' )
@@ -251,9 +250,7 @@
* @param {Object} message
*/
addProofread: function ( message ) {
- var $message, $icon;
-
- $message = $( '<div>' )
+ var $message = $( '<div>' )
.addClass( 'row tux-message tux-message-proofread' );
this.$container.append( $message );
@@ -263,7 +260,7 @@
targetlangcode: this.$container.data( 'targetlangcode' )
} );
- $icon = $message.find( '.tux-proofread-action' );
+ var $icon = $message.find( '.tux-proofread-action' );
if ( $icon.length === 0 ) {
return;
}
@@ -285,14 +282,18 @@
} );
setTimeout( function () {
- var offset, $visibleIcon = $( '.autotooltip:visible' );
+ var $visibleIcon = $( '.autotooltip:visible' );
if ( !$visibleIcon.length ) {
return;
}
- offset = $visibleIcon.offset();
+ var offset = $visibleIcon.offset();
tooltip.$element.appendTo( document.body );
- tooltip.toggle( true ).toggleClipping( false ).togglePositioning( false );
+ tooltip
+ .toggle( true )
+ .toggleClipping( false )
+ .togglePositioning( false )
+ .setAnchorEdge( 'top' );
tooltip.$element.css( {
top: offset.top + $visibleIcon.outerHeight() + 5,
left: offset.left + $visibleIcon.outerWidth() - tooltip.$element.width() / 2 - 15
@@ -311,9 +312,7 @@
* @param {Object} message
*/
addPageModeMessage: function ( message ) {
- var $message;
-
- $message = $( '<div>' )
+ var $message = $( '<div>' )
.addClass( 'row tux-message tux-message-pagemode' );
this.$container.append( $message );
@@ -330,8 +329,7 @@
* @param {string} query
*/
search: function ( query ) {
- var $note, $button, $result,
- resultCount = 0,
+ var resultCount = 0,
matcher = new RegExp( '(^|\\s|\\b)' + escapeRegex( query ), 'gi' );
this.$container.find( itemsClass[ this.mode ] ).each( function () {
@@ -348,12 +346,12 @@
}
} );
- $result = this.$container.find( '.tux-message-filter-result' );
+ var $result = this.$container.find( '.tux-message-filter-result' );
if ( !$result.length ) {
- $note = $( '<div>' )
+ var $note = $( '<div>' )
.addClass( 'advanced-search' );
- $button = $( '<button>' )
+ var $button = $( '<button>' )
.addClass( 'mw-ui-button' )
.text( mw.msg( 'tux-message-filter-advanced-button' ) );
@@ -383,12 +381,13 @@
},
resize: function () {
- var actualWidth = 0, $messageSelector = $( '.row.tux-message-selector' );
+ var $messageSelector = $( '.row.tux-message-selector' );
if ( $messageSelector.is( ':hidden' ) ) {
return;
}
+ var actualWidth = 0;
// Calculate the total width required for the filters
$messageSelector.children( 'li' ).each( function () {
actualWidth += $( this ).outerWidth( true );
@@ -458,9 +457,7 @@
* @param {number} [limit] Only load this many messages and then stop even if there is more.
*/
load: function ( limit ) {
- var remaining,
- query,
- self = this,
+ var self = this,
offset = this.$loader.data( 'offset' ),
pageSize = limit || this.$loader.data( 'pagesize' );
@@ -484,8 +481,7 @@
pageSize,
this.settings.filter
).done( function ( result ) {
- var messages = result.query.messagecollection,
- state, i;
+ var messages = result.query.messagecollection;
if ( !self.loading ) {
// reject. This was cancelled.
@@ -493,7 +489,7 @@
}
if ( result.warnings ) {
- for ( i = 0; i !== result.warnings.length; i++ ) {
+ for ( var i = 0; i !== result.warnings.length; i++ ) {
if ( result.warnings[ i ].code === 'translate-language-disabled-source' ) {
self.handleLoadErrors( [ result.warnings[ i ] ] );
break;
@@ -519,7 +515,7 @@
}
} );
- state = result.query.metadata && result.query.metadata.state;
+ var state = result.query.metadata && result.query.metadata.state;
$( '.tux-workflow' ).workflowselector(
self.settings.group,
self.settings.language,
@@ -527,7 +523,7 @@
).removeClass( 'hide' );
// Dynamically loaded messages should pass the search filter if present.
- query = $( '.tux-message-filter-box' ).val();
+ var query = $( '.tux-message-filter-box' ).val();
if ( query ) {
self.search( query );
@@ -544,7 +540,7 @@
} else {
self.$loader.data( 'offset', result[ 'query-continue' ].messagecollection.mcoffset );
- remaining = result.query.metadata.remaining;
+ var remaining = result.query.metadata.remaining;
self.$loaderInfo.text(
mw.msg( 'tux-messagetable-more-messages', remaining )
@@ -680,7 +676,7 @@
$actions.append( messageTable.otherActionButton(
'tux-empty-list-translated-action',
function () {
- mw.translate.changeFilter( $( '.tux-tab-untranslated' ).trigger( 'click' ) );
+ $( '.tux-tab-untranslated' ).trigger( 'click' );
} )
);
} else {
@@ -717,10 +713,7 @@
switchMode: function ( mode ) {
var messageTable = this,
filter = this.settings.filter,
- userId = mw.config.get( 'wgUserId' ),
- $tuxTabUntranslated,
- $tuxTabUnproofread,
- $hideTranslatedButton;
+ userId = mw.config.get( 'wgUserId' );
messageTable.$actionBar.find( '.tux-view-switcher .down' ).removeClass( 'down' );
if ( mode === 'translate' ) {
@@ -742,9 +735,9 @@
messageTable.$container.empty();
$( '.translate-tooltip' ).remove();
- $tuxTabUntranslated = $( '.tux-message-selector > .tux-tab-untranslated' );
- $tuxTabUnproofread = $( '.tux-message-selector > .tux-tab-unproofread' );
- $hideTranslatedButton = messageTable.$actionBar.find( '.tux-editor-clear-translated' );
+ var $tuxTabUntranslated = $( '.tux-message-selector > .tux-tab-untranslated' );
+ var $tuxTabUnproofread = $( '.tux-message-selector > .tux-tab-unproofread' );
+ var $hideTranslatedButton = messageTable.$actionBar.find( '.tux-editor-clear-translated' );
if ( messageTable.mode === 'proofread' ) {
$tuxTabUntranslated.addClass( 'hide' );
@@ -798,30 +791,20 @@
* The scroll handler
*/
scroll: function () {
- var $window,
- isActionBarFloating,
- needsTableHeaderFloat, needsTableHeaderStick,
- needsActionBarFloat, needsActionBarStick,
- windowScrollTop, windowScrollBottom,
- messageTableRelativePos,
- messageListOffset,
- messageListHeight, messageListWidth,
- messageListTop, messageListBottom;
-
- $window = $( window );
-
- windowScrollTop = $window.scrollTop();
- windowScrollBottom = windowScrollTop + $window.height();
- messageListOffset = this.$container.offset();
- messageListHeight = this.$container.height();
- messageListTop = messageListOffset.top;
- messageListBottom = messageListTop + messageListHeight;
- messageListWidth = this.$container.width();
+ var $window = $( window );
+
+ var windowScrollTop = $window.scrollTop();
+ var windowScrollBottom = windowScrollTop + $window.height();
+ var messageListOffset = this.$container.offset();
+ var messageListHeight = this.$container.height();
+ var messageListTop = messageListOffset.top;
+ var messageListBottom = messageListTop + messageListHeight;
+ var messageListWidth = this.$container.width();
// Header:
- messageTableRelativePos = messageListTop - this.$header.height() - windowScrollTop;
- needsTableHeaderFloat = messageTableRelativePos + 10 < 0;
- needsTableHeaderStick = messageTableRelativePos - 10 >= 0;
+ var messageTableRelativePos = messageListTop - this.$header.height() - windowScrollTop;
+ var needsTableHeaderFloat = messageTableRelativePos + 10 < 0;
+ var needsTableHeaderStick = messageTableRelativePos - 10 >= 0;
if ( needsTableHeaderFloat ) {
this.$header.addClass( 'floating' ).width( messageListWidth );
} else if ( needsTableHeaderStick ) {
@@ -830,9 +813,9 @@
}
// Action bar:
- isActionBarFloating = this.$actionBar.hasClass( 'floating' );
- needsActionBarFloat = windowScrollBottom < messageListBottom;
- needsActionBarStick = windowScrollBottom > ( messageListBottom + this.$actionBar.height() );
+ var isActionBarFloating = this.$actionBar.hasClass( 'floating' );
+ var needsActionBarFloat = windowScrollBottom < messageListBottom;
+ var needsActionBarStick = windowScrollBottom > ( messageListBottom + this.$actionBar.height() );
if ( !isActionBarFloating && needsActionBarFloat ) {
this.$actionBar.addClass( 'floating' ).width( messageListWidth );
@@ -905,13 +888,12 @@
}
function isLoaderVisible( $loader ) {
- var viewportBottom, elementTop,
- $window = $( window );
+ var $window = $( window );
- viewportBottom = ( window.innerHeight ? window.innerHeight : $window.height() ) +
+ var viewportBottom = ( window.innerHeight ? window.innerHeight : $window.height() ) +
$window.scrollTop();
- elementTop = $loader.offset().top;
+ var elementTop = $loader.offset().top;
// Start already if user is reaching close to the bottom
return elementTop - viewportBottom < 200;
diff --git a/MLEB/Translate/resources/js/ext.translate.navitoggle.js b/MLEB/Translate/resources/js/ext.translate.navitoggle.js
index 69d173d8..b421893d 100644
--- a/MLEB/Translate/resources/js/ext.translate.navitoggle.js
+++ b/MLEB/Translate/resources/js/ext.translate.navitoggle.js
@@ -18,19 +18,17 @@
}
$( function () {
- var $miniLogo, $toggle, rtl, delim;
-
- rtl = $body.hasClass( 'rtl' );
- delim = rtl ?
+ var rtl = $body.hasClass( 'rtl' );
+ var delim = rtl ?
$( '#mw-head-base' ).css( 'margin-right' ) :
$( '#mw-head-base' ).css( 'margin-left' );
- $miniLogo = $( '#p-logo' )
+ var $miniLogo = $( '#p-logo' )
.clone()
.removeAttr( 'id' )
.addClass( 'tux-navi-minilogo' );
- $toggle = $( '<div>' )
+ var $toggle = $( '<div>' )
.addClass( 'tux-navitoggle' )
.css( rtl ? 'right' : 'left', delim )
.on( 'click', function () {
diff --git a/MLEB/Translate/resources/js/ext.translate.pagemode.js b/MLEB/Translate/resources/js/ext.translate.pagemode.js
index 9c03ce9f..fb668a73 100644
--- a/MLEB/Translate/resources/js/ext.translate.pagemode.js
+++ b/MLEB/Translate/resources/js/ext.translate.pagemode.js
@@ -1,5 +1,6 @@
( function () {
'use strict';
+
/**
* Page mode plugin
*
@@ -35,50 +36,56 @@
* Initialize the plugin
*/
init: function () {
- var pagemode = this;
+ var that = this;
this.message.proofreadable = false;
this.render();
- pagemode.$message.translateeditor( {
- message: pagemode.message,
+ this.$message.translateeditor( {
+ message: this.message,
beforeSave: function ( translation ) {
- pagemode.$message.find( '.tux-pagemode-translation' )
- .html( mw.translate.formatMessageGently( translation || '', pagemode.message.key ) )
+ that.$message.find( '.tux-pagemode-translation' )
+ .html( mw.translate.formatMessageGently( translation || '', that.message.key ) )
.addClass( 'highlight' );
},
onSave: function ( translation ) {
- pagemode.$message.find( '.tux-pagemode-translation' )
+ that.$message.find( '.tux-pagemode-translation' )
.removeClass( 'highlight' );
- pagemode.message.translation = translation;
+ that.message.translation = translation;
- pagemode.$message.find( '.tux-pagemode-status' )
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
+ that.$message.find( '.tux-pagemode-status' )
.removeClass( 'translated fuzzy proofread untranslated' )
- .addClass( pagemode.message.properties.status );
+ .addClass( that.message.properties.status );
}
} );
},
render: function () {
- var targetLangAttrib, targetLangDir,
- sourceLangDir = $.uls.data.getDir( this.options.sourcelangcode );
+ var sourceLangDir = $.uls.data.getDir( this.options.sourcelangcode );
- if ( this.options.targetlangcode ===
- mw.config.get( 'wgTranslateDocumentationLanguageCode' )
- ) {
+ var targetLangAttrib;
+ if ( this.options.targetlangcode === mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
targetLangAttrib = mw.config.get( 'wgContentLanguage' );
} else {
targetLangAttrib = this.options.targetlangcode;
}
- targetLangDir = $.uls.data.getDir( targetLangAttrib );
+ var targetLangDir = $.uls.data.getDir( targetLangAttrib );
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
this.$message.append(
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
$( '<div>' )
.addClass( 'row tux-message-item-compact message ' + this.message.properties.status )
.append(
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
$( '<div>' )
.addClass( 'one column tux-pagemode-status ' + this.message.properties.status ),
$( '<div>' )
@@ -106,10 +113,10 @@
* Attach event listeners
*/
listen: function () {
- var pagemode = this;
+ var that = this;
this.$message.children( '.message' ).on( 'click', function ( e ) {
- pagemode.$message.data( 'translateeditor' ).show();
+ that.$message.data( 'translateeditor' ).show();
e.preventDefault();
} );
}
diff --git a/MLEB/Translate/resources/js/ext.translate.pagetranslation.uls.js b/MLEB/Translate/resources/js/ext.translate.pagetranslation.uls.js
index a0bfc2d4..9c54557d 100644
--- a/MLEB/Translate/resources/js/ext.translate.pagetranslation.uls.js
+++ b/MLEB/Translate/resources/js/ext.translate.pagetranslation.uls.js
@@ -2,9 +2,7 @@
'use strict';
mw.uls.changeLanguage = function ( language ) {
- var page;
-
- page = 'Special:MyLanguage/' + mw.config.get( 'wgPageName' );
+ var page = 'Special:MyLanguage/' + mw.config.get( 'wgPageName' );
if ( mw.config.get( 'wgTranslatePageTranslation' ) === 'translation' ) {
page = page.replace( /\/[^/]+$/, '' );
diff --git a/MLEB/Translate/resources/js/ext.translate.parsers.js b/MLEB/Translate/resources/js/ext.translate.parsers.js
index 393a76bb..655bf5b1 100644
--- a/MLEB/Translate/resources/js/ext.translate.parsers.js
+++ b/MLEB/Translate/resources/js/ext.translate.parsers.js
@@ -19,8 +19,7 @@
* @return {string} Formatted text in html
*/
formatMessageGently: function ( text, key ) {
- var externals,
- protocols = mw.config.get( 'wgUrlProtocols' );
+ var protocols = mw.config.get( 'wgUrlProtocols' );
// Try to keep simple.
text = $( '<div>' ).text( text ).html();
@@ -59,7 +58,7 @@
return $( '<div>' ).append( $link ).html();
} );
- externals = new RegExp( '\\[((' + protocols + ')[^ ]+) (.+?)\\]', 'g' );
+ var externals = new RegExp( '\\[((' + protocols + ')[^ ]+) (.+?)\\]', 'g' );
text = text.replace( externals, function ( match, p1, p2, p3 ) {
var $link = $( '<a>' ).html( p3 ).prop( 'href', p1 );
return $( '<div>' ).append( $link ).html();
diff --git a/MLEB/Translate/resources/js/ext.translate.proofread.js b/MLEB/Translate/resources/js/ext.translate.proofread.js
index ad3791af..2513ef1f 100644
--- a/MLEB/Translate/resources/js/ext.translate.proofread.js
+++ b/MLEB/Translate/resources/js/ext.translate.proofread.js
@@ -3,6 +3,7 @@
/**
* Proofread Plugin
+ *
* Prepare a proofread UI with all the required actions
* for a translation unit (message).
* This is mainly used with the messagetable plugin in proofread mode,
@@ -35,7 +36,7 @@
* Initialize the plugin
*/
init: function () {
- var proofread = this;
+ var that = this;
this.render();
@@ -53,52 +54,49 @@
this.disableProofread();
}
- proofread.$message.translateeditor( {
- message: proofread.message,
+ this.$message.translateeditor( {
+ message: this.message,
onSave: function ( translation ) {
- proofread.$message.find( '.tux-proofread-translation' )
+ that.$message.find( '.tux-proofread-translation' )
.text( translation );
- proofread.message.translation = translation;
- proofread.markSelfTranslation();
+ that.message.translation = translation;
+ that.markSelfTranslation();
- proofread.$message.find( '.tux-proofread-status' )
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
+ that.$message.find( '.tux-proofread-status' )
.removeClass( 'translated fuzzy proofread untranslated' )
- .addClass( proofread.message.properties.status );
+ .addClass( that.message.properties.status );
}
} );
},
render: function () {
- var targetLangCode, targetLangDir, targetLangAttrib,
- sourceLangCode, sourceLangDir,
- $proofreadAction, $proofreadEdit, userId, reviewers, otherReviewers,
- translatedBySelf, proofreadBySelf;
-
// List of all reviewers
- reviewers = this.message.properties.reviewers || [];
+ var reviewers = this.message.properties.reviewers || [];
// The id of the current user, converted to string as the are in reviewers
- userId = String( mw.config.get( 'wgUserId' ) );
+ var userId = String( mw.config.get( 'wgUserId' ) );
// List of all reviewers excluding the current user.
- otherReviewers = reviewers.filter( function ( element ) {
+ var otherReviewers = reviewers.filter( function ( element ) {
return element !== userId;
} );
/* Whether the current user if the last translator of this message.
* Accepting own translations is prohibited. */
- translatedBySelf = ( this.message.properties[ 'last-translator-text' ] === mw.user.getName() );
- proofreadBySelf = reviewers.indexOf( userId ) > -1;
+ var translatedBySelf = ( this.message.properties[ 'last-translator-text' ] === mw.user.getName() );
+ var proofreadBySelf = reviewers.indexOf( userId ) > -1;
- sourceLangCode = this.options.sourcelangcode;
- sourceLangDir = $.uls.data.getDir( sourceLangCode );
- targetLangCode = this.options.targetlangcode;
+ var sourceLangDir = $.uls.data.getDir( this.options.sourcelangcode );
- $proofreadAction = $( '<div>' )
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
+ var $proofreadAction = $( '<div>' )
.attr( 'title', mw.msg( 'tux-proofread-action-tooltip' ) )
.addClass(
'tux-proofread-action ' + this.message.properties.status + ' ' + ( proofreadBySelf ? 'accepted' : '' )
);
- $proofreadEdit = $( '<div>' )
+ var $proofreadEdit = $( '<div>' )
.addClass( 'tux-proofread-edit' )
.append( $( '<span>' )
.addClass( 'tux-proofread-edit-label hide' )
@@ -111,23 +109,29 @@
$( this ).find( '.tux-proofread-edit-label' ).addClass( 'hide' );
} );
- if ( targetLangCode === mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
+ var targetLangAttrib;
+ if ( this.options.targetlangcode === mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
targetLangAttrib = mw.config.get( 'wgContentLanguage' );
} else {
- targetLangAttrib = targetLangCode;
+ targetLangAttrib = this.options.targetlangcode;
}
- targetLangDir = $.uls.data.getDir( targetLangAttrib );
+ var targetLangDir = $.uls.data.getDir( targetLangAttrib );
+
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
this.$message.append(
$( '<div>' )
.addClass( 'row tux-message-item-compact message' )
.append(
+ // `status` class is documented elsewhere
+ // eslint-disable-next-line mediawiki/class-doc
$( '<div>' )
.addClass( 'one column tux-proofread-status ' + this.message.properties.status ),
$( '<div>' )
.addClass( 'five columns tux-proofread-source' )
.attr( {
- lang: sourceLangCode,
+ lang: this.options.sourcelangcode,
dir: sourceLangDir
} )
.text( this.message.definition ),
@@ -195,12 +199,11 @@
* Mark this message as proofread.
*/
proofread: function () {
- var reviews, $counter, params,
- message = this.message,
+ var message = this.message,
$message = this.$message,
api = new mw.Api();
- params = {
+ var params = {
action: 'translationreview',
revision: this.message.properties.revision
};
@@ -214,8 +217,8 @@
.removeClass( 'tux-notice' ) // in case, it failed previously
.addClass( 'accepted' );
- $counter = $message.find( '.tux-proofread-count' );
- reviews = $counter.data( 'reviewCount' );
+ var $counter = $message.find( '.tux-proofread-count' );
+ var reviews = $counter.data( 'reviewCount' );
$counter.text( mw.language.convertNumber( reviews + 1 ) );
// Update stats
@@ -242,17 +245,17 @@
* Attach event listeners
*/
listen: function () {
- var proofread = this;
+ var that = this;
this.$message.find( '.tux-proofread-action' ).on( 'click', function () {
- proofread.proofread();
+ that.proofread();
return false;
} );
this.$message.find( '.tux-proofread-edit' ).on( 'click', function () {
// Make sure that the tooltip is hidden when going to the editor
$( '.translate-tooltip' ).remove();
- proofread.$message.data( 'translateeditor' ).show();
+ that.$message.data( 'translateeditor' ).show();
return false;
} );
diff --git a/MLEB/Translate/resources/js/ext.translate.selecttoinput.js b/MLEB/Translate/resources/js/ext.translate.selecttoinput.js
index 71253bb4..a27fd903 100644
--- a/MLEB/Translate/resources/js/ext.translate.selecttoinput.js
+++ b/MLEB/Translate/resources/js/ext.translate.selecttoinput.js
@@ -3,14 +3,13 @@ $( function () {
'use strict';
var select = document.getElementById( selectid ),
- target = document.getElementById( targetid ),
- atxt;
+ target = document.getElementById( targetid );
if ( !target || !select ) {
return;
}
- atxt = select.options[ select.selectedIndex ].value;
+ var atxt = select.options[ select.selectedIndex ].value;
if ( !atxt ) {
return;
diff --git a/MLEB/Translate/resources/js/ext.translate.special.aggregategroups.js b/MLEB/Translate/resources/js/ext.translate.special.aggregategroups.js
index 41d4ac0a..cac1edd8 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.aggregategroups.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.aggregategroups.js
@@ -9,15 +9,14 @@
}
function dissociate( event ) {
- var params,
- $target = $( event.target ),
+ var $target = $( event.target ),
api = new mw.Api();
function successFunction() {
$target.parent( 'li' ).remove();
}
- params = $.extend( getApiParams( $target ), {
+ var params = $.extend( getApiParams( $target ), {
do: 'dissociate',
group: $target.data( 'groupid' )
} );
@@ -31,14 +30,14 @@
}
function associate( event, resp ) {
- var successFunction, params, subgroupId, i,
- $target = $( event.target ),
+ var $target = $( event.target ),
$parent = $target.parents( '.mw-tpa-group' ),
parentId = $parent.data( 'id' ),
subgroupName = $parent.children( '.tp-group-input' ).val(),
api = new mw.Api();
- successFunction = function () {
+ var subgroupId;
+ var successFunction = function () {
var aAttr, $a, spanAttr, $span, $ol;
aAttr = {
@@ -63,7 +62,7 @@
// Get the label for the value and make API request if valid
subgroupId = '';
- for ( i = 0; i < resp.length; ++i ) {
+ for ( var i = 0; i < resp.length; ++i ) {
if ( subgroupName === resp[ i ].label ) {
subgroupId = resp[ i ].id;
break;
@@ -71,7 +70,7 @@
}
if ( subgroupId ) {
- params = $.extend( getApiParams( $target ), {
+ var params = $.extend( getApiParams( $target ), {
do: 'associate',
group: subgroupId
} );
@@ -89,8 +88,7 @@
}
function removeGroup( event ) {
- var params,
- $target = $( event.target ),
+ var $target = $( event.target ),
api = new mw.Api();
function successFunction() {
@@ -101,7 +99,7 @@
if ( typeof window.confirm === 'function' &&
// eslint-disable-next-line no-alert
window.confirm( mw.msg( 'tpt-aggregategroup-remove-confirm' ) ) ) {
- params = $.extend( getApiParams( $target ), {
+ var params = $.extend( getApiParams( $target ), {
do: 'remove'
} );
@@ -120,15 +118,13 @@
aggregateGroupId = $parent.data( 'groupid' ),
$displayGroup = $parent.children( '.tp-display-group' ),
$editGroup = $parent.children( '.tp-edit-group' ),
- successFunction,
- params,
$aggGroupNameInputName = $editGroup.children( 'input.tp-aggregategroup-edit-name' ),
$aggGroupNameInputDesc = $editGroup.children( 'input.tp-aggregategroup-edit-description' ),
aggregateGroupName = $aggGroupNameInputName.val(),
aggregateGroupDesc = $aggGroupNameInputDesc.val(),
api = new mw.Api();
- successFunction = function () {
+ var successFunction = function () {
// Replace the text by the new text without altering the other 2 span tags
$displayGroup.children( '.tp-name' ).contents().filter( function () {
return this.nodeType === 3;
@@ -138,7 +134,7 @@
$editGroup.addClass( 'hidden' );
};
- params = {
+ var params = {
action: 'aggregategroups',
do: 'update',
groupname: aggregateGroupName,
@@ -162,13 +158,12 @@
}
$( function () {
- var excludeFunction, autocompleteFunction, resp,
- api = new mw.Api(),
+ var api = new mw.Api(),
exclude = [],
groups = [],
$input = $( '.tp-group-input' );
- excludeFunction = function ( event ) {
+ var excludeFunction = function ( event ) {
exclude = [];
if ( groups.length === 0 ) {
@@ -196,7 +191,8 @@
);
};
- autocompleteFunction = function ( request, response ) {
+ var resp;
+ var autocompleteFunction = function ( request, response ) {
// Allow case insensitive search
var inp = new RegExp( request.term, 'i' );
@@ -245,8 +241,7 @@
} );
$( '#tpt-aggregategroups-save' ).on( 'click', function () {
- var successFunction, params,
- $aggGroupNameInputName = $( 'input.tp-aggregategroup-add-name' ),
+ var $aggGroupNameInputName = $( 'input.tp-aggregategroup-add-name' ),
$aggGroupNameInputDesc = $( 'input.tp-aggregategroup-add-description' ),
aggregateGroupName = $aggGroupNameInputName.val(),
aggregateGroupDesc = $aggGroupNameInputDesc.val();
@@ -256,36 +251,34 @@
$aggGroupNameInputName.val( '' );
$aggGroupNameInputDesc.val( '' );
- successFunction = function ( data ) {
- var $removeSpan, $editSpan, $displayHeader, $div, $groupSelector, $addButton,
- $cancelButton, $divDisplay, $divEdit, $saveButton,
- aggregateGroupId = data.aggregategroups.aggregategroupId;
+ var successFunction = function ( data ) {
+ var aggregateGroupId = data.aggregategroups.aggregategroupId;
- $removeSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
+ var $removeSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
.addClass( 'tp-aggregate-remove-ag-button' );
- $editSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
+ var $editSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
.addClass( 'tp-aggregate-edit-ag-button' );
// Prints the name and the two spans in a single row
- $displayHeader = $( '<h2>' ).addClass( 'tp-name' ).text( aggregateGroupName )
+ var $displayHeader = $( '<h2>' ).addClass( 'tp-name' ).text( aggregateGroupName )
.append( $editSpan, $removeSpan );
- $divDisplay = $( '<div>' ).addClass( 'tp-display-group' )
+ var $divDisplay = $( '<div>' ).addClass( 'tp-display-group' )
.append( $displayHeader )
.append( $( '<p>' ).addClass( 'tp-desc' ).text( aggregateGroupDesc ) );
- $saveButton = $( '<input>' )
+ var $saveButton = $( '<input>' )
.attr( {
type: 'button',
class: 'tp-aggregategroup-update'
} )
.val( mw.msg( 'tpt-aggregategroup-update' ) );
- $cancelButton = $( '<input>' )
+ var $cancelButton = $( '<input>' )
.attr( {
type: 'button',
class: 'tp-aggregategroup-update-cancel'
} )
.val( mw.msg( 'tpt-aggregategroup-update-cancel' ) );
- $divEdit = $( '<div>' )
+ var $divEdit = $( '<div>' )
.addClass( 'tp-edit-group hidden' )
.append( $( '<label>' )
.text( mw.msg( 'tpt-aggregategroup-edit-name' ) ) )
@@ -310,14 +303,14 @@
)
.append( $saveButton, $cancelButton );
- $div = $( '<div>' ).addClass( 'mw-tpa-group' )
+ var $div = $( '<div>' ).addClass( 'mw-tpa-group' )
.append( $divDisplay, $divEdit )
.append( $( '<ol id=\'mw-tpa-grouplist-' + aggregateGroupId + '\'>' ) );
$div.data( 'groupid', aggregateGroupId );
$div.data( 'id', aggregateGroupId );
- $groupSelector = $( '<input>' ).attr( {
+ var $groupSelector = $( '<input>' ).attr( {
type: 'text',
class: 'tp-group-input'
} );
@@ -329,7 +322,7 @@
// Enable showing all groups when nothing is entered
$( this ).autocomplete( 'search', $( this ).val() );
} );
- $addButton = $( '<input>' )
+ var $addButton = $( '<input>' )
.attr( {
type: 'button',
class: 'tp-aggregate-add-button',
@@ -353,7 +346,7 @@
$( 'a.tpt-add-new-group' ).before( $div );
};
- params = {
+ var params = {
action: 'aggregategroups',
do: 'add',
groupname: aggregateGroupName,
diff --git a/MLEB/Translate/resources/js/ext.translate.special.languagestats.js b/MLEB/Translate/resources/js/ext.translate.special.languagestats.js
index 00daca44..9ebe93f4 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.languagestats.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.languagestats.js
@@ -13,6 +13,8 @@
/**
* Add css class to every other visible row.
* It's not possible to do zebra colors with CSS only if there are hidden rows.
+ *
+ * @param {jQuery} $table
*/
function doZebra( $table ) {
$table.find( 'tr:visible:odd' ).toggleClass( 'tux-statstable-even', false );
@@ -20,8 +22,7 @@
}
function addExpanders( $table ) {
- var $allChildRows, $allTogglesCache, $toggleAllButton,
- $metaRows = $( 'tr.AggregateMessageGroup', $table );
+ var $metaRows = $( 'tr.AggregateMessageGroup', $table );
// Quick return
if ( !$metaRows.length ) {
@@ -29,8 +30,7 @@
}
$metaRows.each( function () {
- var $toggler,
- $parent = $( this ),
+ var $parent = $( this ),
thisGroupId = $parent.attr( 'data-groupid' ),
$children = $( 'tr[data-parentgroup="' + thisGroupId + '"]', $table );
@@ -40,7 +40,7 @@
}
// Build toggle link
- $toggler = $( '<span>' ).addClass( 'groupexpander collapsed' )
+ var $toggler = $( '<span>' ).addClass( 'groupexpander collapsed' )
.append(
'[',
$( '<a>' )
@@ -80,9 +80,9 @@
} );
// Create, bind and append the toggle-all button
- $allChildRows = $( 'tr[data-parentgroup]', $table );
- $allTogglesCache = null;
- $toggleAllButton = $( '<span>' ).addClass( 'collapsed' )
+ var $allChildRows = $( 'tr[data-parentgroup]', $table );
+ var $allTogglesCache = null;
+ var $toggleAllButton = $( '<span>' ).addClass( 'collapsed' )
.append(
'[',
$( '<a>' )
@@ -121,13 +121,12 @@
}
function applySorting( $table ) {
- var index,
- sort = {},
+ var sort = {},
re = /#sortable:(\d+)=(asc|desc)/,
match = re.exec( location.hash );
if ( match ) {
- index = parseInt( match[ 1 ], 10 );
+ var index = parseInt( match[ 1 ], 10 );
sort[ index ] = match[ 2 ];
}
$table.tablesorter( { sortList: [ sort ] } );
@@ -144,8 +143,7 @@
}
function narrowTable( $table, enable ) {
- var $select,
- labelColumnCount = 1,
+ var labelColumnCount = 1,
// 0-indexed
defaultValueColumn = 2;
@@ -155,7 +153,7 @@
} );
}
- $select = makeValueColumnSelector( $columns, labelColumnCount, defaultValueColumn );
+ var $select = makeValueColumnSelector( $columns, labelColumnCount, defaultValueColumn );
// Prevent table sorter from making the select inaccessible
$select.on( 'mousedown click', function ( e ) {
e.stopPropagation();
@@ -176,9 +174,9 @@
}
function makeValueColumnSelector( headings, skip, def ) {
- var i, $select = $( '<select>' );
+ var $select = $( '<select>' );
- for ( i = skip; i < headings.length; i++ ) {
+ for ( var i = skip; i < headings.length; i++ ) {
$( '<option>' )
.text( headings[ i ] )
.val( i )
@@ -190,21 +188,18 @@
}
function showValueColumn( $table, $select, skip ) {
- var i, index, cssQuery;
-
- index = parseInt( $select.val(), 10 );
- cssQuery = 'th:nth-child(_)'.replace( '_', index + 1 );
+ var index = parseInt( $select.val(), 10 );
+ var cssQuery = 'th:nth-child(_)'.replace( '_', index + 1 );
$table.find( cssQuery ).html( $select );
- for ( i = 0; i < $select.children().length; i++ ) {
+ for ( var i = 0; i < $select.children().length; i++ ) {
cssQuery = 'tr > *:nth-child(_)'.replace( '_', i + skip + 1 );
$table.find( cssQuery ).toggleClass( 'statstable-hide', i + skip !== index );
}
}
$( function () {
- var isNarrowMode, minimumTableWidth,
- $table = $( '.statstable' );
+ var $table = $( '.statstable' );
// Sometimes the table is not present on the page
if ( !$table.length ) {
@@ -223,19 +218,20 @@
return;
}
+ var minimumTableWidth;
// Hopefully previous stuff have time to render by now to have accurate picture of the width
( window.requestAnimationFrame || setTimeout )( function () {
minimumTableWidth = $table.outerWidth();
$table.css( 'max-width', '' );
} );
+ var isNarrowMode;
new ResizeObserver( function ( entries ) {
- var newMode, shouldCollapse, shouldExpand;
-
- shouldCollapse = entries[ 0 ].contentRect.width < minimumTableWidth;
+ var shouldCollapse = entries[ 0 ].contentRect.width < minimumTableWidth;
// Some fudge to avoid flapping
- shouldExpand = entries[ 0 ].contentRect.width - 20 > minimumTableWidth;
+ var shouldExpand = entries[ 0 ].contentRect.width - 20 > minimumTableWidth;
+ var newMode;
if ( isNarrowMode && shouldExpand ) {
newMode = false;
} else if ( !isNarrowMode && shouldCollapse ) {
diff --git a/MLEB/Translate/resources/js/ext.translate.special.managegroups.js b/MLEB/Translate/resources/js/ext.translate.special.managegroups.js
index 9337ed5f..c796467d 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.managegroups.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.managegroups.js
@@ -3,17 +3,15 @@
GroupSynchronization;
$( function () {
- var windowManager, renameDialog;
-
RenameDropdown.init();
GroupSynchronization.init();
// Create and append a window manager.
- windowManager = new OO.ui.WindowManager();
+ var windowManager = new OO.ui.WindowManager();
windowManager.$element.appendTo( document.body );
// Create a new process dialog window.
- renameDialog = new mw.translate.MessageRenameDialog( {
+ var renameDialog = new mw.translate.MessageRenameDialog( {
classes: [ 'smg-rename-dialog' ],
size: 'large'
}, function ( renameParams ) {
@@ -38,9 +36,8 @@
* Attach the click handler to display the rename dropdown.
*/
$( '#mw-content-text' ).on( 'click', '.smg-rename-actions', function ( event ) {
- var $target, $parentContainer;
- $target = $( event.target );
- $parentContainer = $target.parents( '.mw-translate-smg-change' );
+ var $target = $( event.target );
+ var $parentContainer = $target.parents( '.mw-translate-smg-change' );
RenameDropdown.appendTo( event.target, $parentContainer, {
groupId: $target.data( 'groupId' ),
msgKey: $target.data( 'msgkey' ),
@@ -142,8 +139,8 @@
* @return {jQuery.Promise}
*/
function getRenames( groupId, msgKey ) {
- var params, api = new mw.Api(), changesetName;
- params = {
+ var api = new mw.Api();
+ var params = {
action: 'query',
meta: 'managemessagegroups',
formatversion: 2,
@@ -151,7 +148,7 @@
mmgmessageKey: msgKey
};
- changesetName = getChangesetName();
+ var changesetName = getChangesetName();
if ( changesetName !== null ) {
params.mmgchangesetName = changesetName;
}
@@ -167,10 +164,9 @@
* @return {string}
*/
function getChangesetName() {
- var locationPaths, suffix, pageTitle;
- locationPaths = window.location.pathname.split( '/' );
- suffix = locationPaths.pop();
- pageTitle = $( '#smgPageTitle' ).val();
+ var locationPaths = window.location.pathname.split( '/' );
+ var suffix = locationPaths.pop();
+ var pageTitle = $( '#smgPageTitle' ).val();
if ( suffix && suffix.indexOf( pageTitle ) === -1 ) {
return suffix;
@@ -199,9 +195,9 @@
* @return {jQuery.Promise}
*/
function setRename( renameParams ) {
- var params, api = new mw.Api(), changesetName;
+ var api = new mw.Api();
- params = {
+ var params = {
action: 'managemessagegroups',
groupId: renameParams.groupId,
renameMessageKey: renameParams.selectedKey,
@@ -212,7 +208,7 @@
formatversion: 2
};
- changesetName = getChangesetName();
+ var changesetName = getChangesetName();
if ( changesetName !== null ) {
params.changesetName = changesetName;
}
@@ -227,9 +223,9 @@
* @return {jQuery.Promise}
*/
function setAsNew( groupId, msgKey ) {
- var params, api = new mw.Api(), changesetName;
+ var api = new mw.Api();
- params = {
+ var params = {
action: 'managemessagegroups',
groupId: groupId,
messageKey: msgKey,
@@ -239,7 +235,7 @@
formatversion: 2
};
- changesetName = getChangesetName();
+ var changesetName = getChangesetName();
if ( changesetName !== null ) {
params.changesetName = changesetName;
}
@@ -406,9 +402,9 @@
}
function markAsResolved( operation, groupId, messageTitle ) {
- var params, api = new mw.Api();
+ var api = new mw.Api();
- params = {
+ var params = {
action: 'managegroupsynchronizationcache',
group: groupId,
operation: operation,
diff --git a/MLEB/Translate/resources/js/ext.translate.special.managetranslatorsandbox.js b/MLEB/Translate/resources/js/ext.translate.special.managetranslatorsandbox.js
index e5986e1a..76b605b9 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.managetranslatorsandbox.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.managetranslatorsandbox.js
@@ -34,14 +34,13 @@
}
function removeSelectedRequests() {
- var $nextRequest,
- $selectedRequests = $( '.request-selector:checked' );
+ var $selectedRequests = $( '.request-selector:checked' );
- $nextRequest = $selectedRequests
+ var $nextRequest = $selectedRequests
.first() // First selected request
.closest( '.request' ) // The request corresponds that checkbox
.prevAll( ':not(.hide)' ) // Go back till a non-hidden request
- .first(); // The above selecter gives list from bottom to top. Select the bottom one.
+ .first(); // The above selector gives list from bottom to top. Select the bottom one.
$selectedRequests.closest( '.request' ).remove();
@@ -67,8 +66,7 @@
* @param {Object} request The request data set from backend on request items
*/
function displayRequestDetails( request ) {
- var storage,
- $reminderStatus = $( '<span>' ).addClass( 'reminder-status' ),
+ var $reminderStatus = $( '<span>' ).addClass( 'reminder-status' ),
$detailsPane = $( '.details.pane' );
if ( request.reminderscount ) {
@@ -182,14 +180,27 @@
}
}
- // @todo: move higher in the tree
- storage = new mw.translate.TranslationStashStorage();
- storage.getUserTranslations( request.username ).done( showTranslations );
+ getUserTranslations( request.username ).done( showTranslations );
+ }
+
+ /**
+ * Get the current users translations.
+ *
+ * @param {string} user User name
+ * @return {jQuery.Promise}
+ */
+ function getUserTranslations( user ) {
+ var api = new mw.Api();
+
+ return api.postWithToken( 'csrf', {
+ action: 'translationstash',
+ subaction: 'query',
+ username: user
+ } );
}
function showTranslations( translations ) {
- var gender,
- $target = $( '.translations' );
+ var $target = $( '.translations' );
$target.empty();
@@ -204,7 +215,7 @@
return;
}
- gender = $( '.requests-list .request.selected' ).data( 'data' ).gender;
+ var gender = $( '.requests-list .request.selected' ).data( 'data' ).gender;
$target.append(
$( '<div>' )
.addClass( 'row title' )
@@ -349,12 +360,11 @@
* or hides that link if there are no such requests.
*/
function indicateOlderRequests() {
- var oldRequestsCount, oldRequestsCountString,
- $olderRequests = getOlderRequests(),
+ var $olderRequests = getOlderRequests(),
$olderRequestsIndicator = $( '.older-requests-indicator' );
- oldRequestsCount = $olderRequests.length;
- oldRequestsCountString = mw.language.convertNumber( oldRequestsCount );
+ var oldRequestsCount = $olderRequests.length;
+ var oldRequestsCountString = mw.language.convertNumber( oldRequestsCount );
if ( oldRequestsCount ) {
$olderRequestsIndicator
@@ -404,8 +414,7 @@
}
function selectAllRequests() {
- var selectedCount,
- $requestCheckboxes = $( '.request-selector' ),
+ var $requestCheckboxes = $( '.request-selector' ),
$detailsPane = $( '.details.pane' ),
$selectAll = $( '.request-selector-all' ),
$requestRows = $( '.requests .request' ),
@@ -419,6 +428,7 @@
} );
} );
+ var selectedCount;
if ( selectAllChecked ) {
displayOnMultipleSelection();
$visibleRows.addClass( 'selected' );
@@ -476,8 +486,7 @@
* @param {jQuery.Event} e
*/
function requestSelectHandler( e ) {
- var checkedCount, $checkedBoxes,
- request = e.target,
+ var request = e.target,
$detailsPane = $( '.details.pane' ),
$requestCheckboxes = $( '.request-selector' ),
$selectAll = $( '.request-selector-all' ),
@@ -492,8 +501,8 @@
$thisRequestRow.removeClass( 'selected' );
}
- $checkedBoxes = $requestCheckboxes.filter( ':checked' );
- checkedCount = $checkedBoxes.length;
+ var $checkedBoxes = $requestCheckboxes.filter( ':checked' );
+ var checkedCount = $checkedBoxes.length;
if ( checkedCount === $requestCheckboxes.length ) {
// All boxes are selected
@@ -561,10 +570,9 @@
}
LanguageFilter.prototype.init = function () {
- var languageFilter = this,
- $clearButton;
+ var languageFilter = this;
- $clearButton = $( '<button>' )
+ var $clearButton = $( '<button>' )
.addClass( 'clear-language-selector hide' )
.text( '×' );
@@ -654,12 +662,11 @@
};
TranslatorSearch.prototype.keyup = function () {
- var query,
- translatorSearch = this;
+ var translatorSearch = this;
// Respond to the keypress events after a small timeout to avoid freeze when typed fast
delay( function () {
- query = translatorSearch.$search.val().trim().toLowerCase();
+ var query = translatorSearch.$search.val().trim().toLowerCase();
translatorSearch.filter( query );
}, 300 );
};
@@ -685,14 +692,13 @@
};
function updateAfterFiltering() {
- var $selectedRequests,
- $firstVisibleUser = $( '.request:not(.hide)' ).first();
+ var $firstVisibleUser = $( '.request:not(.hide)' ).first();
if ( $firstVisibleUser.length ) {
$firstVisibleUser.trigger( 'click' );
} else {
$( '.details.pane' ).empty();
- $selectedRequests = $( '.request-selector:checked' );
+ var $selectedRequests = $( '.request-selector:checked' );
$selectedRequests.closest( '.request' ).removeClass( 'selected' );
$selectedRequests.prop( {
checked: false,
diff --git a/MLEB/Translate/resources/js/ext.translate.special.pagemigration.js b/MLEB/Translate/resources/js/ext.translate.special.pagemigration.js
index 06578db1..126aa564 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.pagemigration.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.pagemigration.js
@@ -17,12 +17,11 @@
function createTranslationPage( i, content ) {
return function () {
- var identifier, title, summary,
- api = new mw.Api();
+ var api = new mw.Api();
- identifier = sourceUnits[ i ].identifier;
- title = 'Translations:' + pageName + '/' + identifier + '/' + langCode;
- summary = $( '#pm-summary' ).val();
+ var identifier = sourceUnits[ i ].identifier;
+ var title = 'Translations:' + pageName + '/' + identifier + '/' + langCode;
+ var summary = $( '#pm-summary' ).val();
return api.postWithToken( 'csrf', {
action: 'edit',
@@ -53,9 +52,9 @@
rvstart: fuzzyTimestamp,
titles: pageTitle
} ).then( function ( data ) {
- var pageContent, oldTranslationUnits, obj, page,
- $errorBox = $( '.mw-tpm-sp-error__message' );
- for ( page in data.query.pages ) {
+ var $errorBox = $( '.mw-tpm-sp-error__message' );
+ var obj;
+ for ( var page in data.query.pages ) {
obj = data.query.pages[ page ];
}
if ( obj === undefined ) {
@@ -68,9 +67,8 @@
$errorBox.text( mw.msg( 'pm-old-translations-missing', pageTitle ) ).removeClass( 'hide' );
return $.Deferred().reject();
}
- pageContent = obj.revisions[ 0 ][ '*' ];
- oldTranslationUnits = pageContent.split( '\n\n' );
- return oldTranslationUnits;
+ var pageContent = obj.revisions[ 0 ][ '*' ];
+ return pageContent.split( '\n\n' );
} );
}
@@ -94,10 +92,9 @@
rvdir: 'newer',
titles: pageTitle
} ).then( function ( data ) {
- var timestampFB, dateFB, timestampOld,
- page, obj,
- $errorBox = $( '.mw-tpm-sp-error__message' );
- for ( page in data.query.pages ) {
+ var $errorBox = $( '.mw-tpm-sp-error__message' );
+ var obj;
+ for ( var page in data.query.pages ) {
obj = data.query.pages[ page ];
}
// Page does not exist if missing field is present
@@ -111,10 +108,10 @@
return $.Deferred().reject();
} else {
// FB over here refers to FuzzyBot
- timestampFB = obj.revisions[ 0 ].timestamp;
- dateFB = new Date( timestampFB );
+ var timestampFB = obj.revisions[ 0 ].timestamp;
+ var dateFB = new Date( timestampFB );
dateFB.setSeconds( dateFB.getSeconds() - 1 );
- timestampOld = dateFB.toISOString();
+ var timestampOld = dateFB.toISOString();
mw.log( 'New Timestamp: ' + timestampOld );
return timestampOld;
}
@@ -124,27 +121,26 @@
/**
* Get the translation units created by Translate extension.
*
- * @param {string} pageName
+ * @param {string} page Page name
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {Object[]} return.done.data Array of sUnit Objects
*/
- function getSourceUnits( pageName ) {
+ function getSourceUnits( page ) {
var api = new mw.Api();
return api.get( {
action: 'query',
list: 'messagecollection',
- mcgroup: 'page-' + pageName,
+ mcgroup: 'page-' + page,
mclanguage: 'en',
mcprop: 'definition'
} ).then( function ( data ) {
- var result, i, sUnit, key;
sourceUnits = [];
- result = data.query.messagecollection;
- for ( i = 0; i < result.length; i++ ) {
- sUnit = {};
- key = result[ i ].key;
+ var result = data.query.messagecollection;
+ for ( var i = 0; i < result.length; i++ ) {
+ var sUnit = {};
+ var key = result[ i ].key;
sUnit.identifier = key.slice( key.lastIndexOf( '/' ) + 1 );
sUnit.definition = result[ i ].definition;
sourceUnits.push( sUnit );
@@ -159,12 +155,11 @@
* @param {jQuery} $start The starting node
*/
function shiftRowsUp( $start ) {
- var nextVal,
- $current = $start,
+ var $current = $start,
$next = $start.next();
while ( $next.length ) {
- nextVal = $next.find( '.mw-tpm-sp-unit__target' ).val();
+ var nextVal = $next.find( '.mw-tpm-sp-unit__target' ).val();
$current.find( '.mw-tpm-sp-unit__target' ).val( nextVal );
$current = $next;
$next = $current.next();
@@ -185,10 +180,8 @@
* @return {string} text The text of the last row
*/
function shiftRowsDown( $nextRow, text ) {
- var oldText;
-
while ( $nextRow.length ) {
- oldText = $nextRow.find( '.mw-tpm-sp-unit__target' ).val();
+ var oldText = $nextRow.find( '.mw-tpm-sp-unit__target' ).val();
$nextRow.find( '.mw-tpm-sp-unit__target' ).val( text );
$nextRow = $nextRow.next();
text = oldText;
@@ -205,14 +198,12 @@
*/
function createNewUnit( sourceText, targetText ) {
- var $newUnit, $sourceUnit, $targetUnit, $actionUnit;
-
- $newUnit = $( '<div>' ).addClass( 'mw-tpm-sp-unit row' );
- $sourceUnit = $( '<textarea>' ).addClass( 'mw-tpm-sp-unit__source five columns' )
+ var $newUnit = $( '<div>' ).addClass( 'mw-tpm-sp-unit row' );
+ var $sourceUnit = $( '<textarea>' ).addClass( 'mw-tpm-sp-unit__source five columns' )
.prop( 'readonly', true ).attr( 'tabindex', '-1' ).val( sourceText );
- $targetUnit = $( '<textarea>' ).addClass( 'mw-tpm-sp-unit__target five columns' )
+ var $targetUnit = $( '<textarea>' ).addClass( 'mw-tpm-sp-unit__target five columns' )
.val( targetText ).prop( 'dir', $.uls.data.getDir( langCode ) );
- $actionUnit = $( '<div>' ).addClass( 'mw-tpm-sp-unit__actions two columns' );
+ var $actionUnit = $( '<div>' ).addClass( 'mw-tpm-sp-unit__actions two columns' );
$actionUnit.append(
$( '<span>' ).addClass( 'mw-tpm-sp-action mw-tpm-sp-action--add' )
.attr( 'title', mw.msg( 'pm-add-icon-hover-text' ) ),
@@ -228,27 +219,24 @@
/**
* Display the source and target units alongwith the action icons.
*
- * @param {Array} sourceUnits
+ * @param {Array} units
* @param {Array} translations
*/
- function displayUnits( sourceUnits, translations ) {
- var i, totalUnits, $newUnit, $unitListing,
- sourceText, targetText;
-
- noOfSourceUnits = sourceUnits.length;
+ function displayUnits( units, translations ) {
+ noOfSourceUnits = units.length;
noOfTranslationUnits = translations.length;
- totalUnits = noOfSourceUnits > noOfTranslationUnits ? noOfSourceUnits : noOfTranslationUnits;
- $unitListing = $( '.mw-tpm-sp-unit-listing' );
+ var totalUnits = noOfSourceUnits > noOfTranslationUnits ? noOfSourceUnits : noOfTranslationUnits;
+ var $unitListing = $( '.mw-tpm-sp-unit-listing' );
$unitListing.html( '' );
- for ( i = 0; i < totalUnits; i++ ) {
- sourceText = targetText = '';
- if ( sourceUnits[ i ] !== undefined ) {
- sourceText = sourceUnits[ i ].definition;
+ for ( var i = 0; i < totalUnits; i++ ) {
+ var sourceText = '', targetText = '';
+ if ( units[ i ] !== undefined ) {
+ sourceText = units[ i ].definition;
}
if ( translations[ i ] !== undefined ) {
targetText = translations[ i ];
}
- $newUnit = createNewUnit( sourceText, targetText );
+ var $newUnit = createNewUnit( sourceText, targetText );
$unitListing.append( $newUnit );
}
}
@@ -263,7 +251,10 @@
return translations.map( function ( elem ) {
// Check https://regex101.com/r/oT7fZ2 for details
return elem.match( /(^==.+$|(?:(?!^==).+\n?)+)/gm );
- } );
+ } ).reduce( function ( acc, val ) {
+ // This should be an Array.prototype.flatMap when ES2019 is supported
+ return acc.concat( val );
+ }, [] );
}
/**
@@ -274,9 +265,8 @@
* @return {number} Index of the next unit found, -1 if not.
*/
function getHeaderUnit( startIndex, translationUnits ) {
- var i, regex;
- regex = new RegExp( /^==[^=]+==$/m );
- for ( i = startIndex; i < translationUnits.length; i++ ) {
+ var regex = new RegExp( /^==[^=]+==$/m );
+ for ( var i = startIndex; i < translationUnits.length; i++ ) {
if ( regex.test( translationUnits[ i ] ) ) {
return i;
}
@@ -289,26 +279,24 @@
* Assumption: The source headers and translation headers appear in
* the same order.
*
- * @param {Object[]} sourceUnits
+ * @param {Object[]} units
* @param {string[]} translationUnits
* @return {string[]}
*/
- function alignHeaders( sourceUnits, translationUnits ) {
- var i, regex, tIndex = 0,
- matchText, emptyCount, mergeText;
-
- regex = new RegExp( /^==[^=]+==$/m );
- for ( i = 0; i < sourceUnits.length; i++ ) {
- if ( regex.test( sourceUnits[ i ].definition ) ) {
+ function alignHeaders( units, translationUnits ) {
+ var tIndex = 0;
+ var regex = new RegExp( /^==[^=]+==$/m );
+ for ( var i = 0; i < units.length; i++ ) {
+ if ( regex.test( units[ i ].definition ) ) {
tIndex = getHeaderUnit( tIndex, translationUnits );
- mergeText = '';
+ var mergeText = '';
// search is over
if ( tIndex === -1 ) {
break;
}
// remove the unit
- matchText = translationUnits.splice( tIndex, 1 ).toString();
- emptyCount = i - tIndex;
+ var matchText = translationUnits.splice( tIndex, 1 ).toString();
+ var emptyCount = i - tIndex;
if ( emptyCount > 0 ) {
// add empty units
while ( emptyCount !== 0 ) {
@@ -340,7 +328,7 @@
* Handler for 'Save' button click event.
*/
function saveHandler() {
- var i, content, list = [];
+ var list = [];
$( '.mw-tpm-sp-error__message' ).addClass( 'hide' );
if ( noOfSourceUnits < noOfTranslationUnits ) {
@@ -350,8 +338,8 @@
} else {
$( 'input' ).prop( 'disabled', true );
$( '.mw-tpm-sp-instructions' ).addClass( 'hide' );
- for ( i = 0; i < noOfSourceUnits; i++ ) {
- content = $( '.mw-tpm-sp-unit__target' ).eq( i ).val();
+ for ( var i = 0; i < noOfSourceUnits; i++ ) {
+ var content = $( '.mw-tpm-sp-unit__target' ).eq( i ).val();
content = content.trim();
if ( content !== '' ) {
list.push( createTranslationPage( i, content ) );
@@ -390,16 +378,14 @@
* @param {jQuery.Event} event
*/
function addHandler( event ) {
- var $nextRow, text, $newUnit, $targetUnit;
-
- $nextRow = $( event.target ).closest( '.mw-tpm-sp-unit' ).next();
- $targetUnit = $nextRow.find( '.mw-tpm-sp-unit__target' );
- text = $targetUnit.val();
+ var $nextRow = $( event.target ).closest( '.mw-tpm-sp-unit' ).next();
+ var $targetUnit = $nextRow.find( '.mw-tpm-sp-unit__target' );
+ var text = $targetUnit.val();
$targetUnit.val( '' );
$nextRow = $nextRow.next();
text = shiftRowsDown( $nextRow, text );
if ( text ) {
- $newUnit = createNewUnit( '', text );
+ var $newUnit = createNewUnit( '', text );
$( '.mw-tpm-sp-unit-listing' ).append( $newUnit );
}
noOfTranslationUnits += 1;
@@ -412,9 +398,8 @@
* @param {jQuery.Event} event
*/
function deleteHandler( event ) {
- var sourceText, $rowUnit;
- $rowUnit = $( event.target ).closest( '.mw-tpm-sp-unit' );
- sourceText = $rowUnit.find( '.mw-tpm-sp-unit__source' ).val();
+ var $rowUnit = $( event.target ).closest( '.mw-tpm-sp-unit' );
+ var sourceText = $rowUnit.find( '.mw-tpm-sp-unit__source' ).val();
if ( !sourceText ) {
$rowUnit.remove();
} else {
@@ -431,10 +416,9 @@
* @param {jQuery.Event} event
*/
function swapHandler( event ) {
- var $rowUnit, tempText, nextVal;
- $rowUnit = $( event.target ).closest( '.mw-tpm-sp-unit' );
- tempText = $rowUnit.find( '.mw-tpm-sp-unit__target' ).val();
- nextVal = $rowUnit.next().find( '.mw-tpm-sp-unit__target' ).val();
+ var $rowUnit = $( event.target ).closest( '.mw-tpm-sp-unit' );
+ var tempText = $rowUnit.find( '.mw-tpm-sp-unit__target' ).val();
+ var nextVal = $rowUnit.next().find( '.mw-tpm-sp-unit__target' ).val();
$rowUnit.find( '.mw-tpm-sp-unit__target' ).val( nextVal );
$rowUnit.next().find( '.mw-tpm-sp-unit__target' ).val( tempText );
}
@@ -446,19 +430,18 @@
* @param {jQuery.Event} e
*/
function importHandler( e ) {
- var pageTitle, slashPos, titleObj,
- $errorBox = $( '.mw-tpm-sp-error__message' ),
+ var $errorBox = $( '.mw-tpm-sp-error__message' ),
$messageBox = $( '.mw-tpm-sp-instructions' );
e.preventDefault();
- pageTitle = $( '#title' ).val().trim();
+ var pageTitle = $( '#title' ).val().trim();
if ( pageTitle === '' ) {
$errorBox.text( mw.msg( 'pm-pagetitle-missing' ) ).removeClass( 'hide' );
return;
}
- titleObj = mw.Title.newFromText( pageTitle );
+ var titleObj = mw.Title.newFromText( pageTitle );
$messageBox.addClass( 'hide' );
if ( titleObj === null ) {
$errorBox.text( mw.msg( 'pm-pagetitle-invalid' ) ).removeClass( 'hide' );
@@ -466,7 +449,7 @@
}
pageTitle = titleObj.getPrefixedDb();
- slashPos = pageTitle.lastIndexOf( '/' );
+ var slashPos = pageTitle.lastIndexOf( '/' );
if ( slashPos === -1 ) {
$errorBox.text( mw.msg( 'pm-langcode-missing' ) ).removeClass( 'hide' );
@@ -484,13 +467,13 @@
$errorBox.addClass( 'hide' );
$.when( getSourceUnits( pageName ), getFuzzyTimestamp( pageTitle ) )
- .then( function ( sourceUnits, fuzzyTimestamp ) {
- noOfSourceUnits = sourceUnits.length;
+ .then( function ( units, fuzzyTimestamp ) {
+ noOfSourceUnits = units.length;
splitTranslationPage( fuzzyTimestamp, pageTitle ).done( function ( translations ) {
var translationUnits = splitHeaders( translations );
- translationUnits = alignHeaders( sourceUnits, translationUnits );
+ translationUnits = alignHeaders( units, translationUnits );
noOfTranslationUnits = translationUnits.length;
- displayUnits( sourceUnits, translationUnits );
+ displayUnits( units, translationUnits );
$( '#action-save, #action-cancel' ).removeClass( 'hide' );
$( '#action-import' ).addClass( 'hide' );
$messageBox.text( mw.msg( 'pm-on-import-message-text' ) ).removeClass( 'hide' );
@@ -520,6 +503,7 @@
getSourceUnits: getSourceUnits,
getFuzzyTimestamp: getFuzzyTimestamp,
splitTranslationPage: splitTranslationPage,
+ splitHeaders: splitHeaders,
alignHeaders: alignHeaders
} );
diff --git a/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js b/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js
index cdf1aa52..8b1edea9 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.pagepreparation.js
@@ -39,12 +39,12 @@
titles: pageName,
rvdifftotext: pageContent
} ).then( function ( data ) {
- var page, obj, diff;
-
- for ( page in data.query.pages ) {
+ var obj;
+ for ( var page in data.query.pages ) {
obj = data.query.pages[ page ];
}
+ var diff;
if ( obj !== undefined ) {
diff = obj.revisions[ 0 ].diff[ '*' ];
}
@@ -89,16 +89,14 @@
*/
function doCategories( pageContent ) {
return getNamespaceAliases( 14 ).then( function ( aliases ) {
- var i, aliasList, categoryRegex;
-
aliases.push( 'category' );
- for ( i = 0; i < aliases.length; i++ ) {
+ for ( var i = 0; i < aliases.length; i++ ) {
aliases[ i ] = mw.util.escapeRegExp( aliases[ i ] );
}
- aliasList = aliases.join( '|' );
+ var aliasList = aliases.join( '|' );
// Regex: https://regex101.com/r/sJ3gZ4/2
- categoryRegex = new RegExp( '\\[\\[((' + aliasList + ')' +
+ var categoryRegex = new RegExp( '\\[\\[((' + aliasList + ')' +
':[^\\|]+)(\\|[^\\|]*?)?\\]\\]', 'gi' );
pageContent = pageContent.replace( categoryRegex, '\n</translate>\n' +
'[[$1{{#translation:}}$3]]\n<translate>\n' );
@@ -140,15 +138,12 @@
* @return {string}
*/
function addAnchor( headerText, pageContent ) {
- var headerSearchRegex, anchorID, replaceAnchorRegex,
- spanSearchRegex;
-
- anchorID = headerText.replace( ' ', '-' ).toLowerCase();
+ var anchorID = headerText.replace( ' ', '-' ).toLowerCase();
headerText = mw.RegExp.escape( headerText );
// Search for the header having text as headerText
// Regex: https://regex101.com/r/fD6iL1
- headerSearchRegex = new RegExp( '(==+[ ]*' + headerText + '[ ]*==+)', 'gi' );
+ var headerSearchRegex = new RegExp( '(==+[ ]*' + headerText + '[ ]*==+)', 'gi' );
// This is to ensure the tags and the anchor are added only once
if ( pageContent.indexOf( '<span id="' + mw.html.escape( anchorID ) + '"' ) === -1 ) {
@@ -158,13 +153,13 @@
// This is to add back the tags which were removed in cleanupTags()
if ( pageContent.indexOf( '</translate>\n<span id="' + anchorID + '"' ) === -1 ) {
- spanSearchRegex = new RegExp( '(<span id="' + mw.RegExp.escape( anchorID ) + '"></span>)', 'gi' );
+ var spanSearchRegex = new RegExp( '(<span id="' + mw.RegExp.escape( anchorID ) + '"></span>)', 'gi' );
pageContent = pageContent.replace( spanSearchRegex, '\n</translate>\n$1\n</translate>\n' );
}
// Replace the link text with the anchorID defined above
// Regex: https://regex101.com/r/kB5bK3
- replaceAnchorRegex = new RegExp( '(\\[\\[#)' + headerText + '(.*\\]\\])', 'gi' );
+ var replaceAnchorRegex = new RegExp( '(\\[\\[#)' + headerText + '(.*\\]\\])', 'gi' );
pageContent = pageContent.replace( replaceAnchorRegex, '$1' +
anchorID.replace( '$', '$$$' ) + '$2' );
@@ -180,29 +175,26 @@
* @return {string}
*/
function fixInternalLinks( pageContent ) {
+ var searchText = pageContent;
- var normalizeRegex, linkPrefixRegex, sectionLinksRegex,
- match, searchText, namespaces, nsString;
- searchText = pageContent;
-
- normalizeRegex = new RegExp( /\[\[(?!Category)([^|]*?)\]\]/gi );
+ var normalizeRegex = new RegExp( /\[\[(?!Category)([^|]*?)\]\]/gi );
// First convert all links into two-party form. If a link is not having a pipe,
// add a pipe and duplicate the link text
// Regex: https://regex101.com/r/pO9nN2
pageContent = pageContent.replace( normalizeRegex, '[[$1|$1]]' );
- namespaces = getNamespaces();
- nsString = namespaces.join( '|' );
+ var namespaces = getNamespaces();
+ var nsString = namespaces.join( '|' );
// Finds all the links to sections on the same page.
// Regex: https://regex101.com/r/cX6jT3
- sectionLinksRegex = new RegExp( /\[\[#(.*?)(\|(.*?))?\]\]/gi );
- match = sectionLinksRegex.exec( searchText );
+ var sectionLinksRegex = new RegExp( /\[\[#(.*?)(\|(.*?))?\]\]/gi );
+ var match = sectionLinksRegex.exec( searchText );
while ( match !== null ) {
pageContent = addAnchor( match[ 1 ], pageContent );
match = sectionLinksRegex.exec( searchText );
}
- linkPrefixRegex = new RegExp( '\\[\\[((?:(?:special(?!:MyLanguage\\b)|' + nsString +
+ var linkPrefixRegex = new RegExp( '\\[\\[((?:(?:special(?!:MyLanguage\\b)|' + nsString +
'):)?[^:]*?)\\]\\]', 'gi' );
// Add the 'Special:MyLanguage/' prefix for all internal links of valid namespaces and
// mainspace.
@@ -227,9 +219,9 @@
meta: 'siteinfo',
siprop: 'namespacealiases'
} ).then( function ( data ) {
- var alias, aliases = [];
+ var aliases = [];
- for ( alias in data.query.namespacealiases ) {
+ for ( var alias in data.query.namespacealiases ) {
if ( data.query.namespacealiases[ alias ].id === namespaceID ) {
aliases.push( data.query.namespacealiases[ alias ][ '*' ] );
}
@@ -248,23 +240,21 @@
*/
function doFiles( pageContent ) {
return getNamespaceAliases( 6 ).then( function ( aliases ) {
- var i, aliasList, captionFilesRegex, fileRegex;
-
aliases.push( 'file' );
- for ( i = 0; i < aliases.length; i++ ) {
+ for ( var i = 0; i < aliases.length; i++ ) {
aliases[ i ] = mw.RegExp.escape( aliases[ i ] );
}
- aliasList = aliases.join( '|' );
+ var aliasList = aliases.join( '|' );
// Add translate tags for files with captions
- captionFilesRegex = new RegExp( '\\[\\[(' + aliasList + ')(.*\\|)(.*?)\\]\\]', 'gi' );
+ var captionFilesRegex = new RegExp( '\\[\\[(' + aliasList + ')(.*\\|)(.*?)\\]\\]', 'gi' );
pageContent = pageContent.replace( captionFilesRegex,
'</translate>\n[[$1$2<translate>$3</translate>]]\n<translate>' );
// Add translate tags for files without captions
- fileRegex = new RegExp( '/\\[\\[((' + aliasList + ')[^\\|]*?)\\]\\]', 'gi' );
+ var fileRegex = new RegExp( '/\\[\\[((' + aliasList + ')[^\\|]*?)\\]\\]', 'gi' );
pageContent = pageContent.replace( fileRegex, '\n</translate>[[$1]]\n<translate>' );
return pageContent;
@@ -279,9 +269,8 @@
* @return {string} pageContent
*/
function doTemplates( pageContent ) {
- var templateRegex;
// Regex: https://regex101.com/r/wA3iX0
- templateRegex = new RegExp( /^({{[\s\S]*?}})/gm );
+ var templateRegex = new RegExp( /^({{[\s\S]*?}})/gm );
pageContent = pageContent.replace( templateRegex, '</translate>\n$1\n<translate>' );
return pageContent;
@@ -312,8 +301,7 @@
* @return {string} return.done.value The current revision
*/
function getPageContent( pageName ) {
- var obj,
- api = new mw.Api();
+ var api = new mw.Api();
return api.get( {
action: 'query',
@@ -322,9 +310,9 @@
rvlimit: '1',
titles: pageName
} ).then( function ( data ) {
- var page;
+ var obj;
- for ( page in data.query.pages ) {
+ for ( var page in data.query.pages ) {
obj = data.query.pages[ page ];
}
@@ -339,11 +327,10 @@
* @return {Array} Array of valid namespaces
*/
function getNamespaces() {
- var key, namespacesObject, i,
- namespaces = [];
+ var namespaces = [];
- namespacesObject = mw.config.get( 'wgNamespaceIds' );
- for ( key in namespacesObject ) {
+ var namespacesObject = mw.config.get( 'wgNamespaceIds' );
+ for ( var key in namespacesObject ) {
namespaces.push( key );
}
@@ -352,25 +339,24 @@
namespaces.splice( namespaces.indexOf( ns ), 1 );
} );
- for ( i = 0; i < namespaces.length; i++ ) {
+ for ( var i = 0; i < namespaces.length; i++ ) {
namespaces[ i ] = mw.RegExp.escape( namespaces[ i ] );
}
return namespaces;
}
$( function () {
- var pageContent,
- $input = $( '#page' );
+ var $input = $( '#page' );
$( '#action-cancel' ).on( 'click', function () {
document.location.reload( true );
} );
+ var pageContent;
$( '#action-save' ).on( 'click', function () {
- var pageName,
- pageUrl = '';
+ var pageUrl = '';
- pageName = $input.val().trim();
+ var pageName = $input.val().trim();
savePage( pageName, pageContent ).done( function () {
pageUrl = mw.Title.newFromText( pageName ).getUrl( { action: 'edit' } );
$( '.messageDiv' )
@@ -386,9 +372,9 @@
} );
$( '#action-prepare' ).on( 'click', function () {
- var pageName, $messageDiv = $( '.messageDiv' );
+ var $messageDiv = $( '.messageDiv' );
- pageName = $input.val().trim();
+ var pageName = $input.val().trim();
$messageDiv.addClass( 'hide' );
if ( pageName === '' ) {
// eslint-disable-next-line no-alert
diff --git a/MLEB/Translate/resources/js/ext.translate.special.pagetranslation.js b/MLEB/Translate/resources/js/ext.translate.special.pagetranslation.js
index fc27242a..ab0cee82 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.pagetranslation.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.pagetranslation.js
@@ -13,12 +13,10 @@ var LanguagesMultiselectWidget = require( './LanguagesMultiselectWidget.js' );
window.LanguagesMultiselectWidget = LanguagesMultiselectWidget;
function configureLanguageInput( $form, $widget ) {
- var widget, $input;
-
/** @type {LanguagesMultiselectWidget} */
- widget = OO.ui.infuse( $widget, { api: new mw.Api() } );
+ var widget = OO.ui.infuse( $widget, { api: new mw.Api() } );
- $input = $( '<input>' ).prop( {
+ var $input = $( '<input>' ).prop( {
type: 'hidden',
name: 'prioritylangs',
value: widget.getValue()
@@ -32,10 +30,9 @@ function configureLanguageInput( $form, $widget ) {
function configurePostLinks( $container ) {
$container.on( 'click', '.mw-translate-jspost', function ( e ) {
- var params,
- uri = new mw.Uri( e.target.href );
+ var uri = new mw.Uri( e.target.href );
- params = uri.query;
+ var params = uri.query;
params.token = mw.user.tokens.get( 'csrfToken' );
$.post( uri.path, params ).done( function () {
location.reload();
@@ -47,21 +44,11 @@ function configurePostLinks( $container ) {
// Init
$( function () {
- var mediaWikiVersion = mw.config.get( 'wgVersion' ),
- $widgets = $( '#mw-translate-SpecialPageTranslation-prioritylangs' );
+ var $widgets = $( '#mw-translate-SpecialPageTranslation-prioritylangs' );
configurePostLinks( $( '#mw-content-text' ) );
if ( $widgets.length ) {
- // On MW 1.34, pre-selected priority languages are not being displayed when using
- // LanguagesMultiselectWidget, which in turn uses MenuTagMultiselectWidget.
- // This could be due to an older version of OOUI.
- // Use a normal textarea and remove the loading input.
- if ( ( /^1\.34\./ ).test( mediaWikiVersion ) ) {
- $widgets.find( '.oo-ui-textInputWidget' ).last().remove();
- return;
- }
-
configureLanguageInput( $( '.mw-tpt-sp-markform' ), $widgets );
}
} );
diff --git a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
index e3f5ecb8..2aea5b90 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
@@ -43,9 +43,8 @@
// Make other old browsers happy
if ( !Object.keys ) {
Object.keys = function ( obj ) {
- var keys = [],
- k;
- for ( k in obj ) {
+ var keys = [];
+ for ( var k in obj ) {
if ( Object.prototype.hasOwnProperty.call( obj, k ) ) {
keys.push( k );
}
@@ -55,42 +54,31 @@
}
function showLanguages() {
- var $languages,
- languages,
- ulslanguages = [],
- currentLanguage,
- resultCount,
- $count,
- result,
- i,
+ var ulslanguages = [],
selectedClasss = '',
- languageCode,
quickLanguageList = [],
- unique = [],
- $ulsTrigger,
- uri;
+ unique = [];
- $languages = $( '.facet.languages' );
- languages = $languages.data( 'facets' );
- currentLanguage = $languages.data( 'language' );
+ var $languages = $( '.facet.languages' );
+ var languages = $languages.data( 'facets' );
+ var currentLanguage = $languages.data( 'language' );
if ( !languages ) {
return;
}
if ( currentLanguage !== '' ) {
- uri = new mw.Uri( location.href );
+ var uri = new mw.Uri( location.href );
uri.extend( { language: '', filter: '' } );
addToSelectedBox( getLanguageLabel( currentLanguage ), uri.toString() );
}
- resultCount = Object.keys( languages ).length;
+ var resultCount = Object.keys( languages ).length;
quickLanguageList = quickLanguageList.concat( mw.uls.getFrequentLanguageList() )
.concat( Object.keys( languages ) );
// Remove duplicates from the language list
quickLanguageList.forEach( function ( lang ) {
- result = languages[ lang ];
- if ( result && unique.indexOf( lang ) === -1 ) {
+ if ( languages[ lang ] && unique.indexOf( lang ) === -1 ) {
unique.push( lang );
}
} );
@@ -106,9 +94,9 @@
quickLanguageList.sort( sortLanguages );
- for ( i = 0; i <= quickLanguageList.length; i++ ) {
- languageCode = quickLanguageList[ i ];
- result = languages[ languageCode ];
+ for ( var i = 0; i <= quickLanguageList.length; i++ ) {
+ var languageCode = quickLanguageList[ i ];
+ var result = languages[ languageCode ];
if ( !result ) {
continue;
}
@@ -123,6 +111,9 @@
.addClass( 'row facet-item' )
.append(
$( '<span>' )
+ // The following classes are used here:
+ // * selected
+ // * or no class
.addClass( 'facet-name ' + selectedClasss )
.append( $( '<a>' )
.attr( 'href', result.url )
@@ -135,17 +126,17 @@
);
}
- Object.keys( languages ).forEach( function ( languageCode ) {
- ulslanguages[ languageCode ] = mw.config.get( 'wgTranslateLanguages' )[ languageCode ];
+ Object.keys( languages ).forEach( function ( lang ) {
+ ulslanguages[ lang ] = mw.config.get( 'wgTranslateLanguages' )[ lang ];
} );
mw.translate.addExtraLanguagesToLanguageData( ulslanguages, [ 'SP' ] );
if ( resultCount > 6 ) {
- $ulsTrigger = $( '<a>' )
+ var $ulsTrigger = $( '<a>' )
.text( '...' )
.addClass( 'translate-search-more-languages' );
- $count = $( '<span>' )
+ var $count = $( '<span>' )
.addClass( 'translate-search-more-languages-info' )
.text( mw.msg( 'translate-search-more-languages-info', resultCount - quickLanguageList.length ) );
$languages.append( $ulsTrigger, $count );
@@ -164,42 +155,29 @@
}
function showMessageGroups() {
- var currentGroup,
- groupList,
- $groups;
-
- $groups = $( '.facet.groups' );
+ var $groups = $( '.facet.groups' );
if ( !resultGroups ) {
// No search results
return;
}
- groupList = Object.keys( resultGroups );
- listGroups( groupList, currentGroup, $groups );
+ var groupList = Object.keys( resultGroups );
+ listGroups( groupList, undefined, $groups );
}
function listGroups( groupList, parentGrouppath, $parent, level ) {
- var i,
- $grouSelectorTrigger,
- selectedClass = '',
- group,
- groupId,
- $groupRow,
- uri,
+ var selectedClass = '',
maxListSize = 10,
currentGroup = $( '.facet.groups' ).data( 'group' ),
- resultCount = groupList.length,
- position,
- options,
- grouppath;
+ resultCount = groupList.length;
level = level || 0;
groupList.sort( sortGroups );
if ( level === 0 ) {
groupList = groupList.splice( 0, maxListSize );
}
- grouppath = getParameterByName( 'grouppath' ).split( '|' )[ 0 ];
+ var grouppath = getParameterByName( 'grouppath' ).split( '|' )[ 0 ];
if ( currentGroup && resultGroups[ grouppath ] &&
groupList.indexOf( grouppath ) < 0 &&
level === 0
@@ -208,14 +186,14 @@
groupList = groupList.concat( grouppath );
}
groupList.sort( sortGroups );
- for ( i = 0; i < groupList.length; i++ ) {
- groupId = groupList[ i ];
- group = findGroup( groupId, resultGroups );
+ for ( var i = 0; i < groupList.length; i++ ) {
+ var groupId = groupList[ i ];
+ var group = findGroup( groupId, resultGroups );
if ( !group ) {
continue;
}
- uri = new mw.Uri( location.href );
+ var uri = new mw.Uri( location.href );
if ( parentGrouppath !== undefined ) {
grouppath = parentGrouppath + '|' + groupId;
} else {
@@ -232,10 +210,16 @@
uri.extend( { group: groupId, grouppath: grouppath } );
}
- $groupRow = $( '<div>' )
+ var $groupRow = $( '<div>' )
+ // The following classes are used here:
+ // * facet-level-0
+ // * facet-level-1
+ // * facet-level-2
+ // * facet-level-3
.addClass( 'row facet-item facet-level-' + level )
.append(
$( '<span>' )
+ // Class name documented above
.addClass( 'facet-name ' + selectedClass )
.append( $( '<a>' )
.attr( 'href', uri.toString() )
@@ -252,7 +236,7 @@
}
if ( resultCount > maxListSize && resultCount - groupList.length > 0 && level === 0 ) {
- $grouSelectorTrigger = $( '<div>' )
+ var $grouSelectorTrigger = $( '<div>' )
.addClass( 'rowfacet-item ' )
.append(
$( '<a>' )
@@ -265,6 +249,7 @@
);
$parent.append( $grouSelectorTrigger );
+ var position;
if ( $( document.body ).hasClass( 'rtl' ) ) {
position = {
my: 'right top',
@@ -278,7 +263,7 @@
collision: 'none'
};
}
- options = {
+ var options = {
language: mw.config.get( 'wgUserLanguage' ),
position: position,
onSelect: function ( selectedGroup ) {
@@ -316,13 +301,13 @@
}
function matchOperators( str, callback ) {
- var matches,
- counter = false,
+ var counter = false,
// Add operators for different filters
operatorRegex = [ 'language', 'group', 'filter' ];
operatorRegex.forEach( function ( value ) {
var regex = new RegExp( value + ':(\\S+)', 'i' );
+ var matches;
if ( ( matches = regex.exec( str ) ) !== null ) {
counter = true;
callback( {
diff --git a/MLEB/Translate/resources/js/ext.translate.special.translate.js b/MLEB/Translate/resources/js/ext.translate.special.translate.js
index 1b80061a..1034d7ad 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.translate.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.translate.js
@@ -1,7 +1,9 @@
( function () {
'use strict';
- var state = {
+ var state, hideOptionalMessages = '!optional';
+
+ state = {
group: null,
language: null,
messageList: null
@@ -18,15 +20,13 @@
* @param {Object} group a message group object.
*/
changeGroup: function ( group ) {
- var changes;
-
if ( !checkDirty() ) {
return;
}
state.group = group.id;
- changes = {
+ var changes = {
group: group.id,
showMessage: null
@@ -51,8 +51,8 @@
mw.translate.updateTabLinks( changes );
$( '.tux-editor-header .group-warning' ).empty();
state.messageList.changeSettings( changes );
+ state.groupSelector.updateTargetLanguage( language );
updateGroupInformation( state );
-
},
changeFilter: function ( filter ) {
@@ -98,10 +98,8 @@
*/
updateTabLinks: function ( params ) {
$( '.tux-tab a' ).each( function () {
- var $a, uri;
-
- $a = $( this );
- uri = new mw.Uri( $a.prop( 'href' ) );
+ var $a = $( this );
+ var uri = new mw.Uri( $a.prop( 'href' ) );
uri.extend( params );
$a.prop( 'href', uri.toString() );
} );
@@ -109,12 +107,10 @@
} );
function getActualFilter( filter ) {
- var realFilters, uri;
-
- realFilters = [ '!ignored' ];
- uri = new mw.Uri( window.location.href );
+ var realFilters = [ '!ignored' ];
+ var uri = new mw.Uri( window.location.href );
if ( uri.query.optional !== '1' ) {
- realFilters.push( '!optional' );
+ realFilters.push( hideOptionalMessages );
}
if ( filter ) {
realFilters.push( filter );
@@ -179,15 +175,24 @@
}
function updateGroupWarning( group, language ) {
- var $preferredLanguages, headerMessage, languagesMessage,
- $groupWarning = $( '.tux-editor-header .group-warning' );
+ var $groupWarning = $( '.tux-editor-header .group-warning' );
+
+ if ( group.priority === 'discouraged' ) {
+ $groupWarning.append(
+ $( '<p>' ).append( $( '<strong>' )
+ .text( mw.message( 'tpt-discouraged-translation-header' ).text() )
+ ),
+ $( '<p>' ).append( mw.message( 'tpt-discouraged-translation-content' ).parseDom() )
+ );
+ return;
+ }
if ( !group.prioritylangs || isPriorityLanguage( language, group.prioritylangs ) ) {
return;
}
// Make a comma-separated list of preferred languages
- $preferredLanguages = $( '<span>' );
+ var $preferredLanguages = $( '<span>' );
group.prioritylangs.forEach( function ( languageCode, index ) {
// bidi isolation for language names
$preferredLanguages.append(
@@ -200,6 +205,7 @@
}
} );
+ var headerMessage, languagesMessage;
if ( group.priorityforce ) {
headerMessage = mw.message(
'tpt-discouraged-language-force-header',
@@ -263,10 +269,7 @@
}
$( function () {
- var $translateContainer, $hideTranslatedButton, $messageList,
- filter, uri, position, offset, limit;
-
- $messageList = $( '.tux-messagelist' );
+ var $messageList = $( '.tux-messagelist' );
state.group = $( '.tux-messagetable-loader' ).data( 'messagegroup' );
state.language = $messageList.data( 'targetlangcode' );
@@ -274,9 +277,10 @@
$messageList.messagetable();
state.messageList = $messageList.data( 'messagetable' );
- uri = new mw.Uri( window.location.href );
- filter = uri.query.filter;
- offset = uri.query.showMessage;
+ var uri = new mw.Uri( window.location.href );
+ var filter = uri.query.filter;
+ var offset = uri.query.showMessage;
+ var limit;
if ( offset ) {
limit = uri.query.limit || 1;
// Default to no filters
@@ -304,15 +308,21 @@
} );
// Start loading messages
+ var actualFilter = getActualFilter( filter );
state.messageList.changeSettings( {
group: state.group,
language: state.language,
offset: offset,
limit: limit,
- filter: getActualFilter( filter )
+ filter: actualFilter
} );
+
+ if ( actualFilter.indexOf( hideOptionalMessages ) === -1 ) {
+ $( '#tux-option-optional' ).prop( 'checked', true );
+ }
}
+ var position;
if ( $( document.body ).hasClass( 'rtl' ) ) {
position = {
my: 'right top',
@@ -325,6 +335,7 @@
position: position,
recent: mw.translate.recentGroups.get()
} );
+ state.groupSelector = $( '.tux-breadcrumb__item--aggregate' ).data( 'msggroupselector' );
updateGroupInformation( state );
@@ -341,13 +352,13 @@
$( '.tux-message' ).translateeditor();
}
- $translateContainer = $( '.ext-translate-container' );
+ var $translateContainer = $( '.ext-translate-container' );
if ( mw.translate.canProofread() ) {
$translateContainer.find( '.proofread-mode-button' ).removeClass( 'hide' );
}
- $hideTranslatedButton = $translateContainer.find( '.tux-editor-clear-translated' );
+ var $hideTranslatedButton = $translateContainer.find( '.tux-editor-clear-translated' );
$hideTranslatedButton
.prop( 'disabled', !getTranslatedMessages( $translateContainer ).length )
.on( 'click', function () {
@@ -357,14 +368,13 @@
// Message filter click handler
$translateContainer.find( '.row.tux-message-selector > li' ).on( 'click', function () {
- var newFilter,
- $this = $( this );
+ var $this = $( this );
if ( $this.hasClass( 'more' ) ) {
return false;
}
- newFilter = $this.data( 'filter' );
+ var newFilter = $this.data( 'filter' );
// Remove the 'selected' class from all the items.
// Some of them could have been moved to under the "more" menu,
diff --git a/MLEB/Translate/resources/js/ext.translate.special.translationstash.js b/MLEB/Translate/resources/js/ext.translate.special.translationstash.js
deleted file mode 100644
index d4356923..00000000
--- a/MLEB/Translate/resources/js/ext.translate.special.translationstash.js
+++ /dev/null
@@ -1,256 +0,0 @@
-/*!
- * TranslationStash front-end logic.
- *
- * @author Santhosh Thottingal
- * @license GPL-2.0-or-later
- * @since 2013.10
- */
-
-( function () {
- 'use strict';
-
- var userTranslations = {},
- translationStashStorage = new mw.translate.TranslationStashStorage();
-
- mw.translate.canTranslate = function () {
- // At this page, the new translator can translate
- return true;
- };
-
- function getMessages( messageGroup, language, offset, limit ) {
- var deferred = new mw.Api().get( {
- action: 'query',
- list: 'messagecollection',
- mcgroup: messageGroup,
- mclanguage: language,
- mcoffset: offset,
- mclimit: limit,
- mcprop: 'definition'
- } );
-
- return deferred.promise();
- }
-
- function addMessage( message ) {
- var $messageWrapper, $message,
- $messageTable = $( '.tux-messagelist' ),
- sourceLanguage = $messageTable.data( 'sourcelangcode' ),
- sourceLanguageDir = $.uls.data.getDir( sourceLanguage ),
- targetLanguage = $messageTable.data( 'targetlangcode' ),
- targetLanguageDir = $.uls.data.getDir( targetLanguage ),
- status = message.properties.status,
- statusClass = 'tux-status-' + status,
- statusMsg;
-
- if ( status === 'translated' ) {
- // tux-status-translated
- statusMsg = 'tux-status-' + status;
- }
-
- $messageWrapper = $( '<div>' )
- .addClass( 'row tux-message' );
-
- $message = $( '<div>' )
- .addClass( 'row message tux-message-item ' + status )
- .append(
- $( '<div>' )
- .addClass( 'eight columns tux-list-message' )
- .append(
- $( '<span>' )
- .addClass( 'tux-list-source' )
- .attr( {
- lang: sourceLanguage,
- dir: sourceLanguageDir
- } )
- .text( message.definition ),
- // Bidirectional isolation.
- // This should be removed some day when proper
- // unicode-bidi: isolate
- // is supported everywhere
- $( '<span>' )
- .html( $( document.body ).hasClass( 'rtl' ) ? '&rlm;' : '&lrm;' ),
- $( '<span>' )
- .addClass( 'tux-list-translation' )
- .attr( {
- lang: targetLanguage,
- dir: targetLanguageDir
- } )
- .text( message.translation || '' )
- ),
- $( '<div>' )
- .addClass( 'two columns tux-list-status text-center' )
- .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>' )
- .addClass( 'two column tux-list-edit text-right' )
- .append(
- $( '<a>' )
- .attr( {
- title: mw.msg( 'translate-edit-title', message.key )
- } )
- .text( mw.msg( 'tux-edit' ) )
- )
- );
-
- $messageWrapper.append( $message );
- $messageTable.append( $messageWrapper );
- // Attach translate editor to the message
- $messageWrapper.translateeditor( {
- message: message,
- storage: translationStashStorage,
- onSave: updateStats,
- onSkip: function () {
- var $next = this.$editTrigger.next( '.tux-message' );
-
- // If there is text in the skipped message, avoid showing the
- // regular "you have unsaved messages" when navigating away,
- // because there is no way to get back to these messages.
- this.markUnunsaved();
-
- // This can happen when it's
- // the last message in the translation stash
- if ( !$next.length ) {
- // Reload the page to get more messages
- // when we get to the last one
- window.location.reload();
- }
- },
- onReady: function () {
- this.$editor.find( '.tux-editor-skip-button' )
- .text( mw.msg( 'translate-translationstash-skip-button-label' ) );
- }
- } );
- }
-
- /**
- * Updates the translation count at the top of the message list and
- * displays warning when translation limit has been reached.
- * Relies on classes stash-stats and tux-status-translated.
- */
- function updateStats() {
- var count,
- $target = $( '.stash-stats' );
-
- count = $( '.tux-status-translated' ).length;
- if ( count === 0 ) {
- return;
- }
-
- $target.text( mw.msg(
- 'translate-translationstash-translations',
- mw.language.convertNumber( count )
- ) );
-
- if ( count >= mw.config.get( 'wgTranslateSandboxLimit' ) ) {
- // Remove the untranslated message to disallow translation beyond the limit
- $( '.tux-message' ).has( '.untranslated' ).remove();
-
- // Show a message telling that the limit was reached
- $( '.limit-reached' )
- .empty()
- .append( $( '<h1>' ).text( mw.msg( 'tsb-limit-reached-title' ) ) )
- .append( $( '<p>' ).text( mw.msg( 'tsb-limit-reached-body' ) ) )
- .removeClass( 'hide' );
- }
- }
-
- function loadMessages() {
- var $messageTable = $( '.tux-messagelist' ),
- messagegroup = '!sandbox';
-
- $( '<div>' )
- .addClass( 'tux-loading-indicator' )
- .appendTo( $messageTable );
-
- getMessages( messagegroup, $messageTable.data( 'targetlangcode' ) )
- .done( function ( result ) {
- var $untranslated, messages = result.query.messagecollection;
-
- $messageTable.empty();
- messages.forEach( function ( message ) {
- message.properties = {};
- message.properties.status = 'untranslated';
-
- message.group = messagegroup;
- if ( userTranslations[ message.title ] ) {
- message.translation = userTranslations[ message.title ].translation;
- message.properties.status = 'translated';
- }
-
- addMessage( message );
- } );
-
- // Show the editor for the first untranslated message.
- $untranslated = $( '.tux-message' )
- .has( '.tux-message-item.untranslated' )
- .first();
- if ( $untranslated.length ) {
- $untranslated.data( 'translateeditor' ).show();
- }
-
- updateStats();
- } ).fail( function ( errorCode, response ) {
- $messageTable.empty().addClass( 'error' )
- .text( 'Error: ' + errorCode + ' - ' +
- ( response.error && response.error.info || 'Unknown error' )
- );
- } );
- }
-
- $( function () {
- var $messageTable = $( '.tux-messagelist' ),
- $ulsTrigger = $( '.ext-translate-language-selector > .uls' );
-
- // Some links in helpers will navigate away by default. But since the messages
- // will change on this page on every load, we want to avoid that. Force the
- // links to open on new window/tab.
- mw.hook( 'mw.translate.editor.showTranslationHelpers' ).add( function ( helpers, $editor ) {
- $editor.find( 'a' ).prop( 'target', '_blank' );
- } );
-
- $ulsTrigger.uls( {
- ulsPurpose: 'translate-special-translationstash',
- onSelect: function ( language ) {
- var direction = $.uls.data.getDir( language ),
- autonym = $.uls.data.getAutonym( language );
-
- $ulsTrigger
- .text( autonym )
- .attr( {
- lang: language,
- dir: direction
- } );
-
- $messageTable
- .empty()
- .data( {
- targetlangcode: language,
- targetlangdir: direction
- } );
-
- loadMessages();
- }
- } );
- // Get the user translations if any(possibly from an early attempt)
- // and new messages to try.
- translationStashStorage.getUserTranslations()
- .done( function ( translations ) {
- if ( translations.translationstash.translations ) {
- translations.translationstash.translations.forEach( function ( translation ) {
- userTranslations[ translation.title ] = translation;
- } );
- }
- loadMessages();
- } );
- } );
-}() );
diff --git a/MLEB/Translate/resources/js/ext.translate.special.translationstats.js b/MLEB/Translate/resources/js/ext.translate.special.translationstats.js
index 093be515..108d71fc 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.translationstats.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.translationstats.js
@@ -92,20 +92,19 @@ var FormHandler = function () {
};
$( function () {
- var widget, defaultValue, defaultDate,
- $input = $( '#start' ),
+ var $input = $( '#start' ),
formHandler = new FormHandler(),
- $graphContainer = $( '#translationStatsGraphContainer' ),
- graphBuilder;
+ $graphContainer = $( '#translationStatsGraphContainer' );
- defaultDate = new Date();
+ var defaultDate = new Date();
defaultDate.setDate( 1 );
+ var defaultValue;
if ( $input.val() ) {
defaultValue = new Date( $input.val() );
}
- widget = new mw.widgets.datetime.DateTimeInputWidget( {
+ var widget = new mw.widgets.datetime.DateTimeInputWidget( {
formatter: {
format: '${year|0}-${month|0}-${day|0}',
defaultDate: defaultDate
@@ -122,7 +121,7 @@ $( function () {
// Check if the graph container has been loaded
if ( $graphContainer.length !== 0 ) {
- graphBuilder = new mw.translate.TranslationStatsGraphBuilder( $graphContainer );
+ var graphBuilder = new mw.translate.TranslationStatsGraphBuilder( $graphContainer );
graphBuilder.display( formHandler.getAllOptions() );
}
} );
diff --git a/MLEB/Translate/resources/js/ext.translate.statsbar.js b/MLEB/Translate/resources/js/ext.translate.statsbar.js
index 43ba29da..e60ee4a6 100644
--- a/MLEB/Translate/resources/js/ext.translate.statsbar.js
+++ b/MLEB/Translate/resources/js/ext.translate.statsbar.js
@@ -41,12 +41,11 @@
* Listen for the change events and update the statsbar
*/
listen: function () {
- var i,
- statsbar = this,
+ var statsbar = this,
languageStats = mw.translate.languagestats[ this.language ];
statsbar.$statsBar.on( 'change', function ( event, to, from ) {
- for ( i = 0; i < languageStats.length; i++ ) {
+ for ( var i = 0; i < languageStats.length; i++ ) {
if ( languageStats[ i ].group === statsbar.group ) {
// Changing a proofread message does not create a new translation
if ( to === 'translated' && from !== 'proofread' ) {
@@ -115,16 +114,15 @@
},
update: function () {
- var proofread, translated, fuzzy, untranslated,
- stats = this.getStatsForGroup( this.group );
+ var stats = this.getStatsForGroup( this.group );
- proofread = 100 * stats.proofread / stats.total;
+ var proofread = 100 * stats.proofread / stats.total;
// Proofread messages are also translated, so remove those for
// the bar showing only translated count.
- translated = stats.translated - stats.proofread;
+ var translated = stats.translated - stats.proofread;
translated = 100 * translated / stats.total;
- fuzzy = 100 * stats.fuzzy / stats.total;
- untranslated = 100 - proofread - translated - fuzzy;
+ var fuzzy = 100 * stats.fuzzy / stats.total;
+ var untranslated = 100 - proofread - translated - fuzzy;
this.elements.$proofread[ 0 ].style.width = proofread + '%';
this.elements.$translated[ 0 ].style.width = translated + '%';
@@ -147,10 +145,9 @@
},
getStatsForGroup: function ( group ) {
- var i,
- languageStats = mw.translate.languagestats[ this.language ];
+ var languageStats = mw.translate.languagestats[ this.language ];
- for ( i = 0; i < languageStats.length; i++ ) {
+ for ( var i = 0; i < languageStats.length; i++ ) {
if ( languageStats[ i ].group === group ) {
return languageStats[ i ];
}
diff --git a/MLEB/Translate/resources/js/ext.translate.translationstashstorage.js b/MLEB/Translate/resources/js/ext.translate.translationstashstorage.js
deleted file mode 100644
index 17350cf2..00000000
--- a/MLEB/Translate/resources/js/ext.translate.translationstashstorage.js
+++ /dev/null
@@ -1,57 +0,0 @@
-( function () {
- 'use strict';
-
- /**
- * This class can save translation to translation stash.
- *
- * @since 2013.10
- */
- var TranslationStashStorage = function () {
- // No-op for now. Could take api module as param for example.
- };
-
- TranslationStashStorage.prototype = {
- /**
- * Save the translation.
- *
- * @param {string} title The title of the page including language code
- * to store the translation.
- * @param {string} translation The translation of the message
- * @return {jQuery.Promise}
- */
- save: function ( title, translation ) {
- var api = new mw.Api();
-
- return api.postWithToken( 'csrf', {
- action: 'translationstash',
- subaction: 'add',
- title: title,
- translation: translation
- } ).then( function () {
- // Fake normal save API
- return { edit: { result: 'Success' } };
- } );
- },
-
- /**
- * Get the current users translations.
- *
- * @param {string} user User name
- * @return {jQuery.Promise}
- */
- getUserTranslations: function ( user ) {
- var api = new mw.Api();
-
- return api.postWithToken( 'csrf', {
- action: 'translationstash',
- subaction: 'query',
- username: user
- } ).promise();
- }
-
- };
-
- mw.translate = mw.translate || {};
- mw.translate.TranslationStashStorage = TranslationStashStorage;
-
-}() );
diff --git a/MLEB/Translate/resources/js/ext.translate.translationstats.embedded.js b/MLEB/Translate/resources/js/ext.translate.translationstats.embedded.js
index b0ec95fd..ca12fe16 100644
--- a/MLEB/Translate/resources/js/ext.translate.translationstats.embedded.js
+++ b/MLEB/Translate/resources/js/ext.translate.translationstats.embedded.js
@@ -57,11 +57,8 @@ $( function () {
// Create graph and options instances, then display loader
function initGraph( $graphContainer ) {
- var graphBuilder,
- graphOptions;
-
- graphOptions = new EmbeddedHandler( $graphContainer );
- graphBuilder = new mw.translate.TranslationStatsGraphBuilder(
+ var graphOptions = new EmbeddedHandler( $graphContainer );
+ var graphBuilder = new mw.translate.TranslationStatsGraphBuilder(
$graphContainer, graphOptions.getAllOptions()
);
graphBuilder.showLoading();
diff --git a/MLEB/Translate/resources/js/ext.translate.translationstats.graphbuilder.js b/MLEB/Translate/resources/js/ext.translate.translationstats.graphbuilder.js
index f5280041..c81a4c56 100644
--- a/MLEB/Translate/resources/js/ext.translate.translationstats.graphbuilder.js
+++ b/MLEB/Translate/resources/js/ext.translate.translationstats.graphbuilder.js
@@ -12,6 +12,7 @@
reviews: mw.msg( 'translate-statsf-count-reviews' ),
reviewers: mw.msg( 'translate-statsf-count-reviewers' )
}, granularityInfo = {
+ years: mw.msg( 'translate-statsf-scale-years' ),
months: mw.msg( 'translate-statsf-scale-months' ),
weeks: mw.msg( 'translate-statsf-scale-weeks' ),
days: mw.msg( 'translate-statsf-scale-days' ),
@@ -169,23 +170,23 @@
}
function getAxesLabelsAndData( jsonGraphData ) {
- var labelProp, labels = [], graphData = [],
- labelData, i, labelIndex = 0,
- currentValue, maxValue = 0, minValue = 0;
+ var labels = [], graphData = [],
+ labelIndex = 0,
+ maxValue = 0, minValue = 0;
- for ( labelProp in jsonGraphData ) {
+ for ( var labelProp in jsonGraphData ) {
if ( labels.indexOf( labelProp ) === -1 ) {
labels.push( labelProp );
}
- labelData = jsonGraphData[ labelProp ];
+ var labelData = jsonGraphData[ labelProp ];
- for ( i = 0; i < labelData.length; ++i ) {
+ for ( var i = 0; i < labelData.length; ++i ) {
if ( !graphData[ i ] ) {
graphData[ i ] = [];
}
- currentValue = labelData[ i ];
+ var currentValue = labelData[ i ];
graphData[ i ][ labelIndex ] = currentValue;
if ( currentValue < minValue ) {
minValue = currentValue;
@@ -296,16 +297,14 @@
}
function getTableBody( graphData ) {
- var $tbody = $( '<tbody>' ),
- scaleIndex, datasetIndex, $tBodyRow,
- columnValue;
+ var $tbody = $( '<tbody>' );
- for ( scaleIndex = 0; scaleIndex < graphData.axesLabels.length; scaleIndex++ ) {
- $tBodyRow = $( '<tr>' )
+ for ( var scaleIndex = 0; scaleIndex < graphData.axesLabels.length; scaleIndex++ ) {
+ var $tBodyRow = $( '<tr>' )
.append( $( '<td>' ).text( graphData.axesLabels[ scaleIndex ] ) );
- for ( datasetIndex = 0; datasetIndex < graphData.data.length; datasetIndex++ ) {
- columnValue = '';
+ for ( var datasetIndex = 0; datasetIndex < graphData.data.length; datasetIndex++ ) {
+ var columnValue = '';
if (
graphData.data[ datasetIndex ] &&
graphData.data[ datasetIndex ][ scaleIndex ] !== undefined
diff --git a/MLEB/Translate/resources/js/ext.translate.workflowselector.js b/MLEB/Translate/resources/js/ext.translate.workflowselector.js
index b9d86f67..736bcf5d 100644
--- a/MLEB/Translate/resources/js/ext.translate.workflowselector.js
+++ b/MLEB/Translate/resources/js/ext.translate.workflowselector.js
@@ -58,10 +58,9 @@
* @return {jQuery.Promise}
*/
changeState: function ( state ) {
- var params,
- api = new mw.Api();
+ var api = new mw.Api();
- params = {
+ var params = {
action: 'groupreview',
group: this.groupId,
language: this.language,
@@ -85,18 +84,17 @@
* Actually constructs the DOM and displays the selector.
*/
display: function () {
- var instance = this,
- $display, $list;
+ var instance = this;
instance.$container.empty();
if ( !instance.states ) {
return;
}
- $list = $( '<ul>' )
+ var $list = $( '<ul>' )
.addClass( 'tux-dropdown-menu tux-workflow-status-selector hide' );
- $display = $( '<div>' )
+ var $display = $( '<div>' )
.addClass( 'tux-workflow-status' )
.text( mw.msg( 'translate-workflow-state-' ) )
.on( 'click', function ( e ) {
@@ -130,10 +128,9 @@
} );
$list.find( '.changeable' ).on( 'click', function () {
- var state,
- $this = $( this );
+ var $this = $( this );
- state = $this.data( 'state' ).id;
+ var state = $this.data( 'state' ).id;
$display.text( mw.msg( 'translate-workflow-set-doing' ) );
$display.append( $( '<span>' ).addClass( 'tux-workflow-status-triangle' ) );
diff --git a/MLEB/Translate/resources/js/jquery.ajaxdispatcher.js b/MLEB/Translate/resources/js/jquery.ajaxdispatcher.js
index d9fe3b7a..feaac555 100644
--- a/MLEB/Translate/resources/js/jquery.ajaxdispatcher.js
+++ b/MLEB/Translate/resources/js/jquery.ajaxdispatcher.js
@@ -24,19 +24,18 @@
}
function helper( list, maxRetries ) {
- var first, rest, retries, retrier,
- deferred = $.Deferred();
+ var deferred = $.Deferred();
if ( list.length === 0 ) {
deferred.resolve( [] );
return deferred;
}
- first = list.slice( 0, 1 )[ 0 ];
- rest = list.slice( 1 );
+ var first = list.slice( 0, 1 )[ 0 ];
+ var rest = list.slice( 1 );
- retries = 0;
- retrier = function ( result, promise ) {
+ var retries = 0;
+ var retrier = function ( result, promise ) {
if ( !promise.state ) {
return;
}
diff --git a/MLEB/Translate/resources/js/jquery.textchange.js b/MLEB/Translate/resources/js/jquery.textchange.js
deleted file mode 100644
index fd40790c..00000000
--- a/MLEB/Translate/resources/js/jquery.textchange.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*!
- * Trigger a textchange event on text change in input fields.
- * And make it cross browser compatible.
- *
- * @author Santhosh Thottingal, 2013
- * @see https://gist.github.com/mkelly12/424774
- */
-( function () {
- 'use strict';
-
- $.event.special.textchange = {
-
- setup: function () {
- $( this )
- .data( 'lastValue', $( this ).val() )
- .on( 'keyup.textchange', $.event.special.textchange.handler )
- .on( 'cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler );
- },
-
- teardown: function () {
- $( this ).off( '.textchange' );
- },
-
- handler: function () {
- $.event.special.textchange.triggerIfChanged( $( this ) );
- },
-
- delayedHandler: function () {
- var $element = $( this );
- setTimeout( function () {
- $.event.special.textchange.triggerIfChanged( $element );
- }, 25 );
- },
-
- triggerIfChanged: function ( element ) {
- var current = element.val();
- if ( current !== element.data( 'lastValue' ) ) {
- element.trigger( 'textchange', [ element.data( 'lastValue' ) ] );
- element.data( 'lastValue', current );
- }
- }
- };
-
-}() );