first commit

This commit is contained in:
2025-01-06 20:47:25 +01:00
commit 3bdbd78c2f
25591 changed files with 3586440 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import initMessagesVisibilityToggling from './messages-visibility'
import initMessagesEdition from './messages-edition'
import initMessagesPagination from './messages-pagination'
import initMessagesTree from './messages-tree'
import initSearch from './messages-search'
$(() => {
initMessagesVisibilityToggling(initMessagesPagination);
var search = initSearch();
initMessagesEdition(search);
initMessagesTree()
});

View File

@@ -0,0 +1,76 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
export default function (search) {
$('.reset-translation-value').each((buttonIndex, button) => {
let $editTranslationForm = $(button).parents('form');
let defaultTranslationValue = $editTranslationForm.find('*[name=default]').val();
$(button).click(() => {
$editTranslationForm.find('*[name=translation_value]').val(defaultTranslationValue);
$editTranslationForm.submit();
});
});
let showFlashMessageOnEdit = (form) => {
$(form).submit((event) => {
event.preventDefault();
let $editTranslationForm = $(event.target);
let url = $editTranslationForm.attr('action');
$.post(url, $editTranslationForm.serialize(), (response) => {
let flashMessage;
if (response['successful_update']) {
flashMessage = $editTranslationForm.find('.alert-info');
// Propagate edition
let hash = $editTranslationForm.data('hash');
let $editTranslationForms = $('[data-hash=' + hash + ']');
let $translationValueFields = $($editTranslationForms.find('textarea'));
$translationValueFields.val($editTranslationForm.find('textarea').val());
// Refresh search index
$editTranslationForms.removeAttr('data-jets');
search.update();
} else {
flashMessage = $editTranslationForm.find('.alert-danger');
}
flashMessage.removeClass('hide');
setTimeout(() => {
flashMessage.addClass('hide');
}, 4000);
});
return false;
});
};
$('#jetsContent form, .translation-domain form').each((formIndex, form) => {
showFlashMessageOnEdit(form);
});
}

View File

@@ -0,0 +1,124 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import MultiPagination from './multi-pagination';
export default function () {
let fixedOffset = $('.header-toolbar').height() + $('.main-header').height();
const MAX_PAGINATION = 20;
let addPageLinksToNavigationBar = (nav) => {
let pageTemplate = $(nav).find('.tpl');
pageTemplate.removeClass('tpl');
let pageLinkTemplate = pageTemplate.clone();
pageTemplate.remove();
pageLinkTemplate.removeClass('hide');
let pageIndex;
let pageLink;
let pageLinkAnchor;
let totalPages = $(nav).parents('.translation-domains').find('.page').length;
if (totalPages === 1) {
return $('.pagination').addClass('hide');
}
else {
$('.pagination').removeClass('hide');
}
let i;
for (i = 1; i < totalPages; i++) {
pageIndex = i + 1;
pageLink = pageLinkTemplate.clone();
pageLink.attr('data-page-index', pageIndex);
pageLinkAnchor = pageLink.find('a');
pageLinkAnchor.html(pageIndex);
$(nav).find('.pagination').append(pageLink);
}
};
// Fix internal navigation to anchors
// by adding offset of fixed header height
// @See also http://stackoverflow.com/a/13067009/282073
let scrollToPreviousPaginationBar = (paginationBar, link) => {
let paginationBarTop = paginationBar.getBoundingClientRect().top;
window.scrollTo(window.pageXOffset, window.pageYOffset + paginationBarTop - fixedOffset);
};
$('.translation-domain .go-to-pagination-bar').click((event) => {
let paginationBar = $(event.target).parents('.translation-domain').find('.pagination')[0];
scrollToPreviousPaginationBar(paginationBar, event.target);
return false;
});
$('.translation-domains nav').each((navIndex, nav) => {
addPageLinksToNavigationBar(nav);
let hideActivePageInDomain = (domain) => {
let page = domain.find('.page[data-status=active]');
$(page).addClass('hide');
$(page).attr('data-status', 'inactive');
};
let showPageInDomain = (pageIndex, domain) => {
let targetPage = domain.find('.page[data-page-index=' + pageIndex + ']');
$(targetPage).removeClass('hide');
$(targetPage).attr('data-status', 'active');
};
$(nav).find('.page-link').click((event) => {
let paginationBar = $(event.target).parents('.pagination')[0];
scrollToPreviousPaginationBar(paginationBar, event.target);
});
$(nav).find('.page-item').click((event) => {
let pageLink = $(event.target);
let domain = pageLink.parents('.translation-domains').find('.translation-forms');
let pageItem = pageLink.parent();
let pageIndex = pageItem.data('page-index');
$(`[data-page-index=${pageIndex}]`).addClass('active');
$(`[data-page-index=${pageIndex}]`).siblings().removeClass('active');
pageItem.parent().find('.active').removeClass('active');
pageItem.addClass('active');
hideActivePageInDomain(domain);
showPageInDomain(pageIndex, domain);
return false;
});
});
if($('.translation-domains').find('.page').length > MAX_PAGINATION) {
$('.page-item.hide').removeClass('hide');
$('.pagination').each((index, pagination)=> {
let lastItem = $(pagination).find('.page-item:last-child');
$(pagination).find('.js-next-arrow').insertAfter(lastItem).removeClass('hide');
MultiPagination($(pagination));
});
}
}

