|
|
|
@ -1,28 +1,29 @@ |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () { |
|
|
|
|
if ( |
|
|
|
|
export default function translateHtml() { |
|
|
|
|
if ( |
|
|
|
|
window.user && window.user.locale && |
|
|
|
|
window.config && |
|
|
|
|
window.config['editor.translate_html'] && |
|
|
|
|
'true' === window.config['editor.translate_html'] |
|
|
|
|
) { |
|
|
|
|
var isoCode = window.user.locale; |
|
|
|
|
const translateElement = document.querySelector('.mce-translatehtml'); |
|
|
|
|
if (translateElement) { |
|
|
|
|
document.querySelectorAll('.mce-translatehtml').forEach(function (el) { |
|
|
|
|
el.style.display = 'none'; |
|
|
|
|
}); |
|
|
|
|
const selectedLang = document.querySelectorAll('[lang="' + isoCode + '"]'); |
|
|
|
|
if (selectedLang.length > 0) { |
|
|
|
|
selectedLang.forEach(function (userLang) { |
|
|
|
|
userLang.classList.remove('hidden') |
|
|
|
|
userLang.style.display = 'block'; |
|
|
|
|
) { |
|
|
|
|
var isoCode = window.user.locale; |
|
|
|
|
const translateElement = document.querySelector('.mce-translatehtml'); |
|
|
|
|
if (translateElement) { |
|
|
|
|
document.querySelectorAll('.mce-translatehtml').forEach(function (el) { |
|
|
|
|
el.style.display = 'none'; |
|
|
|
|
}); |
|
|
|
|
const selectedLang = document.querySelectorAll('[lang="' + isoCode + '"]'); |
|
|
|
|
if (selectedLang.length > 0) { |
|
|
|
|
selectedLang.forEach(function (userLang) { |
|
|
|
|
userLang.classList.remove('hidden') |
|
|
|
|
userLang.style.display = 'block'; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
// it checks content from old version
|
|
|
|
|
const langs = document.querySelectorAll('span[lang]'); |
|
|
|
|
const langs = document.querySelectorAll('span[lang]:not(.mce-translatehtml)'); |
|
|
|
|
if (langs.length > 0) { |
|
|
|
|
// it hides all contents with lang
|
|
|
|
|
langs.forEach(function (el) { |
|
|
|
@ -48,5 +49,4 @@ document.addEventListener('DOMContentLoaded', function () { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|