是否可以引用 jQuery UI 对话框 z-index 计数器?
Is it possible to reference the jQuery UI dialog z-index counter?
我正在制作一个使用多个 jQuery UI 对话框的 Web 应用程序。为了跟踪所有这些,我实现了 windows 样式 "taskbar",其中任务项与每个对话框相关联。单击这些任务项目将 "minimize" 和 "restore" 各自的对话框。
我希望能够区分后台对话框和前台对话框。前面的应该最小化,后面的应该放在前面,类似于 MS Windows 的行为。
我正在使用 jQuery UI 的 moveToTop()
方法来突出对话框,但据我所知,没有办法知道是否有一个对话框在后台或前台。我确实注意到 jQuery UI 通过递增其 z-index 属性来对对话框进行排序,因此它必须在某处使用索引来跟踪对话框顺序。然而,检查 UI 对话框 API 并没有显示任何直接访问该值的方法。简单地为对话框分配一个高 z-index 将 a) 只工作一次或 b) 破坏互联网。
所以,简而言之,我如何访问 jQuery UI 对话框 z-index...index?
所以,我找到了我自己问题的答案:
我正在使用以下代码来处理 focus/minimize 功能:
var zindexes = [100] ; // Because jQuery UI starts its dialogs at z-index 101
$( ".ui-dialog" ).each(function( ) {
// for each ui-dialog that is currently displayed, push the z-index to the array
if( $( this ).css("display") === "block" )
zindexes.push( $( this ).css("z-index") );
}) ;
// If z-index is less than the greatest index in the array, bring it to the fore
if($(class_str).parent().css("display") === "block" &&
parseInt($(class_str).parent().css("z-index")) < Math.max.apply(null, zindexes))
$(class_str).parent().css("z-index", Math.max.apply(null, zindexes)+1) ;
// If already in the fore then minimize/restore.
else $(class_str).dialog( "moveToTop" ), $(class_str).parent().toggle("blind", 250) ;
与我提出的不完全相同,但仍然有效。
我正在制作一个使用多个 jQuery UI 对话框的 Web 应用程序。为了跟踪所有这些,我实现了 windows 样式 "taskbar",其中任务项与每个对话框相关联。单击这些任务项目将 "minimize" 和 "restore" 各自的对话框。
我希望能够区分后台对话框和前台对话框。前面的应该最小化,后面的应该放在前面,类似于 MS Windows 的行为。
我正在使用 jQuery UI 的 moveToTop()
方法来突出对话框,但据我所知,没有办法知道是否有一个对话框在后台或前台。我确实注意到 jQuery UI 通过递增其 z-index 属性来对对话框进行排序,因此它必须在某处使用索引来跟踪对话框顺序。然而,检查 UI 对话框 API 并没有显示任何直接访问该值的方法。简单地为对话框分配一个高 z-index 将 a) 只工作一次或 b) 破坏互联网。
所以,简而言之,我如何访问 jQuery UI 对话框 z-index...index?
所以,我找到了我自己问题的答案:
我正在使用以下代码来处理 focus/minimize 功能:
var zindexes = [100] ; // Because jQuery UI starts its dialogs at z-index 101
$( ".ui-dialog" ).each(function( ) {
// for each ui-dialog that is currently displayed, push the z-index to the array
if( $( this ).css("display") === "block" )
zindexes.push( $( this ).css("z-index") );
}) ;
// If z-index is less than the greatest index in the array, bring it to the fore
if($(class_str).parent().css("display") === "block" &&
parseInt($(class_str).parent().css("z-index")) < Math.max.apply(null, zindexes))
$(class_str).parent().css("z-index", Math.max.apply(null, zindexes)+1) ;
// If already in the fore then minimize/restore.
else $(class_str).dialog( "moveToTop" ), $(class_str).parent().toggle("blind", 250) ;
与我提出的不完全相同,但仍然有效。