CMSMacro.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. "formInfor": form.businessData.formInfor,
  41. "target": null,
  42. "event": null
  43. };
  44. this.environment = new MWF.xScript.CMSEnvironment(environment);
  45. },
  46. setTarget: function(target){
  47. if (target){
  48. this.environment.target = target;
  49. }else{
  50. this.environment.target = null;
  51. }
  52. },
  53. setEvent: function(event){
  54. if (event){
  55. this.environment.event = event;
  56. }else{
  57. this.environment.event = null;
  58. }
  59. },
  60. exec: function(code, target){
  61. this.setTarget(target);
  62. var returnValue = MWF.CMSMacro.exec(code, this.environment);
  63. //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
  64. return returnValue;
  65. //this.environment.data
  66. },
  67. fire: function(code, target, event){
  68. this.setTarget(target);
  69. this.setEvent(event);
  70. return MWF.CMSMacro.exec(code, this.environment);
  71. }
  72. });
  73. if( !MWF.CMSMacro.ViewContext ){
  74. MWF.CMSMacro.ViewContext = new Class({
  75. macroFunction: null,
  76. environment: {},
  77. initialize: function(view){
  78. this.form = view;
  79. var environment = {
  80. "view": view,
  81. "viewInfor": view.viewInfor,
  82. "target": null,
  83. "event": null
  84. };
  85. MWF.require("MWF.xScript.ViewEnvironment", null, false);
  86. this.environment = new MWF.xScript.ViewEnvironment(environment);
  87. },
  88. setTarget: function(target){
  89. if (target){
  90. this.environment.target = target;
  91. }else{
  92. this.environment.target = null;
  93. }
  94. },
  95. setEvent: function(event){
  96. if (event){
  97. this.environment.event = event;
  98. }else{
  99. this.environment.event = null;
  100. }
  101. },
  102. exec: function(code, target){
  103. this.setTarget(target);
  104. var returnValue = MWF.CMSMacro.exec(code, this.environment);
  105. //this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
  106. return returnValue;
  107. //this.environment.data
  108. },
  109. fire: function(code, target, event){
  110. this.setTarget(target);
  111. this.setEvent(event);
  112. return MWF.CMSMacro.exec(code, this.environment);
  113. }
  114. });
  115. }
  116. JSONObject = function(o){
  117. };