Skip to content

Commit

Permalink
Show upload .TMX terms
Browse files Browse the repository at this point in the history
  • Loading branch information
mathjazz committed Nov 28, 2024
1 parent 7935bcf commit 36e2d15
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 8 deletions.
55 changes: 52 additions & 3 deletions pontoon/teams/static/css/translation_memory.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
.translation-memory {
.upload-button {
.upload-wrapper {
float: right;

.fa {
padding-right: 2px;
.button.upload {
.fa {
padding-right: 2px;
}
}

.button.cancel {
display: none;
background-color: transparent;
margin-left: 0;

.fa {
margin-right: 0;
}
}

.button.cancel:hover {
.fa {
color: var(--white-1);
}
}

.button.confirm {
display: none;
}
}

.upload-terms {
display: none;
color: var(--light-grey-7);
font-style: italic;
line-height: 1.5em;
padding-top: 10px;
text-align: right;
}

.controls.uploading {
.button.upload {
display: none;
}

.button.cancel {
display: inline-block;
}

.button.confirm {
display: inline-block;
}

.upload-terms {
display: block;
}
}

Expand Down
16 changes: 15 additions & 1 deletion pontoon/teams/static/js/translation_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,24 @@ $(function () {
},
);

const uploadWrapper = '.translation-memory .upload-wrapper';

// Upload TM entries
$('body').on('click', '.translation-memory .upload-button', function () {
$('body').on('click', `${uploadWrapper} .upload`, function () {
const controls = $(this).parents('.controls');
controls.addClass('uploading');
});
// Cancel action
$('body').on('click', `${uploadWrapper} .cancel`, function () {
const controls = $(this).parents('.controls');
controls.removeClass('uploading');
});
$('body').on('click', `${uploadWrapper} .confirm`, function () {
const controls = $(this).parents('.controls');
const fileInput = $('<input type="file" accept=".tmx">');
fileInput.on('change', function () {
controls.removeClass('uploading');

const file = this.files[0];
if (!file) {
return;
Expand Down
26 changes: 22 additions & 4 deletions pontoon/teams/templates/teams/includes/translation_memory.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@
placeholder="Search translation memory">
</div>

<button class="upload-button button">
<span class="fa fa-upload"></span>
Upload .TMX
</button>
<div class="upload-wrapper">
<button class="cancel button">
<span class="fa fa-times"></span>
</button>

<button class="confirm button">
<span class="fa fa-upload"></span>
Continue
</button>

<button class="upload button">
<span class="fa fa-upload"></span>
Upload .TMX
</button>
</div>

<p class="upload-terms">
By uploading content, you confirm that you have the right to share it, either as the owner or under a
license that permits redistribution.<br>
Please ensure that the content complies with applicable copyright laws and does not infringe on
third-party rights.
</p>
</menu>

<table class="translation-memory-list">
Expand Down

0 comments on commit 36e2d15

Please sign in to comment.