Image.js 3.7 KB

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