Image.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. /** @class Image 图片。
  3. * @example
  4. * //可以在脚本中获取该组件
  5. * //方法1:
  6. * var img = this.form.get("name"); //获取组件
  7. * //方法2
  8. * var img = this.target; //在组件事件脚本中获取
  9. * @extends MWF.xApplication.process.Xform.$Module
  10. * @o2category FormComponents
  11. * @o2range {Process|CMS|Portal}
  12. * @hideconstructor
  13. */
  14. MWF.xApplication.process.Xform.Image = MWF.APPImage = new Class(
  15. {
  16. Extends: MWF.APP$Module,
  17. _loadUserInterface: function(){
  18. if (this.json.properties && this.json.properties["src"]){
  19. var value = this.json.properties["src"];
  20. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  21. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  22. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  23. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  24. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  25. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  26. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  27. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  28. }
  29. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  30. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  31. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  32. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  33. }
  34. if (value.indexOf("/x_cms_assemble_control")!==-1){
  35. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  36. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  37. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  38. }
  39. value = o2.filterUrl(value);
  40. }
  41. try{
  42. this.node.set("src", value);
  43. }catch(e){}
  44. }else if (this.json.srcfile && this.json.srcfile!="none"){
  45. value = this.json.srcfile;
  46. if (typeOf(value)==="object"){
  47. var url = (value.portal) ? MWF.xDesktop.getPortalFileUr(value.id, value.portal) : MWF.xDesktop.getProcessFileUr(value.id, value.application);
  48. url = o2.filterUrl(url);
  49. this.node.set("src", url);
  50. }else{
  51. var host = MWF.Actions.getHost("x_portal_assemble_surface");
  52. var action = MWF.Actions.get("x_portal_assemble_surface");
  53. var uri = action.action.actions.readFile.uri;
  54. uri = uri.replace("{flag}", value);
  55. uri = uri.replace("{applicationFlag}", this.form.json.application);
  56. value = host+"/x_portal_assemble_surface"+uri;
  57. value = o2.filterUrl(value);
  58. this.node.set("src", value);
  59. }
  60. }else if (typeOf(this.json.src)=="object"){
  61. var src = MWF.xDesktop.getImageSrc( this.json.src.imageId );
  62. this.node.set("src", src);
  63. }
  64. },
  65. reset: function(){
  66. this._loadUserInterface();
  67. }
  68. });