guy 7 years ago
parent
commit
1723835632
  1. 4
      demo/js/config/core.js
  2. 10
      demo/js/core/abstract/demo.virtual_group.js
  3. 16
      dist/base.js
  4. 36
      dist/core.js
  5. 6
      src/base/collection/collection.js
  6. 8
      src/base/grid/grid.js
  7. 2
      src/base/layer/layer.floatbox.js
  8. 34
      src/core/wrapper/layout.js

4
demo/js/config/core.js

@ -141,10 +141,6 @@ Demo.CORE_CONFIG = [{
pId: 10202,
text: "bi.layer_popup",
value: "demo.layer_popup"
}, {
pId: 10202,
text: "bi.layer_scroll",
value: "demo.layer_scroll"
}, {
pId: 10202,
text: "bi.layer_searcher",

10
demo/js/core/abstract/demo.virtual_group.js

@ -18,7 +18,7 @@ Demo.Func = BI.inherit(BI.Widget, {
vgap: 20,
items: [{
type: "bi.virtual_group",
width: 200,
width: 500,
height: 300,
ref: function () {
self.buttonMap = this;
@ -34,7 +34,9 @@ Demo.Func = BI.inherit(BI.Widget, {
type: "bi.button",
text: "点击刷新",
handler: function () {
self.buttonMap.populate(self._createItems());
var items = self._createItems();
items.pop();
self.buttonMap.populate(items);
}
}]
@ -69,6 +71,10 @@ Demo.Item = BI.inherit(BI.Widget, {
created: function () {
console.log("创建了一项");
},
destroyed: function(){
console.log("删除了一项");
}
});
$.shortcut("demo.virtual_group_item", Demo.Item);

16
dist/base.js vendored

@ -2672,11 +2672,7 @@ BI.Collection = BI.inherit(BI.Widget, {
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
BI.createWidget({
type: "bi.absolute",
element: this.container,
items: addedItems
});
this.container.addItems(addedItems);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
},
@ -14520,7 +14516,7 @@ $.extend(BI, {
BI.Grid = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid",
baseCls: "bi-grid-view",
width: 400,
height: 300,
overflowX: true,
@ -14688,11 +14684,7 @@ BI.Grid = BI.inherit(BI.Widget, {
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
BI.createWidget({
type: "bi.absolute",
element: this.container,
items: addedItems
});
this.container.addItems(addedItems);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
}
@ -14828,7 +14820,7 @@ BI.FloatBox = BI.inherit(BI.Widget, {
});
this._center = BI.createWidget();
this._north = BI.createWidget();
this.element.draggable({
this.element.draggable && this.element.draggable({
handle: ".bi-message-title",
drag: function (e, ui) {
var W = $("body").width(), H = $("body").height();

36
dist/core.js vendored

@ -19419,7 +19419,7 @@ BI.Layout = BI.inherit(BI.Widget, {
return this.element;
},
_addItem: function (index, item) {
_addItemAt: function (index, item) {
for (var i = this.options.items.length; i > index; i--) {
this._children[this._getChildName(i)] = this._children[this._getChildName(i - 1)];
}
@ -19427,7 +19427,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items.splice(index, 0, item);
},
_removeItem: function (index) {
_removeItemAt: function (index) {
for (var i = index; i < this.options.items.length - 1; i++) {
this._children[this._getChildName(i)] = this._children[this._getChildName(i + 1)];
}
@ -19458,7 +19458,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (index < 0 || index > this.options.items.length) {
return;
}
this._addItem(index, item);
this._addItemAt(index, item);
var w = this._addElement(index, item);
if (index > 0) {
this._children[this._getChildName(index - 1)].element.after(w.element);
@ -19474,7 +19474,7 @@ BI.Layout = BI.inherit(BI.Widget, {
return;
}
this._children[this._getChildName(index)].destroy();
this._removeItem(index);
this._removeItemAt(index);
},
updateItemAt: function (index, item) {
@ -19498,17 +19498,35 @@ BI.Layout = BI.inherit(BI.Widget, {
},
addItems: function (items) {
var self = this;
var self = this, o = this.options;
var fragment = document.createDocumentFragment();
var added = [];
BI.each(items, function (i, item) {
self.addItem(item);
var w = self._addElement(o.items.length, item);
o.items.push(item);
added.push(w);
fragment.appendChild(w.element[0]);
});
this._getWrapper().append(fragment);
BI.each(added, function (i, w) {
w._mount();
})
},
prependItems: function (items) {
items = items || [];
var fragment = document.createDocumentFragment();
var added = [];
for (var i = items.length - 1; i >= 0; i--) {
this.prependItem(items[i]);
}
var w = this._addElement(this.options.items.length, items[i]);
this.options.items.unshift(items[i]);
added.push(w);
fragment.appendChild(w.element[0]);
}
this._getWrapper().prepend(fragment);
BI.each(added, function (i, w) {
w._mount();
})
},
getValue: function () {
@ -19539,7 +19557,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var o = this.options;
var items = item.items;
var updated = false, i, len;
for (i = 0, len = o.items.length; i < len; i++) {
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;
}

6
src/base/collection/collection.js

@ -188,11 +188,7 @@ BI.Collection = BI.inherit(BI.Widget, {
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
BI.createWidget({
type: "bi.absolute",
element: this.container,
items: addedItems
});
this.container.addItems(addedItems);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
},

8
src/base/grid/grid.js

@ -8,7 +8,7 @@
BI.Grid = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid",
baseCls: "bi-grid-view",
width: 400,
height: 300,
overflowX: true,
@ -176,11 +176,7 @@ BI.Grid = BI.inherit(BI.Widget, {
BI.each(addSet, function (index) {
addedItems.push(renderedCells[index])
});
BI.createWidget({
type: "bi.absolute",
element: this.container,
items: addedItems
});
this.container.addItems(addedItems);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
}

2
src/base/layer/layer.floatbox.js

@ -19,7 +19,7 @@ BI.FloatBox = BI.inherit(BI.Widget, {
});
this._center = BI.createWidget();
this._north = BI.createWidget();
this.element.draggable({
this.element.draggable && this.element.draggable({
handle: ".bi-message-title",
drag: function (e, ui) {
var W = $("body").width(), H = $("body").height();

34
src/core/wrapper/layout.js

@ -161,7 +161,7 @@ BI.Layout = BI.inherit(BI.Widget, {
return this.element;
},
_addItem: function (index, item) {
_addItemAt: function (index, item) {
for (var i = this.options.items.length; i > index; i--) {
this._children[this._getChildName(i)] = this._children[this._getChildName(i - 1)];
}
@ -169,7 +169,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items.splice(index, 0, item);
},
_removeItem: function (index) {
_removeItemAt: function (index) {
for (var i = index; i < this.options.items.length - 1; i++) {
this._children[this._getChildName(i)] = this._children[this._getChildName(i + 1)];
}
@ -200,7 +200,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (index < 0 || index > this.options.items.length) {
return;
}
this._addItem(index, item);
this._addItemAt(index, item);
var w = this._addElement(index, item);
if (index > 0) {
this._children[this._getChildName(index - 1)].element.after(w.element);
@ -216,7 +216,7 @@ BI.Layout = BI.inherit(BI.Widget, {
return;
}
this._children[this._getChildName(index)].destroy();
this._removeItem(index);
this._removeItemAt(index);
},
updateItemAt: function (index, item) {
@ -240,17 +240,35 @@ BI.Layout = BI.inherit(BI.Widget, {
},
addItems: function (items) {
var self = this;
var self = this, o = this.options;
var fragment = document.createDocumentFragment();
var added = [];
BI.each(items, function (i, item) {
self.addItem(item);
var w = self._addElement(o.items.length, item);
o.items.push(item);
added.push(w);
fragment.appendChild(w.element[0]);
});
this._getWrapper().append(fragment);
BI.each(added, function (i, w) {
w._mount();
})
},
prependItems: function (items) {
items = items || [];
var fragment = document.createDocumentFragment();
var added = [];
for (var i = items.length - 1; i >= 0; i--) {
this.prependItem(items[i]);
var w = this._addElement(this.options.items.length, items[i]);
this.options.items.unshift(items[i]);
added.push(w);
fragment.appendChild(w.element[0]);
}
this._getWrapper().prepend(fragment);
BI.each(added, function (i, w) {
w._mount();
})
},
getValue: function () {
@ -281,7 +299,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var o = this.options;
var items = item.items;
var updated = false, i, len;
for (i = 0, len = o.items.length; i < len; i++) {
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;
}

Loading…
Cancel
Save