Image.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.Image = MWF.FCImage = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Image/image.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Image/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Image/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "image";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("img", {
  23. "MWFType": "image",
  24. "id": this.json.id,
  25. "src": this.json.src || this.path+this.options.style+"/icon/image1.png",
  26. "styles": this.css.moduleNodeMove,
  27. "events": {
  28. "selectstart": function(){
  29. return false;
  30. }
  31. }
  32. }).inject(this.form.container);
  33. },
  34. _getCopyNode: function(){
  35. if (!this.copyNode) this._createCopyNode();
  36. this.copyNode.setStyle("display", "inline-block");
  37. return this.copyNode;
  38. },
  39. _setEditStyle_custom: function(name){
  40. if (name=="src"){
  41. if (this.json.src){
  42. var src = this.json.src.imageSrc;
  43. this.node.src = src;
  44. this.setPropertiesOrStyles("styles");
  45. }else{
  46. if (this.json.properties.src) {
  47. this._setEditStyle_custom("properties");
  48. }else if( this.json.srcfile ){
  49. this._setEditStyle_custom("srcfile");
  50. }else{
  51. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  52. }
  53. }
  54. }
  55. if (name=="srcfile"){
  56. var value = this.json.srcfile;
  57. if (value==="none"){
  58. this.json.srcfile = "";
  59. value = "";
  60. }
  61. if (value){
  62. if (typeOf(value)==="object"){
  63. var url = MWF.xDesktop.getProcessFileUr(value.id, value.application);
  64. try{
  65. this.node.set("src", url);
  66. }catch(e){}
  67. }else{
  68. var host = MWF.Actions.getHost("x_processplatform_assemble_surface");
  69. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  70. var uri = action.action.actions.readFile.uri;
  71. uri = uri.replace("{flag}", value);
  72. uri = uri.replace("{applicationFlag}", this.form.json.application);
  73. value = host+"/x_processplatform_assemble_surface"+uri;
  74. try{
  75. this.node.set("src", value);
  76. }catch(e){}
  77. }
  78. }else{
  79. if (this.json.properties.src) {
  80. this._setEditStyle_custom("properties");
  81. }else if (this.json.src){
  82. this._setEditStyle_custom("src");
  83. }else{
  84. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  85. }
  86. }
  87. }
  88. if (name=="properties"){
  89. this._setNodeProperty();
  90. }
  91. },
  92. _setNodeProperty: function(){
  93. if (this.form.moduleList.indexOf(this)==-1) this.form.moduleList.push(this);
  94. if (this.form.moduleNodeList.indexOf(this.node)==-1) this.form.moduleNodeList.push(this.node);
  95. if (this.form.moduleElementNodeList.indexOf(this.node)==-1) this.form.moduleElementNodeList.push(this.node);
  96. this.node.store("module", this);
  97. if (typeOf(this.json.src)==="object"){
  98. var src = MWF.xDesktop.getImageSrc( this.json.src.imageId );
  99. this.node.set("src", src);
  100. }
  101. if (this.json.properties && this.json.properties["src"]){
  102. var value = this.json.properties["src"];
  103. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  104. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  105. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  106. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  107. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  108. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  109. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  110. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  111. }
  112. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  113. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  114. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  115. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  116. }
  117. if (value.indexOf("/x_cms_assemble_control")!==-1){
  118. value = value.replace("/x_cms_assemble_control", host2+"/x_cms_assemble_control");
  119. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  120. value = value.replace("x_cms_assemble_control", host2+"/x_cms_assemble_control");
  121. }
  122. value = o2.filterUrl(value);
  123. }
  124. if (value){
  125. this.node.set("src", value);
  126. }else{
  127. if (this.json.srcfile && this.json.srcfile!="none") {
  128. this._setEditStyle_custom("srcfile");
  129. }else if (this.json.src){
  130. this._setEditStyle_custom("src");
  131. }else{
  132. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  133. }
  134. }
  135. }else{
  136. if (this.json.srcfile && this.json.srcfile!="none") {
  137. this._setEditStyle_custom("srcfile");
  138. }else if (this.json.src){
  139. this._setEditStyle_custom("src");
  140. }else{
  141. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  142. }
  143. }
  144. }
  145. });