You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
5.1 KiB
177 lines
5.1 KiB
8 years ago
|
/**
|
||
7 years ago
|
* Popover弹出层,
|
||
|
* @class BI.Popover
|
||
8 years ago
|
* @extends BI.Widget
|
||
|
*/
|
||
7 years ago
|
BI.Popover = BI.inherit(BI.Widget, {
|
||
8 years ago
|
_defaultConfig: function () {
|
||
7 years ago
|
return BI.extend(BI.Popover.superclass._defaultConfig.apply(this, arguments), {
|
||
8 years ago
|
baseCls: "bi-float-box bi-card",
|
||
8 years ago
|
width: 600,
|
||
7 years ago
|
height: 500,
|
||
|
header: null,
|
||
|
body: null,
|
||
|
footer: null
|
||
7 years ago
|
});
|
||
8 years ago
|
},
|
||
7 years ago
|
render: function () {
|
||
8 years ago
|
var self = this, o = this.options;
|
||
8 years ago
|
this.element.draggable && this.element.draggable({
|
||
8 years ago
|
handle: ".bi-message-title",
|
||
|
drag: function (e, ui) {
|
||
|
var W = $("body").width(), H = $("body").height();
|
||
|
if (ui.position.left + o.width > W) {
|
||
|
ui.position.left = W - o.width;
|
||
|
}
|
||
|
if (ui.position.top + o.height > H) {
|
||
|
ui.position.top = H - o.height;
|
||
|
}
|
||
|
if (ui.position.left < 0) {
|
||
|
ui.position.left = 0;
|
||
|
}
|
||
|
if (ui.position.top < 0) {
|
||
|
ui.position.top = 0;
|
||
|
}
|
||
7 years ago
|
// BI-12134 没有什么特别好的方法
|
||
7 years ago
|
BI.Resizers._resize();
|
||
8 years ago
|
}
|
||
|
});
|
||
7 years ago
|
var items = {
|
||
|
north: {
|
||
|
el: {
|
||
|
type: "bi.border",
|
||
|
cls: "bi-message-title bi-background",
|
||
|
items: {
|
||
|
center: {
|
||
|
el: {
|
||
|
type: "bi.absolute",
|
||
|
items: [{
|
||
|
el: BI.createWidget(o.header),
|
||
|
left: 10,
|
||
|
top: 0,
|
||
|
right: 0,
|
||
|
bottom: 0
|
||
|
}]
|
||
|
}
|
||
|
},
|
||
|
east: {
|
||
|
el: {
|
||
|
type: "bi.icon_button",
|
||
|
cls: "bi-message-close close-font",
|
||
|
height: 36,
|
||
|
handler: function () {
|
||
|
self.close();
|
||
8 years ago
|
}
|
||
|
},
|
||
7 years ago
|
width: 60
|
||
8 years ago
|
}
|
||
|
}
|
||
|
},
|
||
7 years ago
|
height: 36
|
||
|
},
|
||
|
center: {
|
||
|
el: {
|
||
|
type: "bi.absolute",
|
||
|
items: [{
|
||
|
el: BI.createWidget(o.body),
|
||
|
left: 20,
|
||
|
top: 20,
|
||
|
right: 20,
|
||
|
bottom: 0
|
||
|
}]
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
};
|
||
|
if (o.footer) {
|
||
|
items.south = {
|
||
|
el: {
|
||
|
type: "bi.absolute",
|
||
|
items: [{
|
||
|
el: BI.createWidget(o.footer),
|
||
|
left: 20,
|
||
|
top: 0,
|
||
|
right: 20,
|
||
|
bottom: 0
|
||
|
}]
|
||
|
},
|
||
|
height: 44
|
||
|
};
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
|
BI.createWidget({
|
||
|
type: "bi.border",
|
||
|
element: this,
|
||
|
items: items
|
||
7 years ago
|
});
|
||
8 years ago
|
},
|
||
|
|
||
|
show: function () {
|
||
7 years ago
|
|
||
8 years ago
|
},
|
||
|
|
||
|
hide: function () {
|
||
7 years ago
|
|
||
8 years ago
|
},
|
||
|
|
||
|
open: function () {
|
||
|
this.show();
|
||
7 years ago
|
this.fireEvent(BI.Popover.EVENT_OPEN);
|
||
8 years ago
|
},
|
||
|
|
||
|
close: function () {
|
||
|
this.hide();
|
||
7 years ago
|
this.fireEvent(BI.Popover.EVENT_CLOSE);
|
||
8 years ago
|
},
|
||
|
|
||
|
setZindex: function (zindex) {
|
||
|
this.element.css({"z-index": zindex});
|
||
8 years ago
|
},
|
||
|
|
||
|
destroyed: function () {
|
||
8 years ago
|
}
|
||
|
});
|
||
|
|
||
7 years ago
|
BI.shortcut("bi.popover", BI.Popover);
|
||
8 years ago
|
|
||
7 years ago
|
BI.BarPopover = BI.inherit(BI.Popover, {
|
||
7 years ago
|
_defaultConfig: function () {
|
||
7 years ago
|
return BI.extend(BI.Popover.superclass._defaultConfig.apply(this, arguments), {
|
||
7 years ago
|
btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))]
|
||
|
});
|
||
|
},
|
||
|
|
||
|
beforeCreate: function () {
|
||
|
var self = this, o = this.options;
|
||
|
o.footer || (o.footer = {
|
||
|
type: "bi.right_vertical_adapt",
|
||
|
lgap: 10,
|
||
|
items: [{
|
||
|
type: "bi.button",
|
||
|
text: this.options.btns[1],
|
||
|
value: 1,
|
||
|
level: "ignore",
|
||
|
handler: function (v) {
|
||
7 years ago
|
self.fireEvent(BI.Popover.EVENT_CANCEL, v);
|
||
7 years ago
|
self.close(v);
|
||
|
}
|
||
|
}, {
|
||
|
type: "bi.button",
|
||
|
text: this.options.btns[0],
|
||
|
warningTitle: o.warningTitle,
|
||
|
value: 0,
|
||
|
handler: function (v) {
|
||
7 years ago
|
self.fireEvent(BI.Popover.EVENT_CONFIRM, v);
|
||
7 years ago
|
self.close(v);
|
||
|
}
|
||
|
}]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
7 years ago
|
BI.shortcut("bi.bar_popover", BI.BarPopover);
|
||
7 years ago
|
|
||
7 years ago
|
BI.Popover.EVENT_CLOSE = "EVENT_CLOSE";
|
||
|
BI.Popover.EVENT_OPEN = "EVENT_OPEN";
|
||
|
BI.Popover.EVENT_CANCEL = "EVENT_CANCEL";
|
||
|
BI.Popover.EVENT_CONFIRM = "EVENT_CONFIRM";
|