mui.class.js 940 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function($) {
  2. var initializing = false,
  3. fnTest = /xyz/.test(function() {
  4. xyz;
  5. }) ? /\b_super\b/ : /.*/;
  6. var Class = function() {};
  7. Class.extend = function(prop) {
  8. var _super = this.prototype;
  9. initializing = true;
  10. var prototype = new this();
  11. initializing = false;
  12. for (var name in prop) {
  13. prototype[name] = typeof prop[name] == "function" &&
  14. typeof _super[name] == "function" && fnTest.test(prop[name]) ?
  15. (function(name, fn) {
  16. return function() {
  17. var tmp = this._super;
  18. this._super = _super[name];
  19. var ret = fn.apply(this, arguments);
  20. this._super = tmp;
  21. return ret;
  22. };
  23. })(name, prop[name]) :
  24. prop[name];
  25. }
  26. function Class() {
  27. if (!initializing && this.init)
  28. this.init.apply(this, arguments);
  29. }
  30. Class.prototype = prototype;
  31. Class.prototype.constructor = Class;
  32. Class.extend = arguments.callee;
  33. return Class;
  34. };
  35. $.Class = Class;
  36. })(mui);