Number.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Textfield", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.Number = MWF.FCNumber = new Class({
  4. Extends: MWF.FCTextfield,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Number/number.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Number/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Number/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "number";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. clearTemplateStyles: function(styles){
  22. if (styles){
  23. if (styles.styles) this.removeStyles(styles.styles, "styles");
  24. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  25. if (styles.properties) this.removeStyles(styles.properties, "properties");
  26. }
  27. },
  28. setTemplateStyles: function(styles){
  29. if (styles.styles) this.copyStyles(styles.styles, "styles");
  30. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  31. if (styles.properties) this.copyStyles(styles.properties, "properties");
  32. },
  33. _createMoveNode: function(){
  34. this.moveNode = new Element("div", {
  35. "MWFType": "textfield",
  36. "id": this.json.id,
  37. "styles": this.css.moduleNodeMove,
  38. "events": {
  39. "selectstart": function(){
  40. return false;
  41. }
  42. }
  43. }).inject(this.form.container);
  44. var icon = new Element("div", {
  45. "styles": this.css.textfieldIcon
  46. }).inject(this.moveNode);
  47. var text = new Element("div", {
  48. "styles": this.css.moduleText,
  49. "text": this.json.id
  50. }).inject(this.moveNode);
  51. },
  52. setPropertiesOrStyles: function(name){
  53. if (name=="styles"){
  54. // if (this.parentContainer){
  55. // if (this.parentContainer.moduleName == "datagrid$Data"){
  56. // if (!this.json.styles.width) this.json.styles.width = "90%";
  57. // }
  58. // }
  59. this.setCustomStyles();
  60. }
  61. if (name=="properties"){
  62. this.node.setProperties(this.json.properties);
  63. }
  64. },
  65. _loadNodeStyles: function(){
  66. var icon = this.node.getFirst("div");
  67. var text = this.node.getLast("div");
  68. if (!icon) icon = new Element("div").inject(this.node, "top");
  69. if (!text) text = new Element("div").inject(this.node, "bottom");
  70. icon.setStyles(this.css.textfieldIcon);
  71. text.setStyles(this.css.moduleText);
  72. },
  73. _getCopyNode: function(){
  74. if (!this.copyNode) this._createCopyNode();
  75. this.copyNode.setStyle("display", "inline-block");
  76. return this.copyNode;
  77. },
  78. _setEditStyle_custom: function(name){
  79. if (name=="id"){
  80. this.node.getLast().set("text", this.json.id);
  81. }
  82. }
  83. });