Select.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.Select = MWF.FCSelect = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_process_FormDesigner/Module/Select/select.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_process_FormDesigner/Module/Select/";
  13. this.cssPath = "/x_component_process_FormDesigner/Module/Select/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "select";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "select",
  24. "styles": this.css.moduleNodeMove,
  25. "id": this.json.id,
  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.selectIcon
  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. icon.setStyles(this.css.selectIcon);
  44. text.setStyles(this.css.moduleText);
  45. },
  46. _getCopyNode: function(){
  47. if (!this.copyNode) this._createCopyNode();
  48. this.copyNode.setStyle("display", "inline-block");
  49. return this.copyNode;
  50. },
  51. clearTemplateStyles: function(styles){
  52. if (styles){
  53. if (styles.styles) this.removeStyles(styles.styles, "styles");
  54. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  55. if (styles.properties) this.removeStyles(styles.properties, "properties");
  56. }
  57. },
  58. setTemplateStyles: function(styles){
  59. if (styles.styles) this.copyStyles(styles.styles, "styles");
  60. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  61. if (styles.properties) this.copyStyles(styles.properties, "properties");
  62. },
  63. setPropertiesOrStyles: function(name){
  64. if (name=="styles"){
  65. if (this.parentContainer){
  66. if (this.parentContainer.moduleName == "datagrid$Data"){
  67. if (!this.json.styles.width) this.json.styles.width = "90%";
  68. }
  69. }
  70. try{
  71. this.setCustomStyles();
  72. }catch(e){}
  73. }
  74. if (name=="inputStyles"){
  75. var text = this.node.getLast("div");
  76. text.clearStyles();
  77. text.setStyles(this.css.moduleText);
  78. Object.each(this.json.inputStyles, function(value, key){
  79. var reg = /^border\w*/ig;
  80. if (!key.test(reg)){
  81. text.setStyle(key, value);
  82. }
  83. }.bind(this));
  84. }
  85. if (name=="properties"){
  86. this.node.setProperties(this.json.properties);
  87. }
  88. },
  89. _setEditStyle_custom: function(name){
  90. if (name=="id"){
  91. this.node.getLast().set("text", this.json.id);
  92. }
  93. },
  94. setPropertiesOrStyles: function(name){
  95. if (name=="styles"){
  96. if (this.parentContainer){
  97. if (this.parentContainer.moduleName == "datagrid$Data"){
  98. if (!this.json.styles.width) this.json.styles.width = "90%";
  99. }
  100. }
  101. try{
  102. this.setCustomStyles();
  103. }catch(e){}
  104. }
  105. if (name=="inputStyles"){
  106. var text = this.node.getLast("div");
  107. text.clearStyles();
  108. text.setStyles(this.css.moduleText);
  109. Object.each(this.json.inputStyles, function(value, key){
  110. var reg = /^border\w*/ig;
  111. if (!key.test(reg)){
  112. text.setStyle(key, value);
  113. }
  114. }.bind(this));
  115. }
  116. if (name=="properties"){
  117. this.node.setProperties(this.json.properties);
  118. }
  119. }
  120. });