Nov 22, 2008, 5:27 PM
Fun with Windows
Want to Hide/Cascade/Tile all open windows?
It took me some searching to find this so I thought I would share. This is mostly Animal's code from his modified desktop.js I just tweaked it a little.
<script type="text/javascript">
var HideAllWin = function() {
Ext.WindowMgr.each(function(w) {
if (w.isVisible()) w.minimize();
});
}
var CascAllWin = function() {
var xTick = Math.max(1, 20);
var yTick = Math.max(1, 20);
var x = xTick;
var y = yTick;
Ext.WindowMgr.each(function(w) {
if (w.isVisible() && !w.maximized) {
w.setPosition(x, y);
x += xTick;
y += yTick;
}
});
}
var TileAllWin = function() {
var availWidth = Ext.lib.Dom.getViewWidth();
var x = 1;
var y = 1;
var nextY = y;
Ext.WindowMgr.each(function(w) {
if (w.isVisible() && !w.maximized) {
w.setHeight(300); //remove if you don't want to resize windows
w.setWidth(300); //remove if you don't want to resize windows
var wi = w.el.getWidth();
//Wrap to next row if this Window will go off the end
if ((x > 1) && (x + wi > availWidth)) {
x = 1;
y = nextY;
}
w.setPosition(x, y);
x += wi + 1;
nextY = Math.max(nextY, y + w.el.getHeight() + 1);
}
});
}
</script>
Hope it helps someone!