View File

@@ -0,0 +1,76 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import Jets from 'jets/jets';
export default function () {
$(() => {
const searchSelector = '.search-translation';
$(searchSelector + ' form').submit(function (event) {
event.preventDefault();
$('#jetsContent form').addClass('hide');
const keywords = $('#jetsSearch').val().toLowerCase();
const jetsSelector = '#jetsContent > [data-jets*="' + keywords + '"]';
if (0 === $(jetsSelector).length) {
var notificationElement = $(searchSelector + '> .alert')[0];
$(notificationElement).removeClass('hide');
setTimeout(function () {
$(notificationElement).addClass('hide');
}, 2000);
} else {
$(jetsSelector).removeClass('hide');
}
if($(jetsSelector).length) {
$('.js-results').show().addClass('card').find('h2').removeClass('hide');
}
return false;
});
$(searchSelector + ' input[type=reset]').click(function (event) {
event.preventDefault();
$('#jetsSearch').val('');
$('#jetsContent form').addClass('hide');
return false;
});
});
if ($('#jetsSearch').length > 0) {
return new Jets({
searchTag: '#jetsSearch',
contentTag: '#jetsContent',
callSearchManually: true,
manualContentHandling: function (tag) {
// Search for translation keys and translation values
return $(tag).find('.verbatim')[0].innerText + $(tag).find('textarea')[0].value;
}
});
}
}

View File

@@ -0,0 +1,142 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
export default function () {
function updateVisibilityIcons(domainActions) {
let visibilityOffIcon = domainActions.find('.visibility-off');
let visibilityOnIcon = domainActions.find('.visibility-on');
let showMessagesButton = domainActions.find('.btn-show-messages');
let hideMessagesButton = domainActions.find('.btn-hide-messages');
let expandedMessages = visibilityOffIcon.hasClass('hide');
if (expandedMessages) {
visibilityOffIcon.removeClass('hide');
visibilityOnIcon.addClass('hide');
showMessagesButton.addClass('hide');
hideMessagesButton.removeClass('hide');
} else {
visibilityOnIcon.removeClass('hide');
visibilityOffIcon.addClass('hide');
showMessagesButton.removeClass('hide');
hideMessagesButton.addClass('hide');
}
}
function updateMissingTranslationsWarning(domainActions) {
let subdomain = domainActions.parent().next('.subdomains');
let missingTranslations = subdomain.find('[data-missing-translations]');
let totalMissingTranslations = 0;
$(missingTranslations).each(function (index, element) {
totalMissingTranslations = totalMissingTranslations + parseInt($(element).attr('data-missing-translations'), 10);
});
if (totalMissingTranslations > 0) {
let missingTranslationsWarning = domainActions.find('.missing-translations');
let warningMessage = missingTranslationsWarning .text();
warningMessage = warningMessage.replace('%d', totalMissingTranslations);
missingTranslationsWarning.text(warningMessage);
missingTranslationsWarning.removeClass('hide');
}
return totalMissingTranslations;
}
let allDomainsMissingTranslations = 0;
$('.domain-first-part').each((index, domainToggler) => {
let domainActions = $(domainToggler).find('.domain-actions');
allDomainsMissingTranslations = allDomainsMissingTranslations + updateMissingTranslationsWarning(domainActions);
$(domainToggler).click((event) => {
let domainTitle;
if ($(event.target).hasClass('domain-first-part')) {
domainTitle = $(event.target);
} else {
domainTitle = $(event.target).parent();
}
domainTitle.find('i').toggleClass('expanded');
$(domainTitle.nextAll().filter('.subdomains')[0]).toggleClass('hide');
updateVisibilityIcons(domainActions);
event.stopPropagation();
return false;
});
});
let totalTranslations = $('#jetsContent form').length;
(function (totalTranslations, totalRemainingTranslations) {
let totalTranslationsTemplate = $('.summary .total-translations').attr('data-template') ;
let remainingTranslationsTemplate = $('.summary .total-remaining-translations').attr('data-template') ;
if (totalRemainingTranslations > 0) {
let remainingTranslationsMessage = remainingTranslationsTemplate.replace('%d', totalRemainingTranslations);
$('.total-remaining-translations').text(remainingTranslationsMessage);
$('.summary .separator').removeClass('hide');
}
if (totalTranslationsTemplate) {
let totalTranslationsMessages = totalTranslationsTemplate.replace('%d', totalTranslations);
$('.summary .total-translations').text(totalTranslationsMessages);
}
})(totalTranslations, allDomainsMissingTranslations);
$('.domain-actions').click((event) => {
let domainActions = $(event.target);
if (!$(event.target).hasClass('domain-actions')) {
domainActions = $(event.target).parent();
}
let domainFirstPart = domainActions.prev();
domainFirstPart.click();
});
$('.btn-expand').click(() => {
$('.domain-first-part').each((index, domainToggler) => {
let domainTitle = $(domainToggler);
let isDomainExpanded = domainTitle.find('i').hasClass('expanded');
if (!isDomainExpanded) {
$(domainTitle.find('i')).click();
}
});
});
$('.btn-reduce').click(() => {
$('.domain-first-part').each((index, domainToggler) => {
let domainTitle = $(domainToggler);
let isDomainExpanded = domainTitle.find('i').hasClass('expanded');
if (isDomainExpanded) {
$(domainTitle.find('i')).click();
}
});
});
$($('.domain-first-part')[0]).click(); // Expand first domain in tree
$($('.domain-part .delegate-toggle-messages')[0]).click(); // Show messages of first domain
}

