PDA

View Full Version : [CLOSED] window resize and center on Ext.EventManager.onWindowResize



jstifel
May 02, 2016, 7:50 PM
I would to be able to resize an center a window based on explorer page size every time the uses does a resize of the navigator page.

Is it posible?

I tried the following but it does not seems to be working when page size becomes too small.




<%@ Page Language="VB" %>

<!DOCTYPE html>

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<extnet:ResourceManager ID="ResourceManager1" runat="server" />
<extnet:Viewport runat="server">
<Items>
<extnet:Panel runat="server">
<Buttons>
<extnet:Button runat="server" Text="Zoom">
<Listeners>
<Click Handler="#{ZoomWindow}.show();" />
</Listeners>
</extnet:Button>

</Buttons>
</extnet:Panel>
</Items>
</extnet:Viewport>
<extnet:Window runat="server" ID="ZoomWindow" Title="Buscar Informacion" Hidden="true" Width="600" Height="450" Layout="BorderLayout" />
<script type="text/javascript">
function resize() {
//return;
var width = Ext.getBody().getViewSize().width - 20;
var height = Ext.getBody().getViewSize().height - 20;
var w1;

w1 = eval("<%= ZoomWindow.ClientID%>");
w1.setWidth(width - 20);
w1.center();
}

Ext.EventManager.onWindowResize(function () {
resize();
});

Ext.onReady(function () {
//alert("ready");
resize();
});

</script>

</body>

</html>

fabricio.murta
May 02, 2016, 10:07 PM
Hello @jstifel!

You probably want to add to your resize() function a condition to set the height of the window if the overall height gets below a given threshold. Something like:



function resize() {
var width = Ext.getBody().getViewSize().width - 20;
var height = Ext.getBody().getViewSize().height - 20;
var w1;

w1 = eval("<%= ZoomWindow.ClientID%>");
w1.setWidth(width - 20);

// Check if the height fits the window!
if (height < 500) {
w1.setHeight(height - 20);
} else if (height > 500 && w1.getHeight() != 450) {
// If the window height is 500 pixels or more, fix the window to 450 pixels height.
w1.setHeight(450);
}

w1.center();
}


Or, are your problem not really the height of the window? I didn't notice any problem other than the window not fitting the screen if I let it be too thin height-wise.

Hope this helps!