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