jQuery工具覆盖,切换覆盖时如何保留遮罩 [英] jquery tools overlay, how to keep mask when switching overlays
问题描述
我有2个叠加层的简单问题.一个叠加层是从另一个叠加层(并由另一个叠加层)触发的.由于任何时候只有一个覆盖层可以处于活动状态,因此正确地触发了触发2的覆盖层编号1会关闭.但是,它会带上遮罩,因此会出现没有遮罩的覆盖层2.如何在2个叠加层之间切换而蒙版不消失?
I have a simple problem with 2 overlays. One overlay is triggered from (and by) the other overlay. As only one overlay can be active at any one time, correctly so, overlay number 1 that triggered 2 closes. However, it takes the mask with it and hence overlay 2 appears without the mask. How can I switch between 2 overlays without the mask disappearing?
代码,覆盖1
$("button[rel*=busy]").overlay({
api: true ,
mask: {
maskId: 'defaultMask' ,
color: null
},
effect: 'apple',
onLoad: function() {
$.post( 'ajax_file_here.php' ,
{ var: something } ,
function( data ){
if( data.status == 'confirm' ) {
confirmOverlay();
} else {
errorOverlay();
}
} ,
'json' );
} ,
closeOnClick: false ,
closeOnEsc: false ,
close: '.noClose'
});
并覆盖2
var errOverlayObject = $('#error_overlay').overlay({
api: true,
mask: {
maskId: 'defaultMask' ,
color: null
},
effect: "apple"
});
function errorOverlay() {
errOverlayObject.load();
}
如您所见,第二个叠加层也有一个确认版本,但其作用与错误一个相同.
As you can see there is also a confirm version of the second overlay, but that works identical to the error one.
推荐答案
希望您不要介意,但我创建了自己的简化示例.希望您能够适应您的情况.
I hope you do not mind but I created my own simplified example. Hopefully you will be able to adapt this to your situation.
对话框之间有一些闪烁(由于动画效果),但是遮罩保持在原位.我想您可以通过调整动画效果设置来消除闪烁-我怀疑您可以在叠加层的 onBeforeLoad 方法中做一些事情,但我不确定是什么.
There is a little bit of flicker between the dialogue boxes (due to the animation effect) but the mask stays in place. I imagine you could remove the flickering by adjusting the animation effect settings - I suspect you could do something in the overlay's onBeforeLoad method but I'm not exactly sure what.
<!DOCTYPE html>
<html>
<head>
<title>Chained Modals</title>
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
<style>
.modal {
background-color:#fff;
display:none;
width:350px;
padding:15px;
text-align:left;
border:2px solid #333;
opacity:0.8;
-moz-border-radius:6px;
-webkit-border-radius:6px;
-moz-box-shadow: 0 0 50px #ccc;
-webkit-box-shadow: 0 0 50px #ccc;
}
</style>
</head>
<body>
<p>
<button class="modalInput" rel="#box1">Stage 1</button>
</p>
<div class="modal" id="box1">
<h2>Stage 1 dialogue</h2>
<p>
You can only interact with elements that are inside this dialog.
To close it click a button or use the ESC key.
</p>
<button class="modalInput" rel="#box2">Stage 2</button>
</div>
<div class="modal" id="box2">
<h2>Stage 2 dialogue</h2>
<p>
You can only interact with elements that are inside this dialog.
To close it click a button or use the ESC key.
</p>
<button class="modalInput" rel="#box3">Stage 3</button>
</div>
<div class="modal" id="box3">
<h2>Stage 3 dialogue</h2>
<p>
You can only interact with elements that are inside this dialog.
To close it click a button or use the ESC key.
</p>
<button class="close">End</button>
</div>
<script>
$(window).load(function() {
var msk;
var triggers = $(".modalInput").overlay({
mask: {
color: '#ebecff',
loadSpeed: 200,
opacity: 0.9,
onClose: function() {
var id = this.getExposed().attr('id');
if(id == 'box1'|| id == 'box2'){
var nextId;
if(id == 'box1'){
nextId = '#box2';
}
if(id == 'box2'){
nextId = '#box3';
}
msk = this.getMask();
msk.css('display','block');
$(nextId).css('z-index', '9999');
}
}
},
closeOnClick: false,
onBeforeLoad: function(){
var id = this.getOverlay().attr('id');
if(id == 'box2'|| id == 'box3'){
// need to put something here to avoid flicker
//
// this.getConf().mask.startOpacity = 0.8;
}
}
});
});
</script>
</body>
</html>
我希望这会有所帮助.
这篇关于jQuery工具覆盖,切换覆盖时如何保留遮罩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!