зеркало из https://github.com/mozilla/pontoon.git
Add new ESLint rules: no-var, prefer-const (#3126)
Additionally, fixes the ~230 issues raised by these two new rules when linting against the "pontoon/" subdirectory.
This commit is contained in:
Родитель
3e03b17424
Коммит
b9b70cc172
|
@ -70,6 +70,14 @@ module.exports = {
|
|||
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
|
||||
],
|
||||
'no-console': 1,
|
||||
'no-var': 'error',
|
||||
'prefer-const': [
|
||||
'error',
|
||||
{
|
||||
destructuring: 'any',
|
||||
ignoreReadBeforeAssign: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
|
|
|
@ -2,7 +2,7 @@ $(function () {
|
|||
// Before submitting the form
|
||||
$('#admin-form').submit(function () {
|
||||
// Update locales
|
||||
var locales = [
|
||||
const locales = [
|
||||
{
|
||||
selector: '.admin-team-selector .locale.selected',
|
||||
input: $('#id_locales'),
|
||||
|
@ -18,7 +18,7 @@ $(function () {
|
|||
];
|
||||
|
||||
locales.forEach(function (type) {
|
||||
var ids = $(type.selector)
|
||||
const ids = $(type.selector)
|
||||
.find('li[data-id]')
|
||||
.map(function () {
|
||||
return $(this).data('id');
|
||||
|
@ -28,7 +28,7 @@ $(function () {
|
|||
});
|
||||
|
||||
// Update form action
|
||||
var slug = $('#id_slug').val();
|
||||
let slug = $('#id_slug').val();
|
||||
if (slug.length > 0) {
|
||||
slug += '/';
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ $(function () {
|
|||
$('input[type=text]:focus').length > 0 ||
|
||||
$('input[type=url]:focus').length > 0
|
||||
) {
|
||||
var key = e.keyCode || e.which;
|
||||
const key = e.keyCode || e.which;
|
||||
if (key === 13) {
|
||||
// A short delay to allow digest of autocomplete before submit
|
||||
setTimeout(function () {
|
||||
|
@ -69,7 +69,7 @@ $(function () {
|
|||
$('.sync').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this),
|
||||
const button = $(this),
|
||||
title = button.html();
|
||||
|
||||
if (button.is('.in-progress')) {
|
||||
|
@ -98,7 +98,7 @@ $(function () {
|
|||
$('.pretranslate').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this),
|
||||
const button = $(this),
|
||||
title = button.html();
|
||||
|
||||
if (button.is('.in-progress')) {
|
||||
|
@ -135,7 +135,7 @@ $(function () {
|
|||
name: $('#id_name').val(),
|
||||
},
|
||||
success: function (data) {
|
||||
var value = data === 'error' ? '' : data;
|
||||
const value = data === 'error' ? '' : data;
|
||||
$('#id_slug').val(value);
|
||||
},
|
||||
error: function () {
|
||||
|
@ -145,8 +145,8 @@ $(function () {
|
|||
});
|
||||
|
||||
$('body').on('blur', '[id^=id_tag_set-][id$=-name]', function () {
|
||||
var target = $('input#' + $(this).attr('id').replace('-name', '-slug'));
|
||||
var $this = this;
|
||||
const target = $('input#' + $(this).attr('id').replace('-name', '-slug'));
|
||||
const $this = this;
|
||||
if (target.val() || !$(this).val()) {
|
||||
return;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ $(function () {
|
|||
name: $($this).val(),
|
||||
},
|
||||
success: function (data) {
|
||||
var value = data === 'error' ? '' : data;
|
||||
const value = data === 'error' ? '' : data;
|
||||
target.val(value);
|
||||
target.attr('placeholder', '');
|
||||
},
|
||||
|
@ -169,7 +169,7 @@ $(function () {
|
|||
|
||||
// Copy locales from another project
|
||||
$('#copy-locales option').on('click', function () {
|
||||
var projectLocales = [];
|
||||
let projectLocales = [];
|
||||
|
||||
try {
|
||||
projectLocales = JSON.parse($(this).val());
|
||||
|
@ -203,7 +203,7 @@ $(function () {
|
|||
$('.repositories').show();
|
||||
}
|
||||
}
|
||||
var dataSourceInput = $('#id_data_source');
|
||||
const dataSourceInput = $('#id_data_source');
|
||||
dataSourceInput.on('change', function () {
|
||||
displayNewStringsInput(dataSourceInput);
|
||||
});
|
||||
|
@ -211,7 +211,7 @@ $(function () {
|
|||
|
||||
// Suggest public repository website URL
|
||||
$('body').on('blur', '.repo input', function () {
|
||||
var val = $(this)
|
||||
const val = $(this)
|
||||
.val()
|
||||
.replace(/\.git$/, '')
|
||||
.replace('git@github.com:', 'https://github.com/')
|
||||
|
@ -229,7 +229,7 @@ $(function () {
|
|||
$('.inline [checked]').click().prev().click();
|
||||
|
||||
// Add inline form item (e.g. external resource)
|
||||
var count = {
|
||||
const count = {
|
||||
externalresource: $('.externalresource:last').data('count'),
|
||||
entity: $('.entity:last').data('count'),
|
||||
tag: $('.tag:last').data('count'),
|
||||
|
@ -237,8 +237,8 @@ $(function () {
|
|||
$('.add-inline').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var type = $(this).data('type');
|
||||
var form = $('.' + type + ':last')
|
||||
const type = $(this).data('type');
|
||||
const form = $('.' + type + ':last')
|
||||
.html()
|
||||
.replace(/__prefix__/g, count[type]);
|
||||
|
||||
|
@ -268,13 +268,13 @@ $(function () {
|
|||
});
|
||||
|
||||
// Add repo
|
||||
var $totalForms = $('#id_repositories-TOTAL_FORMS');
|
||||
const $totalForms = $('#id_repositories-TOTAL_FORMS');
|
||||
$('.add-repo').click(function (e) {
|
||||
e.preventDefault();
|
||||
var count = parseInt($totalForms.val(), 10);
|
||||
const count = parseInt($totalForms.val(), 10);
|
||||
|
||||
var $emptyForm = $('.repository-empty');
|
||||
var form = $emptyForm.html().replace(/__prefix__/g, count);
|
||||
const $emptyForm = $('.repository-empty');
|
||||
const form = $emptyForm.html().replace(/__prefix__/g, count);
|
||||
$('.repository:last').after(
|
||||
'<div class="repository clearfix">' + form + '</div>',
|
||||
);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* A 3-column selector to select two lists */
|
||||
$(function () {
|
||||
function getTarget(item) {
|
||||
var list = $(item).parents('.select');
|
||||
var target = list.siblings('.select:nth-child(2)');
|
||||
const list = $(item).parents('.select');
|
||||
let target = list.siblings('.select:nth-child(2)');
|
||||
|
||||
if (list.is('.select:nth-child(2)')) {
|
||||
if ($(item).is('.left') || list.siblings().length === 1) {
|
||||
|
@ -16,7 +16,7 @@ $(function () {
|
|||
}
|
||||
|
||||
function setArrow(element, event) {
|
||||
var x = event.pageX - element.offset().left;
|
||||
const x = event.pageX - element.offset().left;
|
||||
|
||||
if (element.outerWidth() / 2 > x) {
|
||||
element.addClass('left');
|
||||
|
@ -43,15 +43,15 @@ $(function () {
|
|||
);
|
||||
|
||||
// Move items between lists
|
||||
var mainSelector = '.double-list-selector';
|
||||
var itemSelector = mainSelector + ' .select li';
|
||||
var allSelector = mainSelector + ' .move-all';
|
||||
const mainSelector = '.double-list-selector';
|
||||
const itemSelector = mainSelector + ' .select li';
|
||||
const allSelector = mainSelector + ' .move-all';
|
||||
$('body').on('click', [itemSelector, allSelector].join(', '), function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var target = getTarget(this);
|
||||
var ul = target.find('ul');
|
||||
var clone = null;
|
||||
const target = getTarget(this);
|
||||
const ul = target.find('ul');
|
||||
let clone = null;
|
||||
|
||||
// Move selected item
|
||||
if ($(this).is('li')) {
|
||||
|
|
|
@ -9,6 +9,7 @@ $.expr[':'].containsi = function (a, i, m) {
|
|||
};
|
||||
|
||||
/* Public functions used across different files */
|
||||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
/*
|
||||
|
@ -42,7 +43,7 @@ var Pontoon = (function (my) {
|
|||
url: '/notifications/mark-all-as-read/',
|
||||
success: function () {
|
||||
$('#notifications.unread .button .badge').hide();
|
||||
var unreadNotifications = $(
|
||||
const unreadNotifications = $(
|
||||
'.notifications .menu ul.notification-list li.notification-item[data-unread="true"]',
|
||||
);
|
||||
|
||||
|
@ -166,12 +167,12 @@ $(function () {
|
|||
* - Page loaded on Firefox or Chrome (add-on not available for other browsers)
|
||||
*/
|
||||
setTimeout(function () {
|
||||
var dismissed = !$('#addon-promotion').length;
|
||||
var installed = window.PontoonAddon && window.PontoonAddon.installed;
|
||||
const dismissed = !$('#addon-promotion').length;
|
||||
const installed = window.PontoonAddon && window.PontoonAddon.installed;
|
||||
if (!dismissed && !installed) {
|
||||
var isFirefox = navigator.userAgent.indexOf('Firefox') !== -1;
|
||||
var isChrome = navigator.userAgent.indexOf('Chrome') !== -1;
|
||||
var downloadHref = '';
|
||||
const isFirefox = navigator.userAgent.indexOf('Firefox') !== -1;
|
||||
const isChrome = navigator.userAgent.indexOf('Chrome') !== -1;
|
||||
let downloadHref = '';
|
||||
if (isFirefox) {
|
||||
downloadHref =
|
||||
'https://addons.mozilla.org/firefox/addon/pontoon-tools/';
|
||||
|
@ -258,7 +259,7 @@ $(function () {
|
|||
});
|
||||
|
||||
// Display any notifications
|
||||
var notifications = $('.notification li');
|
||||
const notifications = $('.notification li');
|
||||
if (notifications.length) {
|
||||
Pontoon.endLoader(notifications.text());
|
||||
}
|
||||
|
@ -279,7 +280,7 @@ $(function () {
|
|||
|
||||
// Sign out button action
|
||||
$('.sign-out a, #sign-out a').on('click', function (ev) {
|
||||
var $this = $(this),
|
||||
const $this = $(this),
|
||||
$form = $this.find('form');
|
||||
|
||||
ev.preventDefault();
|
||||
|
@ -343,7 +344,7 @@ $(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var ul = $(this).parent().siblings('ul'),
|
||||
const ul = $(this).parent().siblings('ul'),
|
||||
val = $(this).val(),
|
||||
// Only search a limited set if defined
|
||||
limited = ul.find('li.limited').length > 0 ? '.limited' : '';
|
||||
|
@ -372,10 +373,12 @@ $(function () {
|
|||
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
|
||||
function moveMenu(type) {
|
||||
var options =
|
||||
const options =
|
||||
type === 'up' ? ['first', 'last', -1] : ['last', 'first', 1];
|
||||
var items = menu.find('li:visible:not(.horizontal-separator, :has(li))');
|
||||
var element = null;
|
||||
const items = menu.find(
|
||||
'li:visible:not(.horizontal-separator, :has(li))',
|
||||
);
|
||||
let element = null;
|
||||
|
||||
if (
|
||||
hovered.length === 0 ||
|
||||
|
@ -384,7 +387,7 @@ $(function () {
|
|||
menu.find('li.hover').removeClass('hover');
|
||||
element = items[options[1]]();
|
||||
} else {
|
||||
var current = menu.find('li.hover'),
|
||||
const current = menu.find('li.hover'),
|
||||
next = items.index(current) + options[2];
|
||||
|
||||
current.removeClass('hover');
|
||||
|
@ -401,9 +404,10 @@ $(function () {
|
|||
}
|
||||
}
|
||||
|
||||
var key = e.which;
|
||||
const key = e.which;
|
||||
|
||||
if ($('.menu:not(".permanent")').is(':visible')) {
|
||||
// eslint-disable-next-line no-var
|
||||
var menu = $('.menu:not(".permanent"):visible'),
|
||||
hovered = menu.find('li.hover');
|
||||
|
||||
|
@ -426,7 +430,7 @@ $(function () {
|
|||
|
||||
// Enter: confirm
|
||||
if (key === 13) {
|
||||
var a = hovered.find('a');
|
||||
const a = hovered.find('a');
|
||||
if (a.length > 0) {
|
||||
a.click();
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
$(function () {
|
||||
$('canvas.chart').each(function () {
|
||||
// Get data
|
||||
var stats = {},
|
||||
const stats = {},
|
||||
progress = $(this).parents('.progress');
|
||||
|
||||
progress
|
||||
|
@ -19,7 +19,7 @@ $(function () {
|
|||
.find('.all .value')
|
||||
.data('value');
|
||||
|
||||
var fraction = {
|
||||
const fraction = {
|
||||
translated: stats.all ? stats.translated / stats.all : 0,
|
||||
pretranslated: stats.all ? stats.pretranslated / stats.all : 0,
|
||||
warnings: stats.all ? stats.warnings / stats.all : 0,
|
||||
|
@ -34,11 +34,11 @@ $(function () {
|
|||
);
|
||||
|
||||
// Update graph
|
||||
var canvas = this,
|
||||
const canvas = this,
|
||||
context = canvas.getContext('2d');
|
||||
|
||||
// Set up canvas to be HiDPI display ready
|
||||
var dpr = window.devicePixelRatio || 1;
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
canvas.style.width = canvas.width + 'px';
|
||||
canvas.style.height = canvas.height + 'px';
|
||||
canvas.width = canvas.width * dpr;
|
||||
|
@ -48,16 +48,16 @@ $(function () {
|
|||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
context.lineWidth = 3 * dpr;
|
||||
|
||||
var x = canvas.width / 2,
|
||||
const x = canvas.width / 2,
|
||||
y = canvas.height / 2,
|
||||
radius = (canvas.width - context.lineWidth) / 2,
|
||||
end = -0.5;
|
||||
radius = (canvas.width - context.lineWidth) / 2;
|
||||
let end = -0.5;
|
||||
|
||||
progress
|
||||
.siblings('.legend')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
var length = fraction[$(this).attr('class')] * 2,
|
||||
const length = fraction[$(this).attr('class')] * 2,
|
||||
start = end,
|
||||
color = window
|
||||
.getComputedStyle($(this).find('.status')[0], ':before')
|
||||
|
|
|
@ -9,7 +9,8 @@ $.expr[':'].containsi = function (a, i, m) {
|
|||
};
|
||||
|
||||
/* Latest activity tooltip */
|
||||
var date_formatter = new Intl.DateTimeFormat('en-US', {
|
||||
const delay = 500,
|
||||
date_formatter = new Intl.DateTimeFormat('en-US', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
|
@ -18,16 +19,15 @@ var date_formatter = new Intl.DateTimeFormat('en-US', {
|
|||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
}),
|
||||
timer = null,
|
||||
delay = 500;
|
||||
});
|
||||
let timer = null;
|
||||
|
||||
$('body')
|
||||
.on('mouseenter', '.latest-activity .latest time', function () {
|
||||
var $element = $(this);
|
||||
const $element = $(this);
|
||||
|
||||
timer = setTimeout(function () {
|
||||
var translation = Pontoon.doNotRender($element.data('translation')),
|
||||
const translation = Pontoon.doNotRender($element.data('translation')),
|
||||
avatar = $element.data('user-avatar'),
|
||||
action = $element.data('action'),
|
||||
name = $element.data('user-name'),
|
||||
|
@ -74,6 +74,7 @@ $('body')
|
|||
});
|
||||
|
||||
/* Public functions used across different files */
|
||||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
table: {
|
||||
|
@ -89,7 +90,7 @@ var Pontoon = (function (my) {
|
|||
}
|
||||
|
||||
// Filter input field
|
||||
var field = $(this),
|
||||
const field = $(this),
|
||||
// Selector of the element containing a list of items to filter
|
||||
list = $(this).data('list') || '.table-sort tbody',
|
||||
// Selector of the list item element, relative to list
|
||||
|
@ -120,7 +121,7 @@ var Pontoon = (function (my) {
|
|||
sort: (function () {
|
||||
$('body').on('click', 'table.table-sort th', function () {
|
||||
function getProgress(el) {
|
||||
var legend = $(el).find('.progress .legend'),
|
||||
const legend = $(el).find('.progress .legend'),
|
||||
all = legend.find('.all .value').data('value') || 0,
|
||||
translated =
|
||||
legend.find('.translated .value').data('value') / all || 0,
|
||||
|
@ -145,7 +146,7 @@ var Pontoon = (function (my) {
|
|||
}
|
||||
|
||||
function getTime(el) {
|
||||
var date =
|
||||
const date =
|
||||
$(el)
|
||||
.find('td:eq(' + index + ')')
|
||||
.find('time')
|
||||
|
@ -171,7 +172,7 @@ var Pontoon = (function (my) {
|
|||
.text();
|
||||
}
|
||||
|
||||
var node = $(this),
|
||||
const node = $(this),
|
||||
index = node.index(),
|
||||
table = node.parents('.table-sort'),
|
||||
list = table.find('tbody'),
|
||||
|
@ -180,8 +181,9 @@ var Pontoon = (function (my) {
|
|||
cls = node.hasClass('asc') ? 'desc' : 'asc';
|
||||
|
||||
// Default value for rows which don't have a timestamp
|
||||
let defaultTime;
|
||||
if (node.is('.deadline')) {
|
||||
var defaultTime = new Date(0).getTime();
|
||||
defaultTime = new Date(0).getTime();
|
||||
}
|
||||
|
||||
$(table).find('th').removeClass('asc desc');
|
||||
|
@ -190,7 +192,7 @@ var Pontoon = (function (my) {
|
|||
items.sort(function (a, b) {
|
||||
// Sort by completion
|
||||
if (node.is('.progress')) {
|
||||
var chartA = getProgress(a),
|
||||
const chartA = getProgress(a),
|
||||
chartB = getProgress(b);
|
||||
|
||||
if (chartA === 'not-ready') {
|
||||
|
@ -212,7 +214,7 @@ var Pontoon = (function (my) {
|
|||
|
||||
// Sort by deadline
|
||||
} else if (node.is('.deadline')) {
|
||||
var timeA = getTime(a),
|
||||
const timeA = getTime(a),
|
||||
timeB = getTime(b);
|
||||
|
||||
if (timeA === defaultTime && timeB === defaultTime) {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
* Manage tab content as single-page application
|
||||
*/
|
||||
$(function () {
|
||||
var urlSplit = $('#server').data('url-split'),
|
||||
container = $('#main .container'),
|
||||
inProgress = false;
|
||||
const urlSplit = $('#server').data('url-split'),
|
||||
container = $('#main .container');
|
||||
let inProgress = false;
|
||||
|
||||
// Page load
|
||||
loadTabContent(window.location.pathname + window.location.search);
|
||||
|
@ -33,14 +33,14 @@ $(function () {
|
|||
|
||||
e.preventDefault();
|
||||
|
||||
var url = $(this).attr('href');
|
||||
const url = $(this).attr('href');
|
||||
loadTabContent(url);
|
||||
window.history.pushState({}, '', url);
|
||||
},
|
||||
);
|
||||
|
||||
function showTabMessage(text) {
|
||||
var message = $('<p>', {
|
||||
const message = $('<p>', {
|
||||
class: 'no-results',
|
||||
html: text,
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ $(function () {
|
|||
inProgress.abort();
|
||||
}
|
||||
|
||||
var url = '/' + path.split('/' + urlSplit + '/')[1],
|
||||
const url = '/' + path.split('/' + urlSplit + '/')[1],
|
||||
tab = $('#middle .links a[href="' + path.split('?')[0] + '"]');
|
||||
|
||||
// Update menu
|
||||
|
@ -79,7 +79,7 @@ $(function () {
|
|||
container.append(data);
|
||||
|
||||
if (url.startsWith('/contributors/')) {
|
||||
var count = $('table > tbody > tr').length;
|
||||
const count = $('table > tbody > tr').length;
|
||||
updateTabCount(tab, count);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ $(function () {
|
|||
.matchMedia('(prefers-color-scheme: dark)')
|
||||
.addEventListener('change', function () {
|
||||
// Check the 'data-theme' attribute on the body element
|
||||
let userThemeSetting = $('body').data('theme');
|
||||
const userThemeSetting = $('body').data('theme');
|
||||
|
||||
if (userThemeSetting === 'system') {
|
||||
applyTheme(userThemeSetting);
|
||||
|
@ -50,13 +50,13 @@ $(function () {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var self = $(this);
|
||||
const self = $(this);
|
||||
|
||||
if (self.is('.active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var theme = self.val();
|
||||
const theme = self.val();
|
||||
|
||||
$.ajax({
|
||||
url:
|
||||
|
|
|
@ -7,7 +7,7 @@ $(function () {
|
|||
|
||||
// Filter notifications
|
||||
$('.left-column a').on('click', function () {
|
||||
var notifications = $(this).data('notifications');
|
||||
const notifications = $(this).data('notifications');
|
||||
|
||||
// Show all notifications
|
||||
if (!notifications) {
|
||||
|
@ -19,7 +19,7 @@ $(function () {
|
|||
// Show project notifications
|
||||
} else {
|
||||
$('.right-column .notification-item').each(function () {
|
||||
var isProjectNotification =
|
||||
const isProjectNotification =
|
||||
$.inArray($(this).data('id'), notifications) > -1;
|
||||
$(this).toggle(isProjectNotification);
|
||||
$(this).next('.horizontal-separator').toggle(isProjectNotification);
|
||||
|
|
|
@ -14,18 +14,19 @@ const shortDateFormat = new Intl.DateTimeFormat('en-US', {
|
|||
|
||||
const style = getComputedStyle(document.body);
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
insights: {
|
||||
renderCharts: function () {
|
||||
var approvalRateChart = $('#approval-rate-chart');
|
||||
const approvalRateChart = $('#approval-rate-chart');
|
||||
Pontoon.insights.renderRateChart(
|
||||
approvalRateChart,
|
||||
approvalRateChart.data('approval-rates'),
|
||||
approvalRateChart.data('approval-rates-12-month-avg'),
|
||||
);
|
||||
|
||||
var selfApprovalRateChart = $('#self-approval-rate-chart');
|
||||
const selfApprovalRateChart = $('#self-approval-rate-chart');
|
||||
Pontoon.insights.renderRateChart(
|
||||
selfApprovalRateChart,
|
||||
selfApprovalRateChart.data('self-approval-rates'),
|
||||
|
@ -36,9 +37,9 @@ var Pontoon = (function (my) {
|
|||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
gradient.addColorStop(0, style.getPropertyValue('--dark-green'));
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
|
@ -156,7 +157,7 @@ var Pontoon = (function (my) {
|
|||
const contributions = graph.data('contributions');
|
||||
|
||||
// Set start date to 365 days before now
|
||||
let startDate = new Date();
|
||||
const startDate = new Date();
|
||||
startDate.setMonth(startDate.getMonth() - 12);
|
||||
startDate.setUTCDate(startDate.getUTCDate() + 1);
|
||||
startDate.setUTCHours(0, 0, 0, 0);
|
||||
|
@ -165,9 +166,9 @@ var Pontoon = (function (my) {
|
|||
let graphHTML = '';
|
||||
const step = 13;
|
||||
|
||||
let currentDate = startDate;
|
||||
const currentDate = startDate;
|
||||
let currentMonth = currentDate.getMonth();
|
||||
let monthPosition = [{ monthIndex: currentMonth, x: 0 }];
|
||||
const monthPosition = [{ monthIndex: currentMonth, x: 0 }];
|
||||
|
||||
let week = 0;
|
||||
let gx = week * step;
|
||||
|
@ -367,10 +368,10 @@ Pontoon.profile.handleContributionGraphClick();
|
|||
|
||||
// Set up chart group navigation
|
||||
$('body').on('click', '#insights .chart-group-navigation li', function () {
|
||||
var items = $('.chart-group-navigation li').removeClass('active');
|
||||
const items = $('.chart-group-navigation li').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
var index = items.index(this);
|
||||
var itemWidth = $('.chart-item').first().outerWidth();
|
||||
const index = items.index(this);
|
||||
const itemWidth = $('.chart-item').first().outerWidth();
|
||||
|
||||
// Show the selected graph view
|
||||
$('.chart-group').css('marginLeft', -index * itemWidth);
|
||||
|
|
|
@ -3,14 +3,14 @@ $(function () {
|
|||
$('.data-visibility .toggle-button button').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var self = $(this);
|
||||
const self = $(this);
|
||||
|
||||
if (self.is('.active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var attribute = self.data('attribute');
|
||||
var value = self.text();
|
||||
const attribute = self.data('attribute');
|
||||
const value = self.text();
|
||||
|
||||
$.ajax({
|
||||
url: '/api/v1/user/' + $('#profile input[name="username"]').val() + '/',
|
||||
|
@ -24,7 +24,7 @@ $(function () {
|
|||
self.addClass('active');
|
||||
self.siblings().removeClass('active');
|
||||
|
||||
var label = self.parents('.field').find('.toggle-label').text();
|
||||
const label = self.parents('.field').find('.toggle-label').text();
|
||||
Pontoon.endLoader(`${label} visibility set to ${value}.`);
|
||||
},
|
||||
error: function (request) {
|
||||
|
@ -39,7 +39,7 @@ $(function () {
|
|||
|
||||
// Toggle user profile attribute
|
||||
$('.check-box').click(function () {
|
||||
var self = $(this);
|
||||
const self = $(this);
|
||||
|
||||
$.ajax({
|
||||
url: '/api/v1/user/' + $('#profile input[name="username"]').val() + '/',
|
||||
|
@ -51,8 +51,8 @@ $(function () {
|
|||
},
|
||||
success: function () {
|
||||
self.toggleClass('enabled');
|
||||
var is_enabled = self.is('.enabled');
|
||||
var status = is_enabled ? 'enabled' : 'disabled';
|
||||
const is_enabled = self.is('.enabled');
|
||||
const status = is_enabled ? 'enabled' : 'disabled';
|
||||
|
||||
Pontoon.endLoader(self.text() + ' ' + status + '.');
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ $(function () {
|
|||
|
||||
// Save custom homepage
|
||||
$('#homepage .locale .menu li:not(".no-match")').click(function () {
|
||||
var custom_homepage = $(this).find('.language').data('code');
|
||||
const custom_homepage = $(this).find('.language').data('code');
|
||||
|
||||
$.ajax({
|
||||
url: '/save-custom-homepage/',
|
||||
|
@ -94,7 +94,7 @@ $(function () {
|
|||
|
||||
// Save preferred source locale
|
||||
$('#preferred-locale .locale .menu li:not(".no-match")').click(function () {
|
||||
var preferred_source_locale = $(this).find('.language').data('code');
|
||||
const preferred_source_locale = $(this).find('.language').data('code');
|
||||
|
||||
$.ajax({
|
||||
url: '/save-preferred-source-locale/',
|
||||
|
|
|
@ -13,6 +13,7 @@ const longMonthFormat = new Intl.DateTimeFormat('en', {
|
|||
|
||||
const style = getComputedStyle(document.body);
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
insights: {
|
||||
|
@ -46,7 +47,7 @@ var Pontoon = (function (my) {
|
|||
];
|
||||
|
||||
const datasets = chart.data('dataset').map(function (item, index) {
|
||||
var color = colors[index % colors.length];
|
||||
const color = colors[index % colors.length];
|
||||
return {
|
||||
type: 'line',
|
||||
label: item.name,
|
||||
|
@ -130,7 +131,7 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
|
||||
// Render custom legend
|
||||
var chartId = chart.attr('id');
|
||||
const chartId = chart.attr('id');
|
||||
chart
|
||||
.parent()
|
||||
.next('.legend')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
const style = getComputedStyle(document.body);
|
||||
return $.extend(true, my, {
|
||||
|
@ -25,9 +26,9 @@ var Pontoon = (function (my) {
|
|||
|
||||
// Set up canvas to be HiDPI display ready
|
||||
$('#insights canvas.chart').each(function () {
|
||||
var canvas = this;
|
||||
const canvas = this;
|
||||
|
||||
var dpr = window.devicePixelRatio || 1;
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
canvas.style.width = canvas.width + 'px';
|
||||
canvas.style.height = canvas.height + 'px';
|
||||
canvas.width = canvas.width * dpr;
|
||||
|
@ -48,8 +49,8 @@ var Pontoon = (function (my) {
|
|||
customLegend: (chart) => (chart) => {
|
||||
const labels = chart.data.datasets
|
||||
.map((dataset) => {
|
||||
var disabled = dataset.hidden ? 'disabled' : '';
|
||||
var color = dataset.borderColor || dataset.backgroundColor;
|
||||
const disabled = dataset.hidden ? 'disabled' : '';
|
||||
const color = dataset.borderColor || dataset.backgroundColor;
|
||||
|
||||
return `<li class="${disabled}"><i class="icon" style="background-color:${color}"></i><span class="label">${dataset.label}</span></li>`;
|
||||
})
|
||||
|
@ -60,20 +61,20 @@ var Pontoon = (function (my) {
|
|||
// Custom legend item event handler
|
||||
attachCustomLegendHandler: function (chart, selector) {
|
||||
$('body').on('click', selector, function (e) {
|
||||
var li = $(this).parent();
|
||||
var index = li.index();
|
||||
const li = $(this).parent();
|
||||
const index = li.index();
|
||||
|
||||
if (e.altKey || e.metaKey) {
|
||||
// Show clicked and hide the rest
|
||||
chart.data.datasets.forEach((obj, i) => {
|
||||
var meta = chart.getDatasetMeta(i);
|
||||
const meta = chart.getDatasetMeta(i);
|
||||
meta.hidden = i === index ? null : true;
|
||||
});
|
||||
li.parent().find('li').addClass('disabled');
|
||||
} else {
|
||||
// Toggle clicked
|
||||
var meta = chart.getDatasetMeta(index);
|
||||
var dataset = chart.data.datasets[index];
|
||||
const meta = chart.getDatasetMeta(index);
|
||||
const dataset = chart.data.datasets[index];
|
||||
meta.hidden = meta.hidden === null ? !dataset.hidden : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
const nf = new Intl.NumberFormat('en');
|
||||
const pf = new Intl.NumberFormat('en', {
|
||||
|
@ -19,41 +20,43 @@ var Pontoon = (function (my) {
|
|||
renderActiveUsers: function () {
|
||||
$('#insights canvas.chart').each(function () {
|
||||
// Collect data
|
||||
var parent = $(this).parents('.active-users-chart');
|
||||
var id = parent.attr('id');
|
||||
var period = $('.period-selector .active').data('period').toString();
|
||||
var active = $('.active-users').data(period)[id];
|
||||
var total = $('.active-users').data('total')[id];
|
||||
const parent = $(this).parents('.active-users-chart');
|
||||
const id = parent.attr('id');
|
||||
const period = $('.period-selector .active')
|
||||
.data('period')
|
||||
.toString();
|
||||
const active = $('.active-users').data(period)[id];
|
||||
const total = $('.active-users').data('total')[id];
|
||||
|
||||
// Clear old canvas content to avoid aliasing
|
||||
var canvas = this;
|
||||
var context = canvas.getContext('2d');
|
||||
var dpr = window.devicePixelRatio || 1;
|
||||
const canvas = this;
|
||||
const context = canvas.getContext('2d');
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
context.lineWidth = 3 * dpr;
|
||||
|
||||
var x = canvas.width / 2;
|
||||
var y = canvas.height / 2;
|
||||
var radius = (canvas.width - context.lineWidth) / 2;
|
||||
const x = canvas.width / 2;
|
||||
const y = canvas.height / 2;
|
||||
const radius = (canvas.width - context.lineWidth) / 2;
|
||||
|
||||
var activeLength = 0;
|
||||
let activeLength = 0;
|
||||
if (total !== 0) {
|
||||
activeLength = (active / total) * 2;
|
||||
}
|
||||
var activeStart = -0.5;
|
||||
var activeEnd = activeStart + activeLength;
|
||||
const activeStart = -0.5;
|
||||
const activeEnd = activeStart + activeLength;
|
||||
plot(
|
||||
activeStart,
|
||||
activeEnd,
|
||||
style.getPropertyValue('--status-translated'),
|
||||
);
|
||||
|
||||
var inactiveLength = 2;
|
||||
let inactiveLength = 2;
|
||||
if (total !== 0) {
|
||||
inactiveLength = ((total - active) / total) * 2;
|
||||
}
|
||||
var inactiveStart = activeEnd;
|
||||
var inactiveEnd = inactiveStart + inactiveLength;
|
||||
const inactiveStart = activeEnd;
|
||||
const inactiveEnd = inactiveStart + inactiveLength;
|
||||
plot(inactiveStart, inactiveEnd, style.getPropertyValue('--grey-9'));
|
||||
|
||||
// Update number
|
||||
|
@ -69,14 +72,14 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
},
|
||||
renderUnreviewedSuggestionsLifespan: function () {
|
||||
var chart = $('#unreviewed-suggestions-lifespan-chart');
|
||||
const chart = $('#unreviewed-suggestions-lifespan-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
let greenBlue = style.getPropertyValue('--green-blue');
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
const greenBlue = style.getPropertyValue('--green-blue');
|
||||
gradient.addColorStop(0, greenBlue);
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
|
@ -158,13 +161,13 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
},
|
||||
renderTimeToReviewSuggestions: function () {
|
||||
var chart = $('#time-to-review-suggestions-chart');
|
||||
const chart = $('#time-to-review-suggestions-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
gradient.addColorStop(0, style.getPropertyValue('--green-blue'));
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
|
@ -267,13 +270,13 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
},
|
||||
renderTimeToReviewPretranslatons: function () {
|
||||
var chart = $('#time-to-review-pretranslations-chart');
|
||||
const chart = $('#time-to-review-pretranslations-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 160);
|
||||
gradient.addColorStop(0, style.getPropertyValue('--dark-magenta'));
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
|
@ -373,21 +376,21 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
},
|
||||
renderTranslationActivity: function () {
|
||||
var chart = $('#translation-activity-chart');
|
||||
const chart = $('#translation-activity-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
gradient.addColorStop(0, style.getPropertyValue('--dark-green'));
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
var humanData = chart.data('human-translations') || [];
|
||||
var machineryData = chart.data('machinery-translations') || [];
|
||||
var newSourcesData = chart.data('new-source-strings') || [];
|
||||
const humanData = chart.data('human-translations') || [];
|
||||
const machineryData = chart.data('machinery-translations') || [];
|
||||
const newSourcesData = chart.data('new-source-strings') || [];
|
||||
|
||||
var translationActivityChart = new Chart(chart, {
|
||||
const translationActivityChart = new Chart(chart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: $('#insights').data('dates'),
|
||||
|
@ -567,23 +570,23 @@ var Pontoon = (function (my) {
|
|||
);
|
||||
},
|
||||
renderReviewActivity: function () {
|
||||
var chart = $('#review-activity-chart');
|
||||
const chart = $('#review-activity-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
gradient.addColorStop(0, style.getPropertyValue('--status-unreviewed'));
|
||||
gradient.addColorStop(1, 'transparent');
|
||||
|
||||
var unreviewedData = chart.data('unreviewed') || [];
|
||||
var peerApprovedData = chart.data('peer-approved') || [];
|
||||
var selfApprovedData = chart.data('self-approved') || [];
|
||||
var rejectedData = chart.data('rejected') || [];
|
||||
var newSuggestionsData = chart.data('new-suggestions') || [];
|
||||
const unreviewedData = chart.data('unreviewed') || [];
|
||||
const peerApprovedData = chart.data('peer-approved') || [];
|
||||
const selfApprovedData = chart.data('self-approved') || [];
|
||||
const rejectedData = chart.data('rejected') || [];
|
||||
const newSuggestionsData = chart.data('new-suggestions') || [];
|
||||
|
||||
var reviewActivityChart = new Chart(chart, {
|
||||
const reviewActivityChart = new Chart(chart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: $('#insights').data('dates'),
|
||||
|
@ -765,28 +768,28 @@ var Pontoon = (function (my) {
|
|||
);
|
||||
},
|
||||
renderPretranslationQuality: function () {
|
||||
var chart = $('#pretranslation-quality-chart');
|
||||
const chart = $('#pretranslation-quality-chart');
|
||||
if (chart.length === 0) {
|
||||
return;
|
||||
}
|
||||
var ctx = chart[0].getContext('2d');
|
||||
const ctx = chart[0].getContext('2d');
|
||||
|
||||
var gradient_approval = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
const gradient_approval = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
gradient_approval.addColorStop(
|
||||
0,
|
||||
style.getPropertyValue('--dark-purple-2'),
|
||||
);
|
||||
gradient_approval.addColorStop(1, 'transparent');
|
||||
|
||||
var gradient_chrf = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
const gradient_chrf = ctx.createLinearGradient(0, 0, 0, 400);
|
||||
gradient_chrf.addColorStop(0, style.getPropertyValue('--dark-purple'));
|
||||
gradient_chrf.addColorStop(1, 'transparent');
|
||||
|
||||
var approvedData = chart.data('approved') || [];
|
||||
var rejectedData = chart.data('rejected') || [];
|
||||
var newData = chart.data('new') || [];
|
||||
const approvedData = chart.data('approved') || [];
|
||||
const rejectedData = chart.data('rejected') || [];
|
||||
const newData = chart.data('new') || [];
|
||||
|
||||
var pretranslationQualityChart = new Chart(chart, {
|
||||
const pretranslationQualityChart = new Chart(chart, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: $('#insights').data('dates'),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$(function () {
|
||||
var self = Pontoon;
|
||||
const self = Pontoon;
|
||||
|
||||
// Trigger search with Enter
|
||||
$('#search input')
|
||||
.unbind('keydown.pontoon')
|
||||
.bind('keydown.pontoon', function (e) {
|
||||
var value = $(this).val();
|
||||
const value = $(this).val();
|
||||
|
||||
if (e.which === 13 && value.length > 0) {
|
||||
self.locale = $('.locale .selector .language').data();
|
||||
|
@ -15,10 +15,10 @@ $(function () {
|
|||
});
|
||||
|
||||
// Handle "Copy to clipboard" of search results on main Machinery page
|
||||
var clipboard = new Clipboard('.machinery .machinery li');
|
||||
const clipboard = new Clipboard('.machinery .machinery li');
|
||||
|
||||
clipboard.on('success', function (event) {
|
||||
var successMessage = $('<span class="clipboard-success">Copied!</span>'),
|
||||
const successMessage = $('<span class="clipboard-success">Copied!</span>'),
|
||||
$trigger = $(event.trigger);
|
||||
|
||||
$('.clipboard-success').remove();
|
||||
|
@ -36,19 +36,20 @@ $(function () {
|
|||
* original Original string
|
||||
*/
|
||||
function getMachinery(original) {
|
||||
var ul = $('#helpers > .machinery').children('ul').empty(),
|
||||
const ul = $('#helpers > .machinery').children('ul').empty(),
|
||||
tab = $('#search').addClass('loading'), // .loading class used on the /machinery page
|
||||
requests = 0,
|
||||
preferred = 0,
|
||||
remaining = 0,
|
||||
sourcesMap = {};
|
||||
|
||||
let preferred = 0,
|
||||
remaining = 0,
|
||||
requests = 0;
|
||||
|
||||
self.NProgressUnbind();
|
||||
|
||||
function append(data) {
|
||||
var sources = sourcesMap[data.original + data.translation],
|
||||
let originalText = data.original;
|
||||
const sources = sourcesMap[data.original + data.translation],
|
||||
occurrencesTitle = 'Number of translation occurrences',
|
||||
originalText = data.original,
|
||||
translationText = data.translation;
|
||||
|
||||
if (sources) {
|
||||
|
@ -71,10 +72,10 @@ $(function () {
|
|||
sources.prepend('<span class="stress">' + data.quality + '</span>');
|
||||
}
|
||||
} else {
|
||||
var originalTextForDiff = originalText;
|
||||
const originalTextForDiff = originalText;
|
||||
originalText = originalText ? diff(original, originalTextForDiff) : '';
|
||||
|
||||
var li = $(
|
||||
const li = $(
|
||||
'<li class="suggestion"' +
|
||||
' title="Copy to clipboard"' +
|
||||
' data-clipboard-text="' +
|
||||
|
@ -130,7 +131,7 @@ $(function () {
|
|||
}
|
||||
|
||||
// Sort by quality
|
||||
var listitems = ul.children('li'),
|
||||
const listitems = ul.children('li'),
|
||||
sourceMap = {
|
||||
'Translation memory': 1,
|
||||
'Google Translate': 2,
|
||||
|
@ -139,7 +140,7 @@ $(function () {
|
|||
};
|
||||
|
||||
function getTranslationSource(el) {
|
||||
var sources = $(el).find('.translation-source span');
|
||||
const sources = $(el).find('.translation-source span');
|
||||
|
||||
if (sources.length > 1) {
|
||||
return Math.min.apply(
|
||||
|
@ -154,7 +155,7 @@ $(function () {
|
|||
}
|
||||
|
||||
listitems.sort(function (a, b) {
|
||||
var stressA = $(a).find('.stress'),
|
||||
const stressA = $(a).find('.stress'),
|
||||
stressB = $(b).find('.stress'),
|
||||
valA = stressA.length ? parseInt(stressA.html().split('%')[0]) : 0,
|
||||
valB = stressB.length ? parseInt(stressB.html().split('%')[0]) : 0,
|
||||
|
@ -176,10 +177,10 @@ $(function () {
|
|||
|
||||
// Sort sources inside results.
|
||||
ul.find('.sources').each(function () {
|
||||
var $sourcesList = $(this),
|
||||
const $sourcesList = $(this),
|
||||
sources = $sourcesList.children('li'),
|
||||
sortedItems = sources.sort(function (a, b) {
|
||||
var sourceA = sourceMap[$(a).find('span').text()],
|
||||
const sourceA = sourceMap[$(a).find('span').text()],
|
||||
sourceB = sourceMap[$(b).find('span').text()];
|
||||
return sourceA > sourceB ? 1 : sourceA < sourceB ? -1 : 0;
|
||||
});
|
||||
|
@ -406,10 +407,10 @@ $(function () {
|
|||
|
||||
/* Multiple spaces */
|
||||
string = string.replace(/ +/gi, function (match) {
|
||||
var title = 'Multiple spaces';
|
||||
var replacement = '';
|
||||
const title = 'Multiple spaces';
|
||||
let replacement = '';
|
||||
|
||||
for (var i = 0; i < match.length; i++) {
|
||||
for (let i = 0; i < match.length; i++) {
|
||||
replacement += ' · ';
|
||||
}
|
||||
return getPlaceableMarkup(title, replacement);
|
||||
|
@ -453,16 +454,16 @@ $(function () {
|
|||
* Mark diff between the string and the reference string
|
||||
*/
|
||||
function diff(reference, string) {
|
||||
var diff_obj = new diff_match_patch();
|
||||
var diff = diff_obj.diff_main(reference, string);
|
||||
var output = '';
|
||||
const diff_obj = new diff_match_patch();
|
||||
const diff = diff_obj.diff_main(reference, string);
|
||||
let output = '';
|
||||
|
||||
diff_obj.diff_cleanupSemantic(diff);
|
||||
diff_obj.diff_cleanupEfficiency(diff);
|
||||
|
||||
$.each(diff, function () {
|
||||
var type = this[0];
|
||||
var slice = this[1];
|
||||
const type = this[0];
|
||||
const slice = this[1];
|
||||
|
||||
switch (type) {
|
||||
case DIFF_INSERT:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$(function () {
|
||||
var container = $('#main .container');
|
||||
const container = $('#main .container');
|
||||
|
||||
function isValidForm($form, locales, message) {
|
||||
$form.find('.errors p').css('visibility', 'hidden');
|
||||
|
@ -18,10 +18,10 @@ $(function () {
|
|||
// Send notification
|
||||
container.on('click', '#send-notification .send', function (e) {
|
||||
e.preventDefault();
|
||||
var $form = $('#send-notification');
|
||||
const $form = $('#send-notification');
|
||||
|
||||
// Validate form
|
||||
var locales = $form.find('[name=selected_locales]').val(),
|
||||
const locales = $form.find('[name=selected_locales]').val(),
|
||||
message = $form.find('[name=message]').val();
|
||||
|
||||
if (!isValidForm($form, locales, message)) {
|
||||
|
@ -52,7 +52,7 @@ $(function () {
|
|||
container.on('click', '.locale-selector .shortcuts a', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var locales = $(this).data('ids').reverse(),
|
||||
const locales = $(this).data('ids').reverse(),
|
||||
$localeSelector = $(this).parents('.locale-selector');
|
||||
|
||||
$localeSelector.find('.selected .move-all').click();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
bugzilla: {
|
||||
|
@ -35,7 +36,7 @@ var Pontoon = (function (my) {
|
|||
return l.last_change_time < r.last_change_time ? 1 : -1;
|
||||
});
|
||||
|
||||
var tbody = $('<tbody>'),
|
||||
const tbody = $('<tbody>'),
|
||||
formatter = new Intl.DateTimeFormat('en-US', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
|
@ -44,9 +45,9 @@ var Pontoon = (function (my) {
|
|||
|
||||
$.each(data.bugs, function (i, bug) {
|
||||
// Prevent malicious bug summary from executin JS code
|
||||
var summary = Pontoon.doNotRender(bug.summary);
|
||||
const summary = Pontoon.doNotRender(bug.summary);
|
||||
|
||||
var tr = $('<tr>', {
|
||||
const tr = $('<tr>', {
|
||||
title: summary,
|
||||
});
|
||||
|
||||
|
@ -79,7 +80,7 @@ var Pontoon = (function (my) {
|
|||
tbody.append(tr);
|
||||
});
|
||||
|
||||
var table = $('<table>', {
|
||||
const table = $('<table>', {
|
||||
class: 'buglist striped',
|
||||
html:
|
||||
'<thead>' +
|
||||
|
@ -95,7 +96,7 @@ var Pontoon = (function (my) {
|
|||
container.append(table);
|
||||
table.show();
|
||||
|
||||
var count = data.bugs.length;
|
||||
const count = data.bugs.length;
|
||||
countCallback(tab, count);
|
||||
} else {
|
||||
errorCallback('Zarro Boogs Found.');
|
||||
|
@ -127,11 +128,11 @@ var Pontoon = (function (my) {
|
|||
}
|
||||
|
||||
function getTime(el) {
|
||||
var date = $(el).find('.last-changed').attr('datetime') || 0;
|
||||
const date = $(el).find('.last-changed').attr('datetime') || 0;
|
||||
return new Date(date).getTime();
|
||||
}
|
||||
|
||||
var node = $(this),
|
||||
const node = $(this),
|
||||
index = node.index(),
|
||||
table = node.parents('.buglist'),
|
||||
list = table.find('tbody'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$(function () {
|
||||
var container = $('#main .container');
|
||||
const container = $('#main .container');
|
||||
|
||||
function toggleWidgets() {
|
||||
container
|
||||
|
@ -15,8 +15,8 @@ $(function () {
|
|||
|
||||
container.on('click', '#info-wrapper .edit-info', function (e) {
|
||||
e.preventDefault();
|
||||
var content = container.find('.info').html();
|
||||
var textArea = container
|
||||
const content = container.find('.info').html();
|
||||
const textArea = container
|
||||
.find('.read-write-info textarea')
|
||||
.val($.trim(content));
|
||||
toggleWidgets();
|
||||
|
@ -30,7 +30,7 @@ $(function () {
|
|||
|
||||
container.on('click', '#info-wrapper .save', function (e) {
|
||||
e.preventDefault();
|
||||
var textArea = container.find('.read-write-info textarea');
|
||||
const textArea = container.find('.read-write-info textarea');
|
||||
$.ajax({
|
||||
url: textArea.parent().data('url'),
|
||||
type: 'POST',
|
||||
|
|
|
@ -4,7 +4,7 @@ $(function () {
|
|||
* Function keeps track of inputs that contain information about the order of selected locales.
|
||||
*/
|
||||
function updateSelectedLocales() {
|
||||
var $selectedList = $('.multiple-team-selector .locale.selected'),
|
||||
const $selectedList = $('.multiple-team-selector .locale.selected'),
|
||||
$selectedLocalesField = $selectedList.find('input[type=hidden]'),
|
||||
selectedLocales = $selectedList
|
||||
.find('li[data-id]')
|
||||
|
@ -21,7 +21,7 @@ $(function () {
|
|||
'click',
|
||||
'.multiple-team-selector .locale.select li',
|
||||
function () {
|
||||
var ls = $(this).parents('.locale.select'),
|
||||
const ls = $(this).parents('.locale.select'),
|
||||
target = ls.siblings('.locale.select').find('ul'),
|
||||
item = $(this).remove();
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(function () {
|
|||
// Choose/remove all locales
|
||||
$('body').on('click', '.multiple-team-selector .move-all', function (e) {
|
||||
e.preventDefault();
|
||||
var ls = $(this).parents('.locale.select'),
|
||||
const ls = $(this).parents('.locale.select'),
|
||||
target = ls.siblings('.locale.select').find('ul'),
|
||||
items = ls.find('li:visible:not(".no-match")').remove();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$(function () {
|
||||
var container = $('#main .container');
|
||||
const container = $('#main .container');
|
||||
|
||||
function inputHidden(name, value, cssClass) {
|
||||
return $(
|
||||
|
@ -15,16 +15,16 @@ $(function () {
|
|||
|
||||
container.on('click', '#permissions-form .save', function (e) {
|
||||
e.preventDefault();
|
||||
var $form = $('#permissions-form');
|
||||
const $form = $('#permissions-form');
|
||||
|
||||
// Remove stale permissions items (bug 1416890)
|
||||
$('input.permissions-form-item').remove();
|
||||
|
||||
// Before submitting the form, update translators and managers
|
||||
$.each(['translators', 'managers'], function (i, value) {
|
||||
var data = $form.find('.user.' + value + ' li');
|
||||
const data = $form.find('.user.' + value + ' li');
|
||||
data.each(function () {
|
||||
var itemId = $(this).data('id');
|
||||
const itemId = $(this).data('id');
|
||||
|
||||
if ($(this).parents('.general').length > 0) {
|
||||
$form.append(
|
||||
|
@ -32,7 +32,7 @@ $(function () {
|
|||
);
|
||||
} else {
|
||||
// We have to retrieve an index of parent project locale form
|
||||
var localeProjectIndex = $(this)
|
||||
const localeProjectIndex = $(this)
|
||||
.parents('.project-locale')
|
||||
.data('index');
|
||||
$form.append(
|
||||
|
@ -65,7 +65,7 @@ $(function () {
|
|||
|
||||
$(this).addClass('active').siblings('a').removeClass('active');
|
||||
|
||||
var available = $(this).parents('.user.available');
|
||||
const available = $(this).parents('.user.available');
|
||||
available.find('li').show();
|
||||
|
||||
if ($(this).is('.contributors')) {
|
||||
|
@ -81,7 +81,7 @@ $(function () {
|
|||
'input.search',
|
||||
'.user.available .menu input[type=search]',
|
||||
function () {
|
||||
var available = $(this).parents('.user.available');
|
||||
const available = $(this).parents('.user.available');
|
||||
|
||||
if (available.find('label a.contributors').is('.active')) {
|
||||
available.find('li:not(".contributor")').hide();
|
||||
|
@ -96,7 +96,7 @@ $(function () {
|
|||
|
||||
// Add project
|
||||
container.on('click', '#project-selector .menu li', function () {
|
||||
var slug = $(this).data('slug'),
|
||||
const slug = $(this).data('slug'),
|
||||
$permsForm = $(".project-locale[data-slug='" + slug + "']");
|
||||
|
||||
$('.project-locale:last').after($permsForm.removeClass('hidden'));
|
||||
|
@ -137,7 +137,7 @@ $(function () {
|
|||
|
||||
// Remove project
|
||||
container.on('click', '.remove-project', function (e) {
|
||||
var $permsForm = $(this).parents('.project-locale');
|
||||
const $permsForm = $(this).parents('.project-locale');
|
||||
e.preventDefault();
|
||||
|
||||
$('#project-selector').removeClass('hidden');
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line no-var
|
||||
var Pontoon = (function (my) {
|
||||
return $.extend(true, my, {
|
||||
requestItem: {
|
||||
|
@ -15,7 +16,7 @@ var Pontoon = (function (my) {
|
|||
.toggleClass('fa-chevron-left', !show);
|
||||
|
||||
if (type === 'locale-projects') {
|
||||
var localeProjects = $('#server').data('locale-projects');
|
||||
const localeProjects = $('#server').data('locale-projects');
|
||||
|
||||
// Show/hide all projects
|
||||
$('.items')
|
||||
|
@ -34,7 +35,7 @@ var Pontoon = (function (my) {
|
|||
});
|
||||
|
||||
// Toggle table & search box, show no results message based on project visibility
|
||||
var noProject = $('.project-list tr.limited').length === 0;
|
||||
const noProject = $('.project-list tr.limited').length === 0;
|
||||
$('.project-list').toggleClass('hidden', noProject);
|
||||
$('menu.controls').toggleClass('no-projects', noProject);
|
||||
$('.no-results').toggle();
|
||||
|
@ -60,7 +61,7 @@ var Pontoon = (function (my) {
|
|||
|
||||
toggleButton: function (condition, type) {
|
||||
condition = condition || true;
|
||||
var show = condition;
|
||||
let show = condition;
|
||||
|
||||
if (type === 'locale-projects' || type === 'pretranslation') {
|
||||
show = condition && $('.items td.enabled:visible').length > 0;
|
||||
|
@ -161,15 +162,17 @@ var Pontoon = (function (my) {
|
|||
})(Pontoon || {});
|
||||
|
||||
$(function () {
|
||||
var container = $('#main .container');
|
||||
var type = $('#server').data('locale-projects') ? 'locale-projects' : 'team';
|
||||
const container = $('#main .container');
|
||||
let type = $('#server').data('locale-projects') ? 'locale-projects' : 'team';
|
||||
|
||||
// Switch between available projects/teams and projects/team to request
|
||||
container.on('click', '.controls .request-toggle', function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
var type_ = $(this).is('.request-pretranslation') ? 'pretranslation' : type;
|
||||
const type_ = $(this).is('.request-pretranslation')
|
||||
? 'pretranslation'
|
||||
: type;
|
||||
|
||||
Pontoon.requestItem.toggleItem($(this).is('.back'), type_);
|
||||
$(this).siblings('.request-toggle').toggle();
|
||||
|
@ -180,7 +183,7 @@ $(function () {
|
|||
if ($('.controls .request-toggle').is('.back:visible')) {
|
||||
e.stopPropagation();
|
||||
|
||||
var type_ = $('.items').is('.requesting-pretranslation')
|
||||
const type_ = $('.items').is('.requesting-pretranslation')
|
||||
? 'pretranslation'
|
||||
: 'locale-projects';
|
||||
|
||||
|
@ -220,7 +223,7 @@ $(function () {
|
|||
});
|
||||
|
||||
// Prevent openning project page from the request panel
|
||||
var menu = container.find('.project .menu');
|
||||
const menu = container.find('.project .menu');
|
||||
menu.find('a').click(function (e) {
|
||||
if (menu.find('.search-wrapper > a').is('.back:visible')) {
|
||||
e.preventDefault();
|
||||
|
@ -244,12 +247,12 @@ $(function () {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var locale = '';
|
||||
let locale = '';
|
||||
|
||||
if ($(this).is('.confirmed')) {
|
||||
// Requesting from team page
|
||||
if ($('body').hasClass('locale')) {
|
||||
var projects = $('.items td.check.enabled')
|
||||
const projects = $('.items td.check.enabled')
|
||||
.map(function (val, element) {
|
||||
return $(element).siblings('.name').data('slug');
|
||||
})
|
||||
|
@ -269,7 +272,7 @@ $(function () {
|
|||
|
||||
// Requesting from project page
|
||||
else if (type === 'locale-projects' && $('body').hasClass('project')) {
|
||||
var project = $('#server').data('project');
|
||||
const project = $('#server').data('project');
|
||||
locale = $('.items td.radio.enabled').siblings('.name').data('slug');
|
||||
|
||||
Pontoon.requestItem.requestProjects(locale, [project], 'language');
|
||||
|
@ -277,7 +280,7 @@ $(function () {
|
|||
$(this).removeClass('confirmed').html('Request new language');
|
||||
} else if (type === 'team') {
|
||||
locale = $.trim($('#request-team-form #id_name').val());
|
||||
var code = $.trim($('#request-team-form #id_code').val());
|
||||
const code = $.trim($('#request-team-form #id_code').val());
|
||||
|
||||
Pontoon.requestItem.requestTeam(locale, code);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче