Attachment.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.set("data-mwf-el-type", "MWFFormDesignerAttachment");
  44. this.node.addEvent("selectstart", function(e){
  45. e.preventDefault();
  46. });
  47. // this.loadCkeditor();
  48. },
  49. _setEditStyle_custom: function(name){
  50. if (name=="size"){
  51. if (this.json[name]=="min"){
  52. this.attachmentController.changeControllerSizeToMin();
  53. }else{
  54. this.attachmentController.changeControllerSizeToMax();
  55. }
  56. }else if(name=="toolbarGroupHidden"){
  57. this.attachmentController.resetToolbarGroupHidden( this.json[name] );
  58. }else if( name=="availableListStyles" ){
  59. this.attachmentController.resetToolbarAvailableListStyle( this.json[name] );
  60. }
  61. },
  62. _initModule: function(){
  63. this.json.$inDatatable = this.parentContainer && ["datagrid$Data","datatable$Data"].contains(this.parentContainer.json.moduleName);
  64. this.node.empty();
  65. // if (this.parentContainer && this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.size) this.json.size = "min";
  66. // if (this.parentContainer && this.parentContainer.json.moduleName == "datagrid$Data" && !this.json.listStyle) this.json.listStyle = "sequence";
  67. if(!this.json.size){
  68. if( this.json.$inDatatable ){
  69. this.json.size = "min";
  70. }else{
  71. this.json.size = "max";
  72. }
  73. }
  74. if ( this.json.$inDatatable && !this.json.listStyle) this.json.listStyle = "sequence";
  75. this.loadAttachmentController(this.json.editorProperties);
  76. this.setPropertiesOrStyles("styles");
  77. this._setNodeProperty();
  78. if (!this.form.isSubform) this._createIconAction();
  79. this._setNodeEvent();
  80. },
  81. loadAttachmentController: function(){
  82. this.node.set("data-mwf-el-type", "MWFFormDesignerAttachment");
  83. MWF.require("MWF.widget.AttachmentController", function(){
  84. this.attachmentController = new MWF.widget.ATTER(this.node, this, {
  85. "style": this.json.style || "default",
  86. "title": "Attachment",
  87. "readonly": true,
  88. "size": this.json.size,
  89. "toolbarGroupHidden" : this.json.toolbarGroupHidden || [],
  90. "availableListStyles" : this.json.availableListStyles || ["list","seq","icon","preview"]
  91. });
  92. this.attachmentController.load();
  93. }.bind(this));
  94. }
  95. });