Fix A/N and CFG menus on first in the list

14aec430644bee10b5a2de71d663051c7f3c7a24

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +14 -15Showing whitespace changes
public/scripts/authors-note.js+7 -7
@@ -389,7 +389,11 @@ export function setFloatingPrompt() {
389}389}
390390
391function onANMenuItemClick() {391function onANMenuItemClick() {
392 if (selected_group || this_chid) {392 if (!selected_group && this_chid === undefined) {
393 toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 });
394 return;
395 }
396
393 //show AN if it's hidden397 //show AN if it's hidden
394 if ($('#floatingPrompt').css('display') !== 'flex') {398 if ($('#floatingPrompt').css('display') !== 'flex') {
395 $('#floatingPrompt').addClass('resizing');399 $('#floatingPrompt').addClass('resizing');
@@ -416,22 +420,18 @@ function onANMenuItemClick() {
416 $('#floatingPrompt').transition({420 $('#floatingPrompt').transition({
417 opacity: 0.0,421 opacity: 0.0,
418 duration: animation_duration,422 duration: animation_duration,
419 },423 }, async function () {
420 async function () {
421 await delay(50);424 await delay(50);
422 $('#floatingPrompt').removeClass('resizing');425 $('#floatingPrompt').removeClass('resizing');
423 });426 });
424 setTimeout(function () {427 setTimeout(function () {
425 $('#floatingPrompt').hide();428 $('#floatingPrompt').hide();
426 }, animation_duration);429 }, animation_duration);
427
428 }430 }
431
429 //duplicate options menu close handler from script.js432 //duplicate options menu close handler from script.js
430 //because this listener takes priority433 //because this listener takes priority
431 $('#options').stop().fadeOut(animation_duration);434 $('#options').stop().fadeOut(animation_duration);
432 } else {
433 toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 });
434 }
435}435}
436436
437async function onChatChanged() {437async function onChatChanged() {
public/scripts/cfg-scale.js+7 -8
@@ -69,8 +69,7 @@ function setCharCfg(tempValue, setting) {
69 if (!existingCharaCfg.useChara &&69 if (!existingCharaCfg.useChara &&
70 (tempAssign.guidance_scale ?? 1.00) === 1.00 &&70 (tempAssign.guidance_scale ?? 1.00) === 1.00 &&
71 (tempAssign.negative_prompt?.length ?? 0) === 0 &&71 (tempAssign.negative_prompt?.length ?? 0) === 0 &&
72 (tempAssign.positive_prompt?.length ?? 0) === 0)72 (tempAssign.positive_prompt?.length ?? 0) === 0) {
73 {
74 extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1);73 extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1);
75 }74 }
76 } else if (avatarName && tempValue.length > 0) {75 } else if (avatarName && tempValue.length > 0) {
@@ -113,7 +112,11 @@ function setChatCfg(tempValue, setting) {
113112
114// TODO: Only change CFG when character is selected113// TODO: Only change CFG when character is selected
115function onCfgMenuItemClick() {114function onCfgMenuItemClick() {
116 if (selected_group || this_chid) {115 if (!selected_group && this_chid === undefined) {
116 toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 });
117 return;
118 }
119
117 //show CFG config if it's hidden120 //show CFG config if it's hidden
118 if ($('#cfgConfig').css('display') !== 'flex') {121 if ($('#cfgConfig').css('display') !== 'flex') {
119 $('#cfgConfig').addClass('resizing');122 $('#cfgConfig').addClass('resizing');
@@ -140,8 +143,7 @@ function onCfgMenuItemClick() {
140 $('#cfgConfig').transition({143 $('#cfgConfig').transition({
141 opacity: 0.0,144 opacity: 0.0,
142 duration: animation_duration,145 duration: animation_duration,
143 },146 }, async function () {
144 async function () {
145 await delay(50);147 await delay(50);
146 $('#cfgConfig').removeClass('resizing');148 $('#cfgConfig').removeClass('resizing');
147 });149 });
@@ -153,9 +155,6 @@ function onCfgMenuItemClick() {
153 //duplicate options menu close handler from script.js155 //duplicate options menu close handler from script.js
154 //because this listener takes priority156 //because this listener takes priority
155 $('#options').stop().fadeOut(animation_duration);157 $('#options').stop().fadeOut(animation_duration);
156 } else {
157 toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 });
158 }
159}158}
160159
161async function onChatChanged() {160async function onChatChanged() {