Button.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.Button = MWF.FCButton = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Button/button.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/Button/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/Button/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "button";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "button",
  24. "id": this.json.id,
  25. "styles": this.css.moduleNodeMove,
  26. "events": {
  27. "selectstart": function(){
  28. return false;
  29. }
  30. }
  31. }).inject(this.form.container);
  32. var button = new Element("button", {
  33. "styles": this.css.buttonIcon,
  34. "text": this.json.name || this.json.id
  35. }).inject(this.moveNode);
  36. },
  37. _loadNodeStyles: function(){
  38. var button = this.node.getFirst("button");
  39. if (!button) button = this.node.getFirst("input");
  40. if (button)button.setStyles(this.css.buttonIcon);
  41. },
  42. unSelected: function(){
  43. this.node.setStyles({
  44. "border-top": "1px solid #999",
  45. "border-left": "1px solid #999",
  46. "border-right": "1px solid #333",
  47. "border-bottom": "1px solid #333"
  48. });
  49. if (this.actionArea) this.actionArea.setStyle("display", "none");
  50. this.form.currentSelectedModule = null;
  51. this.hideProperty();
  52. },
  53. unOver: function(){
  54. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this) this.node.setStyles({
  55. "border-top": "1px solid #999",
  56. "border-left": "1px solid #999",
  57. "border-right": "1px solid #333",
  58. "border-bottom": "1px solid #333"
  59. });
  60. },
  61. _createCopyNode: function(){
  62. this.copyNode = new Element("div", {
  63. "styles": this.css.moduleNodeShow
  64. });
  65. this.copyNode.addEvent("selectstart", function(){
  66. return false;
  67. });
  68. },
  69. _getCopyNode: function(){
  70. if (!this.copyNode) this._createCopyNode();
  71. this.copyNode.setStyle("display", "inline-block");
  72. return this.copyNode;
  73. },
  74. _setEditStyle_custom: function(name){
  75. if (name=="name"){
  76. if (this.json.name){
  77. var button = this.node.getElement("button");
  78. if (!button) button = this.node.getFirst("input");
  79. if (button) button.set("text", this.json.name);
  80. }
  81. }
  82. if (name=="id"){
  83. if (!this.json.name){
  84. var button = this.node.getElement("button");
  85. if (!button) button = this.node.getFirst("input");
  86. if (button) button.set("text", this.json.id);
  87. }
  88. }
  89. }
  90. });