Stat.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.Stat = MWF.FCStat = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Stat/stat.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Stat/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Stat/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "stat";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. load : function(json, node, parent){
  22. this.json = json;
  23. this.node= node;
  24. this.node.store("module", this);
  25. //this.node.empty();
  26. this.node.setStyles(this.css.moduleNode);
  27. this._loadNodeStyles();
  28. this._initModule();
  29. this._loadTreeNode(parent);
  30. //this.setCustomStyles();
  31. this.parentContainer = this.treeNode.parentNode.module;
  32. this._setEditStyle_custom("id");
  33. this.json.moduleName = this.moduleName;
  34. // this.parseModules();
  35. },
  36. _createMoveNode: function(){
  37. this.moveNode = new Element("div", {
  38. "MWFType": "view",
  39. "id": this.json.id,
  40. "styles": this.css.moduleNodeMove,
  41. "events": {
  42. "selectstart": function(){
  43. return false;
  44. }
  45. }
  46. }).inject(this.form.container);
  47. },
  48. _initModule: function(){
  49. this.setPropertiesOrStyles("styles");
  50. this.setPropertiesOrStyles("properties");
  51. this._setNodeProperty();
  52. if (!this.form.isSubform) this._createIconAction();
  53. this._setNodeEvent();
  54. },
  55. _createNode: function(){
  56. this.node = this.moveNode.clone(true, true);
  57. this.node.setStyles(this.css.moduleNode);
  58. this.node.set("id", this.json.id);
  59. this.node.addEvent("selectstart", function(){
  60. return false;
  61. });
  62. this.iconNode = new Element("div", {
  63. "styles": this.css.iconNode
  64. }).inject(this.node);
  65. new Element("div", {
  66. "styles": this.css.iconNodeIcon
  67. }).inject(this.iconNode);
  68. new Element("div", {
  69. "styles": this.css.iconNodeText,
  70. "text": "STAT"
  71. }).inject(this.iconNode);
  72. },
  73. _loadNodeStyles: function(){
  74. this.iconNode = this.node.getElement("div").setStyles(this.css.iconNode);
  75. this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon);
  76. this.iconNode.getLast("div").setStyles(this.css.iconNodeText);
  77. // this.viewNode = this.node.getChildren("div")[1];
  78. // if (this.viewNode){
  79. // this.viewTable = this.viewNode.getElement("table").setStyles(this.css.viewTitleTableNode);
  80. // this.viewLine = this.viewTable.getElement("tr").setStyles(this.css.viewTitleLineNode);
  81. // this.viewSelectCell = this.viewLine.getElement("td");
  82. // if (this.viewSelectCell) this.viewSelectCell.setStyles(this.css.viewTitleCellNode);
  83. //
  84. // this._setViewNodeTitle();
  85. // }
  86. },
  87. _setEditStyle: function(name, input, oldValue){
  88. if (name=="name"){
  89. var title = this.json.name || this.json.id;
  90. var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  91. this.treeNode.setText("<"+text+"> "+title);
  92. }
  93. if (name=="id"){
  94. if (!this.json.name){
  95. var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  96. this.treeNode.setText("<"+text+"> "+this.json.id);
  97. }
  98. this.treeNode.setTitle(this.json.id);
  99. this.node.set("id", this.json.id);
  100. }
  101. }
  102. });