TinyMCEEditor.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. MWF.xDesktop.requireApp("process.Xform", "TinyMCEEditor", null, false);
  2. MWF.xApplication.cms.Xform.TinyMCEEditor = MWF.CMSTinyMCEEditor = new Class({
  3. Extends: MWF.APPTinyMCEEditor,
  4. getImageUploadOption: function(){
  5. return {
  6. localImageMaxWidth : 2000,
  7. reference: this.form.businessData.document.id,
  8. referenceType: "cmsDocument"
  9. };
  10. },
  11. getEditorId: function(){
  12. return this.form.businessData.document.id +"_"+this.json.id.split(".").join("_") + "_" + (layout.mobile ? "mobile" : "pc");
  13. },
  14. getText: function () {
  15. return (this.editor && this.editor.getContent) ? this.editor.getContent({format: 'text'}) : "";
  16. },
  17. getImages: function () {
  18. if( !this.editor || !this.editor.getBody || !this.editor.getBody() )return [];
  19. return this.editor.getBody().getElementsByTagName("img");
  20. },
  21. getImageIds: function () {
  22. var result = [];
  23. var images = this.getImages();
  24. for (var i = 0; i < images.length; i++) {
  25. var img = images[i];
  26. if (img.getAttribute("data-id")) {
  27. result.push(img.getAttribute("data-id"))
  28. }
  29. }
  30. return result;
  31. },
  32. _loadStyles: function () {
  33. if (this.json.styles) this.node.setStyles(this.json.styles);
  34. this.node.setStyle("overflow", "hidden");
  35. },
  36. validationConfigItem: function (routeName, data) {
  37. var flag = (data.status == "all") ? true : (routeName == "publish");
  38. if (flag) {
  39. var n = this.getData();
  40. var v = (data.valueType == "value") ? n : n.length;
  41. switch (data.operateor) {
  42. case "isnull":
  43. if (!v) {
  44. this.notValidationMode(data.prompt);
  45. return false;
  46. }
  47. break;
  48. case "notnull":
  49. if (v) {
  50. this.notValidationMode(data.prompt);
  51. return false;
  52. }
  53. break;
  54. case "gt":
  55. if (v > data.value) {
  56. this.notValidationMode(data.prompt);
  57. return false;
  58. }
  59. break;
  60. case "lt":
  61. if (v < data.value) {
  62. this.notValidationMode(data.prompt);
  63. return false;
  64. }
  65. break;
  66. case "equal":
  67. if (v == data.value) {
  68. this.notValidationMode(data.prompt);
  69. return false;
  70. }
  71. break;
  72. case "neq":
  73. if (v != data.value) {
  74. this.notValidationMode(data.prompt);
  75. return false;
  76. }
  77. break;
  78. case "contain":
  79. if (v.indexOf(data.value) != -1) {
  80. this.notValidationMode(data.prompt);
  81. return false;
  82. }
  83. break;
  84. case "notcontain":
  85. if (v.indexOf(data.value) == -1) {
  86. this.notValidationMode(data.prompt);
  87. return false;
  88. }
  89. break;
  90. }
  91. }
  92. return true;
  93. }
  94. });