Tree.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.Tree = MWF.FCTree = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Tree/tree.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Tree/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Tree/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "tree";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "tree",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "events": {
  27. "selectstart": function(){
  28. return false;
  29. }
  30. }
  31. }).inject(this.form.container);
  32. },
  33. _initModule: function(){
  34. this._setNodeProperty();
  35. if (!this.form.isSubform) this._createIconAction();
  36. this._setNodeEvent();
  37. this._refreshTree();
  38. },
  39. _setEditStyle_custom: function(name){
  40. if (name=="areaNodeStyle"){
  41. this.tree.node.setStyles(this.json.areaNodeStyle);
  42. }
  43. if (name=="treeItemNodeStyle" || name=="textDivNodeStyle" || name=="textDivNodeSelectedStyle"){
  44. this._setTreeWidgetStyles();
  45. this._refreshTree();
  46. }
  47. if (name=="dataType") this._refreshTree();
  48. },
  49. _setTreeStyles: function(){
  50. this.json.areaNodeStyle = Object.merge( this.tree.css.areaNode , this.json.areaNodeStyle||{});
  51. this.json.treeItemNodeStyle = Object.merge( this.tree.css.treeItemNode, this.json.treeItemNodeStyle||{});
  52. this.json.textDivNodeStyle = Object.merge( this.tree.css.textDivNode, this.json.textDivNodeStyle||{});
  53. this.json.textDivNodeSelectedStyle = Object.merge( this.tree.css.textDivNodeSelected, this.json.textDivNodeSelectedStyle||{});
  54. },
  55. _setTreeWidgetStyles: function(){
  56. this.tree.css.areaNode = this.json.areaNodeStyle;
  57. this.tree.css.treeItemNode = this.json.treeItemNodeStyle;
  58. this.tree.css.textDivNode = this.json.textDivNodeStyle;
  59. this.tree.css.textDivNodeSelected = this.json.textDivNodeSelectedStyle;
  60. },
  61. _refreshTree: function(){
  62. var treeData = this.json.data;
  63. if (this.json.dataType == "script"){
  64. treeData = [
  65. {
  66. "title": "[script]",
  67. "text": "[script]",
  68. "id": "1",
  69. "icon": "none",
  70. "action": "",
  71. "expand": true,
  72. "sub": []
  73. }
  74. ];
  75. }
  76. if (!this.tree){
  77. this.node.empty();
  78. this.tree = new MWF.widget.Tree(this.node, {"style":"form"});
  79. this.tree.css = Object.clone( this.tree.css );
  80. this._setTreeStyles();
  81. this._setTreeWidgetStyles();
  82. this.tree.load(treeData);
  83. }else{
  84. this.tree.reLoad(treeData);
  85. }
  86. }
  87. });