88namespace BootstrapBlazor . Components ;
99
1010/// <summary>
11- /// Modal 组件
11+ /// Modal component
1212/// </summary>
1313public partial class Modal
1414{
1515 /// <summary>
16- /// 获得 样式字符串
16+ /// Gets the style string
1717 /// </summary>
1818 private string ? ClassString => CssBuilder . Default ( "modal" )
1919 . AddClass ( "fade" , IsFade )
20+ . AddClassFromAttributes ( AdditionalAttributes )
2021 . Build ( ) ;
2122
2223 /// <summary>
23- /// 获得 ModalDialog 集合
24+ /// Gets the collection of ModalDialog
2425 /// </summary>
2526 protected List < ModalDialog > Dialogs { get ; } = new ( 8 ) ;
2627
2728 private readonly ConcurrentDictionary < IComponent , Func < Task > > _shownCallbackCache = [ ] ;
2829
2930 /// <summary>
30- /// 获得/设置 是否后台关闭弹窗 默认 false
31+ /// Gets or sets whether to close the popup in the background, default is false
3132 /// </summary>
3233 [ Parameter ]
3334 public bool IsBackdrop { get ; set ; }
3435
3536 /// <summary>
36- /// 获得/设置 是否开启键盘支持 默认 true 响应键盘 ESC 按键
37+ /// Gets or sets whether to enable keyboard support, default is true to respond to the ESC key
3738 /// </summary>
3839 [ Parameter ]
3940 public bool IsKeyboard { get ; set ; } = true ;
4041
4142 /// <summary>
42- /// 获得/设置 是否开启淡入淡出动画 默认为 true 开启动画
43+ /// Gets or sets whether to enable fade in and out animation, default is true to enable animation
4344 /// </summary>
4445 [ Parameter ]
4546 public bool IsFade { get ; set ; } = true ;
4647
4748 /// <summary>
48- /// 获得/设置 子组件
49+ /// Gets or sets the child component
4950 /// </summary>
5051 [ Parameter ]
5152 public RenderFragment ? ChildContent { get ; set ; }
5253
5354 /// <summary>
54- /// 获得/设置 组件已经渲染完毕回调方法
55+ /// Gets or sets the callback method when the component has finished rendering
5556 /// </summary>
5657 [ Parameter ]
5758 public Func < Modal , Task > ? FirstAfterRenderCallbackAsync { get ; set ; }
5859
5960 /// <summary>
60- /// 获得/设置 弹窗已显示时回调此方法
61+ /// Gets or sets the callback method when the popup is shown
6162 /// </summary>
6263 [ Parameter ]
6364 public Func < Task > ? OnShownAsync { get ; set ; }
6465
6566 /// <summary>
66- /// 获得/设置 关闭弹窗回调委托
67+ /// Gets or sets the callback delegate when the popup is closed
6768 /// </summary>
6869 [ Parameter ]
6970 public Func < Task > ? OnCloseAsync { get ; set ; }
7071
7172 /// <summary>
72- /// 获得 后台关闭弹窗设置
73+ /// Gets the background close popup setting
7374 /// </summary>
7475 private string ? Backdrop => IsBackdrop ? null : "static" ;
7576
@@ -97,7 +98,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
9798 protected override Task InvokeInitAsync ( ) => InvokeVoidAsync ( "init" , Id , Interop , nameof ( ShownCallback ) , nameof ( CloseCallback ) ) ;
9899
99100 /// <summary>
100- /// 添加对话框方法
101+ /// Method to add a dialog
101102 /// </summary>
102103 /// <param name="dialog"></param>
103104 internal void AddDialog ( ModalDialog dialog )
@@ -107,12 +108,12 @@ internal void AddDialog(ModalDialog dialog)
107108 }
108109
109110 /// <summary>
110- /// 移除对话框方法
111+ /// Method to remove a dialog
111112 /// </summary>
112113 /// <param name="dialog"></param>
113114 internal void RemoveDialog ( ModalDialog dialog )
114115 {
115- // 移除当前弹窗
116+ // Remove the current popup
116117 Dialogs . Remove ( dialog ) ;
117118
118119 if ( Dialogs . Count > 0 )
@@ -123,15 +124,15 @@ internal void RemoveDialog(ModalDialog dialog)
123124
124125 private void ResetShownDialog ( ModalDialog dialog )
125126 {
126- // 保证新添加的 Dialog 为当前弹窗
127+ // Ensure the newly added Dialog is the current popup
127128 Dialogs . ForEach ( d =>
128129 {
129130 d . IsShown = d == dialog ;
130131 } ) ;
131132 }
132133
133134 /// <summary>
134- /// 弹窗已经弹出回调方法 JSInvoke 调用
135+ /// Callback method when the popup has been shown, called by JSInvoke
135136 /// </summary>
136137 /// <returns></returns>
137138 [ JSInvokable ]
@@ -149,20 +150,20 @@ public async Task ShownCallback()
149150 }
150151
151152 /// <summary>
152- /// 弹窗已经关闭回调方法 JSInvoke 调用
153+ /// Callback method when the popup has been closed, called by JSInvoke
153154 /// </summary>
154155 /// <returns></returns>
155156 [ JSInvokable ]
156157 public async Task CloseCallback ( )
157158 {
158- // 移除当前弹窗
159+ // Remove the current popup
159160 var dialog = Dialogs . FirstOrDefault ( d => d . IsShown ) ;
160161 if ( dialog != null )
161162 {
162163 Dialogs . Remove ( dialog ) ;
163164 }
164165
165- // 多级弹窗支持
166+ // Support for multi-level popups
166167 if ( Dialogs . Count > 0 )
167168 {
168169 ResetShownDialog ( Dialogs . Last ( ) ) ;
@@ -175,7 +176,7 @@ public async Task CloseCallback()
175176 }
176177
177178 /// <summary>
178- /// 弹窗状态切换方法
179+ /// Method to toggle the popup state
179180 /// </summary>
180181 public async Task Toggle ( )
181182 {
@@ -184,7 +185,7 @@ public async Task Toggle()
184185 }
185186
186187 /// <summary>
187- /// 显示弹窗方法
188+ /// Method to show the popup
188189 /// </summary>
189190 /// <returns></returns>
190191 public async Task Show ( )
@@ -194,13 +195,13 @@ public async Task Show()
194195 }
195196
196197 /// <summary>
197- /// 关闭当前弹窗方法
198+ /// Method to close the current popup
198199 /// </summary>
199200 /// <returns></returns>
200201 public Task Close ( ) => InvokeVoidAsync ( "execute" , Id , "hide" ) ;
201202
202203 /// <summary>
203- /// 设置 Header 文字方法
204+ /// Method to set the header text
204205 /// </summary>
205206 /// <param name="text"></param>
206207 public void SetHeaderText ( string text )
@@ -210,19 +211,19 @@ public void SetHeaderText(string text)
210211 }
211212
212213 /// <summary>
213- /// 注册弹窗显示后回调方法,供代码调用等效 OnShownAsync 参数赋值
214+ /// Registers a callback method to be called after the popup is shown, equivalent to setting the OnShownAsync parameter
214215 /// </summary>
215- /// <param name="component">组件 </param>
216- /// <param name="value">回调方法 </param>
216+ /// <param name="component">Component </param>
217+ /// <param name="value">Callback method </param>
217218 public void RegisterShownCallback ( IComponent component , Func < Task > value )
218219 {
219220 _shownCallbackCache . AddOrUpdate ( component , _ => value , ( _ , _ ) => value ) ;
220221 }
221222
222223 /// <summary>
223- /// 取消注册窗口显示后回调方法
224+ /// Unregisters the callback method to be called after the popup is shown
224225 /// </summary>
225- /// <param name="component">组件 </param>
226+ /// <param name="component">Component </param>
226227 public void UnRegisterShownCallback ( IComponent component )
227228 {
228229 _shownCallbackCache . TryRemove ( component , out _ ) ;
0 commit comments