diff options
Diffstat (limited to 'web_src/js/features/comp/MarkupContentPreview.js')
-rw-r--r-- | web_src/js/features/comp/MarkupContentPreview.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/web_src/js/features/comp/MarkupContentPreview.js b/web_src/js/features/comp/MarkupContentPreview.js new file mode 100644 index 0000000000..0b05c4efae --- /dev/null +++ b/web_src/js/features/comp/MarkupContentPreview.js @@ -0,0 +1,21 @@ +import {initMarkupContent} from '../../markup/content.js'; + +const {csrf} = window.config; + +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'), { + _csrf: csrf, + 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(); + }); + }); +} |