2022-01-28 21:00:11 +00:00
|
|
|
import $ from 'jquery';
|
2021-10-16 17:28:04 +00:00
|
|
|
import {initMarkupContent} from '../../markup/content.js';
|
|
|
|
|
2021-10-21 07:37:43 +00:00
|
|
|
const {csrfToken} = window.config;
|
2021-10-16 17:28:04 +00:00
|
|
|
|
|
|
|
export function initCompMarkupContentPreviewTab($form) {
|
|
|
|
const $tabMenu = $form.find('.tabular.menu');
|
|
|
|
$tabMenu.find('.item').tab();
|
|
|
|
$tabMenu.find(`.item[data-tab="${$tabMenu.data('preview')}"]`).on('click', function () {
|
|
|
|
const $this = $(this);
|
|
|
|
$.post($this.data('url'), {
|
2021-10-21 07:37:43 +00:00
|
|
|
_csrf: csrfToken,
|
2021-10-16 17:28:04 +00:00
|
|
|
mode: 'comment',
|
|
|
|
context: $this.data('context'),
|
|
|
|
text: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val()
|
|
|
|
}, (data) => {
|
|
|
|
const $previewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`);
|
|
|
|
$previewPanel.html(data);
|
|
|
|
initMarkupContent();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|