admin管理员组文章数量:1130349
ExtJS provides a number of configs as to whether a Window is configured as maximized, minimizable, etc. It also provides the functions to maximize and minimize a window.
Can't find however what the correct way to fetch an existing window state is. What I need is functions similar to the below:
var myWin = Ext.create('Ext.window.Window', { ... });
...
myWin.isMinimized(); // is current window minimized?
myWin.isMaximized(); // is current window maximized?
Can the current window's state be retrieved from the window instance?
ExtJS provides a number of configs as to whether a Window is configured as maximized, minimizable, etc. It also provides the functions to maximize and minimize a window.
Can't find however what the correct way to fetch an existing window state is. What I need is functions similar to the below:
var myWin = Ext.create('Ext.window.Window', { ... });
...
myWin.isMinimized(); // is current window minimized?
myWin.isMaximized(); // is current window maximized?
Can the current window's state be retrieved from the window instance?
Share Improve this question asked Mar 4, 2013 at 10:30 Joseph Victor ZammitJoseph Victor Zammit 15.3k13 gold badges81 silver badges104 bronze badges3 Answers
Reset to default 3For maximize() there is a boolean property maximized which you can pick up from an object:
if (myWin.maximized) { ... }
However for minimize() ExtJS doesn't provide any functionality and expects individual implementation. Hence, there is no any minimized property supported from the box.
@VisioN's answer is already plete but I want to show you a snippet using toggleCollapse() to hide the window:
Ext.create('Ext.Window',{
height: 100,
width: 100,
minimizable: true,
listeners: {
minimize: function(){
var win = this;
win.toggleCollapse();
if (!win.getCollapsed()) {
win.center();
} else {
win.alignTo(document.body, 'bl-bl');
}
}
}
}).show();
One solution for anyone looking, instead of using minimizable config, use tools. Here is plete example..
var isMinimized = false; //if you want to check for minimized elsewhere..
var winWidth; //to restore to actual width.
Ext.create('Ext.window.Window', {
title: 'Hello',
closable : false,
width : 300, height : 400,
tools: [
{
type: 'restore',
hidden : true,
handler: function( evt,toolEl,owner,tool ) {
var window = owner.up( 'window' );
window.expand('',false);
window.setWidth(winWidth);
window.center();
isMinimized = false;
this.hide();
this.nextSibling().show();
}
},{
type: 'minimize',
handler: function( evt,toolEl,owner,tool ){
var window = owner.up( 'window' );
window.collapse();
winWidth = window.getWidth();
window.setWidth( 150 );
window.alignTo( Ext.getBody(), 'bl-bl');
this.hide();
this.previousSibling().show();
isMinimized = true;
}
}
]
}).show();
ExtJS provides a number of configs as to whether a Window is configured as maximized, minimizable, etc. It also provides the functions to maximize and minimize a window.
Can't find however what the correct way to fetch an existing window state is. What I need is functions similar to the below:
var myWin = Ext.create('Ext.window.Window', { ... });
...
myWin.isMinimized(); // is current window minimized?
myWin.isMaximized(); // is current window maximized?
Can the current window's state be retrieved from the window instance?
ExtJS provides a number of configs as to whether a Window is configured as maximized, minimizable, etc. It also provides the functions to maximize and minimize a window.
Can't find however what the correct way to fetch an existing window state is. What I need is functions similar to the below:
var myWin = Ext.create('Ext.window.Window', { ... });
...
myWin.isMinimized(); // is current window minimized?
myWin.isMaximized(); // is current window maximized?
Can the current window's state be retrieved from the window instance?
Share Improve this question asked Mar 4, 2013 at 10:30 Joseph Victor ZammitJoseph Victor Zammit 15.3k13 gold badges81 silver badges104 bronze badges3 Answers
Reset to default 3For maximize() there is a boolean property maximized which you can pick up from an object:
if (myWin.maximized) { ... }
However for minimize() ExtJS doesn't provide any functionality and expects individual implementation. Hence, there is no any minimized property supported from the box.
@VisioN's answer is already plete but I want to show you a snippet using toggleCollapse() to hide the window:
Ext.create('Ext.Window',{
height: 100,
width: 100,
minimizable: true,
listeners: {
minimize: function(){
var win = this;
win.toggleCollapse();
if (!win.getCollapsed()) {
win.center();
} else {
win.alignTo(document.body, 'bl-bl');
}
}
}
}).show();
One solution for anyone looking, instead of using minimizable config, use tools. Here is plete example..
var isMinimized = false; //if you want to check for minimized elsewhere..
var winWidth; //to restore to actual width.
Ext.create('Ext.window.Window', {
title: 'Hello',
closable : false,
width : 300, height : 400,
tools: [
{
type: 'restore',
hidden : true,
handler: function( evt,toolEl,owner,tool ) {
var window = owner.up( 'window' );
window.expand('',false);
window.setWidth(winWidth);
window.center();
isMinimized = false;
this.hide();
this.nextSibling().show();
}
},{
type: 'minimize',
handler: function( evt,toolEl,owner,tool ){
var window = owner.up( 'window' );
window.collapse();
winWidth = window.getWidth();
window.setWidth( 150 );
window.alignTo( Ext.getBody(), 'bl-bl');
this.hide();
this.previousSibling().show();
isMinimized = true;
}
}
]
}).show();
本文标签: javascriptExtJS check window state (is minimizedis maximizedetc)Stack Overflow
版权声明:本文标题:javascript - ExtJS: check window state (is minimized, is maximized, etc) - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1744872410a2121512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论