3vot-model
Version:
3VOT Model based on SpineJS
97 lines (82 loc) • 2.48 kB
JavaScript
(function() {
var Module, moduleKeywords,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
moduleKeywords = ['included', 'extended'];
Module = (function() {
Module.include = function(obj) {
var key, value, _ref;
if (!obj) {
throw new Error('include(obj) requires obj');
}
for (key in obj) {
value = obj[key];
if (__indexOf.call(moduleKeywords, key) < 0) {
this.prototype[key] = value;
}
}
if ((_ref = obj.included) != null) {
_ref.apply(this);
}
return this;
};
Module.extend = function(obj) {
var key, value, _ref;
if (!obj) {
throw new Error('extend(obj) requires obj');
}
for (key in obj) {
value = obj[key];
if (__indexOf.call(moduleKeywords, key) < 0) {
this[key] = value;
}
}
if ((_ref = obj.extended) != null) {
_ref.apply(this);
}
return this;
};
Module.proxy = function(func) {
return (function(_this) {
return function() {
return func.apply(_this, arguments);
};
})(this);
};
Module.prototype.proxy = function(func) {
return (function(_this) {
return function() {
return func.apply(_this, arguments);
};
})(this);
};
function Module() {
if (typeof this.init === "function") {
this.init.apply(this, arguments);
}
}
return Module;
})();
Module.create = Module.sub = function(instances, statics) {
var Result;
Result = (function(_super) {
__extends(Result, _super);
function Result() {
return Result.__super__.constructor.apply(this, arguments);
}
return Result;
})(this);
if (instances) {
Result.include(instances);
}
if (statics) {
Result.extend(statics);
}
if (typeof Result.unbind === "function") {
Result.unbind();
}
return Result;
};
module.exports = Module;
}).call(this);