2022-01-29 00:00:11 +03:00
|
|
|
import $ from 'jquery';
|
2021-10-16 20:28:04 +03:00
|
|
|
import {initMarkupContent} from '../../markup/content.js';
|
|
|
|
|
2021-10-21 10:37:43 +03:00
|
|
|
const {csrfToken} = window.config;
|
2021-10-16 20:28:04 +03: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 10:37:43 +03:00
|
|
|
_csrf: csrfToken,
|
2021-10-16 20:28:04 +03: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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|