37 lines
1.3 KiB
Smarty
37 lines
1.3 KiB
Smarty
{ifmodule TRANSLATIONS}
|
|
{if !$target}
|
|
{$uniqueKey = rand()}
|
|
{$target = "data-translations-figure=\"`$uniqueKey`\""}
|
|
<div {$target nofilter} class="translations-figure"></div>
|
|
{$target = "[`$target`]"}
|
|
{/if}
|
|
<script type="text/javascript">
|
|
$(() => {
|
|
{get_contexts language=1 assign='ctx'}
|
|
const languages = [{foreach $ctx.language->getAll() as $lang => $_}
|
|
{if $lang === $ctx.language->getDefaultId()}{continue}{/if}
|
|
'{$lang}',
|
|
{/foreach}];
|
|
|
|
const figureToggles = new wpj.TranslationsFigure(
|
|
languages,
|
|
'{if $inputPrefix}{$inputPrefix nofilter}[translation_figure]{else}data[translation_figure]{/if}',
|
|
{if $parentFigure}'{$parentFigure}',{/if}
|
|
);
|
|
|
|
{if $figureData}
|
|
figureToggles.setState({$figureData|json_encode nofilter});
|
|
{/if}
|
|
|
|
figureToggles.render($(`{$target nofilter}`)[0]);
|
|
{if !$parentFigureInput}
|
|
{$parentFigureInput = '[name="data[figure]"]'}
|
|
{/if}
|
|
|
|
$(`{$parentFigureInput nofilter}`).on('click', function () {
|
|
figureToggles.toggleParentFigure();
|
|
});
|
|
});
|
|
</script>
|
|
{/ifmodule}
|