Authorfield.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. MWF.xApplication.cms.FormDesigner.Module = MWF.xApplication.cms.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.cms.FormDesigner.Module.Authorfield = MWF.CMSFCAuthorfield = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements : [MWF.CMSFCMI],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_cms_FormDesigner/Module/Authorfield/authorfield.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_cms_FormDesigner/Module/Authorfield/";
  13. this.cssPath = "../x_component_cms_FormDesigner/Module/Authorfield/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "authorfield";
  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": "authorfield",
  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.authorfieldIcon
  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. _loadNodeStyles: function(){
  53. var icon = this.node.getFirst("div");
  54. var text = this.node.getLast("div");
  55. icon.setStyles(this.css.authorfieldIcon);
  56. text.setStyles(this.css.moduleText);
  57. },
  58. _getCopyNode: function(){
  59. if (!this.copyNode) this._createCopyNode();
  60. this.copyNode.setStyle("display", "inline-block");
  61. return this.copyNode;
  62. },
  63. _setEditStyle_custom: function(name){
  64. if (name=="id"){
  65. this.node.getLast().set("text", this.json.id);
  66. }
  67. },
  68. setPropertiesOrStyles: function(name){
  69. if (name=="styles"){
  70. if (this.parentContainer){
  71. if (this.parentContainer.moduleName == "datagrid$Data"){
  72. if (!this.json.styles.width) this.json.styles.width = "90%";
  73. }
  74. }
  75. try{
  76. this.setCustomStyles();
  77. }catch(e){}
  78. //this.setCustomStyles();
  79. }
  80. if (name=="inputStyles"){
  81. var text = this.node.getLast("div");
  82. text.clearStyles();
  83. text.setStyles(this.css.moduleText);
  84. Object.each(this.json.inputStyles, function(value, key){
  85. var reg = /^border\w*/ig;
  86. if (!key.test(reg)){
  87. text.setStyle(key, value);
  88. }
  89. }.bind(this));
  90. }
  91. if (name=="properties"){
  92. this.node.setProperties(this.json.properties);
  93. }
  94. }
  95. });