/** * @description The prototype of the extended function * @function * @obj The context of this */if (! Function.prototype.bind) {Function.prototype.bind = Function (obj) {var slice = [].slice,args = Slice.call (arguments,1), Self = This,nop = function () {},bound = function () {return self.apply (this instanceof NOP? This: (obj | | {}), Args.concat (Slice.call (arguments)))}nop.prototype = Self.prototype;bound.prototype = new NOP (); return bound}}/** * @description class constructor * @function * @public */var class = function (parent) {var Klass = function () {this.init.apply (this , arguments)}/* @init method*/klass.prototype.init = function () {}klass.fn = klass.prototype/* * @ description Inherit * @ functi On * @ public * @ Params {Object} parent Element * */IF (parent) {var subclass = function () {}subclass.prototype = parent; Klass.fn = new Subclass ();} /* * @ Description Hold Context * @ function * @ Public */klass.proxy = function (func) {var = this;return (function () {Func.ap Ply (Self,arguments)})}/* * @ Description */klass.extend = function (obj) {var extend = Obj.exTendfor (var i in obj) {if (Obj.hasownproperty (i)) {klass[i] = obj[i]}}extend && Extend (Klass)}klass.include = function (obj) {var included = Obj.includedfor (var i in obj) {if (Obj.hasownproperty (i)) {Klass.fn[i] = obj[i]}}included && included (Klass)}klass.fn.proxy = Klass.proxy;return klass}/* Create Instance button */var button = new Class (); Button.include ({init:function (element) {this.element = $ (' #aa ') This.element.click (This.proxy (This.click))}, click: function () {}})
Construct your own constructor function