Browse Source

Merge pull request #142 in FUI/fineui from ~GUY/fineui:master to master

* commit '10e82d024f0ecc55530905928b089e0acf89963c':
  update
  update
  slider 修改digit属性
  update
  update
  update
  update
es6
guy 7 years ago
parent
commit
bd906ccdf1
  1. 2
      bi/base.js
  2. 35
      bi/core.js
  3. 24
      bi/sliders.js
  4. 0
      demo/js/category/largeTable/largeTable.js
  5. 113
      demo/js/category/sortTree/demo.sortTree.js
  6. 4
      demo/js/config/category.js
  7. 3
      demo/js/core/abstract/demo.virtual_group.js
  8. 17
      demo/js/core/layout/demo.horizontal.js
  9. 2
      dist/base.js
  10. 37
      dist/bundle.js
  11. 84
      dist/bundle.min.js
  12. 35
      dist/core.js
  13. 214
      dist/demo.js
  14. 24
      dist/sliders.js
  15. 22
      src/addons/sliders/js/singleslider/singleslider.label.js
  16. 2
      src/addons/sliders/js/singleslider/singleslider.normal.js
  17. 2
      src/base/combination/group.virtual.js
  18. 2
      src/core/utils/tree.js
  19. 4
      src/core/widget.js
  20. 29
      src/core/wrapper/layout.js

2
bi/base.js

@ -3897,7 +3897,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

35
bi/core.js

