OnlyOffice.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.OnlyOffice = MWF.FCOnlyOffice = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/OnlyOffice/onlyoffice.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/OnlyOffice/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/OnlyOffice/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "onlyoffice";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. // var flag = false;
  23. // this.form.moduleList.each(function (module){
  24. // if(module.moduleName === "onlyoffice"){
  25. // flag = true;
  26. // }
  27. // }.bind(this));
  28. // if(flag){
  29. // this.form.designer.notice( "表单中只允许有一个OnlyOffice控件", "error", this.form.container );
  30. // return false;
  31. // }
  32. this.moveNode = new Element("div", {
  33. "MWFType": "onlyoffice",
  34. "id": this.json.id,
  35. "styles": this.css.moduleNodeMove,
  36. "events": {
  37. "selectstart": function(){
  38. return false;
  39. }
  40. }
  41. }).inject(this.form.container);
  42. },
  43. _createNode: function(){
  44. this.node = this.moveNode.clone(true, true);
  45. this.node.setStyles(this.css.moduleNode);
  46. this.node.set("id", this.json.id);
  47. this.node.addEvent("selectstart", function(){
  48. return false;
  49. });
  50. this.iconNode = new Element("div", {
  51. "styles": this.css.iconNode
  52. }).inject(this.node);
  53. var icon = new Element("div", {
  54. "styles": this.css.iconNodeIcon
  55. }).inject(this.iconNode);
  56. var text = new Element("div", {
  57. "styles": this.css.iconNodeText,
  58. "text": "OnlyOffice"
  59. }).inject(this.iconNode);
  60. this.setIcon();
  61. },
  62. _loadNodeStyles: function(){
  63. this.iconNode = this.node.getElement("div").setStyles(this.css.iconNode);
  64. this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon);
  65. this.iconNode.getLast("div").setStyles(this.css.iconNodeText);
  66. this.setIcon();
  67. },
  68. setIconNode: function(img, txt, color, width){
  69. if (this.iconNode){
  70. this.iconNode.setStyle("width", width);
  71. var icon = this.iconNode.getFirst();
  72. var text = this.iconNode.getLast();
  73. icon.setStyle("background-image", "url("+this.path+this.options.style+"/icon/"+img+".png)");
  74. text.set("text", txt);
  75. text.setStyles({
  76. "color": color,
  77. "width": width-34
  78. });
  79. }
  80. },
  81. setIcon: function(){
  82. if (this.json.officeType=="docx"){
  83. this.setIconNode("docx", "Word", "#2b5797", 90);
  84. }
  85. if (this.json.officeType=="xlsx"){
  86. this.setIconNode("xlsx", "Excel", "#1e7145", 86);
  87. }
  88. if (this.json.officeType=="pptx"){
  89. this.setIconNode("pptx", "PowerPoint", "#d04525", 130);
  90. }
  91. if (this.json.officeType=="other"){
  92. this.setIconNode("office", "Office", "#f36523", 96);
  93. }
  94. },
  95. _setEditStyle_custom: function(name){
  96. if (name=="officeType"){
  97. this.setIcon();
  98. }
  99. },
  100. _resetModuleDomNode: function(){
  101. this.setNodeContainer();
  102. },
  103. setNodeContainer:function(){
  104. this.node.empty();
  105. this.iconNode = new Element("div", {
  106. "styles": this.css.iconNode
  107. }).inject(this.node);
  108. var icon = new Element("div", {
  109. "styles": this.css.iconNodeIcon
  110. }).inject(this.iconNode);
  111. var text = new Element("div", {
  112. "styles": this.css.iconNodeText,
  113. "text": "OnlyOffice"
  114. }).inject(this.iconNode);
  115. this.setIcon();
  116. if(!layout.serviceAddressList["x_onlyofficefile_assemble_control"]){
  117. this.tipNode = new Element("div",{"style":"text-align:center"}).inject(this.node);
  118. this.tipNode.set("html","<h3><font color=red>" + MWF.APPFD.LP.onlyoffice.nosetup + "</font></h3>");
  119. }
  120. this.setIcon();
  121. }
  122. });