first commit
This commit is contained in:
36
admin-kalsport/themes/new-theme/js/translation-page/index.js
Normal file
36
admin-kalsport/themes/new-theme/js/translation-page/index.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
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);
|
||||
const search = initSearch();
|
||||
initMessagesEdition(search);
|
||||
initMessagesTree();
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
export default function (search) {
|
||||
$('.reset-translation-value').each((buttonIndex, button) => {
|
||||
const $editTranslationForm = $(button).parents('form');
|
||||
const defaultTranslationValue = $editTranslationForm.find('*[name=default]').val();
|
||||
|
||||
$(button).click(() => {
|
||||
$editTranslationForm.find('*[name=translation_value]').val(defaultTranslationValue);
|
||||
$editTranslationForm.submit();
|
||||
});
|
||||
});
|
||||
|
||||
const showFlashMessageOnEdit = (form) => {
|
||||
$(form).submit((event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const $editTranslationForm = $(event.target);
|
||||
const url = $editTranslationForm.attr('action');
|
||||
|
||||
$.post(url, $editTranslationForm.serialize(), (response) => {
|
||||
let flashMessage;
|
||||
|
||||
if (response.successful_update) {
|
||||
flashMessage = $editTranslationForm.find('.alert-info');
|
||||
|
||||
// Propagate edition
|
||||
const hash = $editTranslationForm.data('hash');
|
||||
const $editTranslationForms = $(`[data-hash=${hash}]`);
|
||||
const $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);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import MultiPagination from './multi-pagination';
|
||||
|
||||
export default function () {
|
||||
const fixedOffset = $('.header-toolbar').height() + $('.main-header').height();
|
||||
const MAX_PAGINATION = 20;
|
||||
|
||||
const addPageLinksToNavigationBar = (nav) => {
|
||||
const pageTemplate = $(nav).find('.tpl');
|
||||
pageTemplate.removeClass('tpl');
|
||||
|
||||
const pageLinkTemplate = pageTemplate.clone();
|
||||
pageTemplate.remove();
|
||||
pageLinkTemplate.removeClass('hide');
|
||||
|
||||
let pageIndex;
|
||||
let pageLink;
|
||||
let pageLinkAnchor;
|
||||
const totalPages = $(nav).parents('.translation-domains').find('.page').length;
|
||||
|
||||
if (totalPages === 1) {
|
||||
return $('.pagination').addClass('hide');
|
||||
}
|
||||
|
||||
$('.pagination').removeClass('hide');
|
||||
|
||||
let i;
|
||||
|
||||
for (i = 1; i < totalPages; i += 1) {
|
||||
pageIndex = i + 1;
|
||||
pageLink = pageLinkTemplate.clone();
|
||||
pageLink.attr('data-page-index', pageIndex);
|
||||
pageLinkAnchor = pageLink.find('a');
|
||||
pageLinkAnchor.html(pageIndex);
|
||||
|
||||
$(nav).find('.pagination').append(pageLink);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Fix internal navigation to anchors
|
||||
// by adding offset of fixed header height
|
||||
// @See also http://stackoverflow.com/a/13067009/282073
|
||||
const scrollToPreviousPaginationBar = (paginationBar) => {
|
||||
const paginationBarTop = paginationBar.getBoundingClientRect().top;
|
||||
window.scrollTo(window.pageXOffset, window.pageYOffset + paginationBarTop - fixedOffset);
|
||||
};
|
||||
|
||||
$('.translation-domain .go-to-pagination-bar').click((event) => {
|
||||
const paginationBar = $(event.target).parents('.translation-domain').find('.pagination')[0];
|
||||
scrollToPreviousPaginationBar(paginationBar);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.translation-domains nav').each((navIndex, nav) => {
|
||||
addPageLinksToNavigationBar(nav);
|
||||
|
||||
const hideActivePageInDomain = (domain) => {
|
||||
const page = domain.find('.page[data-status=active]');
|
||||
$(page).addClass('hide');
|
||||
$(page).attr('data-status', 'inactive');
|
||||
};
|
||||
|
||||
const showPageInDomain = (pageIndex, domain) => {
|
||||
const targetPage = domain.find(`.page[data-page-index=${pageIndex}]`);
|
||||
$(targetPage).removeClass('hide');
|
||||
$(targetPage).attr('data-status', 'active');
|
||||
};
|
||||
|
||||
$(nav).find('.page-link').click((event) => {
|
||||
const paginationBar = $(event.target).parents('.pagination')[0];
|
||||
scrollToPreviousPaginationBar(paginationBar);
|
||||
});
|
||||
|
||||
$(nav).find('.page-item').click((event) => {
|
||||
const pageLink = $(event.target);
|
||||
const domain = pageLink.parents('.translation-domains').find('.translation-forms');
|
||||
const pageItem = pageLink.parent();
|
||||
const 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) => {
|
||||
const lastItem = $(pagination).find('.page-item:last-child');
|
||||
$(pagination).find('.js-next-arrow').insertAfter(lastItem).removeClass('hide');
|
||||
MultiPagination($(pagination));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import Jets from 'jets/jets';
|
||||
|
||||
export default function () {
|
||||
$(() => {
|
||||
const searchSelector = '.search-translation';
|
||||
$(`${searchSelector} form`).submit((event) => {
|
||||
event.preventDefault();
|
||||
|
||||
$('#jetsContent form').addClass('hide');
|
||||
|
||||
const keywords = $('#jetsSearch').val().toLowerCase();
|
||||
const jetsSelector = `#jetsContent > [data-jets*="${keywords}"]`;
|
||||
|
||||
if ($(jetsSelector).length === 0) {
|
||||
const notificationElement = $(`${searchSelector}> .alert`)[0];
|
||||
$(notificationElement).removeClass('hide');
|
||||
setTimeout(() => {
|
||||
$(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((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(tag) {
|
||||
// Search for translation keys and translation values
|
||||
return $(tag).find('.verbatim')[0].innerText + $(tag).find('textarea')[0].value;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
export default function () {
|
||||
function updateVisibilityIcons(domainActions) {
|
||||
const visibilityOffIcon = domainActions.find('.visibility-off');
|
||||
const visibilityOnIcon = domainActions.find('.visibility-on');
|
||||
const showMessagesButton = domainActions.find('.btn-show-messages');
|
||||
const hideMessagesButton = domainActions.find('.btn-hide-messages');
|
||||
const 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) {
|
||||
const subdomain = domainActions.parent().next('.subdomains');
|
||||
const missingTranslations = subdomain.find('[data-missing-translations]');
|
||||
let totalMissingTranslations = 0;
|
||||
|
||||
$(missingTranslations).each((index, element) => {
|
||||
totalMissingTranslations += parseInt($(element).attr('data-missing-translations'), 10);
|
||||
});
|
||||
|
||||
if (totalMissingTranslations > 0) {
|
||||
const 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) => {
|
||||
const domainActions = $(domainToggler).find('.domain-actions');
|
||||
|
||||
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;
|
||||
});
|
||||
});
|
||||
|
||||
(function defineTranslations(totalTranslations, totalRemainingTranslations) {
|
||||
const totalTranslationsTemplate = $('.summary .total-translations').attr('data-template');
|
||||
const remainingTranslationsTemplate = $('.summary .total-remaining-translations').attr('data-template');
|
||||
|
||||
if (totalRemainingTranslations > 0) {
|
||||
const remainingTranslationsMessage = remainingTranslationsTemplate.replace('%d', totalRemainingTranslations);
|
||||
$('.total-remaining-translations').text(remainingTranslationsMessage);
|
||||
$('.summary .separator').removeClass('hide');
|
||||
}
|
||||
|
||||
if (totalTranslationsTemplate) {
|
||||
const totalTranslationsMessages = totalTranslationsTemplate.replace('%d', totalTranslations);
|
||||
$('.summary .total-translations').text(totalTranslationsMessages);
|
||||
}
|
||||
}($('#jetsContent form').length, allDomainsMissingTranslations));
|
||||
|
||||
$('.domain-actions').click((event) => {
|
||||
let domainActions = $(event.target);
|
||||
|
||||
if (!$(event.target).hasClass('domain-actions')) {
|
||||
domainActions = $(event.target).parent();
|
||||
}
|
||||
|
||||
const domainFirstPart = domainActions.prev();
|
||||
domainFirstPart.click();
|
||||
});
|
||||
|
||||
$('.btn-expand').click(() => {
|
||||
$('.domain-first-part').each((index, domainToggler) => {
|
||||
const domainTitle = $(domainToggler);
|
||||
const isDomainExpanded = domainTitle.find('i').hasClass('expanded');
|
||||
|
||||
if (!isDomainExpanded) {
|
||||
$(domainTitle.find('i')).click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-reduce').click(() => {
|
||||
$('.domain-first-part').each((index, domainToggler) => {
|
||||
const domainTitle = $(domainToggler);
|
||||
const 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
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
export default function (callback) {
|
||||
const buttonSuffix = 'translation-messages';
|
||||
const hideClass = 'hide';
|
||||
|
||||
function hideCurrentTranslationForms(formsContainer) {
|
||||
const currentTranslationForms = formsContainer.find('.translation-forms');
|
||||
|
||||
if (currentTranslationForms.length > 0) {
|
||||
const hiddenFormsContainer = $(`[data-parent-of="${currentTranslationForms.attr('id')}"]`);
|
||||
currentTranslationForms.find('form').addClass(hideClass);
|
||||
hiddenFormsContainer.append(currentTranslationForms);
|
||||
}
|
||||
}
|
||||
|
||||
function hideCurrentNavigationBar(navigationContainer) {
|
||||
const currentNavigationBar = navigationContainer.find('nav');
|
||||
|
||||
if (currentNavigationBar.length > 0) {
|
||||
const navIdentifier = currentNavigationBar.attr('data-navigation-of');
|
||||
const hiddenNavigationBarContainer = $(`[data-navigation-parent-of="${navIdentifier}"]`);
|
||||
currentNavigationBar.addClass(hideClass);
|
||||
hiddenNavigationBarContainer.append(currentNavigationBar);
|
||||
}
|
||||
}
|
||||
|
||||
function highlightDomainFirstPart(showTranslationsFormButton) {
|
||||
$('.domain-first-part').removeClass('active');
|
||||
const domainFirstPart = $($(showTranslationsFormButton.parents('.subdomains')[0])
|
||||
.prevAll()
|
||||
.filter('.domain-first-part'))[0];
|
||||
$(domainFirstPart).addClass('active');
|
||||
}
|
||||
|
||||
function updateDomainTitle(editTranslationForms) {
|
||||
const domainPart = editTranslationForms.parents('.translation-domain').prev();
|
||||
const missingTranslationWarning = domainPart.find('.missing-translations-short-message');
|
||||
const warningPlaceholder = $('#domain .missing-translations');
|
||||
const totalPlaceholder = $('#domain .total-expressions');
|
||||
const 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');
|
||||
|
||||
const domain = $('#domain .name');
|
||||
const title = editTranslationForms.attr('data-domain');
|
||||
domain.text(title);
|
||||
}
|
||||
|
||||
function updateMissingTranslationsMessages(title) {
|
||||
const 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) {
|
||||
const navigationContainer = $('.navbar-container:first');
|
||||
const 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) => {
|
||||
const showTranslationsFormButton = $(event.target);
|
||||
|
||||
const translationDomain = showTranslationsFormButton.parent();
|
||||
const editTranslationForms = translationDomain.find('.translation-forms');
|
||||
const formsContainer = $('.forms-container');
|
||||
|
||||
if (editTranslationForms.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
highlightDomainFirstPart(showTranslationsFormButton);
|
||||
|
||||
updateDomainTitle(editTranslationForms);
|
||||
|
||||
updateNavigationBar(translationDomain, editTranslationForms);
|
||||
updateEditTranslationForms(formsContainer, editTranslationForms);
|
||||
|
||||
callback();
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
$('.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);
|
||||
|
||||
const translationDomain = title.next();
|
||||
const showMessagesButton = translationDomain.find(`.show-${buttonSuffix}`);
|
||||
|
||||
showMessagesButton.click();
|
||||
});
|
||||
});
|
||||
})();
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* 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.md.
|
||||
* 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 https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
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', (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', (event) => {
|
||||
current = paginationContainer.find('.page-item.active').data('page-index');
|
||||
event.preventDefault();
|
||||
const direction = $(event.currentTarget).data('direction');
|
||||
|
||||
if (
|
||||
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 -= 1;
|
||||
} else if (
|
||||
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 += 1;
|
||||
}
|
||||
if ($(event.currentTarget).data('direction') === 'prev' && current === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
checkCurrentPage(current);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
function checkCurrentPage(currentEl) {
|
||||
$('.pagination').each((_index, pagination) => {
|
||||
const pagContainer = $(pagination);
|
||||
const prevDots = pagContainer.find('[data-page-index=1]').next('.js-multi');
|
||||
const nextDots = pagContainer.find(`[data-page-index=${lng}]`).prev('.js-multi');
|
||||
const mid = Math.round(displayNumber);
|
||||
|
||||
pagContainer.find('.js-page-link').each((index, item) => {
|
||||
if (currentEl >= displayNumber + 1 && index === 0 && prevDots.length === 0) {
|
||||
$(item).parent().after(multi);
|
||||
}
|
||||
if (currentEl >= displayNumber + 1) {
|
||||
if (index >= currentEl - mid && index <= currentEl + mid) {
|
||||
$(item).show();
|
||||
if (lng - currentEl >= mid && index > currentEl && index !== lng - 1) {
|
||||
$(item).hide();
|
||||
} else if (nextDots.length === 0 && index === lng - 1 && lng - currentEl > displayNumber) {
|
||||
$(item).parent().before(multi);
|
||||
}
|
||||
} else if (index !== 0 && index !== lng - 1 && (lng - 1 - index) > displayNumber) {
|
||||
$(item).hide();
|
||||
if (nextDots.length && lng - displayNumber <= currentEl) {
|
||||
nextDots.remove();
|
||||
}
|
||||
} else if (currentEl === lng) {
|
||||
nextDots.remove();
|
||||
if (index <= displayNumber && index !== 0) {
|
||||
$(item).hide();
|
||||
} else {
|
||||
$(item).show();
|
||||
}
|
||||
}
|
||||
} else if (currentEl && index > displayNumber && index !== lng - 1 && currentEl < displayNumber) {
|
||||
$(item).hide();
|
||||
} else if (index === lng - 1 && currentEl === 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 && currentEl > 1) {
|
||||
$(item).parent().before(multi);
|
||||
} else {
|
||||
$(item).show();
|
||||
if (index === 0 && prevDots.length !== 0) {
|
||||
prevDots.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user