Browse Source

新增Drawer组件,使用和popover一样的zindex机制

es6
guy 3 years ago
parent
commit
a9d69a4aa2
  1. 10
      src/core/controller/controller.drawer.js
  2. 7
      src/core/controller/controller.popover.js

10
src/core/controller/controller.drawer.js

@ -18,7 +18,6 @@ BI.DrawerController = BI.inherit(BI.Controller, {
this.floatLayer = {}; this.floatLayer = {};
this.floatContainer = {}; this.floatContainer = {};
this.floatOpened = {}; this.floatOpened = {};
this.zindex = BI.zIndex_popover;
this.zindexMap = {}; this.zindexMap = {};
}, },
@ -41,17 +40,18 @@ BI.DrawerController = BI.inherit(BI.Controller, {
if (!this.floatOpened[name]) { if (!this.floatOpened[name]) {
this.floatOpened[name] = true; this.floatOpened[name] = true;
var container = this.floatContainer[name]; var container = this.floatContainer[name];
container.element.css("zIndex", this.zindex++); var zIndex = BI.Popovers._getZIndex();
container.element.css("zIndex", zIndex);
this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]);
this.zindexMap[name] = this.zindex; this.zindexMap[name] = zIndex;
if (this.modal) { if (this.modal) {
var mask = container.element.__buildZIndexMask__(this.zindex++); var mask = container.element.__buildZIndexMask__(BI.Popovers._getZIndex());
mask.click(function () { mask.click(function () {
mask.destroy(); mask.destroy();
self.get(name).close(); self.get(name).close();
}); });
} }
this.get(name).setZindex(this.zindex++); this.get(name).setZindex(BI.Popovers._getZIndex());
this.floatContainer[name].visible(); this.floatContainer[name].visible();
var popover = this.get(name); var popover = this.get(name);
popover.show && popover.show(); popover.show && popover.show();

7
src/core/controller/controller.popover.js

@ -48,7 +48,8 @@ BI.PopoverController = BI.inherit(BI.Controller, {
this.floatContainer[name].visible(); this.floatContainer[name].visible();
var popover = this.get(name); var popover = this.get(name);
popover.show && popover.show(); popover.show && popover.show();
var W = BI.Widget._renderEngine.createElement(this.options.render).width(), H = BI.Widget._renderEngine.createElement(this.options.render).height(); var W = BI.Widget._renderEngine.createElement(this.options.render).width(),
H = BI.Widget._renderEngine.createElement(this.options.render).height();
var w = popover.element.width(), h = popover.element.height(); var w = popover.element.width(), h = popover.element.height();
var left = (W - w) / 2, top = (H - h) / 2; var left = (W - w) / 2, top = (H - h) / 2;
if (left < 0) { if (left < 0) {
@ -163,5 +164,9 @@ BI.PopoverController = BI.inherit(BI.Controller, {
this.floatOpened = {}; this.floatOpened = {};
this.zindexMap = {}; this.zindexMap = {};
return this; return this;
},
_getZIndex: function () {
return this.zindex++;
} }
}); });

Loading…
Cancel
Save