Mercurial > pub > ImplabJs
comparison core/src/js/declare/override.js @ 29:acdcdf1a8d21
repository reorganized
| author | cin |
|---|---|
| date | Tue, 26 Jun 2018 19:35:44 +0300 |
| parents | src/implab/declare/override.js@9663631cbdb9 |
| children |
comparison
equal
deleted
inserted
replaced
| 28:d796bbbe558c | 29:acdcdf1a8d21 |
|---|---|
| 1 "use strict"; | |
| 2 define([], function () { | |
| 3 var slice = Array.prototype.slice; | |
| 4 var override = function (method) { | |
| 5 var proxy; | |
| 6 | |
| 7 /** @this target object */ | |
| 8 proxy = function () { | |
| 9 var me = this; | |
| 10 var inherited = (this.getInherited && this.getInherited(proxy.nom, { | |
| 11 callee: proxy | |
| 12 })) || function () {}; | |
| 13 | |
| 14 return method.apply(me, [function () { | |
| 15 return inherited.apply(me, arguments); | |
| 16 }].concat(slice.apply(arguments))); | |
| 17 }; | |
| 18 | |
| 19 proxy.method = method; | |
| 20 proxy.overrides = true; | |
| 21 | |
| 22 return proxy; | |
| 23 }; | |
| 24 | |
| 25 override.before = function (method) { | |
| 26 var proxy; | |
| 27 | |
| 28 /** @this target object */ | |
| 29 proxy = function () { | |
| 30 var me = this; | |
| 31 var inherited = (this.getInherited && this.getInherited(proxy.nom, { | |
| 32 callee: proxy | |
| 33 })) || function () {}; | |
| 34 | |
| 35 | |
| 36 method.apply(me, arguments); | |
| 37 return inherited.apply(me, arguments); | |
| 38 }; | |
| 39 | |
| 40 proxy.method = method; | |
| 41 proxy.overrides = true; | |
| 42 | |
| 43 return proxy; | |
| 44 }; | |
| 45 | |
| 46 override.after = function (method) { | |
| 47 var proxy; | |
| 48 | |
| 49 /** @this target object */ | |
| 50 proxy = function () { | |
| 51 var me = this; | |
| 52 var inherited = (this.getInherited && this.getInherited(proxy.nom, { | |
| 53 callee: proxy | |
| 54 })) || function () {}; | |
| 55 | |
| 56 inherited.apply(me, arguments); | |
| 57 | |
| 58 return method.apply(me, arguments); | |
| 59 }; | |
| 60 | |
| 61 proxy.method = method; | |
| 62 proxy.overrides = true; | |
| 63 | |
| 64 return proxy; | |
| 65 }; | |
| 66 | |
| 67 override.hide = function (method) { | |
| 68 method.overrides = false; | |
| 69 return method; | |
| 70 }; | |
| 71 | |
| 72 return override; | |
| 73 }); |
