📄 window.js
字号:
* If this Window is configured {@link #draggable}, this property will contain
* an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
* @type Ext.dd.DD
* @property dd
*/
this.dd = new Ext.Window.DD(this);
},
// private
onEsc : function(){
this[this.closeAction]();
},
// private
beforeDestroy : function(){
this.hide();
if(this.doAnchor){
Ext.EventManager.removeResizeListener(this.doAnchor, this);
Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
}
Ext.destroy(
this.focusEl,
this.resizer,
this.dd,
this.proxy,
this.mask
);
Ext.Window.superclass.beforeDestroy.call(this);
},
// private
onDestroy : function(){
if(this.manager){
this.manager.unregister(this);
}
Ext.Window.superclass.onDestroy.call(this);
},
// private
initTools : function(){
if(this.minimizable){
this.addTool({
id: 'minimize',
handler: this.minimize.createDelegate(this, [])
});
}
if(this.maximizable){
this.addTool({
id: 'maximize',
handler: this.maximize.createDelegate(this, [])
});
this.addTool({
id: 'restore',
handler: this.restore.createDelegate(this, []),
hidden:true
});
this.header.on('dblclick', this.toggleMaximize, this);
}
if(this.closable){
this.addTool({
id: 'close',
handler: this[this.closeAction].createDelegate(this, [])
});
}
},
// private
resizerAction : function(){
var box = this.proxy.getBox();
this.proxy.hide();
this.window.handleResize(box);
return box;
},
// private
beforeResize : function(){
this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
this.resizeBox = this.el.getBox();
},
// private
updateHandles : function(){
if(Ext.isIE && this.resizer){
this.resizer.syncHandleHeight();
this.el.repaint();
}
},
// private
handleResize : function(box){
var rz = this.resizeBox;
if(rz.x != box.x || rz.y != box.y){
this.updateBox(box);
}else{
this.setSize(box);
}
this.focus();
this.updateHandles();
this.saveState();
if(this.layout){
this.doLayout();
}
this.fireEvent("resize", this, box.width, box.height);
},
/**
* Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
* window itself will receive focus.
*/
focus : function(){
var f = this.focusEl, db = this.defaultButton, t = typeof db;
if(t != 'undefined'){
if(t == 'number'){
f = this.buttons[db];
}else if(t == 'string'){
f = Ext.getCmp(db);
}else{
f = db;
}
}
f.focus.defer(10, f);
},
/**
* Sets the target element from which the window should animate while opening.
* @param {String/Element} el The target element or id
*/
setAnimateTarget : function(el){
el = Ext.get(el);
this.animateTarget = el;
},
// private
beforeShow : function(){
delete this.el.lastXY;
delete this.el.lastLT;
if(this.x === undefined || this.y === undefined){
var xy = this.el.getAlignToXY(this.container, 'c-c');
var pos = this.el.translatePoints(xy[0], xy[1]);
this.x = this.x === undefined? pos.left : this.x;
this.y = this.y === undefined? pos.top : this.y;
}
this.el.setLeftTop(this.x, this.y);
if(this.expandOnShow){
this.expand(false);
}
if(this.modal){
Ext.getBody().addClass("x-body-masked");
this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
this.mask.show();
}
},
/**
* Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
* @param {String/Element} animateTarget (optional) The target element or id from which the window should
* animate while opening (defaults to undefined with no animation)
* @param {Function} callback (optional) A callback function to call after the window is displayed
* @param {Object} scope (optional) The scope in which to execute the callback
*/
show : function(animateTarget, cb, scope){
if(!this.rendered){
this.render(Ext.getBody());
}
if(this.hidden === false){
this.toFront();
return;
}
if(this.fireEvent("beforeshow", this) === false){
return;
}
if(cb){
this.on('show', cb, scope, {single:true});
}
this.hidden = false;
if(animateTarget !== undefined){
this.setAnimateTarget(animateTarget);
}
this.beforeShow();
if(this.animateTarget){
this.animShow();
}else{
this.afterShow();
}
},
// private
afterShow : function(){
this.proxy.hide();
this.el.setStyle('display', 'block');
this.el.show();
if(this.maximized){
this.fitContainer();
}
if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
this.cascade(this.setAutoScroll);
}
if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
Ext.EventManager.onWindowResize(this.onWindowResize, this);
}
this.doConstrain();
if(this.layout){
this.doLayout();
}
if(this.keyMap){
this.keyMap.enable();
}
this.toFront();
this.updateHandles();
this.fireEvent("show", this);
},
// private
animShow : function(){
this.proxy.show();
this.proxy.setBox(this.animateTarget.getBox());
this.proxy.setOpacity(0);
var b = this.getBox(false);
b.callback = this.afterShow;
b.scope = this;
b.duration = .25;
b.easing = 'easeNone';
b.opacity = .5;
b.block = true;
this.el.setStyle('display', 'none');
this.proxy.shift(b);
},
/**
* Hides the window, setting it to invisible and applying negative offsets.
* @param {String/Element} animateTarget (optional) The target element or id to which the window should
* animate while hiding (defaults to null with no animation)
* @param {Function} callback (optional) A callback function to call after the window is hidden
* @param {Object} scope (optional) The scope in which to execute the callback
*/
hide : function(animateTarget, cb, scope){
if(this.activeGhost){ // drag active?
this.hide.defer(100, this, [animateTarget, cb, scope]);
return;
}
if(this.hidden || this.fireEvent("beforehide", this) === false){
return;
}
if(cb){
this.on('hide', cb, scope, {single:true});
}
this.hidden = true;
if(animateTarget !== undefined){
this.setAnimateTarget(animateTarget);
}
if(this.animateTarget){
this.animHide();
}else{
this.el.hide();
this.afterHide();
}
},
// private
afterHide : function(){
this.proxy.hide();
if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
Ext.EventManager.removeResizeListener(this.onWindowResize, this);
}
if(this.modal){
this.mask.hide();
Ext.getBody().removeClass("x-body-masked");
}
if(this.keyMap){
this.keyMap.disable();
}
this.fireEvent("hide", this);
},
// private
animHide : function(){
this.proxy.setOpacity(.5);
this.proxy.show();
var tb = this.getBox(false);
this.proxy.setBox(tb);
this.el.hide();
var b = this.animateTarget.getBox();
b.callback = this.afterHide;
b.scope = this;
b.duration = .25;
b.easing = 'easeNone';
b.block = true;
b.opacity = 0;
this.proxy.shift(b);
},
// private
onWindowResize : function(){
if(this.maximized){
this.fitContainer();
}
if(this.modal){
this.mask.setSize('100%', '100%');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -