|
|
|
@ -8,7 +8,7 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
SIZE: { |
|
|
|
|
SMALL: "small", |
|
|
|
|
NORMAL: "normal", |
|
|
|
|
BIG: "big", |
|
|
|
|
BIG: "big" |
|
|
|
|
}, |
|
|
|
|
MAX_HEIGHT: 600 |
|
|
|
|
}, |
|
|
|
@ -17,7 +17,7 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
baseCls: "bi-popover bi-card bi-border-radius", |
|
|
|
|
size: "normal", // small, normal, big
|
|
|
|
|
logic: { |
|
|
|
|
dynamic: false, |
|
|
|
|
dynamic: false |
|
|
|
|
}, |
|
|
|
|
header: null, |
|
|
|
|
headerHeight: 40, |
|
|
|
@ -30,7 +30,8 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
|
var self = this; var o = this.options; |
|
|
|
|
var self = this; |
|
|
|
|
var o = this.options; |
|
|
|
|
var c = this._constant; |
|
|
|
|
this.startX = 0; |
|
|
|
|
this.startY = 0; |
|
|
|
@ -42,11 +43,11 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
self.startY += deltaY; |
|
|
|
|
self.element.css({ |
|
|
|
|
left: BI.clamp(self.startX, 0, W - self.element.width()) + "px", |
|
|
|
|
top: BI.clamp(self.startY, 0, H - self.element.height()) + "px", |
|
|
|
|
top: BI.clamp(self.startY, 0, H - self.element.height()) + "px" |
|
|
|
|
}); |
|
|
|
|
// BI-12134 没有什么特别好的方法
|
|
|
|
|
BI.Resizers._resize({ |
|
|
|
|
target: self.element[0], |
|
|
|
|
target: self.element[0] |
|
|
|
|
}); |
|
|
|
|
}, function () { |
|
|
|
|
self.tracker.releaseMouseMoves(); |
|
|
|
@ -55,22 +56,27 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
el: { |
|
|
|
|
type: "bi.htape", |
|
|
|
|
cls: "bi-message-title bi-header-background", |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.dragger = _ref; |
|
|
|
|
}, |
|
|
|
|
items: [{ |
|
|
|
|
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, { |
|
|
|
|
extraCls: "bi-font-bold", |
|
|
|
|
}) : { |
|
|
|
|
type: "bi.label", |
|
|
|
|
cls: "bi-font-bold", |
|
|
|
|
height: o.headerHeight, |
|
|
|
|
text: o.header, |
|
|
|
|
title: o.header, |
|
|
|
|
textAlign: "left", |
|
|
|
|
}, |
|
|
|
|
lgap: 20, |
|
|
|
|
rgap: o.closable ? 0 : 20 |
|
|
|
|
el: { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.dragger = _ref; |
|
|
|
|
}, |
|
|
|
|
items: [{ |
|
|
|
|
el: BI.isPlainObject(o.header) ? BI.extend({}, o.header, { |
|
|
|
|
extraCls: "bi-font-bold" |
|
|
|
|
}) : { |
|
|
|
|
type: "bi.label", |
|
|
|
|
cls: "bi-font-bold", |
|
|
|
|
height: o.headerHeight, |
|
|
|
|
text: o.header, |
|
|
|
|
title: o.header, |
|
|
|
|
textAlign: "left" |
|
|
|
|
}, |
|
|
|
|
left: 20, |
|
|
|
|
right: o.closable ? 0 : 20 |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
}, o.closable ? { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.icon_button", |
|
|
|
@ -78,13 +84,13 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
height: o.headerHeight, |
|
|
|
|
handler: function () { |
|
|
|
|
self.close(); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
width: 56, |
|
|
|
|
}: null], |
|
|
|
|
height: o.headerHeight, |
|
|
|
|
width: 56 |
|
|
|
|
} : null], |
|
|
|
|
height: o.headerHeight |
|
|
|
|
}, |
|
|
|
|
height: o.headerHeight, |
|
|
|
|
height: o.headerHeight |
|
|
|
|
}, o.logic.dynamic ? { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.vertical", |
|
|
|
@ -95,14 +101,14 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
}, |
|
|
|
|
css: { |
|
|
|
|
"max-height": this._getSuitableBodyHeight(c.MAX_HEIGHT - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap), |
|
|
|
|
"min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap), |
|
|
|
|
"min-height": this._getSuitableBodyHeight(size.height - o.headerHeight - (o.footer ? o.footerHeight : 0) - o.bodyTgap) |
|
|
|
|
}, |
|
|
|
|
items: [{ |
|
|
|
|
el: o.body, |
|
|
|
|
}], |
|
|
|
|
el: o.body |
|
|
|
|
}] |
|
|
|
|
}, |
|
|
|
|
hgap: o.bodyHgap, |
|
|
|
|
tgap: o.bodyTgap, |
|
|
|
|
tgap: o.bodyTgap |
|
|
|
|
} : { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.absolute", |
|
|
|
@ -111,9 +117,9 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
left: o.bodyHgap, |
|
|
|
|
top: o.bodyTgap, |
|
|
|
|
right: o.bodyHgap, |
|
|
|
|
bottom: 0, |
|
|
|
|
}], |
|
|
|
|
}, |
|
|
|
|
bottom: 0 |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
}]; |
|
|
|
|
if (o.footer) { |
|
|
|
|
items.push({ |
|
|
|
@ -124,30 +130,31 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
left: 20, |
|
|
|
|
top: 0, |
|
|
|
|
right: 20, |
|
|
|
|
bottom: 0, |
|
|
|
|
bottom: 0 |
|
|
|
|
}], |
|
|
|
|
height: o.footerHeight, |
|
|
|
|
height: o.footerHeight |
|
|
|
|
}, |
|
|
|
|
height: o.footerHeight, |
|
|
|
|
height: o.footerHeight |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return BI.extend({ |
|
|
|
|
type: o.logic.dynamic ? "bi.vertical" : "bi.vtape", |
|
|
|
|
items: items, |
|
|
|
|
width: this._getSuitableWidth(size.width), |
|
|
|
|
width: this._getSuitableWidth(size.width) |
|
|
|
|
}, o.logic.dynamic ? { |
|
|
|
|
type: "bi.vertical", |
|
|
|
|
scrolly: false, |
|
|
|
|
scrolly: false |
|
|
|
|
} : { |
|
|
|
|
type: "bi.vtape", |
|
|
|
|
height: this._getSuitableHeight(size.height), |
|
|
|
|
height: this._getSuitableHeight(size.height) |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// mounted之后绑定事件
|
|
|
|
|
mounted: function () { |
|
|
|
|
var self = this; var o = this.options; |
|
|
|
|
var self = this; |
|
|
|
|
var o = this.options; |
|
|
|
|
this.dragger.element.mousedown(function (e) { |
|
|
|
|
var pos = self.element.offset(); |
|
|
|
|
self.startX = pos.left; |
|
|
|
@ -195,7 +202,7 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
return { |
|
|
|
|
width: o.width || size.width, |
|
|
|
|
height: o.height || size.height, |
|
|
|
|
type: size.type || "default", |
|
|
|
|
type: size.type || "default" |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -214,10 +221,11 @@ BI.Popover = BI.inherit(BI.Widget, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
setZindex: function (zindex) { |
|
|
|
|
this.element.css({ "z-index": zindex }); |
|
|
|
|
this.element.css({"z-index": zindex}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
destroyed: function () {}, |
|
|
|
|
destroyed: function () { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
BI.shortcut("bi.popover", BI.Popover); |
|
|
|
@ -225,12 +233,13 @@ BI.shortcut("bi.popover", BI.Popover);
|
|
|
|
|
BI.BarPopover = BI.inherit(BI.Popover, { |
|
|
|
|
_defaultConfig: function () { |
|
|
|
|
return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), { |
|
|
|
|
btns: [BI.i18nText("BI-Basic_Sure"), BI.i18nText("BI-Basic_Cancel")], |
|
|
|
|
btns: [BI.i18nText("BI-Basic_Sure"), BI.i18nText("BI-Basic_Cancel")] |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
beforeCreate: function () { |
|
|
|
|
var self = this; var o = this.options; |
|
|
|
|
var self = this; |
|
|
|
|
var o = this.options; |
|
|
|
|
o.footer || (o.footer = { |
|
|
|
|
type: "bi.right_vertical_adapt", |
|
|
|
|
lgap: 10, |
|
|
|
@ -242,7 +251,7 @@ BI.BarPopover = BI.inherit(BI.Popover, {
|
|
|
|
|
handler: function (v) { |
|
|
|
|
self.fireEvent(BI.Popover.EVENT_CANCEL, v); |
|
|
|
|
self.close(v); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}, { |
|
|
|
|
type: "bi.button", |
|
|
|
|
text: this.options.btns[0], |
|
|
|
@ -251,10 +260,10 @@ BI.BarPopover = BI.inherit(BI.Popover, {
|
|
|
|
|
handler: function (v) { |
|
|
|
|
self.fireEvent(BI.Popover.EVENT_CONFIRM, v); |
|
|
|
|
self.close(v); |
|
|
|
|
}, |
|
|
|
|
}], |
|
|
|
|
} |
|
|
|
|
}] |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
BI.shortcut("bi.bar_popover", BI.BarPopover); |
|
|
|
|