Relatedlink.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.Relatedlink = MWF.FCRelatedlink = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Relatedlink/relatedlink.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Relatedlink/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Relatedlink/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "relatedlink";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _resetModuleDomNode: function(){
  22. this.contentNode = this.node.getElement(".rlcontent");
  23. this.buttonNode = this.node.getElement(".rlbutton");
  24. },
  25. _createMoveNode: function(){
  26. this.moveNode = new Element("div", {
  27. "MWFType": "relatedlink",
  28. "id": this.json.id,
  29. "styles": this.css.moduleNodeMove,
  30. "events": {
  31. "selectstart": function(){
  32. return false;
  33. }
  34. }
  35. }).inject(this.form.container);
  36. },
  37. _createNode: function(){
  38. this.node = this.moveNode.clone(true, true);
  39. this.node.setStyles(this.css.moduleNode);
  40. this.node.set("id", this.json.id);
  41. this.node.addEvent("selectstart", function(){
  42. return false;
  43. });
  44. if( this.json.activeType === "click" || !this.json.activeType ){
  45. this.loadButton();
  46. }else{
  47. this.loadContent();
  48. }
  49. },
  50. loadContent: function(){
  51. this.contentNode = new Element("div.rlcontent", {
  52. "styles": this.css.contentNode
  53. }).inject(this.node);
  54. this.loadIcon();
  55. },
  56. loadIcon: function(){
  57. this.iconNode = new Element("div", {
  58. "styles": this.css.iconNode
  59. }).inject(this.contentNode);
  60. new Element("div", {
  61. "styles": this.css.iconNodeIcon
  62. }).inject(this.iconNode);
  63. new Element("div", {
  64. "styles": this.css.iconNodeText,
  65. "text": "Relatedlink"
  66. }).inject(this.iconNode);
  67. },
  68. loadButton: function(){
  69. this.buttonNode = new Element("div.rlbutton", {
  70. "styles": this.json.buttonStyles || {},
  71. "text": this.json.buttonText
  72. }).inject( this.node, "top" );
  73. // this.contentNode.setStyle("min-height", 100 - this.buttonNode.getSize().y +"px")
  74. },
  75. clearTemplateStyles: function(styles){
  76. if (styles){
  77. if (styles.buttonStyles) this.removeStyles(styles.buttonStyles, "buttonStyles");
  78. if (styles.tableStyles) this.removeStyles(styles.tableStyles, "tableStyles");
  79. if (styles.tableTitleCellStyles) this.removeStyles(styles.tableTitleCellStyles, "tableTitleCellStyles");
  80. if (styles.tableContentLineStyles) this.removeStyles(styles.tableContentLineStyles, "tableContentLineStyles");
  81. if (styles.tableContentLineStyles_over) this.removeStyles(styles.tableContentLineStyles_over, "tableContentLineStyles_over");
  82. if (styles.tableContentCellStyles) this.removeStyles(styles.tableContentCellStyles, "tableContentCellStyles");
  83. if (styles.tableTitleCellStyles) this.removeStyles(styles.tableTitleCellStyles, "tableTitleCellStyles");
  84. }
  85. },
  86. setTemplateStyles: function(styles){
  87. if (styles.buttonStyles) this.copyStyles(styles.buttonStyles, "buttonStyles");
  88. if (styles.tableStyles) this.copyStyles(styles.tableStyles, "tableStyles");
  89. if (styles.tableTitleCellStyles) this.copyStyles(styles.tableTitleCellStyles, "tableTitleCellStyles");
  90. if (styles.tableContentLineStyles) this.copyStyles(styles.tableContentLineStyles, "tableContentLineStyles");
  91. if (styles.tableContentLineStyles_over) this.copyStyles(styles.tableContentLineStyles_over, "tableContentLineStyles_over");
  92. if (styles.tableContentCellStyles) this.copyStyles(styles.tableContentCellStyles, "tableContentCellStyles");
  93. if (styles.tableTitleCellStyles) this.copyStyles(styles.tableTitleCellStyles, "tableTitleCellStyles");
  94. },
  95. setAllStyles: function(){
  96. this.setPropertiesOrStyles("styles");
  97. this.setPropertiesOrStyles("buttonStyles");
  98. this.setPropertiesOrStyles("properties");
  99. this.reloadMaplist();
  100. },
  101. setPropertiesOrStyles: function(name){
  102. if (name=="styles"){
  103. try{
  104. this.setCustomStyles();
  105. }catch(e){}
  106. }
  107. if (name=="buttonStyles"){
  108. try{
  109. if( this.buttonNode ){
  110. this.buttonNode.clearStyles();
  111. this.buttonNode.setStyles(this.json.buttonStyles||{});
  112. }
  113. }catch(e){}
  114. }
  115. if (name=="properties"){
  116. try{
  117. this.setCustomProperties();
  118. }catch(e){}
  119. }
  120. },
  121. _setEditStyle_custom: function(name, obj, oldValue){
  122. switch ( name ){
  123. case "activeType":
  124. switch (this.json.activeType) {
  125. case "click":
  126. if (!this.buttonNode) this.loadButton();
  127. if (this.contentNode) {
  128. this.contentNode.destroy();
  129. this.contentNode = null;
  130. }
  131. break;
  132. case "delay":
  133. case "immediately":
  134. if (!this.contentNode) this.loadContent();
  135. if (this.buttonNode) {
  136. this.buttonNode.destroy();
  137. this.buttonNode = null;
  138. }
  139. break;
  140. }
  141. case "buttonText":
  142. if (this.buttonNode) this.buttonNode.set("text", this.json.buttonText);
  143. }
  144. }
  145. });