OOButton.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Button", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.OOButton = MWF.FCOOButton = new Class({
  4. Extends: MWF.FCButton,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "type": "OOButton",
  9. "path": "../x_component_process_FormDesigner/Module/OOButton/",
  10. "propertyPath": "../x_component_process_FormDesigner/Module/OOButton/OOButton.html"
  11. },
  12. initialize: function(form, options){
  13. this.setOptions(options);
  14. this.path = this.options.path;
  15. this.cssPath = this.path+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.moduleType = "element";
  18. this.moduleName = this.options.type;
  19. this.form = form;
  20. this.container = null;
  21. this.containerNode = null;
  22. },
  23. _createMoveNode: function(){
  24. this.moveNode = new Element("oo-button", {
  25. "MWFType": "OOInput",
  26. "id": this.json.id,
  27. "styles": this.css.moduleNodeMove,
  28. "events": {
  29. "selectstart": function(){
  30. return false;
  31. }
  32. }
  33. }).inject(this.form.container);
  34. this.moveNode.setAttribute("text", this.json.name || this.json.id);
  35. },
  36. _loadNodeStyles: function(){
  37. // this.node.setAttribute('readonly', true);
  38. },
  39. _setEditStyle_custom: function(name){
  40. if (name==="name"){
  41. if (this.json.name){
  42. this.node.setAttribute('text', this.json.name);
  43. }else{
  44. this.node.setAttribute('text', this.json.id);
  45. }
  46. }
  47. if (name==="id"){
  48. if (!this.json.name){
  49. this.node.setAttribute('text', this.json.id);
  50. }
  51. }
  52. if (name==="appearance"){
  53. this.node.setAttribute('type', this.json.appearance || "default");
  54. }
  55. if (name==="leftIcon"){
  56. this.node.setAttribute('left-icon', this.json.leftIcon);
  57. }
  58. if (name==="rightIcon"){
  59. this.node.setAttribute('right-icon', this.json.rightIcon);
  60. }
  61. if (name==="disabled"){
  62. this.node.setAttribute('disabled', this.json.disabled);
  63. }
  64. },
  65. setPropertiesOrStyles: function(name){
  66. if (name=="styles"){
  67. try{
  68. this.setCustomStyles();
  69. }catch(e){}
  70. }
  71. if (name=="inputStyles"){
  72. try{
  73. this.setCustomInputStyles();
  74. }catch(e){}
  75. }
  76. if (name=="properties"){
  77. this.node.setProperties(this.json.properties);
  78. }
  79. },
  80. setCustomStyles: function(){
  81. var border = this.node.getStyle("border");
  82. this._recoveryModuleData();
  83. this.node.clearStyles();
  84. this.node.setStyles(this.css.moduleNode);
  85. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  86. this.node.setStyle("border", border);
  87. this.node.setStyles(this.json.styles);
  88. },
  89. _preprocessingModuleData: function(){
  90. this.node.clearStyles();
  91. this.json.recoveryStyles = Object.clone(this.json.styles);
  92. this.node.setStyles(this.json.recoveryStyles);
  93. this.json.styles = {};
  94. this.json.preprocessing = "y";
  95. },
  96. });