0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-05 05:39:14 +01:00
gitea/web_src/js/features/comp/MarkupContentPreview.js
silverwind 19b017f398
Use explicit jQuery import, remove unused eslint globals (#18435)
- Don't rely on globals (window.$) for jQuery import
- Remove eslint globals no longer in use
2022-01-28 21:00:11 +00:00

22 lines
758 B
JavaScript

import $ from 'jquery';
import {initMarkupContent} from '../../markup/content.js';
const {csrfToken} = 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: csrfToken,
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();
});
});
}