| 1 | dojo.provide("dojox.lang.oo.Decorator"); |
| 2 | |
| 3 | (function(){ |
| 4 | var oo = dojox.lang.oo, |
| 5 | |
| 6 | D = oo.Decorator = function(value, decorator){ |
| 7 | // summary: |
| 8 | // The base class for all decorators. |
| 9 | // description: |
| 10 | // This object holds an original function or another decorator |
| 11 | // object, and implements a special mixin algorithm to be used |
| 12 | // by dojox.lang.oo.mixin. |
| 13 | // value: Object |
| 14 | // a payload to be processed by the decorator. |
| 15 | // decorator: Function|Object |
| 16 | // a function to handle the custom assignment, or an object with exec() |
| 17 | // method. The signature is: |
| 18 | // decorator(/*String*/ name, /*Function*/ newValue, /*Function*/ oldValue). |
| 19 | this.value = value; |
| 20 | this.decorator = typeof decorator == "object" ? |
| 21 | function(){ return decorator.exec.apply(decorator, arguments); } : decorator; |
| 22 | }; |
| 23 | |
| 24 | oo.makeDecorator = function(decorator){ |
| 25 | // summary: |
| 26 | // creates new custom decorator creator |
| 27 | // decorator: Function|Object |
| 28 | // a function to handle the custom assignment, |
| 29 | // or an object with exec() method |
| 30 | // returns: Function |
| 31 | // new decorator constructor |
| 32 | return function(value){ |
| 33 | return new D(value, decorator); |
| 34 | }; |
| 35 | }; |
| 36 | })(); |