2022-01-28 16:00:11 -05:00
|
|
|
import $ from 'jquery';
|
2023-02-18 23:06:14 -05:00
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2022-01-28 16:00:11 -05:00
|
|
|
|
2022-01-06 20:18:52 -05:00
|
|
|
export function initUnicodeEscapeButton() {
|
2023-05-21 16:47:41 -04:00
|
|
|
$(document).on('click', '.escape-button', (e) => {
|
2022-01-06 20:18:52 -05:00
|
|
|
e.preventDefault();
|
|
|
|
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').addClass('unicode-escaped');
|
2023-02-18 23:06:14 -05:00
|
|
|
hideElem($(e.target));
|
2023-05-21 16:47:41 -04:00
|
|
|
showElem($(e.target).siblings('.unescape-button'));
|
2022-01-06 20:18:52 -05:00
|
|
|
});
|
2023-05-21 16:47:41 -04:00
|
|
|
$(document).on('click', '.unescape-button', (e) => {
|
2022-01-06 20:18:52 -05:00
|
|
|
e.preventDefault();
|
|
|
|
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').removeClass('unicode-escaped');
|
2023-02-18 23:06:14 -05:00
|
|
|
hideElem($(e.target));
|
2023-05-21 16:47:41 -04:00
|
|
|
showElem($(e.target).siblings('.escape-button'));
|
2022-01-06 20:18:52 -05:00
|
|
|
});
|
2023-05-21 16:47:41 -04:00
|
|
|
$(document).on('click', '.toggle-escape-button', (e) => {
|
2022-01-06 20:18:52 -05:00
|
|
|
e.preventDefault();
|
|
|
|
const fileContent = $(e.target).parents('.file-content, .non-diff-file-content');
|
|
|
|
const fileView = fileContent.find('.file-code, .file-view');
|
|
|
|
if (fileView.hasClass('unicode-escaped')) {
|
|
|
|
fileView.removeClass('unicode-escaped');
|
2023-05-21 16:47:41 -04:00
|
|
|
hideElem(fileContent.find('.unescape-button'));
|
|
|
|
showElem(fileContent.find('.escape-button'));
|
2022-01-06 20:18:52 -05:00
|
|
|
} else {
|
|
|
|
fileView.addClass('unicode-escaped');
|
2023-05-21 16:47:41 -04:00
|
|
|
showElem(fileContent.find('.unescape-button'));
|
|
|
|
hideElem(fileContent.find('.escape-button'));
|
2022-01-06 20:18:52 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|