mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: hook events on document
This commit is contained in:
1 parent
2b9c71c009
commit
91d85c69a0
4 files changed
+22
-24
No files matched your search
@@ -251,7 +251,7 @@ small, figcaption
|
|||||||
|
|
||||||
.typo a, .typo .link, .typo-a
|
.typo a, .typo .link, .typo-a
|
||||||
&, &:visited, &:active, &:hover
|
&, &:visited, &:active, &:hover
|
||||||
:not(.user-profile-name)
|
&:not(.user-profile-name)
|
||||||
color: $primary-color
|
color: $primary-color
|
||||||
|
|
||||||
.typo p, .typo dl, .typo form, .typo hr, .typo table
|
.typo p, .typo dl, .typo form, .typo hr, .typo table
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.8.34",
|
"version": "4.8.35",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -225,11 +225,9 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
const language = {
|
const language = {
|
||||||
yaml: 'yaml',
|
yaml: 'yaml',
|
||||||
yml: 'yaml',
|
yml: 'yaml',
|
||||||
txt: 'plain',
|
cc: 'cpp',
|
||||||
in: 'plain',
|
json: 'json',
|
||||||
out: 'plain',
|
}[filename.split('.').pop()] || 'plain';
|
||||||
ans: 'plain',
|
|
||||||
}[filename.split('.').pop()];
|
|
||||||
const editor = new Editor($('[name="fileContent"]'), {
|
const editor = new Editor($('[name="fileContent"]'), {
|
||||||
value,
|
value,
|
||||||
autoResize: false,
|
autoResize: false,
|
||||||
@@ -248,6 +246,7 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
* @param {JQuery.ClickEvent<HTMLElement, undefined, HTMLElement, HTMLElement>} ev
|
* @param {JQuery.ClickEvent<HTMLElement, undefined, HTMLElement, HTMLElement>} ev
|
||||||
*/
|
*/
|
||||||
async function handleEdit(type, ev) {
|
async function handleEdit(type, ev) {
|
||||||
|
if (ev?.metaKey || ev?.ctrlKey || ev?.shiftKey) return;
|
||||||
if (ev) ev.preventDefault();
|
if (ev) ev.preventDefault();
|
||||||
const filename = ev
|
const filename = ev
|
||||||
? ev.currentTarget.closest('[data-filename]').getAttribute('data-filename')
|
? ev.currentTarget.closest('[data-filename]').getAttribute('data-filename')
|
||||||
@@ -266,7 +265,6 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
content = await request.get(res.url, undefined, { dataType: 'text' });
|
content = await request.get(res.url, undefined, { dataType: 'text' });
|
||||||
} else Notification.info(i18n('Loading editor...'));
|
} else Notification.info(i18n('Loading editor...'));
|
||||||
const val = await startEdit(filename, content);
|
const val = await startEdit(filename, content);
|
||||||
console.log(val);
|
|
||||||
if (typeof val !== 'string') return;
|
if (typeof val !== 'string') return;
|
||||||
Notification.info(i18n('Saving file...'));
|
Notification.info(i18n('Saving file...'));
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
@@ -280,21 +278,21 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($('[name="upload_testdata"]').length) {
|
if ($('[name="upload_testdata"]').length) {
|
||||||
$('.problem-files-testdata .col--name').on('click', (ev) => handleEdit('testdata', ev));
|
$(document).on('click', '.problem-files-testdata .col--name', (ev) => handleEdit('testdata', ev));
|
||||||
$('.problem-files-additional_file .col--name').on('click', (ev) => handleEdit('additional_file', ev));
|
$(document).on('click', '.problem-files-additional_file .col--name', (ev) => handleEdit('additional_file', ev));
|
||||||
$('[name="upload_testdata"]').on('click', () => handleClickUpload('testdata'));
|
$(document).on('click', '[name="upload_testdata"]', () => handleClickUpload('testdata'));
|
||||||
$('[name="upload_file"]').on('click', () => handleClickUpload('additional_file'));
|
$(document).on('click', '[name="upload_file"]', () => handleClickUpload('additional_file'));
|
||||||
$('[name="create_testdata"]').on('click', () => handleEdit('testdata'));
|
$(document).on('click', '[name="create_testdata"]', () => handleEdit('testdata'));
|
||||||
$('[name="create_file"]').on('click', () => handleEdit('additional_file'));
|
$(document).on('click', '[name="create_file"]', () => handleEdit('additional_file'));
|
||||||
$('[name="remove_selected_testdata"]').on('click', () => handleClickRemoveSelected('testdata'));
|
$(document).on('click', '[name="remove_selected_testdata"]', () => handleClickRemoveSelected('testdata'));
|
||||||
$('[name="remove_selected_file"]').on('click', () => handleClickRemoveSelected('additional_file'));
|
$(document).on('click', '[name="remove_selected_file"]', () => handleClickRemoveSelected('additional_file'));
|
||||||
}
|
}
|
||||||
$('.problem-files-testdata').on('dragover', (ev) => handleDragOver('testdata', ev));
|
$(document).on('dragover', '.problem-files-testdata', (ev) => handleDragOver('testdata', ev));
|
||||||
$('.problem-files-additional_file').on('dragover', (ev) => handleDragOver('additional_file', ev));
|
$(document).on('dragover', '.problem-files-additional_file', (ev) => handleDragOver('additional_file', ev));
|
||||||
$('.problem-files-testdata').on('drop', (ev) => handleDrop('testdata', ev));
|
$(document).on('drop', '.problem-files-testdata', (ev) => handleDrop('testdata', ev));
|
||||||
$('.problem-files-additional_file').on('drop', (ev) => handleDrop('additional_file', ev));
|
$(document).on('drop', '.problem-files-additional_file', (ev) => handleDrop('additional_file', ev));
|
||||||
$('[name="download_selected_testdata"]').on('click', () => handleClickDownloadSelected('testdata'));
|
$(document).on('click', '[name="download_selected_testdata"]', () => handleClickDownloadSelected('testdata'));
|
||||||
$('[name="download_selected_file"]').on('click', () => handleClickDownloadSelected('additional_file'));
|
$(document).on('click', '[name="download_selected_file"]', () => handleClickDownloadSelected('additional_file'));
|
||||||
});
|
});
|
||||||
|
|
||||||
export default page;
|
export default page;
|
||||||
@@ -170,7 +170,7 @@ function parseCategorySelection() {
|
|||||||
|
|
||||||
function ensureAndGetSelectedPids() {
|
function ensureAndGetSelectedPids() {
|
||||||
const pids = _.map(
|
const pids = _.map(
|
||||||
$(`tbody [data-checkbox-group="problem"]:checked`),
|
$('tbody [data-checkbox-group="problem"]:checked'),
|
||||||
(ch) => $(ch).closest('tr').attr('data-pid'),
|
(ch) => $(ch).closest('tr').attr('data-pid'),
|
||||||
);
|
);
|
||||||
if (pids.length === 0) {
|
if (pids.length === 0) {
|
||||||
@@ -204,7 +204,7 @@ async function handleOperation(operation) {
|
|||||||
|
|
||||||
const page = new NamedPage(['problem_main', 'problem_category'], () => {
|
const page = new NamedPage(['problem_main', 'problem_category'], () => {
|
||||||
const doc = document.documentElement;
|
const doc = document.documentElement;
|
||||||
doc.className = doc.className + ' display-mode';
|
doc.className += ' display-mode';
|
||||||
buildCategoryFilter();
|
buildCategoryFilter();
|
||||||
parseCategorySelection();
|
parseCategorySelection();
|
||||||
$('[name="leave-edit-mode"]').on('click', () => {
|
$('[name="leave-edit-mode"]').on('click', () => {
|
||||||
|
|||||||
Reference in new issue
Block a user