View File

@@ -0,0 +1,149 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
export default function(callback) {
var buttonSuffix = 'translation-messages';
var hideClass = 'hide';
function hideCurrentTranslationForms(formsContainer) {
let currentTranslationForms = formsContainer.find('.translation-forms');
if (currentTranslationForms.length > 0) {
let hiddenFormsContainer = $('[data-parent-of="' + currentTranslationForms.attr('id') + '"]');
currentTranslationForms.find('form').addClass(hideClass);
hiddenFormsContainer.append(currentTranslationForms);
}
}
function hideCurrentNavigationBar(navigationContainer) {
let currentNavigationBar = navigationContainer.find('nav');
if (currentNavigationBar.length > 0) {
let navIdentifier = currentNavigationBar.attr('data-navigation-of');
let hiddenNavigationBarContainer = $('[data-navigation-parent-of="' + navIdentifier + '"]');
currentNavigationBar.addClass(hideClass);
hiddenNavigationBarContainer.append(currentNavigationBar);
}
}
function highlightDomainFirstPart(showTranslationsFormButton) {
$('.domain-first-part').removeClass('active');
let domainFirstPart = $($(showTranslationsFormButton.parents('.subdomains')[0]).prevAll().filter('.domain-first-part'))[0];
$(domainFirstPart).addClass('active');
}
function updateDomainTitle(editTranslationForms) {
let domainPart = editTranslationForms.parents('.translation-domain').prev();
let missingTranslationWarning = domainPart.find('.missing-translations-short-message');
let warningPlaceholder = $('#domain .missing-translations');
let totalPlaceholder = $('#domain .total-expressions');
let separator = $('#domain .separator');
totalPlaceholder.text(editTranslationForms.data('total-translations'));
if (missingTranslationWarning.length > 0) {
warningPlaceholder.text(missingTranslationWarning.text());
separator.removeClass('hide');
} else {
warningPlaceholder.text('');
separator.addClass('hide');
}
separator.first().removeClass('hide');
let domain = $('#domain .name');
let title = editTranslationForms.attr('data-domain');
domain.text(title);
}
function updateMissingTranslationsMessages(title) {
let missingTranslationsMessage = title.find('.missing-translations-long-message');
if (missingTranslationsMessage.text().length > 0) {
$('.translation-domains .missing-translations-paragraph').text(missingTranslationsMessage.text());
} else {
$('.translation-domains .missing-translations-paragraph').text('');
}
}
function updateNavigationBar(translationDomain, editTranslationForms) {
let navigationContainer = $('.navbar-container:first');
let navigation = translationDomain.find('nav');
navigation.parent().attr('data-navigation-parent-of', editTranslationForms.attr('id'));
navigation.attr('data-navigation-of', editTranslationForms.attr('id'));
hideCurrentNavigationBar(navigationContainer);
navigationContainer.append(navigation);
$(navigationContainer.find('nav')).removeClass(hideClass);
$('.forms-container + .navbar-container').remove();
$('.forms-container').after(navigationContainer.clone());
}
function updateEditTranslationForms(formsContainer, editTranslationForms) {
hideCurrentTranslationForms(formsContainer);
formsContainer.append(editTranslationForms);
$(formsContainer.find('.translation-forms form')).removeClass(hideClass);
}
(() => {
$('.show-' + buttonSuffix).each((buttonIndex, button) => {
$(button).click((event) => {
let showTranslationsFormButton = $(event.target);
let translationDomain = showTranslationsFormButton.parent();
let editTranslationForms = translationDomain.find('.translation-forms');
let formsContainer = $('.forms-container');
if (editTranslationForms.length === 0) {
return false;
}
highlightDomainFirstPart(showTranslationsFormButton);
updateDomainTitle(editTranslationForms);
updateNavigationBar(translationDomain, editTranslationForms);
updateEditTranslationForms(formsContainer, editTranslationForms);
callback();
});
});
$('.domain-part .delegate-toggle-messages').each((togglerIndex, toggler) => {
$(toggler).click((event) => {
let title = $(event.target);
if (!$(event.target).hasClass('domain-part')) {
title = $(event.target).parent();
}
updateMissingTranslationsMessages(title);
let translationDomain = title.next();
let showMessagesButton = translationDomain.find('.show-' + buttonSuffix);
showMessagesButton.click();
});
});
})();
}

