Select.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. 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.selectIcon);
  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. clearTemplateStyles: function(styles){
  54. if (styles){
  55. if (styles.styles) this.removeStyles(styles.styles, "styles");
  56. if (styles.inputStyles) this.removeStyles(styles.inputStyles, "inputStyles");
  57. if (styles.properties) this.removeStyles(styles.properties, "properties");
  58. }
  59. },
  60. setTemplateStyles: function(styles){
  61. if (styles.styles) this.copyStyles(styles.styles, "styles");
  62. if (styles.inputStyles) this.copyStyles(styles.inputStyles, "inputStyles");
  63. if (styles.properties) this.copyStyles(styles.properties, "properties");
  64. },
  65. setPropertiesOrStyles: function(name){
  66. if (name=="styles"){
  67. if (this.parentContainer){
  68. if (this.parentContainer.moduleName == "datagrid$Data"){
  69. if (!this.json.styles.width) this.json.styles.width = "90%";
  70. }
  71. }
  72. try{
  73. this.setCustomStyles();
  74. }catch(e){}
  75. }
  76. if (name=="inputStyles"){
  77. var text = this.node.getLast("div");
  78. text.clearStyles();
  79. text.setStyles(this.css.moduleText);
  80. Object.each(this.json.inputStyles, function(value, key){
  81. var reg = /^border\w*/ig;
  82. if (!key.test(reg)){
  83. text.setStyle(key, value);
  84. }
  85. }.bind(this));
  86. }
  87. if (name=="properties"){
  88. this.node.setProperties(this.json.properties);
  89. }
  90. },
  91. _setEditStyle_custom: function(name){
  92. if (name=="id"){
  93. this.node.getLast().set("text", this.json.id);
  94. }
  95. },
  96. setPropertiesOrStyles: function(name){
  97. if (name=="styles"){
  98. if (this.parentContainer){
  99. if (this.parentContainer.moduleName == "datagrid$Data"){
  100. if (!this.json.styles.width) this.json.styles.width = "90%";
  101. }
  102. }
  103. try{
  104. this.setCustomStyles();
  105. }catch(e){}
  106. }
  107. if (name=="inputStyles"){
  108. var text = this.node.getLast("div");
  109. text.clearStyles();
  110. text.setStyles(this.css.moduleText);
  111. Object.each(this.json.inputStyles, function(value, key){
  112. var reg = /^border\w*/ig;
  113. if (!key.test(reg)){
  114. text.setStyle(key, value);
  115. }
  116. }.bind(this));
  117. }
  118. if (name=="properties"){
  119. this.node.setProperties(this.json.properties);
  120. }
  121. }
  122. });