-
Notifications
You must be signed in to change notification settings - Fork 4
/
js.class.min.js
11 lines (11 loc) · 2.71 KB
/
js.class.min.js
1
2
3
4
5
6
7
8
9
10
11
/*--------------------------------------------*
* Info: https://github.com/kilhage/class.js
*--------------------------------------------*
* Copyright 2011, Emil Kilhage
* Released under the MIT License
*--------------------------------------------*
* Environment-release: js
* Last Update: 2011-04-29 18:10:51
* Version 1.1.0
*--------------------------------------------*/
var Class=function(a){function w(b,c,d){var e,g,k,l=function(){if(k===a){var b;k={};for(b in c)h.call(c[b])===j&&(k[b]=v(c[b]))}return k};d===a&&(d=c);for(e in b)i.call(b,e)&&(g=b[e],d[e]=h.call(g)===j&&f.test(g)?u(e,g,c[e],l):g)}function v(a){return function(){return a.apply(this[d],arguments)}}function u(a,b,c,e){var f=g.test(b),k=f,l=h.call(c)===j?function(){return c.apply(this,arguments)}:function(){throw new p(a)};return function(){var a=this,c=a._parent,g,h,j;a._parent=l;if(k){if(f){f=!1,j=e();for(h in j)i.call(j,h)&&(l[h]=j[h])}l[d]=a}g=b.apply(a,arguments),a._parent=c;return g}}function t(){function d(e){var f=this;if(f instanceof d)b===!1&&(c!==f.init&&("init"in f&&h.call(f.init)===j?c=f.init:c=a),c!==a&&c.apply(f,e&&e.callee===d?e:arguments));else return new d(arguments)}var c;return d}function s(a){return!!a&&a.extend===q.extend}function r(a){return q.extend(a)}function q(){}function p(a){l.apply(this,arguments),this.message=c+"::Parent Class doesn't have the method: "+a}function o(a){l.apply(this,arguments),this.message=c+"::"+a}"use strict";var b=!1,c="Class",d=c+(new Date).getTime(),e=function(){this._parent()},f=/\b_parent\b/,g=f.test(e)?/\b_parent\b\./:f=/.*/,h=Object.prototype.toString,i=Object.prototype.hasOwnProperty,j=h.call(e),k=h.call({}),l=Error,m,n={};m=o.prototype=new l,n[m.name="InvalidClassDefinition"]=o,m=p.prototype=new l,n[m.name="InvalidParentMethodCall"]=p,q.extend=function(a){var c=t(),d,e=this,f,g=e.prototype,j;if(!a||h.call(a)!==k){j="Unable to "+(e===q?"extend":"create")+" class";throw new o(j)}for(d in e)i.call(e,d)&&(c[d]=e[d]);if(a.hasOwnProperty("prototype")){f=a.prototype;if(f&&h.call(f)===k)delete a.prototype,w(a,e,c),a=a.prototype=f;else{j="Invalid type on properties.prototype("+f+"), literal object expected";throw new o(j)}}b=!0,f=new e,b=!1,w(a,g,f),c.constructor=f.constructor=c,c.prototype=f,c.inherits=function(a){return a===e||e.inherits(a)};return c},q.inherits=function(){return!1},q.addMethods=function(a,b,c){if(a&&h.call(a)===k)b=a.prototype,c=this.prototype,b&&h.call(b)===k?(w(b,c),delete a.prototype,w(a,this),a.prototype=b):w(a,c);else throw new o("Unable to add methods to class")},q.prototype.addMethods=function(a){if(a&&h.call(a)===k)w(a,this);else throw new o("Unable to add methods to instance")},r.is=s,r.makeClass=t,r.fnSearch=f,r.parentFnSearch=g,r.errors=n,r.version="1.1.0";return r}();