guy 8 years ago
parent
commit
116856fd7a
  1. 80
      bi/core.js
  2. 259
      dist/core.js
  3. 178
      src/core/m.js
  4. 80
      src/core/mvc/fbi.js

80
bi/core.js

@ -173,6 +173,10 @@ BI.Factory = {
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -188,6 +192,10 @@ BI.Factory = {
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -274,11 +282,21 @@ BI.Factory = {
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -329,10 +347,17 @@ BI.Factory = {
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -695,12 +720,15 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -1124,18 +1152,23 @@ BI.Factory = {
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -1162,8 +1195,8 @@ BI.Factory = {
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -1230,21 +1263,21 @@ BI.Factory = {
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.element.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -1394,7 +1427,8 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -1766,7 +1800,9 @@ BI.Factory = {
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -1774,7 +1810,9 @@ BI.Factory = {
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;

259
dist/core.js vendored

@ -11189,6 +11189,10 @@ BI.Factory = {
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -11204,6 +11208,10 @@ BI.Factory = {
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -11290,11 +11298,21 @@ BI.Factory = {
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -11345,10 +11363,17 @@ BI.Factory = {
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -11711,12 +11736,15 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -12140,18 +12168,23 @@ BI.Factory = {
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -12178,8 +12211,8 @@ BI.Factory = {
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -12246,21 +12279,21 @@ BI.Factory = {
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.element.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -12410,7 +12443,8 @@ BI.Factory = {
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -12782,7 +12816,9 @@ BI.Factory = {
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -12790,7 +12826,9 @@ BI.Factory = {
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;
@ -23188,7 +23226,184 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
_init: function () {
BI.HorizontalFillLayoutLogic.superclass._init.apply(this, arguments);
}
});BI.Plugin = BI.Plugin || {};
});// BI.M = BI.inherit(BI.OB, {
// validationError: null,
//
// _init: function () {
// BI.M.superclass._init.apply(this, arguments);
// this.attributes = {};
// _.extend(this, _.pick(this.options, ['rootURL', 'parent', 'data', 'id']));
// this.set(this.options);
// this.changed = {};
// },
//
// _validate: function (attrs, options) {
// if (!options.validate || !this.validate) return true;
// attrs = _.extend({}, this.attributes, attrs);
// var error = this.validationError = this.validate(attrs, options) || null;
// if (!error) return true;
// this.fireEvent('invalid', error, this, _.extend(options, {validationError: error}));
// return false;
// },
//
// toJSON: function (options) {
// return _.clone(this.attributes);
// },
//
// get: function (attr) {
// return this.attributes[attr];
// },
//
// has: function (attr) {
// return _.has(this.attributes, attr);
// },
//
// matches: function (attrs) {
// var keys = _.keys(attrs), length = keys.length;
// var obj = Object(this.attributes);
// for (var i = 0; i < length; i++) {
// var key = keys[i];
// if (!_.isEqual(attrs[key], obj[key]) || !(key in obj)) return false;
// }
// return true;
// },
//
// set: function (key, val, options) {
// var attr, attrs, unset, changes, silent, changing, changed, prev, current;
// if (key == null) return this;
//
// // Handle both `"key", value` and `{key: value}` -style arguments.
// if (typeof key === 'object') {
// attrs = key;
// options = val;
// } else {
// (attrs = {})[key] = val;
// }
//
// options || (options = {});
//
// // Run validation.
// if (!this._validate(attrs, options)) return false;
//
// // Extract attributes and options.
// unset = options.unset;
// silent = options.silent;
// changes = [];
// changing = this._changing;
// this._changing = true;
//
// if (!changing) {
// this._previousAttributes = _.clone(this.attributes);
// this.changed = {};
// }
// current = this.attributes, prev = this._previousAttributes;
//
// // Check for changes of `id`.
// if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
//
// // For each `set` attribute, update or delete the current value.
// for (attr in attrs) {
// val = attrs[attr];
// if (!_.isEqual(current[attr], val)) changes.push(attr);
// if (!_.isEqual(prev[attr], val)) {
// this.changed[attr] = val;
// } else {
// delete this.changed[attr];
// }
// unset ? delete current[attr] : current[attr] = val;
// }
//
// // Trigger all relevant attribute changes.
// if (!silent) {
// if (changes.length) this._pending = options;
// for (var i = 0, length = changes.length; i < length; i++) {
// this.trigger('change:' + changes[i], this, current[changes[i]], options);
// }
// }
//
// // You might be wondering why there's a `while` loop here. Changes can
// // be recursively nested within `"change"` events.
// if (changing) return this;
// changed = BI.clone(this.changed);
// if (!silent) {
// while (this._pending) {
// options = this._pending;
// this._pending = false;
// this.trigger('change', changed, prev, this, options);
// }
// }
// this._pending = false;
// this._changing = false;
// if (!silent && changes.length) this.trigger("changed", changed, prev, this, options);
// return this;
// },
//
// unset: function (attr, options) {
// return this.set(attr, void 0, _.extend({}, options, {unset: true}));
// },
//
// clear: function (options) {
// var attrs = {};
// for (var key in this.attributes) attrs[key] = void 0;
// return this.set(attrs, _.extend({}, options, {unset: true}));
// },
//
// hasChanged: function (attr) {
// if (attr == null) return !_.isEmpty(this.changed);
// return _.has(this.changed, attr);
// },
//
// changedAttributes: function (diff) {
// if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
// var val, changed = false;
// var old = this._changing ? this._previousAttributes : this.attributes;
// for (var attr in diff) {
// if (_.isEqual(old[attr], (val = diff[attr]))) continue;
// (changed || (changed = {}))[attr] = val;
// }
// return changed;
// },
//
// // Get the previous value of an attribute, recorded at the time the last
// // `"change"` event was fired.
// previous: function (attr) {
// if (attr == null || !this._previousAttributes) return null;
// return this._previousAttributes[attr];
// },
//
// // Get all of the attributes of the model at the time of the previous
// // `"change"` event.
// previousAttributes: function () {
// return _.clone(this._previousAttributes);
// },
//
// destroy: function (options) {
// options = options ? _.clone(options) : {};
// var model = this;
// var success = options.success;
//
// var destroy = function () {
// model.stopListening();
// model.trigger('destroy', model.collection, model, options);
// };
//
// options.success = function (resp) {
// if (options.wait || model.isNew()) destroy();
// if (success) success(resp, model, options);
// if (!model.isNew()) model.trigger('sync', resp, model, options).trigger('delete', resp, model, options);
// };
//
// if (this.isNew()) {
// options.success();
// return false;
// }
// wrapError(this, options);
//
// var xhr = this.sync('delete', this, options);
// if (!options.wait) destroy();
// return xhr;
// },
// });BI.Plugin = BI.Plugin || {};
;
(function () {
var _WidgetsPlugin = {};

178
src/core/m.js

@ -0,0 +1,178 @@
// BI.M = BI.inherit(BI.OB, {
// validationError: null,
//
// _init: function () {
// BI.M.superclass._init.apply(this, arguments);
// this.attributes = {};
// _.extend(this, _.pick(this.options, ['rootURL', 'parent', 'data', 'id']));
// this.set(this.options);
// this.changed = {};
// },
//
// _validate: function (attrs, options) {
// if (!options.validate || !this.validate) return true;
// attrs = _.extend({}, this.attributes, attrs);
// var error = this.validationError = this.validate(attrs, options) || null;
// if (!error) return true;
// this.fireEvent('invalid', error, this, _.extend(options, {validationError: error}));
// return false;
// },
//
// toJSON: function (options) {
// return _.clone(this.attributes);
// },
//
// get: function (attr) {
// return this.attributes[attr];
// },
//
// has: function (attr) {
// return _.has(this.attributes, attr);
// },
//
// matches: function (attrs) {
// var keys = _.keys(attrs), length = keys.length;
// var obj = Object(this.attributes);
// for (var i = 0; i < length; i++) {
// var key = keys[i];
// if (!_.isEqual(attrs[key], obj[key]) || !(key in obj)) return false;
// }
// return true;
// },
//
// set: function (key, val, options) {
// var attr, attrs, unset, changes, silent, changing, changed, prev, current;
// if (key == null) return this;
//
// // Handle both `"key", value` and `{key: value}` -style arguments.
// if (typeof key === 'object') {
// attrs = key;
// options = val;
// } else {
// (attrs = {})[key] = val;
// }
//
// options || (options = {});
//
// // Run validation.
// if (!this._validate(attrs, options)) return false;
//
// // Extract attributes and options.
// unset = options.unset;
// silent = options.silent;
// changes = [];
// changing = this._changing;
// this._changing = true;
//
// if (!changing) {
// this._previousAttributes = _.clone(this.attributes);
// this.changed = {};
// }
// current = this.attributes, prev = this._previousAttributes;
//
// // Check for changes of `id`.
// if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
//
// // For each `set` attribute, update or delete the current value.
// for (attr in attrs) {
// val = attrs[attr];
// if (!_.isEqual(current[attr], val)) changes.push(attr);
// if (!_.isEqual(prev[attr], val)) {
// this.changed[attr] = val;
// } else {
// delete this.changed[attr];
// }
// unset ? delete current[attr] : current[attr] = val;
// }
//
// // Trigger all relevant attribute changes.
// if (!silent) {
// if (changes.length) this._pending = options;
// for (var i = 0, length = changes.length; i < length; i++) {
// this.trigger('change:' + changes[i], this, current[changes[i]], options);
// }
// }
//
// // You might be wondering why there's a `while` loop here. Changes can
// // be recursively nested within `"change"` events.
// if (changing) return this;
// changed = BI.clone(this.changed);
// if (!silent) {
// while (this._pending) {
// options = this._pending;
// this._pending = false;
// this.trigger('change', changed, prev, this, options);
// }
// }
// this._pending = false;
// this._changing = false;
// if (!silent && changes.length) this.trigger("changed", changed, prev, this, options);
// return this;
// },
//
// unset: function (attr, options) {
// return this.set(attr, void 0, _.extend({}, options, {unset: true}));
// },
//
// clear: function (options) {
// var attrs = {};
// for (var key in this.attributes) attrs[key] = void 0;
// return this.set(attrs, _.extend({}, options, {unset: true}));
// },
//
// hasChanged: function (attr) {
// if (attr == null) return !_.isEmpty(this.changed);
// return _.has(this.changed, attr);
// },
//
// changedAttributes: function (diff) {
// if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
// var val, changed = false;
// var old = this._changing ? this._previousAttributes : this.attributes;
// for (var attr in diff) {
// if (_.isEqual(old[attr], (val = diff[attr]))) continue;
// (changed || (changed = {}))[attr] = val;
// }
// return changed;
// },
//
// // Get the previous value of an attribute, recorded at the time the last
// // `"change"` event was fired.
// previous: function (attr) {
// if (attr == null || !this._previousAttributes) return null;
// return this._previousAttributes[attr];
// },
//
// // Get all of the attributes of the model at the time of the previous
// // `"change"` event.
// previousAttributes: function () {
// return _.clone(this._previousAttributes);
// },
//
// destroy: function (options) {
// options = options ? _.clone(options) : {};
// var model = this;
// var success = options.success;
//
// var destroy = function () {
// model.stopListening();
// model.trigger('destroy', model.collection, model, options);
// };
//
// options.success = function (resp) {
// if (options.wait || model.isNew()) destroy();
// if (success) success(resp, model, options);
// if (!model.isNew()) model.trigger('sync', resp, model, options).trigger('delete', resp, model, options);
// };
//
// if (this.isNew()) {
// options.success();
// return false;
// }
// wrapError(this, options);
//
// var xhr = this.sync('delete', this, options);
// if (!options.wait) destroy();
// return xhr;
// },
// });

80
src/core/mvc/fbi.js

@ -122,6 +122,10 @@
return this;
},
un: function () {
this.off.apply(this, arguments);
},
// Trigger one or many events, firing all bound callbacks. Callbacks are
// passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to
@ -137,6 +141,10 @@
return this;
},
fireEvent: function () {
this.trigger.apply(this, arguments);
},
// Inversion-of-control versions of `on` and `once`. Tell *this* object to
// listen to an event in another object ... keeping track of what it's
// listening to.
@ -223,11 +231,21 @@
var triggerEvents = function (events, args) {
var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
case 0:
while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
return;
case 2:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
return;
case 3:
while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
return;
default:
while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
return;
}
};
@ -278,10 +296,17 @@
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'ID',
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
init: function () {
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
this.init();
},
// Return a copy of the model's `attributes` object.
toJSON: function (options) {
@ -644,12 +669,15 @@
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// The JSON representation of a Collection is an array of the
// models' attributes.
toJSON: function (options) {
return this.map(function(model){ return model.toJSON(options); });
return this.map(function (model) {
return model.toJSON(options);
});
},
// Proxy `BI.sync` by default.
@ -1073,18 +1101,23 @@
return this.$el.find(selector);
},
_defaultConfig: function(){return {}},
_defaultConfig: function () {
return {}
},
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
//容器,默认放在this.element上
_vessel: function(){return this},
_vessel: function () {
return this
},
// **render** is the core function that your view should override, in order
// to populate its element (`this.el`), with the appropriate HTML. The
// convention is for **render** to always return `this`.
_render: function(vessel) {
render: function (vessel) {
return this;
},
@ -1111,8 +1144,8 @@
setElement: function (element) {
this.undelegateEvents();
this._setElement(element);
this.$vessel = this._vessel();
this._render(this.$vessel);
this.vessel = this._vessel();
this.render(this.vessel);
this.delegateEvents();
return this;
},
@ -1179,21 +1212,21 @@
// using `selector`). This only works for delegate-able events: not `focus`,
// `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.
delegate: function (eventName, selector, listener) {
this.$vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.on(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Clears all callbacks previously bound to the view by `delegateEvents`.
// You usually don't need to use this, but may wish to if you have multiple
// BI views attached to the same DOM element.
undelegateEvents: function () {
if (this.$vessel) this.$vessel.element.off('.delegateEvents' + this.cid);
if (this.vessel) this.vessel.element.off('.delegateEvents' + this.cid);
return this;
},
// A finer-grained `undelegateEvents` for removing a single delegated event.
// `selector` and `listener` are both optional.
undelegate: function (eventName, selector, listener) {
this.$vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
this.vessel.element.off(eventName + '.delegateEvents' + this.cid, selector, listener);
},
// Produces a DOM element to be assigned to your view. Exposed for
@ -1343,7 +1376,8 @@
// _init is an empty function by default. Override it with your own
// initialization logic.
_init: function(){},
_init: function () {
},
// Manually bind a single named route to a callback. For example:
//
@ -1715,7 +1749,9 @@
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){ return parent.apply(this, arguments); };
child = function () {
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
@ -1723,7 +1759,9 @@
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
var Surrogate = function(){ this.constructor = child; };
var Surrogate = function () {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;

Loading…
Cancel
Save