Browse Source

整体布局的resize和update

es6
guy 3 years ago
parent
commit
26a6a96088
  1. 15
      src/core/wrapper/layout.js
  2. 4
      src/core/wrapper/layout/adapt/absolute.center.js
  3. 6
      src/core/wrapper/layout/adapt/absolute.horizontal.js
  4. 6
      src/core/wrapper/layout/adapt/absolute.leftrightvertical.js
  5. 6
      src/core/wrapper/layout/adapt/absolute.vertical.js
  6. 6
      src/core/wrapper/layout/adapt/adapt.center.js
  7. 23
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  8. 4
      src/core/wrapper/layout/adapt/adapt.table.js
  9. 6
      src/core/wrapper/layout/adapt/adapt.vertical.js
  10. 4
      src/core/wrapper/layout/adapt/auto.horizontal.js
  11. 8
      src/core/wrapper/layout/adapt/inline.center.js
  12. 8
      src/core/wrapper/layout/adapt/inline.horizontal.js
  13. 8
      src/core/wrapper/layout/adapt/inline.vertical.js
  14. 4
      src/core/wrapper/layout/fill/float.fill.horizontal.js
  15. 2
      src/core/wrapper/layout/flex/flex.center.js
  16. 2
      src/core/wrapper/layout/flex/flex.horizontal.center.js
  17. 4
      src/core/wrapper/layout/flex/flex.horizontal.js
  18. 6
      src/core/wrapper/layout/flex/flex.leftrightvertical.center.js
  19. 2
      src/core/wrapper/layout/flex/flex.vertical.center.js
  20. 4
      src/core/wrapper/layout/flex/flex.vertical.js
  21. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js
  22. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.center.js
  23. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js
  24. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js
  25. 4
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js
  26. 4
      src/core/wrapper/layout/float/float.absolute.center.js
  27. 8
      src/core/wrapper/layout/float/float.absolute.horizontal.js
  28. 10
      src/core/wrapper/layout/float/float.absolute.leftrightvertical.js
  29. 6
      src/core/wrapper/layout/float/float.absolute.vertical.js
  30. 4
      src/core/wrapper/layout/layout.absolute.js
  31. 4
      src/core/wrapper/layout/layout.adaptive.js
  32. 7
      src/core/wrapper/layout/layout.border.js
  33. 5
      src/core/wrapper/layout/layout.card.js
  34. 4
      src/core/wrapper/layout/layout.default.js
  35. 7
      src/core/wrapper/layout/layout.division.js
  36. 8
      src/core/wrapper/layout/layout.flow.js
  37. 3
      src/core/wrapper/layout/layout.grid.js
  38. 8
      src/core/wrapper/layout/layout.inline.js
  39. 16
      src/core/wrapper/layout/layout.lattice.js
  40. 10
      src/core/wrapper/layout/layout.table.js
  41. 18
      src/core/wrapper/layout/layout.tape.js
  42. 14
      src/core/wrapper/layout/layout.td.js
  43. 4
      src/core/wrapper/layout/layout.vertical.js
  44. 7
      src/core/wrapper/layout/layout.window.js

15
src/core/wrapper/layout.js

