Common.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. MWF.xApplication.process.FormDesigner.Module.Common = MWF.FCCommon = new Class({
  2. Extends: MWF.FCDiv,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "propertyPath": "/x_component_process_FormDesigner/Module/Common/common.html"
  7. },
  8. initialize: function(form, options){
  9. this.setOptions(options);
  10. this.path = "/x_component_process_FormDesigner/Module/Common/";
  11. this.cssPath = "/x_component_process_FormDesigner/Module/Common/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.moduleType = "container";
  14. this.moduleName = "common";
  15. this.Node = null;
  16. this.form = form;
  17. },
  18. _setEditStyle_custom: function(name, obj, oldValue){
  19. if (name==="tagName"){
  20. var tagName = this.json.tagName.toString().toLowerCase();
  21. var nodeTag = this.node.tagName.toString().toLowerCase();
  22. if (tagName !== nodeTag){
  23. var node = new Element(tagName).inject(this.node, "before");
  24. var nodes = this.node.childNodes;
  25. for (var i = 0; i < nodes.length; i++){
  26. node.appendChild(nodes[i]);
  27. }
  28. this.node.destroy();
  29. this.node = node;
  30. this.node.set("mwftype", "common");
  31. this.node.set("id", this.json.id);
  32. this.isSetEvents = false;
  33. this._initModule();
  34. var title = this.json.name || this.json.id;
  35. var text = text = this.json.tagName+"(Common)";
  36. this.treeNode.setText("<"+text+"> "+title);
  37. }
  38. }
  39. },
  40. setPropertiesOrStyles: function(name, oldData){
  41. if (name=="styles"){
  42. try{
  43. this.setCustomStyles();
  44. }catch(e){}
  45. }
  46. if (name==="properties"){
  47. try{
  48. if (oldData){
  49. Object.each(oldData, function(v,k){
  50. this.node.removeProperty(k);
  51. }.bind(this));
  52. }
  53. Object.each(this.json.properties, function(v,k){
  54. if (k.toString().toLowerCase()==="href"){
  55. this.node.setProperty(k, "#");
  56. }else if (k.toString().toLowerCase()==="target") {
  57. this.node.removeProperty("target");
  58. }else{
  59. this.node.setProperty(k, v);
  60. }
  61. }.bind(this));
  62. }catch(e){}
  63. }
  64. },
  65. setCustomStyles: function(){
  66. var border = this.node.getStyle("border");
  67. this.node.clearStyles();
  68. var styles = this.node.getStyles("display", "padding");
  69. this.node.setStyles(this.css.moduleNode);
  70. var style = Object.clone(this.json.styles);
  71. //style = Object.merge(style, styles);
  72. if (styles.display.toString().toLowerCase()==="inline"){
  73. if (!style.display) style.display = "inline-block";
  74. if (!style.padding && !style["padding-left"] && !style["padding-right"]) style.padding = "0px 2px";
  75. }
  76. if (this.json.tagName==="button"){
  77. if (!style["min-height"]) style["min-height"] = "20px";
  78. }
  79. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  80. this.node.setStyle("border", border);
  81. if (style) Object.each(style, function(value, key){
  82. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  83. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  84. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  85. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  86. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  87. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  88. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  89. }
  90. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  91. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  92. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  93. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  94. }
  95. }
  96. var reg = /^border\w*/ig;
  97. if (!key.test(reg)){
  98. if (key){
  99. if (key.toString().toLowerCase()==="display"){
  100. if (value.toString().toLowerCase()==="none"){
  101. this.node.setStyle("opacity", 0.3);
  102. }else{
  103. this.node.setStyle("opacity", 1);
  104. this.node.setStyle(key, value);
  105. }
  106. }else{
  107. this.node.setStyle(key, value);
  108. }
  109. }
  110. }
  111. }.bind(this));
  112. }
  113. });