Commit 9d38c274 authored by Michal Čihař's avatar Michal Čihař

Avoid duplicate lookups

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent f1c5246b
...@@ -156,14 +156,15 @@ function processMachineTranslation(data, textStatus, jqXHR) { ...@@ -156,14 +156,15 @@ function processMachineTranslation(data, textStatus, jqXHR) {
newRow.append($('<td/>').text(el.service)); newRow.append($('<td/>').text(el.service));
/* Translators: Verb for copy operation */ /* Translators: Verb for copy operation */
newRow.append($('<td><a class="copymt btn btn-xs btn-default">' + gettext('Copy') + '</a></td>')); newRow.append($('<td><a class="copymt btn btn-xs btn-default">' + gettext('Copy') + '</a></td>'));
$('#machine-translations').children('tr').each(function (idx) { var $machineTranslations = $('#machine-translations');
$machineTranslations.children('tr').each(function (idx) {
if ($(this).data('quality') < el.quality && !done) { if ($(this).data('quality') < el.quality && !done) {
$(this).before(newRow); $(this).before(newRow);
done = true; done = true;
} }
}); });
if (! done) { if (! done) {
$('#machine-translations').append(newRow); $machineTranslations.append(newRow);
} }
}); });
$('a.copymt').button({text: true, icons: { primary: "ui-icon-copy" }}).click(function () { $('a.copymt').button({text: true, icons: { primary: "ui-icon-copy" }}).click(function () {
...@@ -581,11 +582,12 @@ $(function () { ...@@ -581,11 +582,12 @@ $(function () {
/* Zen mode handling */ /* Zen mode handling */
if ($('.zen').length > 0) { if ($('.zen').length > 0) {
$window.scroll(function(){ $window.scroll(function(){
var $loadingNext = $('#loading-next');
if ($window.scrollTop() >= $document.height() - (2 * $window.height())) { if ($window.scrollTop() >= $document.height() - (2 * $window.height())) {
if ($('#last-section').length > 0 || $('#loading-next').css('display') != 'none') { if ($('#last-section').length > 0 || $loadingNext.css('display') != 'none') {
return; return;
} }
$('#loading-next').show(); $loadingNext.show();
var loader = $('#zen-load'); var loader = $('#zen-load');
loader.data('offset', 20 + parseInt(loader.data('offset'))); loader.data('offset', 20 + parseInt(loader.data('offset')));
...@@ -593,7 +595,7 @@ $(function () { ...@@ -593,7 +595,7 @@ $(function () {
$.get( $.get(
loader.attr('href') + '&offset=' + loader.data('offset'), loader.attr('href') + '&offset=' + loader.data('offset'),
function (data) { function (data) {
$('#loading-next').hide(); $loadingNext.hide();
$('.zen tbody').append(data); $('.zen tbody').append(data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment