Decorator.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // wrapped by build app
  2. define("dojox/lang/oo/Decorator", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){
  3. dojo.provide("dojox.lang.oo.Decorator");
  4. (function(){
  5. var oo = dojox.lang.oo,
  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. oo.makeDecorator = function(decorator){
  24. // summary:
  25. // creates new custom decorator creator
  26. // decorator: Function|Object:
  27. // a function to handle the custom assignment,
  28. // or an object with exec() method
  29. // returns: Function:
  30. // new decorator constructor
  31. return function(value){
  32. return new D(value, decorator);
  33. };
  34. };
  35. })();
  36. });