修复Extjs5.1.4的弹出窗(window)BUG

时间:2022-02-28 08:47:52

Extjs5.1.4版本目前是兼容性及稳定性最好的,5.0-5.1.3在window10环境下都有比较严重的BUG。

目前使用5.1.4感觉还不错。

Ext.define(‘Ext.overrides.ZIndexManager‘,{
override:‘Ext.ZIndexManager‘,
register: function(comp) {
var me = this;
if (comp.zIndexManager) {
comp.zIndexManager.unregister(comp);
}
comp.zIndexManager = me;
if (!comp.rendered) {
comp.on(‘render‘, me.onComponentRender, me, {
single: true
});
}
me.zIndexStack.add(comp);
},
unregister: function(comp) {
var me = this;
delete comp.zIndexManager;
comp.un(‘render‘, me.onComponentRender, me);
me.zIndexStack.remove(comp);
me.onCollectionSort();
},
onComponentRender: function(comp) {
this.zIndexStack.itemChanged(comp, ‘hidden‘);
},
privates: {
showModalMask: function(comp) {
var me = this,
compEl = comp.el,
zIndex = compEl.getStyle(‘zIndex‘) - 4,
maskTarget = comp.floatParent ? comp.floatParent.getEl() : comp.container,
mask = me.mask,
shim = me.maskShim,
viewSize, tabbableAttr, tempTabbableAttr, tabbables;
if (!mask) {
me.mask = mask = Ext.getBody().createChild({
‘data-sticky‘: true,
role: ‘presentation‘,
//修改window遮罩层的颜色
cls: Ext.baseCSSPrefix + ‘mask my-mask ‘ + Ext.baseCSSPrefix + ‘border-box‘,
style: ‘height:0;width:0‘
});
mask.setVisibilityMode(Ext.Element.DISPLAY);
mask.on(‘click‘, me.onMaskClick, me);
} else {
me.hideModalMask();
}
mask.maskTarget = maskTarget;
viewSize = me.getMaskBox();
if (shim) {
shim.setStyle(‘zIndex‘, zIndex);
shim.show();
shim.setBox(viewSize);
}
mask.setStyle(‘zIndex‘, zIndex);
tabbableAttr = ‘data-savedtabindex-‘ + maskTarget.getId();
tempTabbableAttr = tabbableAttr + ‘-temp‘;
tabbables = compEl.findTabbableElements();
if (tabbables.length) {
compEl.saveTabbableState(tempTabbableAttr);
compEl.saveChildrenTabbableState(tempTabbableAttr);
}
maskTarget.saveTabbableState(tabbableAttr);
maskTarget.saveChildrenTabbableState(tabbableAttr);
if (tabbables.length) {
compEl.restoreChildrenTabbableState(tempTabbableAttr);
compEl.restoreTabbableState(tempTabbableAttr);
}
mask.show();
mask.setBox(viewSize);
}
}
});

修复Extjs5.1.4的弹出窗(window)BUG