From 0e0bd0d3d941ce1b273f5d7bc0aa020fc9f71e81 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 25 Jun 2024 02:25:38 +0300 Subject: [PATCH] Update char avatar crop. Remove old cropper --- public/script.js | 46 +++++++++------------------------------------- public/style.css | 10 ++-------- 2 files changed, 11 insertions(+), 45 deletions(-) diff --git a/public/script.js b/public/script.js index e276d0af2..03be886e3 100644 --- a/public/script.js +++ b/public/script.js @@ -228,7 +228,7 @@ import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, de import { initPresetManager } from './scripts/preset-manager.js'; import { evaluateMacros } from './scripts/macros.js'; import { currentUser, setUserControls } from './scripts/user.js'; -import { POPUP_TYPE, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js'; +import { POPUP_TYPE, Popup, callGenericPopup, fixToastrForDialogs } from './scripts/popup.js'; import { renderTemplate, renderTemplateAsync } from './scripts/templates.js'; import { ScraperManager } from './scripts/scrapers.js'; import { SlashCommandParser } from './scripts/slash-commands/SlashCommandParser.js'; @@ -525,7 +525,7 @@ let dialogueResolve = null; let dialogueCloseStop = false; export let chat_metadata = {}; export let streamingProcessor = null; -export let crop_data = undefined; +let crop_data = undefined; let is_delete_mode = false; let fav_ch_checked = false; let scrollLock = false; @@ -5754,17 +5754,20 @@ async function read_avatar_load(input) { create_save.avatar = input.files; } + crop_data = undefined; const file = input.files[0]; const fileData = await getBase64Async(file); if (!power_user.never_resize_avatars) { - $('#dialogue_popup').addClass('large_dialogue_popup wide_dialogue_popup'); - const croppedImage = await callPopup(getCropPopup(fileData), 'avatarToCrop'); + const dlg = new Popup('Set the crop position of the avatar image', POPUP_TYPE.CROP, '', { cropImage: fileData }); + const croppedImage = await dlg.show(); + if (!croppedImage) { return; } - $('#avatar_load_preview').attr('src', croppedImage); + crop_data = dlg.cropData; + $('#avatar_load_preview').attr('src', String(croppedImage)); } else { $('#avatar_load_preview').attr('src', fileData); } @@ -5807,13 +5810,6 @@ async function read_avatar_load(input) { } } -export function getCropPopup(src) { - return `