Checkbox.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.Checkbox = MWF.FCCheckbox = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Checkbox/checkbox.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Checkbox/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Checkbox/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "checkbox";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "checkbox",
  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 icon = new Element("div", {
  33. "styles": this.css.checkboxIcon
  34. }).inject(this.moveNode);
  35. var text = new Element("div", {
  36. "styles": this.css.moduleText,
  37. "text": this.json.id
  38. }).inject(this.moveNode);
  39. },
  40. _loadNodeStyles: function(){
  41. var icon = this.node.getFirst("div");
  42. var text = this.node.getLast("div");
  43. if (!icon) icon = new Element("div").inject(this.node, "top");
  44. if (!text) text = new Element("div").inject(this.node, "bottom");
  45. icon.setStyles(this.css.checkboxIcon);
  46. text.setStyles(this.css.moduleText);
  47. },
  48. _getCopyNode: function(){
  49. if (!this.copyNode) this._createCopyNode();
  50. this.copyNode.setStyle("display", "inline-block");
  51. return this.copyNode;
  52. },
  53. unSelected: function(){
  54. this.node.setStyles({
  55. "border-width": "1px",
  56. "border-color": "#999"
  57. });
  58. if (this.actionArea) this.actionArea.setStyle("display", "none");
  59. this.form.currentSelectedModule = null;
  60. this.hideProperty();
  61. },
  62. unOver: function(){
  63. if (!this.form.moveModule) if (this.form.currentSelectedModule!=this) this.node.setStyles({
  64. "border-width": "1px",
  65. "border-color": "#999"
  66. });
  67. },
  68. _setEditStyle_custom: function(name){
  69. if (name=="id"){
  70. this.node.getLast().set("text", this.json.id);
  71. }
  72. }
  73. });