@ -550,6 +550,10 @@ BI.Layout = BI.inherit(BI.Widget, {
return updated;
},
shouldUpdate: function () {
return true;
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
@ -618,16 +622,23 @@ BI.Layout = BI.inherit(BI.Widget, {
populate: function (items) {
var self = this, o = this.options;
items = items || [];
if (this._isMounted) {
var shouldUpdate = this.shouldUpdate();
if (this._isMounted && shouldUpdate) {
this.update({items: items});
return;
}
if (this._isMounted && !shouldUpdate){
BI.each(this._children, function (i, c) {
c.destroy();
});
this._children = {};
}
this.options.items = items;
this.stroke(items);
},
resize: function () {
this.stroke(this.options.items);
}
});
BI.shortcut("bi.layout", BI.Layout);

4
src/core/wrapper/layout/adapt/absolute.center.js

@ -35,10 +35,6 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("absolute_center_adapt布局不需要resize");
},
populate: function (items) {
BI.AbsoluteCenterLayout.superclass.populate.apply(this, arguments);
this._mount();

6
src/core/wrapper/layout/adapt/absolute.horizontal.js

@ -42,7 +42,11 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("absolute_horizontal_adapt布局不需要resize");
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {

6
src/core/wrapper/layout/adapt/absolute.leftrightvertical.js

@ -80,7 +80,7 @@ BI.AbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("absolute_left_right_vertical_adapt布局不需要resize");
this.layout.stroke(this._formatItems())
},
addItem: function () {
@ -132,7 +132,11 @@ BI.AbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke([{}].concat(this.options.items))
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {

6
src/core/wrapper/layout/adapt/absolute.vertical.js

@ -42,7 +42,11 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("absolute_vertical_adapt布局不需要resize");
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {

6
src/core/wrapper/layout/adapt/adapt.center.js

@ -43,7 +43,11 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("center_adapt布局不需要resize");
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {

23
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -76,7 +76,18 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("left_right_vertical_adapt布局不需要resize");
this.left.stroke(this.options.items.left);
this.right.stroke(this.options.items.right);
},
update: function (opt) {
this.left.update({
items: opt.items.left
});
this.right.update({
items: opt.items.right
});
return true;
},
addItem: function () {
@ -129,7 +140,11 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("left_vertical_adapt布局不需要resize");
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {
@ -181,7 +196,11 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {

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

@ -100,10 +100,6 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, {
this.element.append(this.$table);
},
resize: function () {
// console.log("center_adapt布局不需要resize");
},
populate: function (items) {
BI.TableAdaptLayout.superclass.populate.apply(this, arguments);
this._mount();

6
src/core/wrapper/layout/adapt/adapt.vertical.js

@ -43,7 +43,11 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("vertical_adapt布局不需要resize");
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {

4
src/core/wrapper/layout/adapt/auto.horizontal.js

@ -32,10 +32,6 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("horizontal_adapt布局不需要resize");
},
populate: function (items) {
BI.HorizontalAutoLayout.superclass.populate.apply(this, arguments);
this._mount();

8
src/core/wrapper/layout/adapt/inline.center.js

@ -44,6 +44,14 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {
this.layout.populate.apply(this.layout, arguments);
}

8
src/core/wrapper/layout/adapt/inline.horizontal.js

@ -44,6 +44,14 @@ BI.InlineHorizontalAdaptLayout = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {
this.layout.populate.apply(this.layout, arguments);
}

8
src/core/wrapper/layout/adapt/inline.vertical.js

@ -44,6 +44,14 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.layout.resize();
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {
this.layout.populate.apply(this.layout, arguments);
}

4
src/core/wrapper/layout/fill/float.fill.horizontal.js

@ -123,6 +123,10 @@ BI.FloatHorizontalFillLayout = BI.inherit(BI.Layout, {
});
},
shouldUpdate: function () {
return false;
},
populate: function (items) {
BI.FloatHorizontalFillLayout.superclass.populate.apply(this, arguments);
this._mount();

2
src/core/wrapper/layout/flex/flex.center.js

@ -42,7 +42,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("flex_center_adapt布局不需要resize");
this.wrapper.resize();
},
update: function (opt) {

2
src/core/wrapper/layout/flex/flex.horizontal.center.js

@ -43,7 +43,7 @@ BI.FlexHorizontalCenter = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("flex_vertical_center_adapt布局不需要resize");
this.wrapper.resize();
},
update: function (opt) {

4
src/core/wrapper/layout/flex/flex.horizontal.js

@ -78,10 +78,6 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("flex_horizontal布局不需要resize");
},
populate: function (items) {
BI.FlexHorizontalLayout.superclass.populate.apply(this, arguments);
this._mount();

6
src/core/wrapper/layout/flex/flex.leftrightvertical.center.js

@ -72,7 +72,11 @@ BI.FlexLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("left_right_vertical_adapt布局不需要resize");
this.layout.stroke(this._formatItems());
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {

2
src/core/wrapper/layout/flex/flex.vertical.center.js

@ -44,7 +44,7 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("flex_vertical_center_adapt布局不需要resize");
this.wrapper.resize();
},
update: function (opt) {

4
src/core/wrapper/layout/flex/flex.vertical.js

@ -77,10 +77,6 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("flex_vertical布局不需要resize");
},
populate: function (items) {
BI.FlexVerticalLayout.superclass.populate.apply(this, arguments);
this._mount();

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js

@ -44,6 +44,10 @@ BI.FlexWrapperCenterLayout = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.wrapper.resize();
},
update: function (opt) {
return this.wrapper.update(opt);
},

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.center.js

@ -44,6 +44,10 @@ BI.FlexWrapperHorizontalCenter = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.wrapper.resize();
},
update: function (opt) {
return this.wrapper.update(opt);
},

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js

@ -84,10 +84,6 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, {
return this.$wrapper;
},
resize: function () {
// console.log("flex_wrapper_horizontal布局不需要resize");
},
populate: function (items) {
BI.FlexWrapperHorizontalLayout.superclass.populate.apply(this, arguments);
this._mount();

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js

@ -44,6 +44,10 @@ BI.FlexWrapperVerticalCenter = BI.inherit(BI.Layout, {
};
},
resize: function () {
this.wrapper.resize();
},
update: function (opt) {
return this.wrapper.update(opt);
},

4
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js

@ -84,10 +84,6 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, {
return this.$wrapper;
},
resize: function () {
// console.log("flex_wrapper_vertical布局不需要resize");
},
populate: function (items) {
BI.FlexWrapperVerticalLayout.superclass.populate.apply(this, arguments);
this._mount();

4
src/core/wrapper/layout/float/float.absolute.center.js

@ -24,10 +24,6 @@ BI.FloatAbsoluteCenterLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("float_absolute_center_adapt布局不需要resize");
},
populate: function (items) {
BI.FloatAbsoluteCenterLayout.superclass.populate.apply(this, arguments);
this._mount();

8
src/core/wrapper/layout/float/float.absolute.horizontal.js

@ -57,11 +57,15 @@ BI.FloatAbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("float_absolute_horizontal_adapt布局不需要resize");
this.layout.stroke(this._formatItems(this.options.items));
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {
this.layout.populate.apply(this, arguments);
this.layout.populate(this._formatItems(items));
}
});
BI.shortcut("bi.absolute_horizontal_float", BI.FloatAbsoluteHorizontalLayout);

10
src/core/wrapper/layout/float/float.absolute.leftrightvertical.js

@ -97,7 +97,11 @@ BI.FloatAbsoluteLeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("absolute_left_right_vertical_adapt布局不需要resize");
this.layout.stroke(this._formatItems());
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {
@ -162,7 +166,11 @@ BI.FloatAbsoluteRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
resize: function () {
this.layout.stroke([{}].concat(this._formatItems(this.options.items)));
},
update: function (opt) {
return this.layout.update(opt);
},
addItem: function () {

6
src/core/wrapper/layout/float/float.absolute.vertical.js

@ -57,7 +57,11 @@ BI.FloatAbsoluteVerticalLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("float_absolute_vertical_adapt布局不需要resize");
this.layout.stroke(this._formatItems(this.options.items));
},
update: function (opt) {
return this.layout.update(opt);
},
populate: function (items) {

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

@ -81,10 +81,6 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.AbsoluteLayout.superclass.populate.apply(this, arguments);
this._mount();

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

@ -51,10 +51,6 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.AbsoluteLayout.superclass.populate.apply(this, arguments);
this._mount();

7
src/core/wrapper/layout/layout.border.js

@ -16,10 +16,6 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
@ -130,7 +126,8 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
}
},
update: function (opt) {
shouldUpdate: function () {
return false;
},
populate: function (items) {

5
src/core/wrapper/layout/layout.card.js

@ -20,7 +20,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
},
resize: function () {
// console.log("default布局不需要resize");
// console.log("Card布局不需要resize");
},
stroke: function (items) {
@ -48,7 +48,8 @@ BI.CardLayout = BI.inherit(BI.Layout, {
});
},
update: function () {
shouldUpdate: function () {
return false;
},
empty: function () {

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

@ -27,10 +27,6 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
// console.log("default布局不需要resize")
},
populate: function (items) {
BI.DefaultLayout.superclass.populate.apply(this, arguments);
this._mount();

7
src/core/wrapper/layout/layout.division.js

@ -41,10 +41,6 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.opitons.items);
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
@ -151,7 +147,8 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
}
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

8
src/core/wrapper/layout/layout.flow.js

@ -64,10 +64,6 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.FloatLeftLayout.superclass.populate.apply(this, arguments);
this._mount();
@ -141,10 +137,6 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.FloatRightLayout.superclass.populate.apply(this, arguments);
this._mount();

3
src/core/wrapper/layout/layout.grid.js

@ -119,7 +119,8 @@ BI.GridLayout = BI.inherit(BI.Layout, {
}
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

8
src/core/wrapper/layout/layout.inline.js

@ -76,14 +76,6 @@ BI.InlineLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
throw new Error("不能添加子组件");
},
populate: function (items) {
BI.InlineLayout.superclass.populate.apply(this, arguments);
this._mount();

16
src/core/wrapper/layout/layout.lattice.js

@ -31,22 +31,6 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
return w;
},
addItem: function (item) {
var w = BI.LatticeLayout.superclass.addItem.apply(this, arguments);
this.resize();
return w;
},
addItemAt: function (item) {
var w = BI.LatticeLayout.superclass.addItemAt.apply(this, arguments);
this.resize();
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.LatticeLayout.superclass.populate.apply(this, arguments);
this._mount();

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

@ -121,14 +121,8 @@ BI.TableLayout = BI.inherit(BI.Layout, {
// console.log("table布局不需要resize");
},
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("必须是数组", arr);
}
return BI.TableLayout.superclass.addItem.apply(this, arguments);
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

18
src/core/wrapper/layout/layout.tape.js

@ -23,9 +23,6 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
@ -122,12 +119,8 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
});
},
update: function () {
var updated;
BI.each(this._children, function (i, child) {
updated = child.update() || updated;
});
return updated;
shouldUpdate: function () {
return false;
},
populate: function (items) {
@ -162,10 +155,6 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
@ -262,7 +251,8 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
});
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

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

@ -172,18 +172,8 @@ BI.TdLayout = BI.inherit(BI.Layout, {
this.element.append(this.$table);
},
resize: function () {
// console.log("td布局不需要resize");
},
addItem: function (arr) {
if (!BI.isArray(arr)) {
throw new Error("必须是数组", arr);
}
return BI.TdLayout.superclass.addItem.apply(this, arguments);
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

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

@ -42,10 +42,6 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
return w;
},
resize: function () {
this.stroke(this.options.items);
},
populate: function (items) {
BI.VerticalLayout.superclass.populate.apply(this, arguments);
this._mount();

7
src/core/wrapper/layout/layout.window.js

@ -25,10 +25,6 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
this.populate(this.options.items);
},
resize: function () {
this.stroke(this.options.items);
},
addItem: function (item) {
// do nothing
throw new Error("不能添加子组件");
@ -171,7 +167,8 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
}
},
update: function () {
shouldUpdate: function () {
return false;
},
populate: function (items) {

Loading…
Cancel
Save