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