|
|
@ -1,16 +1,8 @@ |
|
|
|
/** |
|
|
|
BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
* 左右分离,垂直方向居中容器 |
|
|
|
|
|
|
|
* items:{ |
|
|
|
|
|
|
|
left: [{el:{type:"bi.button"}}], |
|
|
|
|
|
|
|
right:[{el:{type:"bi.button"}}] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
* @class BI.LeftRightVerticalAdaptLayout |
|
|
|
|
|
|
|
* @extends BI.Layout |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
|
|
|
|
props: function () { |
|
|
|
props: function () { |
|
|
|
return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { |
|
|
|
return BI.extend(BI.AbsoluteLeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { |
|
|
|
baseCls: "bi-lr-v-a", |
|
|
|
baseCls: "bi-abs-lr-v-a", |
|
|
|
|
|
|
|
verticalAlign: BI.VerticalAlign.Middle, |
|
|
|
items: {}, |
|
|
|
items: {}, |
|
|
|
llgap: 0, |
|
|
|
llgap: 0, |
|
|
|
lrgap: 0, |
|
|
|
lrgap: 0, |
|
|
@ -28,59 +20,24 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
}, |
|
|
|
}, |
|
|
|
render: function () { |
|
|
|
render: function () { |
|
|
|
var o = this.options, self = this; |
|
|
|
var o = this.options, self = this; |
|
|
|
BI.LeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
BI.AbsoluteLeftRightVerticalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
var leftRight = this._getLeftRight(o.items); |
|
|
|
return { |
|
|
|
var layoutArray = []; |
|
|
|
type: "bi.htape", |
|
|
|
if (leftRight.left || "left" in o.items) { |
|
|
|
innerHgap: o.innerHgap, |
|
|
|
layoutArray.push({ |
|
|
|
innerVgap: o.innerVgap, |
|
|
|
type: "bi.left", |
|
|
|
|
|
|
|
lgap: o.innerHgap, |
|
|
|
|
|
|
|
vgap: o.innerVgap, |
|
|
|
|
|
|
|
items: [{ |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.vertical_adapt", |
|
|
|
|
|
|
|
ref: function (_ref) { |
|
|
|
|
|
|
|
self.left = _ref; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
height: "100%", |
|
|
|
|
|
|
|
items: leftRight.left || o.items.left, |
|
|
|
|
|
|
|
hgap: o.lhgap, |
|
|
|
|
|
|
|
lgap: o.llgap, |
|
|
|
|
|
|
|
rgap: o.lrgap, |
|
|
|
|
|
|
|
tgap: o.ltgap, |
|
|
|
|
|
|
|
bgap: o.lbgap, |
|
|
|
|
|
|
|
vgap: o.lvgap |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (leftRight.right || "right" in o.items) { |
|
|
|
|
|
|
|
layoutArray.push({ |
|
|
|
|
|
|
|
type: "bi.right", |
|
|
|
|
|
|
|
rgap: o.innerHgap, |
|
|
|
|
|
|
|
vgap: o.innerVgap, |
|
|
|
|
|
|
|
items: [{ |
|
|
|
|
|
|
|
el: { |
|
|
|
|
|
|
|
type: "bi.vertical_adapt", |
|
|
|
|
|
|
|
ref: function (_ref) { |
|
|
|
ref: function (_ref) { |
|
|
|
self.right = _ref; |
|
|
|
self.layout = _ref; |
|
|
|
}, |
|
|
|
}, |
|
|
|
height: "100%", |
|
|
|
verticalAlign: o.verticalAlign, |
|
|
|
items: leftRight.right || o.items.right, |
|
|
|
items: this._formatItems(o.items), |
|
|
|
hgap: o.rhgap, |
|
|
|
scrollx: o.scrollx, |
|
|
|
lgap: o.rlgap, |
|
|
|
scrolly: o.scrolly, |
|
|
|
rgap: o.rrgap, |
|
|
|
scrollable: o.scrollable |
|
|
|
tgap: o.rtgap, |
|
|
|
}; |
|
|
|
bgap: o.rbgap, |
|
|
|
|
|
|
|
vgap: o.rvgap |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return layoutArray; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_getLeftRight: function (items) { |
|
|
|
_formatItems: function (items) { |
|
|
|
|
|
|
|
var o = this.options; |
|
|
|
var left, right; |
|
|
|
var left, right; |
|
|
|
if (BI.isArray(items)) { |
|
|
|
if (BI.isArray(items)) { |
|
|
|
BI.each(items, function (i, item) { |
|
|
|
BI.each(items, function (i, item) { |
|
|
@ -92,72 +49,51 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
var leftItems = left || items.left || []; |
|
|
|
left: left, |
|
|
|
var rightItems = right || items.right || []; |
|
|
|
right: right |
|
|
|
leftItems = BI.map(leftItems, function (i, item) { |
|
|
|
|
|
|
|
var json = { |
|
|
|
|
|
|
|
el: BI.stripEL(item), |
|
|
|
|
|
|
|
width: item.width |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
if (o.lvgap + o.ltgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
|
|
|
json.tgap = o.lvgap + o.ltgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
|
|
|
resize: function () { |
|
|
|
|
|
|
|
var leftRight = this._getLeftRight(this.options.items); |
|
|
|
|
|
|
|
this.left.stroke(leftRight.left || this.options.items.left); |
|
|
|
|
|
|
|
this.right.stroke(leftRight.right || this.options.items.right); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addItem: function () { |
|
|
|
|
|
|
|
// do nothing
|
|
|
|
|
|
|
|
throw new Error("不能添加子组件"); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
|
|
|
|
var leftRight = this._getLeftRight(items); |
|
|
|
|
|
|
|
this.left.populate(leftRight.left || items.left); |
|
|
|
|
|
|
|
this.right.populate(leftRight.right || items.right); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if (o.lhgap + o.llgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
BI.shortcut("bi.left_right_vertical_adapt", BI.LeftRightVerticalAdaptLayout); |
|
|
|
json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (o.lhgap + o.lrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
json.rgap = o.lhgap + o.lrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
|
|
|
props: function () { |
|
|
|
} |
|
|
|
return BI.extend(BI.LeftRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { |
|
|
|
if (o.lvgap + o.lbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
baseCls: "bi-l-v-a", |
|
|
|
json.bgap = o.lvgap + o.lbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
|
|
|
items: [], |
|
|
|
} |
|
|
|
columnSize: [], |
|
|
|
return json; |
|
|
|
lgap: 0, |
|
|
|
|
|
|
|
rgap: 0, |
|
|
|
|
|
|
|
hgap: 0, |
|
|
|
|
|
|
|
tgap: 0, |
|
|
|
|
|
|
|
bgap: 0, |
|
|
|
|
|
|
|
vgap: 0 |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
rightItems = BI.map(rightItems, function (i, item) { |
|
|
|
render: function () { |
|
|
|
var json = { |
|
|
|
var o = this.options, self = this; |
|
|
|
el: BI.stripEL(item), |
|
|
|
BI.LeftVerticalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
width: item.width |
|
|
|
return { |
|
|
|
|
|
|
|
type: "bi.vertical_adapt", |
|
|
|
|
|
|
|
ref: function (_ref) { |
|
|
|
|
|
|
|
self.layout = _ref; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
items: o.items, |
|
|
|
|
|
|
|
columnSize: o.columnSize, |
|
|
|
|
|
|
|
hgap: o.hgap, |
|
|
|
|
|
|
|
lgap: o.lgap, |
|
|
|
|
|
|
|
rgap: o.rgap, |
|
|
|
|
|
|
|
tgap: o.tgap, |
|
|
|
|
|
|
|
bgap: o.bgap, |
|
|
|
|
|
|
|
vgap: o.vgap, |
|
|
|
|
|
|
|
innerHgap: o.innerHgap, |
|
|
|
|
|
|
|
innerVgap: o.innerVgap, |
|
|
|
|
|
|
|
scrollx: o.scrollx, |
|
|
|
|
|
|
|
scrolly: o.scrolly, |
|
|
|
|
|
|
|
scrollable: o.scrollable |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
if (o.rvgap + o.rtgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
|
|
|
json.tgap = o.rvgap + o.rtgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (o.rhgap + o.rlgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
|
|
|
json.lgap = (i === 0 ? o.rhgap : 0) + o.rlgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (o.rhgap + o.rrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) { |
|
|
|
|
|
|
|
json.rgap = o.rhgap + o.rrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (o.rvgap + o.rbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) { |
|
|
|
|
|
|
|
json.bgap = o.rvgap + o.rbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return json; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return leftItems.concat({}, rightItems); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
resize: function () { |
|
|
|
resize: function () { |
|
|
|
this.layout.resize(); |
|
|
|
this.layout.stroke(this._formatItems(this.options.items)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
addItem: function () { |
|
|
|
addItem: function () { |
|
|
@ -166,17 +102,17 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
populate: function (items) { |
|
|
|
this.layout.populate.apply(this, arguments); |
|
|
|
this.layout.populate(this._formatItems(items)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
BI.shortcut("bi.left_vertical_adapt", BI.LeftVerticalAdaptLayout); |
|
|
|
BI.shortcut("bi.absolute_left_right_vertical_adapt", BI.AbsoluteLeftRightVerticalAdaptLayout); |
|
|
|
|
|
|
|
|
|
|
|
BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
BI.AbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
props: function () { |
|
|
|
props: function () { |
|
|
|
return BI.extend(BI.RightVerticalAdaptLayout.superclass.props.apply(this, arguments), { |
|
|
|
return BI.extend(BI.AbsoluteRightVerticalAdaptLayout.superclass.props.apply(this, arguments), { |
|
|
|
baseCls: "bi-r-v-a", |
|
|
|
baseCls: "bi-abs-r-v-a", |
|
|
|
|
|
|
|
verticalAlign: BI.VerticalAlign.Middle, |
|
|
|
items: [], |
|
|
|
items: [], |
|
|
|
columnSize: [], |
|
|
|
|
|
|
|
lgap: 0, |
|
|
|
lgap: 0, |
|
|
|
rgap: 0, |
|
|
|
rgap: 0, |
|
|
|
hgap: 0, |
|
|
|
hgap: 0, |
|
|
@ -187,23 +123,20 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
}, |
|
|
|
}, |
|
|
|
render: function () { |
|
|
|
render: function () { |
|
|
|
var o = this.options, self = this; |
|
|
|
var o = this.options, self = this; |
|
|
|
BI.RightVerticalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
BI.AbsoluteRightVerticalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
return { |
|
|
|
return { |
|
|
|
type: "bi.vertical_adapt", |
|
|
|
type: "bi.htape", |
|
|
|
ref: function (_ref) { |
|
|
|
ref: function (_ref) { |
|
|
|
self.layout = _ref; |
|
|
|
self.layout = _ref; |
|
|
|
}, |
|
|
|
}, |
|
|
|
horizontalAlign: BI.HorizontalAlign.Right, |
|
|
|
verticalAlign: o.verticalAlign, |
|
|
|
items: o.items, |
|
|
|
items: [{}].concat(o.items), |
|
|
|
columnSize: o.columnSize, |
|
|
|
|
|
|
|
hgap: o.hgap, |
|
|
|
hgap: o.hgap, |
|
|
|
lgap: o.lgap, |
|
|
|
lgap: o.lgap, |
|
|
|
rgap: o.rgap, |
|
|
|
rgap: o.rgap, |
|
|
|
tgap: o.tgap, |
|
|
|
tgap: o.tgap, |
|
|
|
bgap: o.bgap, |
|
|
|
bgap: o.bgap, |
|
|
|
vgap: o.vgap, |
|
|
|
vgap: o.vgap, |
|
|
|
innerHgap: o.innerHgap, |
|
|
|
|
|
|
|
innerVgap: o.innerVgap, |
|
|
|
|
|
|
|
scrollx: o.scrollx, |
|
|
|
scrollx: o.scrollx, |
|
|
|
scrolly: o.scrolly, |
|
|
|
scrolly: o.scrolly, |
|
|
|
scrollable: o.scrollable |
|
|
|
scrollable: o.scrollable |
|
|
@ -211,7 +144,7 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
resize: function () { |
|
|
|
resize: function () { |
|
|
|
this.layout.resize(); |
|
|
|
this.layout.stroke([{}].concat(this.options.items)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
addItem: function () { |
|
|
|
addItem: function () { |
|
|
@ -220,7 +153,7 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
populate: function (items) { |
|
|
|
this.layout.populate(items); |
|
|
|
this.layout.populate([{}].concat(items)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout); |
|
|
|
BI.shortcut("bi.absolute_right_vertical_adapt", BI.AbsoluteRightVerticalAdaptLayout); |
|
|
|