forked from fanruan/fineui
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.
84 lines
2.2 KiB
84 lines
2.2 KiB
2 years ago
|
import { Logic } from "./logic";
|
||
|
import { VerticalLayoutLogic, HorizontalLayoutLogic, TableLayoutLogic, HorizontalFillLayoutLogic } from "./logic.layout";
|
||
|
|
||
|
export const LogicFactory = {
|
||
|
Type: {
|
||
|
Vertical: "vertical",
|
||
|
Horizontal: "horizontal",
|
||
|
Table: "table",
|
||
|
HorizontalFill: "horizontal_fill",
|
||
|
},
|
||
|
createLogic (key, options) {
|
||
|
let LogicCls;
|
||
|
switch (key) {
|
||
|
case LogicFactory.Type.Vertical:
|
||
|
LogicCls = VerticalLayoutLogic;
|
||
|
break;
|
||
|
case LogicFactory.Type.Horizontal:
|
||
|
LogicCls = HorizontalLayoutLogic;
|
||
|
break;
|
||
|
case LogicFactory.Type.Table:
|
||
|
LogicCls = TableLayoutLogic;
|
||
|
break;
|
||
|
case LogicFactory.Type.HorizontalFill:
|
||
|
LogicCls = HorizontalFillLayoutLogic;
|
||
|
break;
|
||
|
default:
|
||
|
LogicCls = Logic;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return new LogicCls(options).createLogic();
|
||
|
},
|
||
|
|
||
|
createLogicTypeByDirection (direction) {
|
||
|
switch (direction) {
|
||
|
case BI.Direction.Top:
|
||
|
case BI.Direction.Bottom:
|
||
|
case BI.Direction.Custom:
|
||
|
return BI.LogicFactory.Type.Vertical;
|
||
|
case BI.Direction.Left:
|
||
|
case BI.Direction.Right:
|
||
|
return BI.LogicFactory.Type.Horizontal;
|
||
|
default:
|
||
|
}
|
||
|
},
|
||
|
|
||
|
createLogicItemsByDirection (direction) {
|
||
|
let items = Array.prototype.slice.call(arguments, 1);
|
||
|
items = BI.map(items, (i, item) => {
|
||
|
if (BI.isWidget(item)) {
|
||
|
return {
|
||
|
el: item,
|
||
|
width: item.options.width,
|
||
|
height: item.options.height,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return item;
|
||
|
});
|
||
|
switch (direction) {
|
||
|
case BI.Direction.Bottom:
|
||
|
items.reverse();
|
||
|
break;
|
||
|
case BI.Direction.Right:
|
||
|
items.reverse();
|
||
|
break;
|
||
|
case BI.Direction.Custom:
|
||
|
items = items.slice(1);
|
||
|
break;
|
||
|
default:
|
||
|
}
|
||
|
|
||
|
return items;
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export {
|
||
|
Logic,
|
||
|
VerticalLayoutLogic,
|
||
|
HorizontalLayoutLogic,
|
||
|
TableLayoutLogic,
|
||
|
HorizontalFillLayoutLogic
|
||
|
};
|