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.
67 lines
1.8 KiB
67 lines
1.8 KiB
8 years ago
|
/**
|
||
|
* 浮动的居中布局
|
||
|
*/
|
||
|
BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
|
||
|
_defaultConfig: function () {
|
||
|
return BI.extend(BI.FloatCenterAdaptLayout.superclass._defaultConfig.apply(this, arguments), {
|
||
|
baseCls: "bi-float-center-adapt-layout",
|
||
|
items: [],
|
||
|
hgap: 0,
|
||
|
vgap: 0,
|
||
|
tgap: 0,
|
||
|
bgap: 0,
|
||
|
lgap: 0,
|
||
|
rgap: 0
|
||
|
});
|
||
|
},
|
||
|
_init: function () {
|
||
|
BI.FloatCenterAdaptLayout.superclass._init.apply(this, arguments);
|
||
|
this.populate(this.options.items);
|
||
|
},
|
||
|
|
||
|
resize: function () {
|
||
|
// console.log("float_center_adapt布局不需要resize");
|
||
|
},
|
||
|
|
||
|
addItem: function () {
|
||
|
//do nothing
|
||
|
throw new Error("不能添加元素")
|
||
|
},
|
||
|
|
||
|
stroke: function (items) {
|
||
|
var self = this, o = this.options;
|
||
|
var left = BI.createWidget({
|
||
|
type: "bi.vertical",
|
||
|
items: items,
|
||
|
hgap: o.hgap,
|
||
|
vgap: o.vgap,
|
||
|
tgap: o.tgap,
|
||
|
bgap: o.bgap,
|
||
|
lgap: o.lgap,
|
||
|
rgap: o.rgap
|
||
|
});
|
||
|
|
||
|
BI.createWidget({
|
||
|
type: "bi.left",
|
||
|
element: this.element,
|
||
|
items: [left]
|
||
|
});
|
||
|
|
||
|
BI.nextTick(function () {
|
||
|
var width = left.element.width(),
|
||
|
height = left.element.height();
|
||
|
BI.DOM.hang([left]);
|
||
|
left.element.width(width).height(height).css("float", "none");
|
||
|
BI.createWidget({
|
||
|
type: "bi.center_adapt",
|
||
|
element: self.element,
|
||
|
items: [left]
|
||
|
})
|
||
|
});
|
||
|
},
|
||
|
|
||
|
populate: function (items) {
|
||
|
BI.FloatCenterAdaptLayout.superclass.populate.apply(this, arguments);
|
||
|
}
|
||
|
});
|
||
|
$.shortcut('bi.float_center_adapt', BI.FloatCenterAdaptLayout);
|