You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wizardObject.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2015, Arthur Schiwon <blizzz@owncloud.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. OCA = OCA || {};
  7. (function() {
  8. var initializing = false;
  9. var superPattern = /xyz/.test(function() { xyz; }) ? /\b_super\b/ : /.*/;
  10. /**
  11. * @classdesc a base class that allows inheritance
  12. *
  13. * @abstrcact
  14. * @constructor
  15. */
  16. var WizardObject = function(){};
  17. WizardObject.subClass = function(properties) {
  18. var _super = this.prototype;
  19. initializing = true;
  20. var proto = new this();
  21. initializing = false;
  22. for (var name in properties) {
  23. proto[name] =
  24. typeof properties[name] === "function" &&
  25. typeof _super[name] === 'function' &&
  26. superPattern.test(properties[name]) ?
  27. (function (name, fn) {
  28. return function () {
  29. var tmp = this._super;
  30. this._super = _super[name];
  31. var ret = fn.apply(this, arguments);
  32. this._super = tmp;
  33. return ret;
  34. };
  35. })(name, properties[name]) :
  36. properties[name];
  37. };
  38. function Class() {
  39. if(!initializing && this.init) {
  40. this.init.apply(this, arguments);
  41. }
  42. }
  43. Class.prototype = proto;
  44. Class.constructor = Class;
  45. Class.subClass = arguments.callee;
  46. return Class;
  47. };
  48. WizardObject.constructor = WizardObject;
  49. OCA.LDAP.Wizard.WizardObject = WizardObject;
  50. })();