CMSMacro.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. MWF.xScript = MWF.xScript || {};
  2. MWF.require("MWF.xScript.CMSEnvironment", null, false);
  3. MWF.xScript.CMSMacro = MWF.CMSMacro = {
  4. "swapSpace": {},
  5. expression: function(code, bind){},
  6. runEvent: function(code, bind, arg){},
  7. exec: function(code, bind){
  8. var returnValue;
  9. // try{
  10. if (!bind) bind = window;
  11. try {
  12. var f = eval("(function(){\n"+code+"\n})");
  13. returnValue = f.apply(bind);
  14. }catch(e){}
  15. // }catch(e){}
  16. // var CMSMacroCode = "MWF.CMSMacro.swapSpace.tmpMacroFunction = function (){"+code+"};";
  17. // Browser.exec(macroCode);
  18. // var returnValue;
  19. // if (!bind) bind = window;
  20. //// try {
  21. // returnValue = MWF.Macro.swapSpace.tmpMacroFunction.apply(bind);
  22. //// }catch(e){};
  23. return returnValue;
  24. }
  25. };
  26. MWF.CMSMacro.CMSFormContext = new Class({
  27. macroFunction: null,
  28. environment: {},
  29. initialize: function(form){
  30. this.form = form;
  31. var environment = {
  32. "form": form,
  33. "forms": form.forms,
  34. "all": form.all,
  35. "data": form.businessData.data,
  36. "document": form.businessData.document,
  37. "control": form.businessData.control,
  38. "attachmentList": form.businessData.attachmentList,
  39. "status": form.businessData.status,
  40. "target": null,
  41. "event": null
  42. };
  43. this.environment = new MWF.xScript.CMSEnvironment(environment);
  44. },
  45. setTarget: function(target){
  46. if (target){
  47. this.environment.target = target;
  48. }else{
  49. this.environment.target = null;
  50. }
  51. },
  52. setEvent: function(event){
  53. if (event){
  54. this.environment.event = event;
  55. }else{
  56. this.environment.event = null;
  57. }
  58. },
  59. exec: function(code, target){
  60. this.setTarget(target);
  61. var returnValue = MWF.CMSMacro.exec(code, this.environment);
  62. //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
  63. return returnValue;
  64. //this.environment.data
  65. },
  66. fire: function(code, target, event){
  67. this.setTarget(target);
  68. this.setEvent(event);
  69. return MWF.CMSMacro.exec(code, this.environment);
  70. }
  71. });
  72. JSONObject = function(o){
  73. };