Property.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  2. MWF.xApplication.cms.FormDesigner.Property = MWF.CMSFCProperty = new Class({
  3. Extends: MWF.FCProperty,
  4. loadScriptEditor: function(scriptAreas, style){
  5. scriptAreas.each(function(node){
  6. var title = node.get("title");
  7. var name = node.get("name");
  8. var scriptContent = this.data[name];
  9. MWF.require("MWF.widget.ScriptArea", function(){
  10. var scriptArea = new MWF.widget.ScriptArea(node, {
  11. "title": title,
  12. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  13. "maxObj": this.designer.formContentNode,
  14. "onChange": function(){
  15. this.data[name] = scriptArea.toJson();
  16. }.bind(this),
  17. "onSave": function(){
  18. this.designer.saveForm();
  19. }.bind(this),
  20. "style": style || "default",
  21. "helpStyle" : "cms"
  22. });
  23. scriptArea.load(scriptContent);
  24. }.bind(this));
  25. }.bind(this));
  26. },
  27. getViewList: function(callback, refresh){
  28. if (!this.views || refresh){
  29. this.form.designer.actions.listQueryView(this.form.designer.application.id, function(json){
  30. this.views = json.data;
  31. if (callback) callback();
  32. }.bind(this));
  33. }else{
  34. if (callback) callback();
  35. }
  36. },
  37. loadActionArea: function(){
  38. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  39. actionAreas.each(function(node){
  40. var name = node.get("name");
  41. var actionContent = this.data[name];
  42. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  43. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  44. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  45. "onChange": function(){
  46. this.data[name] = actionEditor.data;
  47. this.changeData(name);
  48. }.bind(this)
  49. });
  50. actionEditor.load(actionContent);
  51. }.bind(this));
  52. }.bind(this));
  53. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  54. //actionAreas.each(function(node){
  55. // var name = node.get("name");
  56. // var actionContent = this.data[name];
  57. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  58. //
  59. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  60. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  61. // "onChange": function(){
  62. // this.data[name] = actionEditor.data;
  63. // this.changeData(name);
  64. // }.bind(this)
  65. // });
  66. // actionEditor.load(actionContent);
  67. // }.bind(this));
  68. //
  69. //}.bind(this));
  70. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  71. actionAreas.each(function(node){
  72. var name = node.get("name");
  73. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  74. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  75. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  76. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  77. "noCreate": true,
  78. "noDelete": true,
  79. "noCode": true,
  80. "onChange": function(){
  81. this.data[name] = actionEditor.data;
  82. this.changeData(name);
  83. }.bind(this)
  84. });
  85. actionEditor.load(actionContent);
  86. }.bind(this));
  87. }.bind(this));
  88. },
  89. //loadActionArea: function(){
  90. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  91. // actionAreas.each(function(node){
  92. // var name = node.get("name");
  93. // var actionContent = this.data[name];
  94. //
  95. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  96. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  97. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  98. // "onChange": function(){
  99. // this.data[name] = actionEditor.data;
  100. // }.bind(this)
  101. // });
  102. // actionEditor.load(actionContent);
  103. // }.bind(this));
  104. // }.bind(this));
  105. //},
  106. loadEventsEditor: function(){
  107. var events = this.propertyContent.getElement(".MWFEventsArea");
  108. if (events){
  109. var name = events.get("name");
  110. var eventsObj = this.data[name];
  111. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  112. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  113. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  114. "maxObj": this.designer.formContentNode
  115. });
  116. eventsEditor.load(eventsObj);
  117. }.bind(this));
  118. }
  119. },
  120. loadValidation: function(){
  121. var nodes = this.propertyContent.getElements(".MWFValidation");
  122. if (nodes.length){
  123. nodes.each(function(node){
  124. var name = node.get("name");
  125. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  126. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  127. "onChange": function(){
  128. var data = validationEditor.getValidationData();
  129. this.data[name] = data;
  130. }.bind(this)
  131. });
  132. validationEditor.load(this.data[name])
  133. }.bind(this));
  134. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  135. }.bind(this));
  136. }
  137. }
  138. });
  139. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  140. Extends: MWF.xApplication.cms.FormDesigner.Property,
  141. Implements: [Options, Events],
  142. initialize: function(form, modules, propertyNode, designer, options){
  143. this.setOptions(options);
  144. this.modules = modules;
  145. this.form = form;
  146. // this.data = module.json;
  147. this.data = {};
  148. this.htmlPath = this.options.path;
  149. this.designer = designer;
  150. this.maplists = {};
  151. this.propertyNode = propertyNode;
  152. },
  153. load: function(){
  154. if (this.fireEvent("queryLoad")){
  155. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  156. this.htmlString = responseText;
  157. MWF.require("MWF.widget.JsonTemplate", function(){
  158. this.fireEvent("postLoad");
  159. }.bind(this));
  160. }.bind(this));
  161. }
  162. },
  163. show: function(){
  164. if (!this.propertyContent){
  165. if (this.htmlString){
  166. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  167. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  168. this.propertyContent.set("html", this.JsonTemplate.load());
  169. this.setEditNodeEvent();
  170. this.setEditNodeStyles(this.propertyContent);
  171. this.loadPropertyTab();
  172. this.loadMaplist();
  173. this.loadScriptArea();
  174. this.loadTreeData();
  175. this.loadArrayList();
  176. //this.loadEventsEditor();
  177. //this.loadHTMLArea();
  178. //this.loadJSONArea();
  179. // this.loadScriptInput();
  180. //MWF.process.widget.EventsEditor
  181. }
  182. }else{
  183. this.propertyContent.setStyle("display", "block");
  184. }
  185. },
  186. hide: function(){
  187. if (this.propertyContent) this.propertyContent.destroy();
  188. },
  189. changeStyle: function(name){
  190. this.modules.each(function(module){
  191. module.setPropertiesOrStyles(name);
  192. }.bind(this));
  193. },
  194. changeData: function(name, input, oldValue){
  195. this.modules.each(function(module){
  196. module._setEditStyle(name, input, oldValue);
  197. }.bind(this));
  198. },
  199. changeJsonDate: function(key, value){
  200. //alert(key+": "+value );
  201. this.modules.each(function(module){
  202. module.json[key] = value;
  203. }.bind(this));
  204. }
  205. });