Image.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. url = o2.filterUrl(url);
  40. try{
  41. this.node.set("src", url);
  42. }catch(e){}
  43. }else{
  44. var host = MWF.Actions.getHost("x_portal_assemble_surface");
  45. var action = MWF.Actions.get("x_portal_assemble_surface");
  46. var uri = action.action.actions.readFile.uri;
  47. uri = uri.replace("{flag}", value);
  48. uri = uri.replace("{applicationFlag}", this.form.json.application);
  49. value = host+"/x_portal_assemble_surface"+uri;
  50. value = o2.filterUrl(value);
  51. try{
  52. this.node.set("src", value);
  53. }catch(e){}
  54. }
  55. }else{
  56. if (this.json.properties.src) {
  57. this._setEditStyle_custom("properties");
  58. }else if (this.json.src){
  59. this._setEditStyle_custom("src");
  60. }else{
  61. this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  62. }
  63. }
  64. // if (value==="none"){
  65. // this.json.srcfile = "";
  66. // value = "";
  67. // }
  68. // if (value){
  69. // var host = MWF.Actions.getHost("x_portal_assemble_surface");
  70. // var action = MWF.Actions.get("x_portal_assemble_surface");
  71. // var uri = action.action.actions.readFile.uri;
  72. // uri = uri.replace("{flag}", value);
  73. // uri = uri.replace("{applicationFlag}", this.form.json.application);
  74. // value = host+"/x_portal_assemble_surface"+uri;
  75. //
  76. // try{
  77. // this.node.set("src", value);
  78. // }catch(e){}
  79. // }else{
  80. // if (this.json.properties.src) {
  81. // this._setEditStyle_custom("properties");
  82. // }else if (this.json.src){
  83. // this._setEditStyle_custom("src");
  84. // }else{
  85. // this.node.set("src", this.path +this.options.style+"/icon/image1.png");
  86. // }
  87. // }
  88. }
  89. if (name=="properties"){
  90. this._setNodeProperty();
  91. }
  92. }
  93. });