Org.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.Org = MWF.FCOrg = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Org/org.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Org/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Org/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "org";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. clearTemplateStyles: function(styles){
  22. if (styles){
  23. if (styles.styles) this.removeStyles(styles.styles, "styles");
  24. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  25. if (styles.properties) this.removeStyles(styles.properties, "properties");
  26. }
  27. },
  28. setTemplateStyles: function(styles){
  29. if (styles.styles) this.copyStyles(styles.styles, "styles");
  30. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  31. if (styles.properties) this.copyStyles(styles.properties, "properties");
  32. },
  33. _createMoveNode: function(){
  34. this.moveNode = new Element("div", {
  35. "MWFType": "org",
  36. "id": this.json.id,
  37. "styles": this.css.moduleNodeMove,
  38. "events": {
  39. "selectstart": function(){
  40. return false;
  41. }
  42. }
  43. }).inject(this.form.container);
  44. var icon = new Element("div", {
  45. "styles": this.css.fieldIcon
  46. }).inject(this.moveNode);
  47. var text = new Element("div", {
  48. "styles": this.css.moduleText,
  49. "text": this.json.id
  50. }).inject(this.moveNode);
  51. },
  52. _loadNodeStyles: function(){
  53. var icon = this.node.getFirst("div");
  54. var text = this.node.getLast("div");
  55. if (!icon) icon = new Element("div").inject(this.node, "top");
  56. if (!text) text = new Element("div").inject(this.node, "bottom");
  57. icon.setStyles(this.css.fieldIcon);
  58. text.setStyles(this.css.moduleText);
  59. },
  60. _getCopyNode: function(){
  61. if (!this.copyNode) this._createCopyNode();
  62. this.copyNode.setStyle("display", "inline-block");
  63. return this.copyNode;
  64. },
  65. _setEditStyle_custom: function(name){
  66. if (name=="id"){
  67. this.node.getLast().set("text", this.json.id);
  68. }
  69. },
  70. setPropertiesOrStyles: function(name){
  71. if (name=="styles"){
  72. //if (this.parentContainer){
  73. // if (this.parentContainer.moduleName == "datagrid$Data"){
  74. // if (!this.json.styles.width) this.json.styles.width = "90%";
  75. //}
  76. //}
  77. try{
  78. this.setCustomStyles();
  79. }catch(e){}
  80. //this.setCustomStyles();
  81. }
  82. if (name=="inputStyles"){
  83. var text = this.node.getLast("div");
  84. text.clearStyles();
  85. text.setStyles(this.css.moduleText);
  86. Object.each(this.json.inputStyles, function(value, key){
  87. var reg = /^border\w*/ig;
  88. if (!key.test(reg)){
  89. text.setStyle(key, value);
  90. }
  91. }.bind(this));
  92. }
  93. if (name=="properties"){
  94. this.node.setProperties(this.json.properties);
  95. }
  96. }
  97. });