Image.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. //if (!this.json.styles.width || !this.json.styles.height){
  46. // var tmpImg = new Element("img",{
  47. // "src": src
  48. // }).inject(this.form.node);
  49. // var size = tmpImg.getSize();
  50. // if (!this.json.styles.width){
  51. // this.node.setStyles({"width": ""+size.x+"px"});
  52. // this.json.styles.width = ""+size.x+"px";
  53. // }
  54. // if (!this.json.styles.height){
  55. // this.node.setStyles({"height": ""+size.y+"px"});
  56. // this.json.styles.height = ""+size.y+"px";
  57. // }
  58. // this.property.maplists["styles"].reload(this.json.styles);
  59. // tmpImg.destroy();
  60. //}
  61. }
  62. }
  63. },
  64. _setNodeProperty: function(){
  65. debugger;
  66. if (typeOf(this.json.src)=="object"){
  67. var src = MWF.xDesktop.getImageSrc( this.json.src.imageId );
  68. this.node.set("src", src);
  69. }
  70. }
  71. });