11// custom_value_dialog_manager.js - Manages custom value input dialogs for ResolutionMaster
22import { createModuleLogger } from "../log_system/log_funcs.js" ;
3+ import { createModalWrapper } from "../utils/dialog_helper.js" ;
34
45const log = createModuleLogger ( 'custom_value_dialog_manager' ) ;
56
@@ -10,6 +11,7 @@ export class CustomValueDialogManager {
1011 this . customInputDialog = null ;
1112 this . customInputOverlay = null ;
1213 this . inputDialogActive = false ;
14+ this . closeWrapper = null ;
1315 }
1416
1517 /**
@@ -83,28 +85,32 @@ export class CustomValueDialogManager {
8385 this . inputDialogActive = true ;
8486 log . debug ( `Creating dialog for ${ valueType } , current: ${ currentValue } ` ) ;
8587
86- // Create overlay
87- const overlay = document . createElement ( 'div' ) ;
88- this . customInputOverlay = overlay ;
89- overlay . style . cssText = `
90- position: fixed; top: 0; left: 0; width: 100%; height: 100%;
91- background: rgba(0,0,0,0.5); z-index: 9999;
92- ` ;
93- overlay . addEventListener ( 'mousedown' , ( ) => this . closeCustomInputDialog ( ) ) ;
94- document . body . appendChild ( overlay ) ;
88+ // Create overlay and dialog container via dialog_helper
89+ const wrapper = createModalWrapper ( {
90+ className : 'litegraph-custom-input-dialog' ,
91+ overlayStyle : `
92+ position: fixed; top: 0; left: 0; width: 100%; height: 100%;
93+ background: rgba(0,0,0,0.5); z-index: 9999;
94+ ` ,
95+ dialogStyle : `
96+ position: fixed;
97+ background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
98+ border: 2px solid #555; border-radius: 8px; padding: 20px;
99+ box-shadow: 0 8px 32px rgba(0,0,0,0.8); z-index: 10000;
100+ font-family: Arial, sans-serif; min-width: 280px;
101+ ` ,
102+ onClose : ( ) => {
103+ this . customInputDialog = null ;
104+ this . customInputOverlay = null ;
105+ this . inputDialogActive = false ;
106+ this . closeWrapper = null ;
107+ }
108+ } ) ;
95109
96- // Create dialog container
97- const dialog = document . createElement ( 'div' ) ;
98- this . customInputDialog = dialog ;
99- dialog . className = 'litegraph-custom-input-dialog' ;
100- dialog . addEventListener ( 'mousedown' , ( e ) => e . stopPropagation ( ) ) ; // Prevent clicks inside from closing
101- dialog . style . cssText = `
102- position: fixed;
103- background: linear-gradient(135deg, #2a2a2a 0%, #1e1e1e 100%);
104- border: 2px solid #555; border-radius: 8px; padding: 20px;
105- box-shadow: 0 8px 32px rgba(0,0,0,0.8); z-index: 10000;
106- font-family: Arial, sans-serif; min-width: 280px;
107- ` ;
110+ this . customInputOverlay = wrapper . overlay ;
111+ this . customInputDialog = wrapper . dialog ;
112+ this . closeWrapper = wrapper . close ;
113+ const dialog = wrapper . dialog ;
108114
109115 // Position dialog
110116 const x = e . clientX ? e . clientX + 20 : ( window . innerWidth - 280 ) / 2 ;
@@ -129,8 +135,6 @@ export class CustomValueDialogManager {
129135 </div>
130136 ` ;
131137
132- document . body . appendChild ( dialog ) ;
133-
134138 // Get elements
135139 const input = dialog . querySelector ( '#customValueInput' ) ;
136140 const validationMsg = dialog . querySelector ( '#validationMessage' ) ;
@@ -222,15 +226,20 @@ export class CustomValueDialogManager {
222226 * Closes and cleans up the custom input dialog
223227 */
224228 closeCustomInputDialog ( ) {
225- if ( this . customInputDialog ) {
226- document . body . removeChild ( this . customInputDialog ) ;
227- this . customInputDialog = null ;
228- }
229- if ( this . customInputOverlay ) {
230- document . body . removeChild ( this . customInputOverlay ) ;
231- this . customInputOverlay = null ;
229+ if ( this . closeWrapper ) {
230+ this . closeWrapper ( ) ;
231+ this . closeWrapper = null ;
232+ } else {
233+ if ( this . customInputDialog ) {
234+ document . body . removeChild ( this . customInputDialog ) ;
235+ this . customInputDialog = null ;
236+ }
237+ if ( this . customInputOverlay ) {
238+ document . body . removeChild ( this . customInputOverlay ) ;
239+ this . customInputOverlay = null ;
240+ }
241+ this . inputDialogActive = false ;
232242 }
233- this . inputDialogActive = false ;
234243 }
235244
236245 /**
0 commit comments