Image.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. MWF.xApplication.portal.PageDesigner.Module.Image = MWF.PCImage = new Class({
  2. Extends: MWF.FCImage,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "propertyPath": "/x_component_portal_PageDesigner/Module/Image/image.html"
  7. },
  8. initialize: function(form, options){
  9. this.setOptions(options);
  10. this.path = "/x_component_portal_PageDesigner/Module/Image/";
  11. this.cssPath = "/x_component_portal_PageDesigner/Module/Image/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.moduleType = "element";
  14. this.moduleName = "image";
  15. this.form = form;
  16. this.container = null;
  17. this.containerNode = null;
  18. },
  19. _setEditStyle_custom: function(name){
  20. if (name=="src"){
  21. if (this.json.src){
  22. var src = this.json.src.imageSrc;
  23. this.node.src = src;
  24. this.setPropertiesOrStyles("styles");
  25. }else{
  26. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  27. }
  28. }
  29. debugger;
  30. if (name=="srcfile"){
  31. var value = this.json.srcfile;
  32. if (value==="none"){
  33. this.json.srcfile = "";
  34. value = "";
  35. }
  36. if (value){
  37. if (typeOf(value)==="object"){
  38. var url = MWF.xDesktop.getPortalFileUr(value.id, value.portal);
  39. try{
  40. this.node.set("src", url);
  41. }catch(e){}
  42. }else{
  43. var host = MWF.Actions.getHost("x_portal_assemble_surface");
  44. var action = MWF.Actions.get("x_portal_assemble_surface");
  45. var uri = action.action.actions.readFile.uri;
  46. uri = uri.replace("{flag}", value);
  47. uri = uri.replace("{applicationFlag}", this.form.json.application);
  48. value = host+"/x_portal_assemble_surface"+uri;
  49. try{
  50. this.node.set("src", value);
  51. }catch(e){}
  52. }
  53. }else{
  54. if (this.json.properties.src) {
  55. this._setEditStyle_custom("properties");
  56. }else if (this.json.src){
  57. this._setEditStyle_custom("src");
  58. }else{
  59. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  60. }
  61. }
  62. // if (value==="none"){
  63. // this.json.srcfile = "";
  64. // value = "";
  65. // }
  66. // if (value){
  67. // var host = MWF.Actions.getHost("x_portal_assemble_surface");
  68. // var action = MWF.Actions.get("x_portal_assemble_surface");
  69. // var uri = action.action.actions.readFile.uri;
  70. // uri = uri.replace("{flag}", value);
  71. // uri = uri.replace("{applicationFlag}", this.form.json.application);
  72. // value = host+"/x_portal_assemble_surface"+uri;
  73. //
  74. // try{
  75. // this.node.set("src", value);
  76. // }catch(e){}
  77. // }else{
  78. // if (this.json.properties.src) {
  79. // this._setEditStyle_custom("properties");
  80. // }else if (this.json.src){
  81. // this._setEditStyle_custom("src");
  82. // }else{
  83. // this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  84. // }
  85. // }
  86. }
  87. if (name=="properties"){
  88. this._setNodeProperty();
  89. }
  90. }
  91. });