guy 8 years ago
parent
commit
1f6e013999
  1. 4
      bi/base.js
  2. 40
      bi/core.js
  3. 4
      dist/base.js
  4. 40
      dist/core.js
  5. 4
      src/base/combination/group.button.js
  6. 8
      src/core/view.js
  7. 6
      src/core/widget.js
  8. 26
      src/core/wrapper/layout.js

4
bi/base.js

@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]); self.setValue([]);
break; break;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
btn.on(BI.Events.DESTROY, function () { btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn); BI.remove(self.buttons, btn);

40
bi/core.js

@ -4711,11 +4711,7 @@ BI.Widget = BI.inherit(BI.OB, {
removeWidget: function (nameOrWidget) { removeWidget: function (nameOrWidget) {
var self = this; var self = this;
if (BI.isWidget(nameOrWidget)) { if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, widget) { BI.remove(this._children, nameOrWidget);
if (widget === nameOrWidget) {
delete self._children[name];
}
})
} else { } else {
delete this._children[nameOrWidget]; delete this._children[nameOrWidget];
} }
@ -5607,7 +5603,7 @@ BI.View = BI.inherit(BI.V, {
} }
//采用静默方式读数据,该数据变化不引起data的change事件触发 //采用静默方式读数据,该数据变化不引起data的change事件触发
var success = options.success; var success = options.success;
this.read(BI.extend({ this.model.read(BI.extend({
silent: true silent: true
}, options, { }, options, {
success: function (data, model) { success: function (data, model) {
@ -5652,7 +5648,7 @@ BI.View = BI.inherit(BI.V, {
reading: function (options) { reading: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.read(BI.extend({}, options, { this.model.read(BI.extend({}, options, {
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
type: 'bi.vertical', type: 'bi.vertical',
@ -5675,7 +5671,7 @@ BI.View = BI.inherit(BI.V, {
updating: function (options) { updating: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.update(BI.extend({}, options, { this.model.update(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
@ -5699,7 +5695,7 @@ BI.View = BI.inherit(BI.V, {
patching: function (options) { patching: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.patch(BI.extend({}, options, { this.model.patch(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
@ -11261,6 +11257,7 @@ BI.Layout = BI.inherit(BI.Widget, {
w.on(BI.Events.DESTROY, function () { w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) { BI.each(self._children, function (name, child) {
if (child === w) { if (child === w) {
BI.remove(self._children, child);
self.removeItemAt(name | 0); self.removeItemAt(name | 0);
} }
}); });
@ -11414,7 +11411,7 @@ BI.Layout = BI.inherit(BI.Widget, {
for (var i = 0, len = this.options.items.length; i < len; i++) { for (var i = 0, len = this.options.items.length; i < len; i++) {
var child = this._children[this._getChildName(i)]; var child = this._children[this._getChildName(i)];
if (indexes.contains(i)) { if (indexes.contains(i)) {
deleted.push(child); child && deleted.push(child);
} else { } else {
newChildren[this._getChildName(newItems.length)] = child; newChildren[this._getChildName(newItems.length)] = child;
newItems.push(this.options.items[i]); newItems.push(this.options.items[i]);
@ -11489,26 +11486,32 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
var self = this, value = []; var self = this, value = [], child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
var v = self._children[self._getChildName(i)].getValue(); if (child = self._children[self._getChildName(i)]) {
v = BI.isArray(v) ? v : [v]; var v = child.getValue();
value = value.concat(v); v = BI.isArray(v) ? v : [v];
value = value.concat(v);
}
}); });
return value; return value;
}, },
setValue: function (v) { setValue: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setValue(v); if (child = self._children[self._getChildName(i)]) {
child.setValue(v);
}
}) })
}, },
setText: function (v) { setText: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setText(v); if (child = self._children[self._getChildName(i)]) {
child.setText(v);
}
}) })
}, },
@ -11525,6 +11528,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var deleted = []; var deleted = [];
for (i = items.length; i < o.items.length; i++) { for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]); deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {

4
dist/base.js vendored

@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]); self.setValue([]);
break; break;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
btn.on(BI.Events.DESTROY, function () { btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn); BI.remove(self.buttons, btn);

40
dist/core.js vendored

@ -14623,11 +14623,7 @@ BI.Widget = BI.inherit(BI.OB, {
removeWidget: function (nameOrWidget) { removeWidget: function (nameOrWidget) {
var self = this; var self = this;
if (BI.isWidget(nameOrWidget)) { if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, widget) { BI.remove(this._children, nameOrWidget);
if (widget === nameOrWidget) {
delete self._children[name];
}
})
} else { } else {
delete this._children[nameOrWidget]; delete this._children[nameOrWidget];
} }
@ -15519,7 +15515,7 @@ BI.View = BI.inherit(BI.V, {
} }
//采用静默方式读数据,该数据变化不引起data的change事件触发 //采用静默方式读数据,该数据变化不引起data的change事件触发
var success = options.success; var success = options.success;
this.read(BI.extend({ this.model.read(BI.extend({
silent: true silent: true
}, options, { }, options, {
success: function (data, model) { success: function (data, model) {
@ -15564,7 +15560,7 @@ BI.View = BI.inherit(BI.V, {
reading: function (options) { reading: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.read(BI.extend({}, options, { this.model.read(BI.extend({}, options, {
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
type: 'bi.vertical', type: 'bi.vertical',
@ -15587,7 +15583,7 @@ BI.View = BI.inherit(BI.V, {
updating: function (options) { updating: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.update(BI.extend({}, options, { this.model.update(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
@ -15611,7 +15607,7 @@ BI.View = BI.inherit(BI.V, {
patching: function (options) { patching: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.patch(BI.extend({}, options, { this.model.patch(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
@ -19394,6 +19390,7 @@ BI.Layout = BI.inherit(BI.Widget, {
w.on(BI.Events.DESTROY, function () { w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) { BI.each(self._children, function (name, child) {
if (child === w) { if (child === w) {
BI.remove(self._children, child);
self.removeItemAt(name | 0); self.removeItemAt(name | 0);
} }
}); });
@ -19547,7 +19544,7 @@ BI.Layout = BI.inherit(BI.Widget, {
for (var i = 0, len = this.options.items.length; i < len; i++) { for (var i = 0, len = this.options.items.length; i < len; i++) {
var child = this._children[this._getChildName(i)]; var child = this._children[this._getChildName(i)];
if (indexes.contains(i)) { if (indexes.contains(i)) {
deleted.push(child); child && deleted.push(child);
} else { } else {
newChildren[this._getChildName(newItems.length)] = child; newChildren[this._getChildName(newItems.length)] = child;
newItems.push(this.options.items[i]); newItems.push(this.options.items[i]);
@ -19622,26 +19619,32 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
var self = this, value = []; var self = this, value = [], child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
var v = self._children[self._getChildName(i)].getValue(); if (child = self._children[self._getChildName(i)]) {
v = BI.isArray(v) ? v : [v]; var v = child.getValue();
value = value.concat(v); v = BI.isArray(v) ? v : [v];
value = value.concat(v);
}
}); });
return value; return value;
}, },
setValue: function (v) { setValue: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setValue(v); if (child = self._children[self._getChildName(i)]) {
child.setValue(v);
}
}) })
}, },
setText: function (v) { setText: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setText(v); if (child = self._children[self._getChildName(i)]) {
child.setText(v);
}
}) })
}, },
@ -19658,6 +19661,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var deleted = []; var deleted = [];
for (i = items.length; i < o.items.length; i++) { for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]); deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {

4
src/base/combination/group.button.js

@ -57,9 +57,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]); self.setValue([]);
break; break;
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
} }
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
btn.on(BI.Events.DESTROY, function () { btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn); BI.remove(self.buttons, btn);

8
src/core/view.js

@ -327,7 +327,7 @@ BI.View = BI.inherit(BI.V, {
} }
//采用静默方式读数据,该数据变化不引起data的change事件触发 //采用静默方式读数据,该数据变化不引起data的change事件触发
var success = options.success; var success = options.success;
this.read(BI.extend({ this.model.read(BI.extend({
silent: true silent: true
}, options, { }, options, {
success: function (data, model) { success: function (data, model) {
@ -372,7 +372,7 @@ BI.View = BI.inherit(BI.V, {
reading: function (options) { reading: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.read(BI.extend({}, options, { this.model.read(BI.extend({}, options, {
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
type: 'bi.vertical', type: 'bi.vertical',
@ -395,7 +395,7 @@ BI.View = BI.inherit(BI.V, {
updating: function (options) { updating: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.update(BI.extend({}, options, { this.model.update(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({
@ -419,7 +419,7 @@ BI.View = BI.inherit(BI.V, {
patching: function (options) { patching: function (options) {
var self = this; var self = this;
var name = BI.UUID(); var name = BI.UUID();
this.patch(BI.extend({}, options, { this.model.patch(BI.extend({}, options, {
noset: true, noset: true,
beforeSend: function () { beforeSend: function () {
var loading = BI.createWidget({ var loading = BI.createWidget({

6
src/core/widget.js

@ -288,11 +288,7 @@ BI.Widget = BI.inherit(BI.OB, {
removeWidget: function (nameOrWidget) { removeWidget: function (nameOrWidget) {
var self = this; var self = this;
if (BI.isWidget(nameOrWidget)) { if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, widget) { BI.remove(this._children, nameOrWidget);
if (widget === nameOrWidget) {
delete self._children[name];
}
})
} else { } else {
delete this._children[nameOrWidget]; delete this._children[nameOrWidget];
} }

26
src/core/wrapper/layout.js

@ -74,6 +74,7 @@ BI.Layout = BI.inherit(BI.Widget, {
w.on(BI.Events.DESTROY, function () { w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) { BI.each(self._children, function (name, child) {
if (child === w) { if (child === w) {
BI.remove(self._children, child);
self.removeItemAt(name | 0); self.removeItemAt(name | 0);
} }
}); });
@ -227,7 +228,7 @@ BI.Layout = BI.inherit(BI.Widget, {
for (var i = 0, len = this.options.items.length; i < len; i++) { for (var i = 0, len = this.options.items.length; i < len; i++) {
var child = this._children[this._getChildName(i)]; var child = this._children[this._getChildName(i)];
if (indexes.contains(i)) { if (indexes.contains(i)) {
deleted.push(child); child && deleted.push(child);
} else { } else {
newChildren[this._getChildName(newItems.length)] = child; newChildren[this._getChildName(newItems.length)] = child;
newItems.push(this.options.items[i]); newItems.push(this.options.items[i]);
@ -302,26 +303,32 @@ BI.Layout = BI.inherit(BI.Widget, {
}, },
getValue: function () { getValue: function () {
var self = this, value = []; var self = this, value = [], child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
var v = self._children[self._getChildName(i)].getValue(); if (child = self._children[self._getChildName(i)]) {
v = BI.isArray(v) ? v : [v]; var v = child.getValue();
value = value.concat(v); v = BI.isArray(v) ? v : [v];
value = value.concat(v);
}
}); });
return value; return value;
}, },
setValue: function (v) { setValue: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setValue(v); if (child = self._children[self._getChildName(i)]) {
child.setValue(v);
}
}) })
}, },
setText: function (v) { setText: function (v) {
var self = this; var self = this, child;
BI.each(this.options.items, function (i) { BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setText(v); if (child = self._children[self._getChildName(i)]) {
child.setText(v);
}
}) })
}, },
@ -338,6 +345,7 @@ BI.Layout = BI.inherit(BI.Widget, {
var deleted = []; var deleted = [];
for (i = items.length; i < o.items.length; i++) { for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]); deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {

Loading…
Cancel
Save