ModuleImplements.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. MWF.xDesktop.requireApp("process.Xform", "$Input", null, false);
  2. if( !MWF.CMS$Input_Process ){
  3. MWF.CMS$Input_Process = {
  4. validationConfigItem : MWF.xApplication.process.Xform.$Input.prototype.validationConfigItem.$origin,
  5. _loadStyles : MWF.xApplication.process.Xform.$Input.prototype._loadStyles.$origin
  6. };
  7. MWF.xApplication.process.Xform.$Input.implement({
  8. _loadStyles: function(){
  9. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  10. var isCMS = this.form.app.options.name.toLowerCase().contains("cms");
  11. if( isCMS ){
  12. return this._loadStyles_CMS();
  13. }else{
  14. return this._loadStyles_Process();
  15. }
  16. },
  17. _loadStyles_Process : MWF.CMS$Input_Process._loadStyles,
  18. _loadStyles_CMS: function(){
  19. if (this.json.styles) this.node.setStyles(this.json.styles);
  20. if( this.readonly ){
  21. var parent = this.node.parentNode;
  22. if( parent.tagName.toLowerCase() == "td" ){
  23. var border = parent.getStyle("borderBottomWidth");
  24. if( border.toInt() > 0 ){
  25. this.node.setStyle("border","0px");
  26. }
  27. }
  28. }
  29. if (this.json.inputStyles) if (this.node.getFirst()) this.node.getFirst().setStyles(this.json.inputStyles);
  30. if (this.iconNode && this.iconNode.offsetParent !== null ){
  31. var size = this.node.getSize();
  32. this.iconNode.setStyle("height", ""+size.y+"px");
  33. }
  34. },
  35. validationConfigItem: function(routeName, data){
  36. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  37. var isCMS = this.form.app.options.name.toLowerCase().contains("cms");
  38. if( isCMS ){
  39. return this.validationConfigItem_CMS( routeName, data );
  40. }else{
  41. return this.validationConfigItem_Process( routeName, data );
  42. }
  43. },
  44. validationConfigItem_Process : MWF.CMS$Input_Process.validationConfigItem,
  45. validationConfigItem_CMS: function(routeName, data){
  46. var flag = (data.status=="all") ? true: ( routeName == "publish");
  47. if (flag){
  48. var n = this.getInputData();
  49. var v = (data.valueType=="value") ? n : n.length;
  50. switch (data.operateor){
  51. case "isnull":
  52. if (!v){
  53. this.notValidationMode(data.prompt);
  54. return false;
  55. }
  56. break;
  57. case "notnull":
  58. if (v){
  59. this.notValidationMode(data.prompt);
  60. return false;
  61. }
  62. break;
  63. case "gt":
  64. if (v>data.value){
  65. this.notValidationMode(data.prompt);
  66. return false;
  67. }
  68. break;
  69. case "lt":
  70. if (v<data.value){
  71. this.notValidationMode(data.prompt);
  72. return false;
  73. }
  74. break;
  75. case "equal":
  76. if (v==data.value){
  77. this.notValidationMode(data.prompt);
  78. return false;
  79. }
  80. break;
  81. case "neq":
  82. if (v!=data.value){
  83. this.notValidationMode(data.prompt);
  84. return false;
  85. }
  86. break;
  87. case "contain":
  88. if (v.indexOf(data.value)!=-1){
  89. this.notValidationMode(data.prompt);
  90. return false;
  91. }
  92. break;
  93. case "notcontain":
  94. if (v.indexOf(data.value)==-1){
  95. this.notValidationMode(data.prompt);
  96. return false;
  97. }
  98. break;
  99. }
  100. }
  101. return true;
  102. }
  103. });
  104. }
  105. MWF.xApplication.cms = MWF.xApplication.cms || {};
  106. MWF.xApplication.cms.Xform = MWF.xApplication.cms.Xform || {};
  107. MWF.xApplication.cms.Xform.ModuleImplements = {};