diff --git a/index.html b/index.html new file mode 100644 index 0000000..b2c0874 --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ + + + + Oop.JS: Object Oriented JavaScript Class Library + + + + + + \ No newline at end of file diff --git a/oop.js b/oop.js new file mode 100644 index 0000000..848526b --- /dev/null +++ b/oop.js @@ -0,0 +1,68 @@ +(function(window, undefined) { + + var oop = (function(){ + + var Class = function (klass) { + var Klass, definitor; + + Klass = function (conf) { + var that = this; + var conf = conf || {}; + this.type = klass; + + if (Klass.parent && Klass.parent.hasOwnProperty("construct")) { Klass.parent.construct.call(this, conf); + } + + if (Klass.prototype.hasOwnProperty("construct")) { + Klass.prototype.construct.call(this, conf); } + + return this; + }; + + definitor = { + + "extends": (function () { + var F = function () {}; + return function (Parent) { + F.prototype = Parent.prototype; + Klass.prototype = new F(); + Klass.parent = Parent.prototype; + Klass.prototype.constructor = Klass; + + return definitor; + } + }()), + + "construct": function (func) { + Klass.prototype.construct = func; + + return definitor; + }, + + "method": function (member, param) { + Klass.prototype[member] = param; + + return definitor; + }, + + "build": function () { + return Klass; + } + + }; + + return definitor; + + }; + + var core = { + "Class": Class + }; + + return core; + + })(); + + window.oop = oop; + +})(window); \ No newline at end of file