Skip to content

Commit

Permalink
Merge c677f66 into db30ded
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed Feb 11, 2019
2 parents db30ded + c677f66 commit 51e1011
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 3 deletions.
24 changes: 24 additions & 0 deletions assets/translate.js
Expand Up @@ -160,3 +160,27 @@ $( window ).on( 'load', function () {
appConfig.imageMapLayer = L.imageOverlay( $imageElement.attr( 'src' ), [ [ 0, 0 ], [ $imageElement.height(), $imageElement.width() ] ] );
appConfig.imageMapLayer.addTo( imagemap );
} );

/**
* Disable the upload button once it's been clicked.
*/
$( function () {
var uploadButtonWidget,
$uploadButtonElement = $( '#upload-button-widget' );
if ( $uploadButtonElement.length === 1 ) {
// If there is an upload button, infuse it and modify its submission behaviour.
uploadButtonWidget = OO.ui.infuse( $uploadButtonElement );
uploadButtonWidget.on( 'click', function () {
// Because we want to disable the upload button after its been clicked but before the
// form has been submitted, we need to make sure the 'upload' parameter is still sent
// (because that's how we distinguish between upload and download; they're both form
// submission buttons on the same form). We do this by creating a new hidden element.
var $form = uploadButtonWidget.$element.parents( 'form' ),
$hiddenUpload = $( '<input>' ).attr( 'type', 'hidden' ).attr( 'name', 'upload' );
$form.prepend( $hiddenUpload );
uploadButtonWidget.setLabel( $.i18n( 'upload-button-in-progress' ) );
uploadButtonWidget.setDisabled( true );
$form.submit();
} );
}
} );
1 change: 1 addition & 0 deletions i18n/en.json
Expand Up @@ -32,6 +32,7 @@
"confirmation-to-switch-target-lang": "You are trying to change the translation language but you have unsaved translations. Changing the language will result in loss of any added translations. Please upload the translations to Commons or download the translated file before proceeding. Do you wish to continue?",
"confirm-change-target-lang": "Change language",
"upload-button-label": "Upload to Commons",
"upload-button-in-progress": "Uploading to Commons…",
"download-button-label": "Download",
"download-or-upload": "or",
"translation-image-alt": "The image that's currently being translated. No description available.",
Expand Down
1 change: 1 addition & 0 deletions i18n/qqq.json
Expand Up @@ -32,6 +32,7 @@
"confirmation-to-switch-target-lang": "Confirmation message shown when a user tries to switch the target language but has unsaved changes in the form.",
"confirm-change-target-lang": "Label for the confirm button for {{msg-wm|confirmation-to-switch-target-lang}}, to appear next to 'Cancel' (i.e. {{wm-msg|ooui-dialog-message-reject}}).",
"upload-button-label": "Label for the button that uploads the translated SVG to Wikimedia Commons.",
"upload-button-in-progress": "Label that the upload button swiches to after it's been clicked, while the file is uploading. The button is also disabled at this point.",
"download-button-label": "Label for the button that downloads the translated SVG to the user's local computer.",
"download-or-upload": "Label positioned between the download and the upload buttons.",
"translation-image-alt": "Alt text for the image that's currently being translated. Doesn't explain the image, just explains that we don't explain it.",
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/assets/entrypoints.json
Expand Up @@ -5,7 +5,7 @@
"assets/app.1709d2c7.css"
],
"js": [
"assets/app.ae00a295.js"
"assets/app.af6924dc.js"
]
}
}
Expand Down
1 change: 1 addition & 0 deletions public/assets/i18n/app/en.json
Expand Up @@ -32,6 +32,7 @@
"confirmation-to-switch-target-lang": "You are trying to change the translation language but you have unsaved translations. Changing the language will result in loss of any added translations. Please upload the translations to Commons or download the translated file before proceeding. Do you wish to continue?",
"confirm-change-target-lang": "Change language",
"upload-button-label": "Upload to Commons",
"upload-button-in-progress": "Uploading to Commons…",
"download-button-label": "Download",
"download-or-upload": "or",
"translation-image-alt": "The image that's currently being translated. No description available.",
Expand Down
1 change: 1 addition & 0 deletions public/assets/i18n/app/qqq.json
Expand Up @@ -32,6 +32,7 @@
"confirmation-to-switch-target-lang": "Confirmation message shown when a user tries to switch the target language but has unsaved changes in the form.",
"confirm-change-target-lang": "Label for the confirm button for {{msg-wm|confirmation-to-switch-target-lang}}, to appear next to 'Cancel' (i.e. {{wm-msg|ooui-dialog-message-reject}}).",
"upload-button-label": "Label for the button that uploads the translated SVG to Wikimedia Commons.",
"upload-button-in-progress": "Label that the upload button swiches to after it's been clicked, while the file is uploading. The button is also disabled at this point.",
"download-button-label": "Label for the button that downloads the translated SVG to the user's local computer.",
"download-or-upload": "Label positioned between the download and the upload buttons.",
"translation-image-alt": "Alt text for the image that's currently being translated. Doesn't explain the image, just explains that we don't explain it.",
Expand Down
2 changes: 1 addition & 1 deletion public/assets/manifest.json
@@ -1,6 +1,6 @@
{
"assets/app.css": "assets/app.1709d2c7.css",
"assets/app.js": "assets/app.ae00a295.js",
"assets/app.js": "assets/app.af6924dc.js",
"assets/grabbing.cur": "assets/a8c874b93b3d848f39a71260c57e3863.cur",
"assets/grab.cur": "assets/b06c243f534d9c5461d16528156cd5a8.cur",
"assets/i18n/app/af.json": "assets/i18n/app/af.json",
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/TranslateController.php
Expand Up @@ -68,6 +68,8 @@ public function translate(
'type' => 'submit',
'icon' => 'logoWikimediaCommons',
'name' => 'upload',
'id' => 'upload-button-widget',
'infusable' => true,
]);
if (!$session->get('logged_in_user')) {
// Only logged in users can upload.
Expand Down

0 comments on commit 51e1011

Please sign in to comment.