ImageClipper.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. MWF.xDesktop.requireApp("process.Xform", "ImageClipper", null, false);
  2. MWF.xApplication.cms.Xform.ImageClipper = MWF.CMSImageClipper = new Class({
  3. Extends: MWF.APPImageClipper,
  4. selectImage: function(d, callback){
  5. var clipperType = this.json.clipperType || "unrestricted";
  6. var ratio = 1;
  7. if( clipperType == "unrestricted" ){
  8. ratio = 0;
  9. }else if( clipperType == "size" ){
  10. var width = this.json.imageWidth.toInt();
  11. var height = this.json.imageHeight.toInt();
  12. ratio = width / height
  13. }else if( clipperType == "ratio" ){
  14. ratio = this.json.imageRatio || 1
  15. }
  16. MWF.xDesktop.requireApp("process.Xform", "widget.ImageClipper", function(){
  17. this.imageClipper = new MWF.xApplication.process.Xform.widget.ImageClipper(this.form.app, {
  18. "style": "default",
  19. "aspectRatio" : ratio,
  20. "imageUrl" : d ? MWF.xDesktop.getImageSrc( d ) : "",
  21. "reference" : this.form.businessData.document.id,
  22. "referenceType": "cmsDocument",
  23. "onChange" : function(){
  24. callback( { src : this.imageClipper.imageSrc, id : this.imageClipper.imageId } );
  25. }.bind(this)
  26. });
  27. this.imageClipper.load();
  28. }.bind(this));
  29. },
  30. validationConfigItem: function(routeName, data){
  31. var flag = (data.status=="all") ? true: (routeName == "publish");
  32. if (flag){
  33. var n = this.getData();
  34. var v = (data.valueType=="value") ? n : n.length;
  35. switch (data.operateor){
  36. case "isnull":
  37. if (!v){
  38. this.notValidationMode(data.prompt);
  39. return false;
  40. }
  41. break;
  42. case "notnull":
  43. if (v){
  44. this.notValidationMode(data.prompt);
  45. return false;
  46. }
  47. break;
  48. case "gt":
  49. if (v>data.value){
  50. this.notValidationMode(data.prompt);
  51. return false;
  52. }
  53. break;
  54. case "lt":
  55. if (v<data.value){
  56. this.notValidationMode(data.prompt);
  57. return false;
  58. }
  59. break;
  60. case "equal":
  61. if (v==data.value){
  62. this.notValidationMode(data.prompt);
  63. return false;
  64. }
  65. break;
  66. case "neq":
  67. if (v!=data.value){
  68. this.notValidationMode(data.prompt);
  69. return false;
  70. }
  71. break;
  72. case "contain":
  73. if (v.indexOf(data.value)!=-1){
  74. this.notValidationMode(data.prompt);
  75. return false;
  76. }
  77. break;
  78. case "notcontain":
  79. if (v.indexOf(data.value)==-1){
  80. this.notValidationMode(data.prompt);
  81. return false;
  82. }
  83. break;
  84. }
  85. }
  86. return true;
  87. }
  88. });