Textfield.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("cms.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.cms.FormDesigner.Module.Textfield = MWF.CMSFCTextfield = new Class({
  4. Extends: MWF.CMSFC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "/x_component_cms_FormDesigner/Module/Textfield/textfield.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "/x_component_cms_FormDesigner/Module/Textfield/";
  13. this.cssPath = "/x_component_cms_FormDesigner/Module/Textfield/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "textfield";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _createMoveNode: function(){
  22. this.moveNode = new Element("div", {
  23. "MWFType": "textfield",
  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.textfieldIcon
  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. setPropertiesOrStyles: function(name){
  41. if (name=="styles"){
  42. if (this.parentContainer){
  43. if (this.parentContainer.moduleName == "datagrid$Data"){
  44. if (!this.json.styles.width) this.json.styles.width = "90%";
  45. }
  46. }
  47. this.setCustomStyles();
  48. }
  49. if (name=="properties"){
  50. this.node.setProperties(this.json.properties);
  51. }
  52. },
  53. _loadNodeStyles: function(){
  54. var icon = this.node.getFirst("div");
  55. var text = this.node.getLast("div");
  56. icon.setStyles(this.css.textfieldIcon);
  57. text.setStyles(this.css.moduleText);
  58. },
  59. _getCopyNode: function(){
  60. if (!this.copyNode) this._createCopyNode();
  61. this.copyNode.setStyle("display", "inline-block");
  62. return this.copyNode;
  63. },
  64. _setEditStyle_custom: function(name){
  65. if (name=="id"){
  66. this.node.getLast().set("text", this.json.id);
  67. }
  68. }
  69. });