|
|
|
@ -25,78 +25,27 @@ BI.InlineHorizontalAdaptLayout = BI.inherit(BI.Layout, {
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
render: function () { |
|
|
|
|
BI.InlineHorizontalAdaptLayout.superclass.render.apply(this, arguments); |
|
|
|
|
var o = this.options; |
|
|
|
|
this.element.css({ |
|
|
|
|
whiteSpace: "nowrap", |
|
|
|
|
textAlign: o.horizontalAlign |
|
|
|
|
}); |
|
|
|
|
this.populate(o.items); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_addElement: function (i, item, length) { |
|
|
|
|
var o = this.options; |
|
|
|
|
var w = BI.InlineHorizontalAdaptLayout.superclass._addElement.apply(this, arguments); |
|
|
|
|
w.element.css({ |
|
|
|
|
width: o.columnSize[i] === "" ? "" : (o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit)), |
|
|
|
|
position: "relative", |
|
|
|
|
"vertical-align": o.verticalAlign |
|
|
|
|
}); |
|
|
|
|
w.element.addClass("i-h-a-item"); |
|
|
|
|
if (o.columnSize[i] === "fill") { |
|
|
|
|
var left = o.hgap + (item.lgap || 0) + (item.hgap || 0), |
|
|
|
|
right = o.hgap + (item.rgap || 0) + (item.hgap || 0); |
|
|
|
|
for (var k = 0; k < i; k++) { |
|
|
|
|
left += o.hgap + o.lgap + o.rgap + o.columnSize[k]; |
|
|
|
|
} |
|
|
|
|
for (var k = i + 1; k < o.columnSize.length; k++) { |
|
|
|
|
right += o.hgap + o.lgap + o.rgap + o.columnSize[k]; |
|
|
|
|
} |
|
|
|
|
w.element.css("min-width", "calc(100% - " + ((left + right) / BI.pixRatio + BI.pixUnit) + ")"); |
|
|
|
|
} |
|
|
|
|
if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-top": (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-left": ((i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-right": (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0)) / BI.pixRatio + BI.pixUnit |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { |
|
|
|
|
w.element.css({ |
|
|
|
|
"margin-bottom": (o.vgap + o.bgap + (item.bgap || 0) + (item.vgap || 0)) / BI.pixRatio + BI.pixUnit |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return w; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
resize: function () { |
|
|
|
|
this.stroke(this.options.items); |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
return { |
|
|
|
|
type: "bi.inline", |
|
|
|
|
ref: function (_ref) { |
|
|
|
|
self.layout = _ref; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
addItem: function (item) { |
|
|
|
|
throw new Error("不能添加元素"); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
stroke: function (items) { |
|
|
|
|
var self = this; |
|
|
|
|
BI.each(items, function (i, item) { |
|
|
|
|
if (item) { |
|
|
|
|
self._addElement(i, item, items.length); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
items: o.items, |
|
|
|
|
horizontalAlign: o.horizontalAlign, |
|
|
|
|
verticalAlign: o.verticalAlign, |
|
|
|
|
columnSize: o.columnSize, |
|
|
|
|
hgap: o.hgap, |
|
|
|
|
vgap: o.vgap, |
|
|
|
|
lgap: o.lgap, |
|
|
|
|
rgap: o.rgap, |
|
|
|
|
tgap: o.tgap, |
|
|
|
|
bgap: o.bgap |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
|
BI.InlineHorizontalAdaptLayout.superclass.populate.apply(this, arguments); |
|
|
|
|
this._mount(); |
|
|
|
|
this.layout.populate.apply(this.layout, arguments); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
BI.shortcut("bi.inline_horizontal_adapt", BI.InlineHorizontalAdaptLayout); |
|
|
|
|