Urthur 7 years ago
parent
commit
bf33db543d
  1. 642
      bi/base.js
  2. 176
      bi/core.js
  3. 2
      bi/sliders.js
  4. 34
      demo/js/core/abstract/demo.virtual_group.js
  5. 176
      dist/bundle.js
  6. 82
      dist/bundle.min.js
  7. 176
      dist/core.js
  8. 34
      dist/demo.js
  9. 2
      dist/sliders.js
  10. 2
      src/addons/sliders/js/singleslider/singleslider.normal.js
  11. 4
      src/core/widget.js
  12. 172
      src/core/wrapper/layout.js

642
bi/base.js

@ -16400,68 +16400,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) {
}
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
});/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器
*
@ -16742,57 +16742,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
}
});
}());
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
*
* Created by GUY on 2015/11/26.
@ -17060,214 +17060,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 12,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 12,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: 70,
minWidth: 70,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器
*

176
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();
@ -11527,33 +11527,167 @@ BI.Layout = BI.inherit(BI.Widget, {
})
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated, i, len;
for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
if (!this._compare(o.items[i], items[i])) {
updated = this.updateItemAt(i, items[i]) || updated;
patchItem: function (oldVnode, vnode, index) {
if (!this._compare(oldVnode, vnode)) {
return this.updateItemAt(index, vnode);
}
},
updateChildren: function (oldCh, newCh) {
var self = this;
var oldStartIdx = 0, newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newEndIdx = newCh.length - 1;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx;
var idxInOld;
var elmToMove;
var before;
var updated;
var children = {};
BI.each(oldCh, function (i, child) {
child = self._getOptions(child);
var key = child.key == null ? i : child.key;
if (BI.isKey(key)) {
children[key] = self._children[self._getChildName(i)];
}
});
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (BI.isNull(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (BI.isNull(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode, oldStartIdx, newStartIdx)) {
updated = this.patchItem(oldStartVnode, newStartVnode, oldStartIdx) || updated;
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode, oldEndIdx, newEndIdx)) {
updated = this.patchItem(oldEndVnode, newEndVnode, oldEndIdx) || updated;
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
updated = this.patchItem(oldStartVnode, newEndVnode, oldStartIdx) || updated;
insertBefore(oldStartVnode, oldEndVnode, true);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
updated = this.patchItem(oldEndVnode, newStartVnode, oldEndIdx) || updated;
insertBefore(oldEndVnode, oldStartVnode);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
}
}
if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
} else if (newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
this._children = {};
BI.each(newCh, function (i, child) {
var node = self._getOptions(child);
var key = node.key == null ? i : node.key;
self._children[self._getChildName(i)] = children[key];
});
function sameVnode(vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key;
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]);
if (oldIndex >= 0) {
return oldIndex === newIndex
}
}
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
return children[key] = self._addElement(key, vnode);
}
function addVnodes(before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before);
}
}
function removeVnodes(vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]);
var key = node.key == null ? startIdx : node.key;
children[key]._destroy();
}
}
function insertBefore(insert, before, isNext) {
insert = self._getOptions(insert);
before = before && self._getOptions(before);
if (BI.isKey(insert.key)) {
if (before && children[before.key]) {
var next;
if (isNext) {
next = children[before.key].element.next();
} else {
next = children[before.key].element;
}
if (next.length > 0) {
next.before(children[insert.key].element);
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
throw "key is not defined";
}
}
return updated;
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated = this.updateChildren(o.items, items);
this.options.items = items;
return updated;
// var updated, i, len;
// for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
// if (!this._compare(o.items[i], items[i])) {
// updated = this.updateItemAt(i, items[i]) || updated;
// }
// }
// if (o.items.length > items.length) {
// var deleted = [];
// for (i = items.length; i < o.items.length; i++) {
// deleted.push(this._children[this._getChildName(i)]);
// delete this._children[this._getChildName(i)];
// }
// o.items.splice(items.length);
// BI.each(deleted, function (i, w) {
// w._destroy();
// })
// } else if (items.length > o.items.length) {
// for (i = o.items.length; i < items.length; i++) {
// this.addItemAt(i, items[i]);
// }
// }
// return updated;
},
stroke: function (items) {
var self = this;
BI.each(items, function (i, item) {

2
bi/sliders.js

@ -1862,7 +1862,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) {

34
demo/js/core/abstract/demo.virtual_group.js

@ -4,19 +4,29 @@ Demo.Func = BI.inherit(BI.Widget, {
},
_createItems: function () {
var items = BI.makeArray(1000, {
type: "demo.virtual_group_item"
var items = BI.map(BI.range(1000), function (i) {
return {
type: "demo.virtual_group_item",
value: i,
key: i + 1
}
});
items[0].value = BI.UUID();
return items;
},
render: function () {
var self = this;
var buttonGroupItems = self._createItems();
var virtualGroupItems = self._createItems();
return {
type: "bi.vertical",
vgap: 20,
items: [{
type: "bi.label",
cls: "layout-bg5",
height: 50,
text: "共1000个元素,演示button_group和virtual_group每次删除第一个元素,打开控制台看输出"
}, {
type: "bi.button_group",
width: 500,
height: 300,
@ -26,17 +36,14 @@ Demo.Func = BI.inherit(BI.Widget, {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}, {
type: "bi.center_adapt",
}],
items: this._createItems()
}, {
type: "bi.button",
text: "演示button_group的刷新",
handler: function () {
var items = self._createItems();
items.pop();
self.buttonGroup.populate(items);
buttonGroupItems.shift();
self.buttonGroup.populate(BI.deepClone(buttonGroupItems));
}
}, {
type: "bi.virtual_group",
@ -48,17 +55,14 @@ Demo.Func = BI.inherit(BI.Widget, {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}, {
type: "bi.center_adapt",
}],
items: this._createItems()
}, {
type: "bi.button",
text: "演示virtual_group的刷新",
handler: function () {
var items = self._createItems();
items.pop();
self.virtualGroup.populate(items);
virtualGroupItems.shift();
self.virtualGroup.populate(BI.deepClone(virtualGroupItems));
}
}]
@ -74,14 +78,14 @@ Demo.Item = BI.inherit(BI.Widget, {
},
render: function () {
var self = this;
var self = this, o = this.options;
return {
type: "bi.label",
ref: function () {
self.label = this;
},
height: this.options.height,
text: "这是一个测试项" + BI.UUID()
text: "key:" + o.key + ",随机数" + BI.UUID()
}
},

176
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();
@ -19883,33 +19883,167 @@ BI.Layout = BI.inherit(BI.Widget, {
})
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated, i, len;
for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
if (!this._compare(o.items[i], items[i])) {
updated = this.updateItemAt(i, items[i]) || updated;
patchItem: function (oldVnode, vnode, index) {
if (!this._compare(oldVnode, vnode)) {
return this.updateItemAt(index, vnode);
}
},
updateChildren: function (oldCh, newCh) {
var self = this;
var oldStartIdx = 0, newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newEndIdx = newCh.length - 1;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx;
var idxInOld;
var elmToMove;
var before;
var updated;
var children = {};
BI.each(oldCh, function (i, child) {
child = self._getOptions(child);
var key = child.key == null ? i : child.key;
if (BI.isKey(key)) {
children[key] = self._children[self._getChildName(i)];
}
});
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (BI.isNull(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (BI.isNull(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode, oldStartIdx, newStartIdx)) {
updated = this.patchItem(oldStartVnode, newStartVnode, oldStartIdx) || updated;
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode, oldEndIdx, newEndIdx)) {
updated = this.patchItem(oldEndVnode, newEndVnode, oldEndIdx) || updated;
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
updated = this.patchItem(oldStartVnode, newEndVnode, oldStartIdx) || updated;
insertBefore(oldStartVnode, oldEndVnode, true);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
updated = this.patchItem(oldEndVnode, newStartVnode, oldEndIdx) || updated;
insertBefore(oldEndVnode, oldStartVnode);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
} else if (newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
this._children = {};
BI.each(newCh, function (i, child) {
var node = self._getOptions(child);
var key = node.key == null ? i : node.key;
self._children[self._getChildName(i)] = children[key];
});
function sameVnode(vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key;
}
if (oldIndex >= 0) {
return oldIndex === newIndex
}
}
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
return children[key] = self._addElement(key, vnode);
}
function addVnodes(before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before);
}
}
if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
function removeVnodes(vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]);
var key = node.key == null ? startIdx : node.key;
children[key]._destroy();
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]);
}
function insertBefore(insert, before, isNext) {
insert = self._getOptions(insert);
before = before && self._getOptions(before);
if (BI.isKey(insert.key)) {
if (before && children[before.key]) {
var next;
if (isNext) {
next = children[before.key].element.next();
} else {
next = children[before.key].element;
}
if (next.length > 0) {
next.before(children[insert.key].element);
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
throw "key is not defined";
}
}
return updated;
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated = this.updateChildren(o.items, items);
this.options.items = items;
return updated;
// var updated, i, len;
// for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
// if (!this._compare(o.items[i], items[i])) {
// updated = this.updateItemAt(i, items[i]) || updated;
// }
// }
// if (o.items.length > items.length) {
// var deleted = [];
// for (i = items.length; i < o.items.length; i++) {
// deleted.push(this._children[this._getChildName(i)]);
// delete this._children[this._getChildName(i)];
// }
// o.items.splice(items.length);
// BI.each(deleted, function (i, w) {
// w._destroy();
// })
// } else if (items.length > o.items.length) {
// for (i = o.items.length; i < items.length; i++) {
// this.addItemAt(i, items[i]);
// }
// }
// return updated;
},
stroke: function (items) {
var self = this;
BI.each(items, function (i, item) {

82
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

176
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();
@ -19832,33 +19832,167 @@ BI.Layout = BI.inherit(BI.Widget, {
})
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated, i, len;
for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
if (!this._compare(o.items[i], items[i])) {
updated = this.updateItemAt(i, items[i]) || updated;
patchItem: function (oldVnode, vnode, index) {
if (!this._compare(oldVnode, vnode)) {
return this.updateItemAt(index, vnode);
}
},
updateChildren: function (oldCh, newCh) {
var self = this;
var oldStartIdx = 0, newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newEndIdx = newCh.length - 1;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx;
var idxInOld;
var elmToMove;
var before;
var updated;
var children = {};
BI.each(oldCh, function (i, child) {
child = self._getOptions(child);
var key = child.key == null ? i : child.key;
if (BI.isKey(key)) {
children[key] = self._children[self._getChildName(i)];
}
});
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (BI.isNull(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (BI.isNull(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode, oldStartIdx, newStartIdx)) {
updated = this.patchItem(oldStartVnode, newStartVnode, oldStartIdx) || updated;
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode, oldEndIdx, newEndIdx)) {
updated = this.patchItem(oldEndVnode, newEndVnode, oldEndIdx) || updated;
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
updated = this.patchItem(oldStartVnode, newEndVnode, oldStartIdx) || updated;
insertBefore(oldStartVnode, oldEndVnode, true);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
updated = this.patchItem(oldEndVnode, newStartVnode, oldEndIdx) || updated;
insertBefore(oldEndVnode, oldStartVnode);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
}
}
if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
} else if (newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
this._children = {};
BI.each(newCh, function (i, child) {
var node = self._getOptions(child);
var key = node.key == null ? i : node.key;
self._children[self._getChildName(i)] = children[key];
});
function sameVnode(vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key;
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]);
if (oldIndex >= 0) {
return oldIndex === newIndex
}
}
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
return children[key] = self._addElement(key, vnode);
}
function addVnodes(before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before);
}
}
function removeVnodes(vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]);
var key = node.key == null ? startIdx : node.key;
children[key]._destroy();
}
}
function insertBefore(insert, before, isNext) {
insert = self._getOptions(insert);
before = before && self._getOptions(before);
if (BI.isKey(insert.key)) {
if (before && children[before.key]) {
var next;
if (isNext) {
next = children[before.key].element.next();
} else {
next = children[before.key].element;
}
if (next.length > 0) {
next.before(children[insert.key].element);
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
throw "key is not defined";
}
}
return updated;
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated = this.updateChildren(o.items, items);
this.options.items = items;
return updated;
// var updated, i, len;
// for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
// if (!this._compare(o.items[i], items[i])) {
// updated = this.updateItemAt(i, items[i]) || updated;
// }
// }
// if (o.items.length > items.length) {
// var deleted = [];
// for (i = items.length; i < o.items.length; i++) {
// deleted.push(this._children[this._getChildName(i)]);
// delete this._children[this._getChildName(i)];
// }
// o.items.splice(items.length);
// BI.each(deleted, function (i, w) {
// w._destroy();
// })
// } else if (items.length > o.items.length) {
// for (i = o.items.length; i < items.length; i++) {
// this.addItemAt(i, items[i]);
// }
// }
// return updated;
},
stroke: function (items) {
var self = this;
BI.each(items, function (i, item) {

34
dist/demo.js vendored

@ -6872,19 +6872,29 @@ BI.shortcut("demo.list_view", Demo.Func);Demo.Func = BI.inherit(BI.Widget, {
},
_createItems: function () {
var items = BI.makeArray(1000, {
type: "demo.virtual_group_item"
var items = BI.map(BI.range(1000), function (i) {
return {
type: "demo.virtual_group_item",
value: i,
key: i + 1
}
});
items[0].value = BI.UUID();
return items;
},
render: function () {
var self = this;
var buttonGroupItems = self._createItems();
var virtualGroupItems = self._createItems();
return {
type: "bi.vertical",
vgap: 20,
items: [{
type: "bi.label",
cls: "layout-bg5",
height: 50,
text: "共1000个元素,演示button_group和virtual_group每次删除第一个元素,打开控制台看输出"
}, {
type: "bi.button_group",
width: 500,
height: 300,
@ -6894,17 +6904,14 @@ BI.shortcut("demo.list_view", Demo.Func);Demo.Func = BI.inherit(BI.Widget, {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}, {
type: "bi.center_adapt",
}],
items: this._createItems()
}, {
type: "bi.button",
text: "演示button_group的刷新",
handler: function () {
var items = self._createItems();
items.pop();
self.buttonGroup.populate(items);
buttonGroupItems.shift();
self.buttonGroup.populate(BI.deepClone(buttonGroupItems));
}
}, {
type: "bi.virtual_group",
@ -6916,17 +6923,14 @@ BI.shortcut("demo.list_view", Demo.Func);Demo.Func = BI.inherit(BI.Widget, {
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}, {
type: "bi.center_adapt",
}],
items: this._createItems()
}, {
type: "bi.button",
text: "演示virtual_group的刷新",
handler: function () {
var items = self._createItems();
items.pop();
self.virtualGroup.populate(items);
virtualGroupItems.shift();
self.virtualGroup.populate(BI.deepClone(virtualGroupItems));
}
}]
@ -6942,14 +6946,14 @@ Demo.Item = BI.inherit(BI.Widget, {
},
render: function () {
var self = this;
var self = this, o = this.options;
return {
type: "bi.label",
ref: function () {
self.label = this;
},
height: this.options.height,
text: "这是一个测试项" + BI.UUID()
text: "key:" + o.key + ",随机数" + BI.UUID()
}
},

2
dist/sliders.js vendored

@ -1862,7 +1862,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/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) {

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();

172
src/core/wrapper/layout.js

@ -347,31 +347,165 @@ BI.Layout = BI.inherit(BI.Widget, {
})
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated, i, len;
for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
if (!this._compare(o.items[i], items[i])) {
updated = this.updateItemAt(i, items[i]) || updated;
patchItem: function (oldVnode, vnode, index) {
if (!this._compare(oldVnode, vnode)) {
return this.updateItemAt(index, vnode);
}
},
updateChildren: function (oldCh, newCh) {
var self = this;
var oldStartIdx = 0, newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newEndIdx = newCh.length - 1;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx;
var idxInOld;
var elmToMove;
var before;
var updated;
var children = {};
BI.each(oldCh, function (i, child) {
child = self._getOptions(child);
var key = child.key == null ? i : child.key;
if (BI.isKey(key)) {
children[key] = self._children[self._getChildName(i)];
}
});
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (BI.isNull(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (BI.isNull(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode, oldStartIdx, newStartIdx)) {
updated = this.patchItem(oldStartVnode, newStartVnode, oldStartIdx) || updated;
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode, oldEndIdx, newEndIdx)) {
updated = this.patchItem(oldEndVnode, newEndVnode, oldEndIdx) || updated;
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
updated = this.patchItem(oldStartVnode, newEndVnode, oldStartIdx) || updated;
insertBefore(oldStartVnode, oldEndVnode, true);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
updated = this.patchItem(oldEndVnode, newStartVnode, oldEndIdx) || updated;
insertBefore(oldEndVnode, oldStartVnode);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
var node = addNode(newStartVnode);
insertBefore(node, oldStartVnode);
newStartVnode = newCh[++newStartIdx];
}
}
if (o.items.length > items.length) {
var deleted = [];
for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
if (oldStartIdx > oldEndIdx) {
before = BI.isNull(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(before, newCh, newStartIdx, newEndIdx);
} else if (newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
this._children = {};
BI.each(newCh, function (i, child) {
var node = self._getOptions(child);
var key = node.key == null ? i : node.key;
self._children[self._getChildName(i)] = children[key];
});
function sameVnode(vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key;
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w._destroy();
})
} else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) {
this.addItemAt(i, items[i]);
if (oldIndex >= 0) {
return oldIndex === newIndex
}
}
function addNode(vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? i : opt.key;
return children[key] = self._addElement(key, vnode);
}
function addVnodes(before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before);
}
}
function removeVnodes(vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]);
var key = node.key == null ? startIdx : node.key;
children[key]._destroy();
}
}
function insertBefore(insert, before, isNext) {
insert = self._getOptions(insert);
before = before && self._getOptions(before);
if (BI.isKey(insert.key)) {
if (before && children[before.key]) {
var next;
if (isNext) {
next = children[before.key].element.next();
} else {
next = children[before.key].element;
}
if (next.length > 0) {
next.before(children[insert.key].element);
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
self._getWrapper().append(children[insert.key].element);
}
} else {
throw "key is not defined";
}
}
return updated;
},
update: function (opt) {
var o = this.options;
var items = opt.items || [];
var updated = this.updateChildren(o.items, items);
this.options.items = items;
return updated;
// var updated, i, len;
// for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
// if (!this._compare(o.items[i], items[i])) {
// updated = this.updateItemAt(i, items[i]) || updated;
// }
// }
// if (o.items.length > items.length) {
// var deleted = [];
// for (i = items.length; i < o.items.length; i++) {
// deleted.push(this._children[this._getChildName(i)]);
// delete this._children[this._getChildName(i)];
// }
// o.items.splice(items.length);
// BI.each(deleted, function (i, w) {
// w._destroy();
// })
// } else if (items.length > o.items.length) {
// for (i = o.items.length; i < items.length; i++) {
// this.addItemAt(i, items[i]);
// }
// }
// return updated;
},
stroke: function (items) {

Loading…
Cancel
Save