fineui是帆软报表和BI产品线所使用的前端框架。
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.

179 lines
7.4 KiB

8 years ago
/**
* z-index在1亿层级
* 弹出提示消息框用于模拟阻塞操作通过回调函数实现
* @class BI.Msg
*/
$.extend(BI, {
Msg: function () {
var messageShow, $mask, $pop;
return {
alert: function (title, message, callback) {
this._show(false, title, message, callback);
},
confirm: function (title, message, callback, min_width) {
this._show(true, title, message, callback);
},
prompt: function (title, message, value, callback, min_width) {
8 years ago
BI.Msg.prompt(title, message, value, callback, min_width);
},
8 years ago
toast: function (message, level, context) {
context = context || $("body");
var toast = BI.createWidget({
type: "bi.toast",
level: level,
text: message
});
BI.createWidget({
type: "bi.absolute",
element: context,
items: [{
el: toast,
left: "50%",
top: 0
}]
});
if (toast.element.outerWidth() > context.outerWidth()) {
toast.setWidth(context.width());
}
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.invisible();
toast.element.slideDown(500, function () {
BI.delay(function () {
toast.element.slideUp(500, function () {
toast.destroy();
})
}, 5000)
})
},
_show: function (hasCancel, title, message, callback) {
8 years ago
$mask = $('<div class="bi-z-index-mask">').css({
8 years ago
position: 'absolute',
'zIndex': BI.zIndex_tip - 2,
8 years ago
top: 0,
left: 0,
right: 0,
bottom: 0,
opacity: 0.5
8 years ago
}).appendTo('body');
$pop = $('<div class="bi-message-depend">').css({
position: 'absolute',
'zIndex': BI.zIndex_tip - 1,
8 years ago
top: 0,
left: 0,
right: 0,
bottom: 0
}).appendTo('body');
var close = function () {
messageShow.destroy();
$mask.remove();
};
var controlItems = [];
if (hasCancel === true) {
controlItems.push({
el: {
type: 'bi.button',
text: BI.i18nText("BI-Basic_Cancel"),
8 years ago
height: 30,
level: 'ignore',
handler: function () {
close();
if (BI.isFunction(callback)) {
callback.apply(null, [false]);
}
}
}
});
}
controlItems.push({
el: {
type: 'bi.button',
text: BI.i18nText("BI-Basic_OK"),
8 years ago
height: 30,
handler: function () {
close();
if (BI.isFunction(callback)) {
callback.apply(null, [true]);
}
}
}
});
var conf = {
element: $pop,
type: 'bi.center_adapt',
items: [
{
type: 'bi.border',
8 years ago
cls: 'bi-message-content bi-card',
8 years ago
items: {
'north': {
el: {
type: 'bi.border',
8 years ago
cls: 'bi-message-title bi-background',
8 years ago
items: {
center: {
el: {
type: 'bi.label',
text: title || BI.i18nText("BI-Basic_Prompt"),
8 years ago
textAlign: 'left',
hgap: 20,
height: 50
}
},
east: {
el: {
type: 'bi.icon_button',
cls: 'bi-message-close close-font',
// height: 50,
handler: function () {
close();
}
},
width: 60
}
}
},
height: 50
},
'center': {
el: {
type: "bi.text",
cls: "bi-message-text",
tgap: 60,
hgap: 20,
lineHeight: 30,
whiteSpace: "normal",
text: message
}
},
'south': {
el: {
type: "bi.absolute",
items: [{
el: {
type: 'bi.right_vertical_adapt',
hgap: 5,
items: controlItems
},
top: 0,
left: 20,
right: 20,
bottom: 0
}]
},
height: 60
}
},
width: 400,
height: 300
}
]
};
messageShow = BI.createWidget(conf);
}
};
}()
});