Button.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. button.setStyles(this.css.buttonIcon);
  40. },
  41. unSelected: function(){
  42. this.node.setStyles({
  43. "border-top": "1px solid #999",
  44. "border-left": "1px solid #999",
  45. "border-right": "1px solid #333",
  46. "border-bottom": "1px solid #333"
  47. });
  48. if (this.actionArea) this.actionArea.setStyle("display", "none");
  49. this.form.currentSelectedModule = null;
  50. this.hideProperty();
  51. },
  52. unOver: function(){
  53. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this) this.node.setStyles({
  54. "border-top": "1px solid #999",
  55. "border-left": "1px solid #999",
  56. "border-right": "1px solid #333",
  57. "border-bottom": "1px solid #333"
  58. });
  59. },
  60. _createCopyNode: function(){
  61. this.copyNode = new Element("div", {
  62. "styles": this.css.moduleNodeShow
  63. });
  64. this.copyNode.addEvent("selectstart", function(){
  65. return false;
  66. });
  67. },
  68. _getCopyNode: function(){
  69. if (!this.copyNode) this._createCopyNode();
  70. this.copyNode.setStyle("display", "inline-block");
  71. return this.copyNode;
  72. },
  73. _setEditStyle_custom: function(name){
  74. if (name=="name"){
  75. if (this.json.name){
  76. var button = this.node.getElement("button");
  77. button.set("text", this.json.name);
  78. }
  79. }
  80. if (name=="id"){
  81. if (!this.json.name){
  82. var button = this.node.getElement("button");
  83. button.set("text", this.json.id);
  84. }
  85. }
  86. }
  87. });