Browse Source

移动端适配

es6
guy 4 years ago
parent
commit
3d572b6aa5
  1. 2
      src/core/wrapper/layout/adapt/adapt.table.js
  2. 70
      src/core/wrapper/layout/adapt/float.horizontal.js
  3. 14
      src/core/wrapper/layout/layout.table.js
  4. 4
      src/core/wrapper/layout/layout.td.js

2
src/core/wrapper/layout/adapt/adapt.table.js

@ -35,7 +35,7 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) {
var o = this.options;
var td;
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit);
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI._lazyCreateWidget(item);
w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});

70
src/core/wrapper/layout/adapt/float.horizontal.js

@ -1,70 +0,0 @@
/**
* 浮动的水平居中布局
*/
BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
props: function () {
return BI.extend(BI.FloatHorizontalLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-float-horizontal-adapt-layout",
items: [],
hgap: 0,
vgap: 0,
tgap: 0,
bgap: 0,
lgap: 0,
rgap: 0
});
},
render: function () {
BI.FloatHorizontalLayout.superclass.render.apply(this, arguments);
this.populate(this.options.items);
},
resize: function () {
// console.log("float_horizontal_adapt布局不需要resize");
},
mounted: function () {
var self = this;
var width = this.left.element.width(),
height = this.left.element.height();
this.left.element.width(width).height(height).css("float", "none");
BI.remove(this._children, function (i, wi) {
if (wi === self.container) {
delete self._children[i];
}
});
BI._lazyCreateWidget({
type: "bi.horizontal_auto",
element: this,
items: [this.left]
});
},
_addElement: function (i, item) {
var self = this, o = this.options;
this.left = BI._lazyCreateWidget({
type: "bi.vertical",
items: [item],
hgap: o.hgap,
vgap: o.vgap,
tgap: o.tgap,
bgap: o.bgap,
lgap: o.lgap,
rgap: o.rgap
});
this.container = BI._lazyCreateWidget({
type: "bi.left",
element: this,
items: [this.left]
});
return this.left;
},
populate: function (items) {
BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments);
this._mount();
}
});
BI.shortcut("bi.horizontal_float", BI.FloatHorizontalLayout);

14
src/core/wrapper/layout/layout.table.js

@ -79,8 +79,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
abs.push(BI.extend({
top: 0,
bottom: 0,
left: o.columnSize[i] <= 1 ? left * 100 + "%" : left / BI.pixRatio + BI.pixUnit,
width: o.columnSize[i] <= 1 ? o.columnSize[i] * 100 + "%" : o.columnSize[i] / BI.pixRatio + BI.pixUnit
left: o.columnSize[i] <= 1 ? left * 100 + "%" : left,
width: o.columnSize[i] <= 1 ? o.columnSize[i] * 100 + "%" : o.columnSize[i]
}, arr[i]));
left += o.columnSize[i] + (o.columnSize[i] < 1 ? 0 : o.hgap);
} else {
@ -93,8 +93,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
abs.push(BI.extend({
top: 0,
bottom: 0,
right: o.columnSize[j] <= 1 ? right * 100 + "%" : right / BI.pixRatio + BI.pixUnit,
width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] / BI.pixRatio + BI.pixUnit
right: o.columnSize[j] <= 1 ? right * 100 + "%" : right,
width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j]
}, arr[j]));
right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap);
} else {
@ -106,13 +106,13 @@ BI.TableLayout = BI.inherit(BI.Layout, {
abs.push(BI.extend({
top: 0,
bottom: 0,
left: left <= 1 ? left * 100 + "%" : left / BI.pixRatio + BI.pixUnit,
right: right <= 1 ? right * 100 + "%" : right / BI.pixRatio + BI.pixUnit
left: left <= 1 ? left * 100 + "%" : left,
right: right <= 1 ? right * 100 + "%" : right
}, arr[i]));
}
var w = BI._lazyCreateWidget({
type: "bi.absolute",
height: (BI.isArray(o.rowSize) ? o.rowSize[this.rows] : o.rowSize) / BI.pixRatio + BI.pixUnit,
height: BI.isArray(o.rowSize) ? o.rowSize[this.rows] : o.rowSize,
items: abs
});
if (this.rows > 0) {

4
src/core/wrapper/layout/layout.td.js

@ -100,9 +100,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
first(w, this.rows++, i);
var td = BI._lazyCreateWidget({
type: "bi.default",
attributes: {
width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i] / BI.pixRatio + BI.pixUnit
},
width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i],
tagName: "td",
items: [w]
});

Loading…
Cancel
Save