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.

140 lines
6.1 KiB

7 years ago
// 工程配置
7 years ago
BI.prepares.push(function () {
7 years ago
// 注册布局
// adapt类布局优先级规则
// 1、在非IE且支持flex的浏览器下使用flex布局
// 2、IE或者不支持flex的浏览器下使用inline布局
// 3、在2的情况下如果布局的items大于1的话使用display:table的布局
// 4、在3的情况下如果IE版本低于8使用table标签布局
6 years ago
var _isSupportFlex;
7 years ago
var isSupportFlex = function () {
6 years ago
if (_isSupportFlex == null) {
_isSupportFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex"));
7 years ago
}
6 years ago
return _isSupportFlex;
7 years ago
};
BI.Plugin.configWidget("bi.horizontal", function (ob) {
var isIE = BI.isIE(), supportFlex = isSupportFlex(), isLessIE8 = isIE && BI.getIEVersion() < 8;
5 years ago
if (isLessIE8) {
return ob;
7 years ago
}
5 years ago
// 在横向自适应场景下我们需要使用table的自适应撑出滚动条的特性(flex处理不了这种情况)
// 主要出现在center_adapt或者horizontal_adapt的场景,或者主动设置horizontalAlign的场景
if (ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch) {
5 years ago
return BI.extend(ob, {type: "bi.table_adapt"});
}
if (!isIE && supportFlex) {
5 years ago
return BI.extend(ob, {type: "bi.flex_horizontal"});
8 years ago
}
5 years ago
// 解决使用inline_vertical_adapt的顺序问题
// 从右往左放置时,为了兼容,我们统一采用从右到左的放置方式
if (ob.horizontalAlign === BI.HorizontalAlign.Right) {
5 years ago
return BI.extend({verticalAlign: BI.VerticalAlign.Top}, ob, {
type: "bi.inline_vertical_adapt",
items: ob.items && ob.items.reverse()
});
5 years ago
}
5 years ago
return BI.extend(ob, {type: "bi.table_adapt"});
8 years ago
});
BI.Plugin.configWidget("bi.center_adapt", function (ob) {
var isIE = BI.isIE(), supportFlex = isSupportFlex(), justOneItem = (ob.items && ob.items.length <= 1);
5 years ago
var isAdapt = !ob.horizontalAlign || ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
5 years ago
if (!isAdapt || justOneItem) {
if (!isIE && supportFlex) {
5 years ago
return BI.extend(ob, {type: "bi.flex_center_adapt"});
}
5 years ago
if (ob.horizontalAlign === BI.HorizontalAlign.Right) {
return BI.extend(ob, {type: "bi.inline_center_adapt", items: ob.items && ob.items.reverse()});
}
return BI.extend(ob, {type: "bi.inline_center_adapt"});
}
7 years ago
return ob;
8 years ago
});
BI.Plugin.configWidget("bi.vertical_adapt", function (ob) {
5 years ago
var isIE = BI.isIE(), supportFlex = isSupportFlex(), justOneItem = (ob.items && ob.items.length <= 1);
var isAdapt = ob.horizontalAlign === BI.HorizontalAlign.Center || ob.horizontalAlign === BI.HorizontalAlign.Stretch;
5 years ago
if (!isAdapt || justOneItem) {
if (!isIE && supportFlex) {
5 years ago
return BI.extend(ob, {type: "bi.flex_vertical_center_adapt"});
}
5 years ago
if (ob.horizontalAlign === BI.HorizontalAlign.Right) {
5 years ago
return BI.extend(ob, {type: "bi.inline_vertical_adapt", items: ob.items && ob.items.reverse()});
5 years ago
}
5 years ago
return BI.extend(ob, {type: "bi.inline_vertical_adapt"});
}
return ob;
8 years ago
});
BI.Plugin.configWidget("bi.horizontal_adapt", function (ob) {
5 years ago
var justOneItem = (ob.items && ob.items.length <= 1);
5 years ago
if (!ob.verticalAlign || ob.verticalAlign === BI.VerticalAlign.TOP) {
5 years ago
if (justOneItem) {
5 years ago
return BI.extend(ob, {type: "bi.horizontal_auto"});
}
7 years ago
}
return ob;
});
5 years ago
BI.Plugin.configWidget("bi.horizontal_float", function (ob) {
7 years ago
if (!BI.isIE() && isSupportFlex()) {
5 years ago
return BI.extend(ob, {type: "bi.flex_horizontal_adapt"});
8 years ago
}
5 years ago
return BI.extend(ob, {type: "bi.inline_horizontal_adapt"});
8 years ago
});
BI.Plugin.configWidget("bi.flex_horizontal", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrolly === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_horizontal"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_vertical", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrollx === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_vertical"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_horizontal_adapt", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrollx === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_horizontal_adapt"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_vertical_adapt", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrolly === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_vertical_adapt"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_horizontal_center_adapt", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrollx === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_horizontal_adapt"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_vertical_center_adapt", function (ob) {
5 years ago
if (ob.scrollable === true || ob.scrolly === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_vertical_adapt"});
6 years ago
}
});
BI.Plugin.configWidget("bi.flex_center_adapt", function (ob) {
6 years ago
if (ob.scrollable === true || ob.scrolly === true || ob.scrollx === true) {
5 years ago
return BI.extend(ob, {type: "bi.flex_scrollable_center_adapt"});
6 years ago
}
});
BI.Plugin.configWidget("bi.radio", function (ob) {
4 years ago
if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend(ob, {type: "bi.image_radio"});
}
return ob;
});
BI.Plugin.configWidget("bi.checkbox", function (ob) {
if (BI.isIE() && BI.getIEVersion() <= 9) {
return BI.extend(ob, {type: "bi.image_checkbox"});
}
return ob;
});
BI.Plugin.configWidget("bi.half_icon_button", function (ob) {
if (BI.isIE() && BI.getIEVersion() < 9) {
return ob;
}
return BI.extend(ob, {type: "bi.half_button"});
});
});