guy 7 years ago
parent
commit
f6a3473356
  1. 35
      bi/core.js
  2. 35
      docs/core.js
  3. 9
      src/core/model.js
  4. 7
      src/core/mvc/fbi.js
  5. 19
      src/core/view.js

35
bi/core.js

@ -351,12 +351,9 @@ BI.Factory = {
return {} return {}
}, },
init: function () {
},
// _init is an empty function by default. Override it with your own // _init is an empty function by default. Override it with your own
// initialization logic. // initialization logic.
_init: function () { _init: function () {
this.init();
}, },
// Return a copy of the model's `attributes` object. // Return a copy of the model's `attributes` object.
@ -1204,9 +1201,9 @@ BI.Factory = {
setVisible: function (visible) { setVisible: function (visible) {
this.options.invisible = !visible; this.options.invisible = !visible;
if (visible) { if (visible) {
this.element.show(); this.element.css("display", "");
} else { } else {
this.element.hide(); this.element.css("display", "none");
} }
}, },
@ -4750,11 +4747,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.purgeListeners(); this.purgeListeners();
} }
});BI.Model = BI.inherit(BI.M, { });BI.Model = BI.inherit(BI.M, {
props: {},
init: null,
destroyed: null,
_defaultConfig: function () { _defaultConfig: function () {
return { return BI.extend({
"default": "just a default", "default": "just a default",
"current": void 0 "current": void 0
} }, this.props)
}, },
_static: function () { _static: function () {
@ -4788,6 +4789,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._read = BI.debounce(BI.bind(this.fetch, this), 30);
this._save = BI.debounce(BI.bind(this.save, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30);
this._F = []; this._F = [];
this.init && this.init();
}, },
toJSON: function () { toJSON: function () {
@ -5230,8 +5232,16 @@ BI.Widget = BI.inherit(BI.OB, {
*/ */
BI.View = BI.inherit(BI.V, { BI.View = BI.inherit(BI.V, {
//生命周期函数
beforeCreate: null,
created: null,
destroyed: null,
_init: function () { _init: function () {
BI.View.superclass._init.apply(this, arguments); BI.View.superclass._init.apply(this, arguments);
this.beforeCreate && this.beforeCreate();
var self = this; var self = this;
this.listenTo(this.model, "change:current", function (obj, val) { this.listenTo(this.model, "change:current", function (obj, val) {
if (BI.isNotNull(val) && val.length > 0) { if (BI.isNotNull(val) && val.length > 0) {
@ -5275,7 +5285,8 @@ BI.View = BI.inherit(BI.V, {
return f.apply(this, arguments); return f.apply(this, arguments);
}, self); }, self);
} }
}) });
this.created && this.created();
}, },
change: function (changed, prev) { change: function (changed, prev) {
@ -5720,7 +5731,7 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.off(); this.off();
}, },
@ -5730,14 +5741,10 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.remove(); this.remove();
this.trigger(BI.Events.DESTROY); this.trigger(BI.Events.DESTROY);
this.off(); this.off();
},
destroyed: function () {
} }
});(function () { });(function () {

35
docs/core.js

@ -11493,12 +11493,9 @@ BI.Factory = {
return {} return {}
}, },
init: function () {
},
// _init is an empty function by default. Override it with your own // _init is an empty function by default. Override it with your own
// initialization logic. // initialization logic.
_init: function () { _init: function () {
this.init();
}, },
// Return a copy of the model's `attributes` object. // Return a copy of the model's `attributes` object.
@ -12346,9 +12343,9 @@ BI.Factory = {
setVisible: function (visible) { setVisible: function (visible) {
this.options.invisible = !visible; this.options.invisible = !visible;
if (visible) { if (visible) {
this.element.show(); this.element.css("display", "");
} else { } else {
this.element.hide(); this.element.css("display", "none");
} }
}, },
@ -14752,11 +14749,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.purgeListeners(); this.purgeListeners();
} }
});BI.Model = BI.inherit(BI.M, { });BI.Model = BI.inherit(BI.M, {
props: {},
init: null,
destroyed: null,
_defaultConfig: function () { _defaultConfig: function () {
return { return BI.extend({
"default": "just a default", "default": "just a default",
"current": void 0 "current": void 0
} }, this.props)
}, },
_static: function () { _static: function () {
@ -14790,6 +14791,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._read = BI.debounce(BI.bind(this.fetch, this), 30);
this._save = BI.debounce(BI.bind(this.save, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30);
this._F = []; this._F = [];
this.init && this.init();
}, },
toJSON: function () { toJSON: function () {
@ -15232,8 +15234,16 @@ BI.Widget = BI.inherit(BI.OB, {
*/ */
BI.View = BI.inherit(BI.V, { BI.View = BI.inherit(BI.V, {
//生命周期函数
beforeCreate: null,
created: null,
destroyed: null,
_init: function () { _init: function () {
BI.View.superclass._init.apply(this, arguments); BI.View.superclass._init.apply(this, arguments);
this.beforeCreate && this.beforeCreate();
var self = this; var self = this;
this.listenTo(this.model, "change:current", function (obj, val) { this.listenTo(this.model, "change:current", function (obj, val) {
if (BI.isNotNull(val) && val.length > 0) { if (BI.isNotNull(val) && val.length > 0) {
@ -15277,7 +15287,8 @@ BI.View = BI.inherit(BI.V, {
return f.apply(this, arguments); return f.apply(this, arguments);
}, self); }, self);
} }
}) });
this.created && this.created();
}, },
change: function (changed, prev) { change: function (changed, prev) {
@ -15722,7 +15733,7 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.off(); this.off();
}, },
@ -15732,14 +15743,10 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.remove(); this.remove();
this.trigger(BI.Events.DESTROY); this.trigger(BI.Events.DESTROY);
this.off(); this.off();
},
destroyed: function () {
} }
});(function () { });(function () {

9
src/core/model.js

@ -1,9 +1,13 @@
BI.Model = BI.inherit(BI.M, { BI.Model = BI.inherit(BI.M, {
props: {},
init: null,
destroyed: null,
_defaultConfig: function () { _defaultConfig: function () {
return { return BI.extend({
"default": "just a default", "default": "just a default",
"current": void 0 "current": void 0
} }, this.props)
}, },
_static: function () { _static: function () {
@ -37,6 +41,7 @@ BI.Model = BI.inherit(BI.M, {
this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._read = BI.debounce(BI.bind(this.fetch, this), 30);
this._save = BI.debounce(BI.bind(this.save, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30);
this._F = []; this._F = [];
this.init && this.init();
}, },
toJSON: function () { toJSON: function () {

7
src/core/mvc/fbi.js

@ -300,12 +300,9 @@
return {} return {}
}, },
init: function () {
},
// _init is an empty function by default. Override it with your own // _init is an empty function by default. Override it with your own
// initialization logic. // initialization logic.
_init: function () { _init: function () {
this.init();
}, },
// Return a copy of the model's `attributes` object. // Return a copy of the model's `attributes` object.
@ -1153,9 +1150,9 @@
setVisible: function (visible) { setVisible: function (visible) {
this.options.invisible = !visible; this.options.invisible = !visible;
if (visible) { if (visible) {
this.element.show(); this.element.css("display", "");
} else { } else {
this.element.hide(); this.element.css("display", "none");
} }
}, },

19
src/core/view.js

@ -5,8 +5,16 @@
*/ */
BI.View = BI.inherit(BI.V, { BI.View = BI.inherit(BI.V, {
//生命周期函数
beforeCreate: null,
created: null,
destroyed: null,
_init: function () { _init: function () {
BI.View.superclass._init.apply(this, arguments); BI.View.superclass._init.apply(this, arguments);
this.beforeCreate && this.beforeCreate();
var self = this; var self = this;
this.listenTo(this.model, "change:current", function (obj, val) { this.listenTo(this.model, "change:current", function (obj, val) {
if (BI.isNotNull(val) && val.length > 0) { if (BI.isNotNull(val) && val.length > 0) {
@ -50,7 +58,8 @@ BI.View = BI.inherit(BI.V, {
return f.apply(this, arguments); return f.apply(this, arguments);
}, self); }, self);
} }
}) });
this.created && this.created();
}, },
change: function (changed, prev) { change: function (changed, prev) {
@ -495,7 +504,7 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.off(); this.off();
}, },
@ -505,13 +514,9 @@ BI.View = BI.inherit(BI.V, {
}); });
delete this._cardLayouts; delete this._cardLayouts;
delete this._cards; delete this._cards;
this.destroyed(); this.destroyed && this.destroyed();
this.remove(); this.remove();
this.trigger(BI.Events.DESTROY); this.trigger(BI.Events.DESTROY);
this.off(); this.off();
},
destroyed: function () {
} }
}); });
Loading…
Cancel
Save