tools.js 824 B

123456789101112131415161718192021222324
  1. function heriter(destination, source) {
  2. function initClassIfNecessary(obj) {
  3. if( typeof obj["_super"] == "undefined" ) {
  4. obj["_super"] = function() {
  5. var methodName = arguments[0];
  6. var parameters = arguments[1];
  7. return this["__parent_methods"][methodName].apply(this, parameters);
  8. }
  9. }
  10. if( typeof obj["__parent_methods"] == "undefined" ) {
  11. obj["__parent_methods"] = {};
  12. }
  13. }
  14. for (var element in source) {
  15. if( typeof destination[element] != "undefined" ) {
  16. initClassIfNecessary(destination);
  17. destination["__parent_methods"][element] = source[element];
  18. } else {
  19. destination[element] = source[element];
  20. }
  21. }
  22. }