-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello.
I have a screen divided in two . I create an overlapping window in one half which can be maximized. When I click maximize it stretches over whole screen. Is there any way I can force overlapping window to only take up its parent size at most?
I guess another question related to this issue would be , any way make a part of layout unable to be overlapped?
regards.
You can listen to sizing/moving events and fix the size and position as needed, e.g.,
<zk>
<script><![CDATA[
function fixSize (uuid) {
var wgt = zk.Widget.$('#'+uuid),
n = wgt.$n(),
$n = jq(n),
parent = wgt.parent,
$pcave = jq(parent.$n('cave')),
w, h,
fireOnSize;
w = $pcave.width();
if ($n.width() > w) {
fireOnSize = true;
n.style.width = w + 'px';
}
h = $pcave.height();
if ($n.height() > h) {
fireOnSize = true;
n.style.height = h + 'px';
}
if (fireOnSize) {
_fireOnSize(wgt, $n);
}
}
function fixPosition (uuid) {
fixSize(uuid);
var wgt = zk.Widget.$('#'+uuid),
n = wgt.$n(),
$n = jq(n),
parent = wgt.parent,
$pcave = jq(parent.$n('cave')),
noffset = $n.offset(),
pcoffset = $pcave.offset(),
nt, nb, nl, nr,
t, b, l, r,
diff,
fireOnSize;
t = pcoffset.top;
nt = noffset.top;
if (nt < t) {
fireOnSize = true;
n.style.top = t + 'px';
} else {
b = t + $pcave.height();
nb = nt + $n.height();
if (nb > b) {
fireOnSize = true;
diff = nb - b;
n.style.top = nt - diff + 'px';
}
}
l = pcoffset.left;
nl = noffset.left;
if (nl < l) {
fireOnSize = true;
n.style.left = l + 'px';
} else {
r = l + $pcave.width();
nr = nl + $n.width();
if (nr > r) {
fireOnSize = true;
diff = nr - r;
n.style.left = nl - diff + 'px';
}
}
if (fireOnSize) {
_fireOnSize(wgt, $n);
}
}
function _fireOnSize (wgt, $n) {
var data = {
top: $n.offset().top + 'px', left: $n.offset().left + 'px',
height: $n.height() + 'px', width: $n.width() + 'px'
};
wgt.fire('onSize', data, {ignorable: true});
}
]]></script>
<vlayout hflex="1" vflex="1">
<window title="first win" border="normal" vflex="1">
<window mode="overlapped"
title="overlapped win" border="normal"
sizable="true" maximizable="true">
<attribute name="onSize"><![CDATA[
Clients.evalJavaScript("fixPosition('"+self.getUuid()+"')");
]]></attribute>
<attribute name="onMaximize"><![CDATA[
Clients.evalJavaScript("fixPosition('"+self.getUuid()+"')");
]]></attribute>
<attribute name="onMove"><![CDATA[
Clients.evalJavaScript("fixPosition('"+self.getUuid()+"')");
]]></attribute>
</window>
</window>
<window title="second win" border="normal" vflex="1" />
</vlayout>
</zk>
Hi, SergeTk, Can you please post this solution here? I have simiar issue
Hi, SergeTk, Can you please post this solution here? I have simiar issue
Asked: 2013-03-29 08:52:20 +0800
Seen: 41 times
Last updated: Apr 09 '13
composite component help [closed]
EL in a forEach @command not working?
Different template for each grid row
Cardlayout animation is broken
Grid RowRender slow using 6.5.1 and sizable=true
setVisible(false), component will load or not
Decimalbox and doublebox value rounded on iPad
history management with page status