Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markunknown sent with translateDoc interface #180

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions assets/js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ if(modeEnabled('translation')) {
});

$('#markUnknown').change(function () {
if($('div#translateText').is(':visible')) {
translateText();
}
translate();
persistChoices('translator');
});

Expand Down Expand Up @@ -218,12 +216,14 @@ if(modeEnabled('translation')) {
});

$('button#translateDoc').click(function () {
$('div#translateText').fadeOut('fast', function () {
$('#fileInput').show();
$('div#fileName').hide();
$('div#docTranslation').fadeIn('fast');
$('#detect, #srcLangSelect option[value=detect]').prop('disabled', true);
});
$('#translateText > *:not(#translateOptionsContainer), #translateOptions > *:not(#markUnknownContainer)')
.fadeOut('fast', function () {
$('#fileInput').show();
$('div#fileName').hide();
$('div#docTranslation').fadeIn('fast');
$('#markUnknownContainer').css('margin-top', '200px');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding pixel values isn't a great approach. Is there any other method of handling this?

$('#detect, #srcLangSelect option[value=detect]').prop('disabled', true);
});
pairs = originalPairs;
populateTranslationList();
});
Expand All @@ -233,9 +233,11 @@ if(modeEnabled('translation')) {
$('div#docTranslation').fadeOut('fast', function () {
$('a#fileDownload').hide();
$('span#uploadError').hide();
$('div#translateText').fadeIn('fast', synchronizeTextareaHeights);
$('#translateText > *:not(#translateOptionsContainer), #translateOptions > *:not(#markUnknownContainer)')
.fadeIn('fast', synchronizeTextareaHeights);
$('input#fileInput').wrap('<form>').closest('form')[0].reset();
$('input#fileInput').unwrap();
$('#markUnknownContainer').css('margin-top', '0px');
$('#detect, #srcLangSelect option[value=detect]').prop('disabled', false);
});
updatePairList();
Expand Down Expand Up @@ -568,7 +570,7 @@ function populateTranslationList() {
}

function translate() {
if($('div#translateText').is(':visible')) {
if($('#translateText > *:not(#translateOptionsContainer), #translateOptions > *:not(#markUnknownContainer)').is(':visible')) {
translateText();
}
else if($('div#docTranslation').is(':visible')) {
Expand Down
65 changes: 32 additions & 33 deletions index.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,36 @@
</div>
</div>
<div class="form-group">
<div id="docTranslation" style="display: none;">
<div class="col-sm-6">
<div class="well well-lg">
<input type="file" id="fileInput" accept="text/plain,text/html,text/rtf,application/rtf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.text,application/x-latex,application/x-tex">
<div class="lead" id="fileName" style="display: none;"></div>
<div style="min-height: 50px; margin-top: 1em;">
<span id="uploadError" class="text-danger lead" style="display: none"></span>
<div class="progress progress-striped active" style="display: none; margin-bottom: 0px;">
<div id="fileUploadProgress" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
</div>
</div>
<p><span data-text="Supported_Formats"></span></p>
<button class="btn btn-sm btn-default pull-right" id="cancelDocTranslate">
<i class="fa fa-arrow-left"></i> <span data-text="Cancel">Cancel</span>
</button>
</div>
</div>
<div class="col-sm-6">
<div id="fileLoading" class="text-center" style="display: none; position: absolute; top: 50%; left: 50%;">
<i class="fa fa-spinner fa-spin fa-4x"></i>
</div>
<h1>
<a id="fileDownload" href="#" class="text-center lead" style="display: none;">
<i class="fa fa-download"></i>
<span id="fileDownloadText"></span>
</a>
</h1>
<p style="display:none" id="fileDownloadBrowserWarning" data-text="Download_Browser_Warning">Your browser might not handle downloads correctly. Either right-click and "Save As" that file-name or open this page in Firefox.</p>
</div>
</div>
<div id="translateText">
<div class="col-sm-6">
<textarea class="form-control" id="originalText" rows="15" spellcheck="false"></textarea>
Expand All @@ -191,9 +221,9 @@
<i class="fa fa-file-text"></i> <span data-text="Translate_Document">Translate a document</span>
</button>
</div>
<div class="col-lg-3 col-md-6 pull-right">
<div class="col-lg-3 col-md-6 pull-right" id="translateOptionsContainer">
<div class="checkbox" id="translateOptions">
<label class="pull-right">
<label class="pull-right" id="markUnknownContainer">
<input type="checkbox" id="markUnknown" checked>
<span data-text="Mark_Unknown_Words">Mark unknown words</span>
</label>
Expand All @@ -217,37 +247,6 @@
</div>
<div class="modal-backdrop" id="fileDropMask" style="opacity: 0; z-index: 10000;"></div>
</div>

<div id="docTranslation" style="display: none;">
<div class="col-sm-6">
<div class="well well-lg">
<input type="file" id="fileInput" accept="text/plain,text/html,text/rtf,application/rtf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.text,application/x-latex,application/x-tex">
<div class="lead" id="fileName" style="display: none;"></div>
<div style="min-height: 50px; margin-top: 1em;">
<span id="uploadError" class="text-danger lead" style="display: none"></span>
<div class="progress progress-striped active" style="display: none; margin-bottom: 0px;">
<div id="fileUploadProgress" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
</div>
</div>
<p><span data-text="Supported_Formats"></span></p>
<button class="btn btn-sm btn-default pull-right" id="cancelDocTranslate">
<i class="fa fa-arrow-left"></i> <span data-text="Cancel">Cancel</span>
</button>
</div>
</div>
<div class="col-sm-6">
<div id="fileLoading" class="text-center" style="display: none; position: absolute; top: 50%; left: 50%;">
<i class="fa fa-spinner fa-spin fa-4x"></i>
</div>
<h1>
<a id="fileDownload" href="#" class="text-center lead" style="display: none;">
<i class="fa fa-download"></i>
<span id="fileDownloadText"></span>
</a>
</h1>
<p style="display:none" id="fileDownloadBrowserWarning" data-text="Download_Browser_Warning">Your browser might not handle downloads correctly. Either right-click and "Save As" that file-name or open this page in Firefox.</p>
</div>
</div>
</div>
</fieldset>
</form>
Expand Down