View File

@@ -0,0 +1,127 @@
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
export default function(paginationContainer) {
const lng = paginationContainer.find('.js-page-link').length;
const multi = '<li class="page-item js-multi"><span class="page-link">...</span></li>';
const displayNumber = paginationContainer.data('display-number'); // Number of pages to display after the first
let current = paginationContainer.find('.page-item.active').data('page-index');
checkCurrentPage(current);
paginationContainer.find('.js-page-link').on('click', function(event) {
event.preventDefault();
paginationContainer.find('.active').removeClass('active');
$(event.currentTarget).parent().addClass('active');
current = $(event.currentTarget).parent().data('page-index');
checkCurrentPage(current);
});
paginationContainer.find('.js-arrow').on('click', function(event) {
current = paginationContainer.find('.page-item.active').data('page-index');
event.preventDefault();
if($(event.currentTarget).data('direction') === 'prev' && !$(event.currentTarget).parent().next().hasClass('active')) {
$(`.page[data-page-index=${current - 1}]`).removeClass('hide');
$(`.page[data-page-index=${current}]`).addClass('hide');
$(`.page-item[data-page-index=${current - 1}]`).addClass('active');
$(`.page-item[data-page-index=${current}]`).removeClass('active');
current --;
}
else if($(event.currentTarget).data('direction') === 'next' && !$(event.currentTarget).parent().prev().hasClass('active')) {
$(`.page[data-page-index=${current + 1}]`).removeClass('hide');
$(`.page[data-page-index=${current}]`).addClass('hide');
$(`.page-item[data-page-index=${current + 1}]`).addClass('active');
$(`.page-item[data-page-index=${current}]`).removeClass('active');
current ++;
}
if($(event.currentTarget).data('direction') === 'prev' && current === 1) {
return false;
}
checkCurrentPage(current);
});
function checkCurrentPage(current) {
$('.pagination').each((index, pagination) => {
var paginationContainer = $(pagination);
var prevDots = paginationContainer.find('[data-page-index=1]').next('.js-multi');
var nextDots = paginationContainer.find('[data-page-index='+lng+']').prev('.js-multi');
var mid = Math.round(displayNumber);
paginationContainer.find('.js-page-link').each(function(index, item) {
if(current >= displayNumber + 1 && index === 0 && prevDots.length === 0) {
$(item).parent().after(multi);
}
if(current >= displayNumber + 1 ) {
if(index >= current - mid && index <= current + mid) {
$(item).show();
if(lng - current >= mid && index > current && index !== lng - 1) {
$(item).hide();
}
else if(nextDots.length === 0 && index === lng -1 && lng - current > displayNumber) {
$(item).parent().before(multi);
}
}
else if(index !== 0 && index !== lng-1 && (lng-1 - index) > displayNumber) {
$(item).hide();
if(nextDots.length && lng - displayNumber <= current) {
nextDots.remove();
}
}
else if(current === lng){
nextDots.remove();
if(index <= displayNumber && index !==0) {
$(item).hide();
}
else {
$(item).show();
}
}
}
else if(current && index > displayNumber && index !== lng-1 && current < displayNumber) {
$(item).hide();
}
else if(index === lng-1 && current === 1 && nextDots.length === 0) {
$(item).parent().before(multi);
}
else {
if(index > displayNumber && index !== lng-1) {
$(item).hide();
}
else if(index === lng-1 && nextDots.length === 0 && current > 1) {
$(item).parent().before(multi);
}
else {
$(item).show();
if(index === 0 && prevDots.length !== 0) {
prevDots.remove();
}
}
}
});
});
}
}