Attachment.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.Attachment = MWF.FCAttachment = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Attachment/attachment.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Attachment/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Attachment/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "attachment";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. setTemplateStyles: function(styles){
  22. this.json.style = styles.style || "default";
  23. },
  24. clearTemplateStyles: function(styles){
  25. this.json.style = "default";
  26. },
  27. _createMoveNode: function(){
  28. this.moveNode = new Element("div", {
  29. "MWFType": "attachment",
  30. "id": this.json.id,
  31. "styles": this.css.moduleNodeMove,
  32. "events": {
  33. "selectstart": function(){
  34. return false;
  35. }
  36. }
  37. }).inject(this.form.container);
  38. },
  39. _createNode: function(){
  40. this.node = this.moveNode.clone(true, true);
  41. this.node.setStyles(this.css.moduleNode);
  42. this.node.set("id", this.json.id);
  43. this.node.addEvent("selectstart", function(e){
  44. e.preventDefault();
  45. });
  46. // this.loadCkeditor();
  47. },
  48. _setEditStyle_custom: function(name){
  49. if (name=="size"){
  50. if (this.json[name]=="min"){
  51. this.attachmentController.changeControllerSizeToMin();
  52. }else{
  53. this.attachmentController.changeControllerSizeToMax();
  54. }
  55. }else if(name=="toolbarGroupHidden"){
  56. this.attachmentController.resetToolbarGroupHidden( this.json[name] );
  57. }else if( name=="availableListStyles" ){
  58. this.attachmentController.resetToolbarAvailableListStyle( this.json[name] );
  59. }
  60. },
  61. _initModule: function(){
  62. this.node.empty();
  63. // if (this.parentContainer && this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.size) this.json.size = "min";
  64. // if (this.parentContainer && this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.listStyle) this.json.listStyle = "sequence";
  65. if(!this.json.size){
  66. if(this.parentContainer && ["datagrid$Data","datatable$Data"].contains(this.parentContainer.json.moduleName)){
  67. this.json.size = "min";
  68. }else{
  69. this.json.size = "max";
  70. }
  71. }
  72. if (this.parentContainer && ["datagrid$Data","datatable$Data"].contains(this.parentContainer.json.moduleName) && !this.json.listStyle) this.json.listStyle = "sequence";
  73. this.loadAttachmentController(this.json.editorProperties);
  74. this.setPropertiesOrStyles("styles");
  75. this._setNodeProperty();
  76. if (!this.form.isSubform) this._createIconAction();
  77. this._setNodeEvent();
  78. debugger;
  79. },
  80. loadAttachmentController: function(){
  81. MWF.require("MWF.widget.AttachmentController", function(){
  82. this.attachmentController = new MWF.widget.ATTER(this.node, this, {
  83. "readonly": true,
  84. "size": this.json.size,
  85. "toolbarGroupHidden" : this.json.toolbarGroupHidden || [],
  86. "availableListStyles" : this.json.availableListStyles || ["list","seq","icon","preview"]
  87. });
  88. this.attachmentController.load();
  89. }.bind(this));
  90. }
  91. });