$Element.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Module", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.$Element = MWF.FC$Element = new Class({
  4. Extends: MWF.FC$Module,
  5. Implements: [Options, Events],
  6. _setNodeProperty: function(){
  7. if (this.form.moduleList.indexOf(this)==-1) this.form.moduleList.push(this);
  8. if (this.form.moduleNodeList.indexOf(this.node)==-1) this.form.moduleNodeList.push(this.node);
  9. if (this.form.moduleElementNodeList.indexOf(this.node)==-1) this.form.moduleElementNodeList.push(this.node);
  10. this.node.store("module", this);
  11. },
  12. _dragIn: function(module){
  13. module.onDragModule = this;
  14. if (this.parentContainer.moduleName === "datagrid$Data") {
  15. this.parentContainer._dragIn(module);
  16. }else if( this.parentContainer.moduleName === "datatable$Data" && !this.parentContainer.options.allowModules.contains( module.moduleName )){
  17. this.parentContainer._dragIn(module);
  18. }else{
  19. module.inContainer = null;
  20. module.parentContainer = this.parentContainer;
  21. module.nextModule = this;
  22. //this.parentContainer.node.setStyles({"border": "1px solid #ffa200"});
  23. this.node.setStyles({"border": "1px solid #ffa200"});
  24. if (module.controlMode){
  25. if (module.copyNode) module.copyNode.hide();
  26. }else{
  27. var copyNode = module._getCopyNode(this);
  28. copyNode.show();
  29. copyNode.inject(this.node, "before");
  30. this._positionCopyNode(copyNode)
  31. }
  32. //this._showInjectAction( module );
  33. // var e = new Event(event);
  34. // if (e.control){
  35. //
  36. // }else{
  37. // var copyNode = module._getCopyNode(this);
  38. // copyNode.inject(this.node, "before");
  39. // }
  40. }
  41. },
  42. _setControlModeNode: function(){
  43. if (this.controlMode){
  44. if (this.copyNode) this.copyNode.hide();
  45. }else{
  46. if (this.onDragModule) this.onDragModule._dragIn(this);
  47. }
  48. },
  49. _dragOut: function(module){
  50. module.onDragModule = null;
  51. module.inContainer = null;
  52. module.parentContainer = null;
  53. module.nextModule = null;
  54. //this.parentContainer.node.setStyles(this.parentContainer.css.moduleNode);
  55. //this.parentContainer.setCustomStyles();
  56. this.node.setStyles(this.css.moduleNode);
  57. this.setCustomStyles();
  58. //this._hideInjectAction();
  59. // if (this._controlKeyEventFun){
  60. // this.node.removeEvent("keydown", this._controlKeyEventFun);
  61. // this._controlKeyEventFun = null;
  62. // }
  63. if (!module.controlMode){
  64. var copyNode = module._getCopyNode();
  65. copyNode.setStyle("display", "none");
  66. }
  67. },
  68. _dragDrop: function(module, flag){
  69. var f = flag || !(window.event || {}).ctrlKey;
  70. if( f ){
  71. this.node.setStyles(this.css.moduleNode);
  72. this.setCustomStyles();
  73. }
  74. //this.parentContainer.node.setStyles(this.parentContainer.css.moduleNode);
  75. //this.parentContainer.setCustomStyles();
  76. //this._hideInjectAction();
  77. },
  78. destroy: function(){
  79. this.form.moduleList.erase(this);
  80. this.form.moduleNodeList.erase(this.node);
  81. this.form.moduleElementNodeList.erase(this.node);
  82. if (this.form.scriptDesigner){
  83. this.form.scriptDesigner.removeModule(this.json);
  84. }
  85. if (this.property) this.property.destroy();
  86. this.node.destroy();
  87. this.actionArea.destroy();
  88. delete this.form.json.moduleList[this.json.id];
  89. this.json = null;
  90. delete this.json;
  91. this.treeNode.destroy();
  92. o2.release(this);
  93. },
  94. parseModules: function(){},
  95. _deleteModule: function(){
  96. this.destroy();
  97. },
  98. getJson: function(){
  99. var json = Object.clone(this.json);
  100. var o = {};
  101. o[json.id] = json;
  102. return o;
  103. }
  104. });