@ -4804,7 +4804,7 @@ BI.Widget = BI.inherit(BI.OB, {
__d: function () {
this.beforeDestroy && this.beforeDestroy();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
@ -4827,7 +4827,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -10504,7 +10504,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -11580,29 +11580,11 @@ BI.Layout = BI.inherit(BI.Widget, {
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (BI.isNull(idxInOld)) {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
// if (elmToMove.sel !== newStartVnode.sel) {
// api.insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
// } else {
// updated = this.patchItem(elmToMove, newStartVnode, idxInOld) || updated;
// oldCh[idxInOld] = undefined;
// api.insertBefore(parentElm, (elmToMove.elm), oldStartVnode.elm);
// }
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
@ -11630,7 +11612,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
@ -11673,15 +11655,6 @@ BI.Layout = BI.inherit(BI.Widget, {
}
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, map = {}, key;
for (i = beginIdx; i <= endIdx; ++i) {
key = children[i].key;
if (key !== undefined) map[key] = i;
}
return map;
}
return updated;
},

24
bi/sliders.js

@ -1485,7 +1485,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-label bi-slider-track",
digit: "",
digit: false,
unit: ""
});
},
@ -1493,7 +1493,6 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
BI.SingleSliderLabel.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant;
this.enable = false;
this.value = "";
@ -1523,7 +1522,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -1561,7 +1560,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -1692,17 +1691,16 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
setValue: function (v) {
var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v);
value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
v = BI.parseFloat(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if ((!isNaN(v))) {
if (this._checkValidation(v)) {
this.value = v;
}
if (value > this.max) {
if (v > this.max) {
this.value = this.max;
}
if (value < this.min) {
if (v < this.min) {
this.value = this.min;
}
}
@ -1862,7 +1860,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track",
cls: "blue-track bi-high-light-background",
height: 6
});
if (this.options.color) {

0
demo/js/category/largeTable/face.js → demo/js/category/largeTable/largeTable.js

113
demo/js/category/sortTree/demo.sortTree.js

@ -0,0 +1,113 @@
/**
* guy
* 二级树
* @class Demo.SortTree
* @extends BI.Widget
*/
Demo.SortTree = BI.inherit(BI.Widget, {
render: function () {
var self = this, o = this.options;
var tree = new BI.Tree();
tree.initTree(BI.Tree.transformToTreeFormat(Demo.CONSTANTS.TREEITEMS));
this.tree = BI.createWidget({
type: "bi.custom_tree",
element: this,
expander: {},
items: this._formatItems(0, tree.toJSON()),
el: {
type: "bi.virtual_group",
layouts: [{
type: "bi.vertical",
scrolly: false
}]
}
});
this.tree.element.sortable({
items: ".sort-item",
placeholder: {
element: function ($currentItem) {
var holder = BI.createWidget({
type: "bi.layout",
cls: "bi-sortable-holder",
height: $currentItem.outerHeight()
});
holder.element.css({
"margin-left": $currentItem.css("margin-left"),
"margin-right": $currentItem.css("margin-right"),
"margin-top": $currentItem.css("margin-top"),
"margin-bottom": $currentItem.css("margin-bottom"),
"margin": $currentItem.css("margin")
});
return holder.element;
},
update: function () {
}
},
update: function (event, ui) {
var node = ui.item.data("node");
var findTheNode = tree.search(node.id);
//这里简单处理下找到它的父节点
var currentIndex = 0, parentNode;
if (ui.item.next().length > 0) {
var n = ui.item.next().data("node");
var nextId = n.id;
var nextNode = tree.search(nextId)
parentNode = nextNode.getParent();
var nextIndex = parentNode.getChildIndex(nextId);
currentIndex = nextIndex > 0 && (nextIndex - 1);
} else if (ui.item.prev().length > 0) {
var n = ui.item.prev().data("node");
var prevId = n.id;
var prevNode = tree.search(prevId)
parentNode = prevNode.getParent();
var prevIndex = parentNode.getChildIndex(prevId);
currentIndex = prevIndex + 1;
}
findTheNode.getParent().removeChild(node.id);
parentNode.addChild(findTheNode, currentIndex);
self.tree.populate(self._formatItems(0, tree.toJSON()));
},
start: function (event, ui) {
},
stop: function (event, ui) {
},
over: function (event, ui) {
}
});
},
_formatItems: function (layer, nodes) {
var self = this;
BI.each(nodes, function (i, node) {
if (node.isParent === true || BI.isNotEmptyArray(node.children)) {
BI.defaults(node, {
type: "bi.multilayer_icon_arrow_node",
height: 30,
layer: layer
});
self._formatItems(layer + 1, node.children);
} else {
BI.defaults(node, {
type: "bi.multilayer_icon_tree_leaf_item",
cls: "sort-item",
height: 30,
key: node.id,
layer: layer,
data: {
node: node
}
});
}
});
return nodes;
},
});
BI.shortcut("demo.sort_tree", Demo.SortTree);

4
demo/js/config/category.js

@ -9,4 +9,8 @@ Demo.CATEGORY_CONFIG = [{
pId: 100000,
text: "大表格",
value: "demo.large_table"
}, {
pId: 100000,
text: "可以排序的树",
value: "demo.sort_tree"
}];

3
demo/js/core/abstract/demo.virtual_group.js

@ -7,6 +7,7 @@ Demo.Func = BI.inherit(BI.Widget, {
var items = BI.map(BI.range(1000), function (i) {
return {
type: "demo.virtual_group_item",
value: i,
key: i + 1
}
});
@ -24,7 +25,7 @@ Demo.Func = BI.inherit(BI.Widget, {
type: "bi.label",
cls: "layout-bg5",
height: 50,
text: "共1000个元素演示button_group和virtual_group每次删除第一个元素"
text: "共1000个元素,演示button_group和virtual_group每次删除第一个元素,打开控制台看输出"
}, {
type: "bi.button_group",
width: 500,

17
demo/js/core/layout/demo.horizontal.js

@ -10,14 +10,27 @@ Demo.Horizontal = BI.inherit(BI.Widget, {
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "水平布局",
whiteSpace: "normal",
text: "因为大多数场景下都需要垂直居中,所以这个布局一般会被vertical_adapt布局设置scrollx=true取代",
cls: "layout-bg3",
width: 500,
height: 50
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg4",
width: 300,
height: 30
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg4",
cls: "layout-bg5",
width: 300,
height: 30
}, {
type: "bi.label",
text: "水平布局",
cls: "layout-bg6",
width: 300,
height: 30
}]

2
dist/base.js vendored

@ -3897,7 +3897,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

37
dist/bundle.js vendored

@ -14791,7 +14791,7 @@ BI.Widget = BI.inherit(BI.OB, {
__d: function () {
this.beforeDestroy && this.beforeDestroy();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
@ -14814,7 +14814,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -18934,7 +18934,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -19936,29 +19936,11 @@ BI.Layout = BI.inherit(BI.Widget, {
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (BI.isNull(idxInOld)) {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
// if (elmToMove.sel !== newStartVnode.sel) {
// api.insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
// } else {
// updated = this.patchItem(elmToMove, newStartVnode, idxInOld) || updated;
// oldCh[idxInOld] = undefined;
// api.insertBefore(parentElm, (elmToMove.elm), oldStartVnode.elm);
// }
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
@ -19986,7 +19968,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
@ -20029,15 +20011,6 @@ BI.Layout = BI.inherit(BI.Widget, {
}
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, map = {}, key;
for (i = beginIdx; i <= endIdx; ++i) {
key = children[i].key;
if (key !== undefined) map[key] = i;
}
return map;
}
return updated;
},
@ -32929,7 +32902,7 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

84
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

35
dist/core.js vendored

@ -14740,7 +14740,7 @@ BI.Widget = BI.inherit(BI.OB, {
__d: function () {
this.beforeDestroy && this.beforeDestroy();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
@ -14763,7 +14763,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();
@ -18883,7 +18883,7 @@ $.extend(BI, {
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {
@ -19885,29 +19885,11 @@ BI.Layout = BI.inherit(BI.Widget, {
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (BI.isNull(idxInOld)) {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
// if (elmToMove.sel !== newStartVnode.sel) {
// api.insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
// } else {
// updated = this.patchItem(elmToMove, newStartVnode, idxInOld) || updated;
// oldCh[idxInOld] = undefined;
// api.insertBefore(parentElm, (elmToMove.elm), oldStartVnode.elm);
// }
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
@ -19935,7 +19917,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
@ -19978,15 +19960,6 @@ BI.Layout = BI.inherit(BI.Widget, {
}
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, map = {}, key;
for (i = beginIdx; i <= endIdx; ++i) {
key = children[i].key;
if (key !== undefined) map[key] = i;
}
return map;
}
return updated;
},

214
dist/demo.js vendored

File diff suppressed because one or more lines are too long

24
dist/sliders.js vendored

@ -1485,7 +1485,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-label bi-slider-track",
digit: "",
digit: false,
unit: ""
});
},
@ -1493,7 +1493,6 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
BI.SingleSliderLabel.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant;
this.enable = false;
this.value = "";
@ -1523,7 +1522,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -1561,7 +1560,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -1692,17 +1691,16 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
setValue: function (v) {
var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v);
value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
v = BI.parseFloat(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if ((!isNaN(v))) {
if (this._checkValidation(v)) {
this.value = v;
}
if (value > this.max) {
if (v > this.max) {
this.value = this.max;
}
if (value < this.min) {
if (v < this.min) {
this.value = this.min;
}
}
@ -1862,7 +1860,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track",
cls: "blue-track bi-high-light-background",
height: 6
});
if (this.options.color) {

22
src/addons/sliders/js/singleslider/singleslider.label.js

@ -14,7 +14,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-slider-label bi-slider-track",
digit: "",
digit: false,
unit: ""
});
},
@ -22,7 +22,6 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
BI.SingleSliderLabel.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var digitExist = (o.digit === "") ? false : true;
var c = this._constant;
this.enable = false;
this.value = "";
@ -52,7 +51,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
self._setBlueTrack(significantPercent);
self._setLabelPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -90,7 +89,7 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
var significantPercent = BI.parseFloat(percent.toFixed(1));
self._setAllPosition(significantPercent);
var v = self._getValueByPercent(significantPercent);
v = digitExist ? v.toFixed(o.digit) : v;
v = o.digit === false ? v : v.toFixed(o.digit);
self.label.setText(v + o.unit);
self.value = v;
self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
@ -221,17 +220,16 @@ BI.SingleSliderLabel = BI.inherit(BI.Widget, {
setValue: function (v) {
var o = this.options;
var digitExist = (o.digit === "") ? false : true;
var value = BI.parseFloat(v);
value = digitExist ? value.toFixed(o.digit) : value;
if ((!isNaN(value))) {
if (this._checkValidation(value)) {
this.value = value;
v = BI.parseFloat(v);
v = o.digit === false ? v : v.toFixed(o.digit);
if ((!isNaN(v))) {
if (this._checkValidation(v)) {
this.value = v;
}
if (value > this.max) {
if (v > this.max) {
this.value = this.max;
}
if (value < this.min) {
if (v < this.min) {
this.value = this.min;
}
}

2
src/addons/sliders/js/singleslider/singleslider.normal.js

@ -118,7 +118,7 @@ BI.SingleSliderNormal = BI.inherit(BI.Widget, {
});
this.blueTrack = BI.createWidget({
type: "bi.layout",
cls: "blue-track",
cls: "blue-track bi-high-light-background",
height: 6
});
if (this.options.color) {

2
src/base/combination/group.virtual.js

@ -56,7 +56,7 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
},
setValue: function (v) {
this.layouts.setValue(v);
// this.layouts.setValue(v);
},
getValue: function () {

2
src/core/utils/tree.js

@ -365,7 +365,7 @@
}
child.setParent(this);
if (cur >= 0) {
this.getChild(cur).setRight(child);
this.getChild(cur) && this.getChild(cur).setRight(child);
child.setLeft(this.getChild(cur));
}
if (BI.isUndefined(index)) {

4
src/core/widget.js

@ -407,7 +407,7 @@ BI.Widget = BI.inherit(BI.OB, {
__d: function () {
this.beforeDestroy && this.beforeDestroy();
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
@ -430,7 +430,7 @@ BI.Widget = BI.inherit(BI.OB, {
empty: function () {
BI.each(this._children, function (i, widget) {
widget._unMount && widget._unMount();
widget && widget._unMount && widget._unMount();
});
this._children = {};
this.element.empty();

29
src/core/wrapper/layout.js

@ -400,29 +400,11 @@ BI.Layout = BI.inherit(BI.Widget, {
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (BI.isNull(idxInOld)) {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
// if (elmToMove.sel !== newStartVnode.sel) {
// api.insertBefore(parentElm, createElm(newStartVnode), oldStartVnode.elm);
// } else {
// updated = this.patchItem(elmToMove, newStartVnode, idxInOld) || updated;
// oldCh[idxInOld] = undefined;
// api.insertBefore(parentElm, (elmToMove.elm), oldStartVnode.elm);
// }
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
@ -450,7 +432,7 @@ BI.Layout = BI.inherit(BI.Widget, {
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
@ -493,15 +475,6 @@ BI.Layout = BI.inherit(BI.Widget, {
}
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, map = {}, key;
for (i = beginIdx; i <= endIdx; ++i) {
key = children[i].key;
if (key !== undefined) map[key] = i;
}
return map;
}
return updated;
},

Loading…
Cancel
Save