From 8e0886835417562b7f7e7a47c527ffdeac66af4d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 00:50:48 +0000 Subject: [PATCH] mujma: BUGFIX: Fixed buttons(Ok/Cancel) visibility after "Crop area to small" message. (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@41989 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/ImageEditor/Crop.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/javascript/ImageEditor/Crop.js b/javascript/ImageEditor/Crop.js index d1dbfd0b..fedb4f48 100644 --- a/javascript/ImageEditor/Crop.js +++ b/javascript/ImageEditor/Crop.js @@ -14,7 +14,6 @@ var Crop = { this.centerCropBox = Crop.centerCropBox.bind(this); this.placeGreyBox = Crop.placeGreyBox.bind(this); this.setListeners = Crop.setListeners.bind(this); - this.onCropStop = Crop.onCropStop.bind(this); this.onCropStart = Crop.onCropStart.bind(this); this.onCropOk = Crop.onCropOk.bind(this); this.onCropCancel = Crop.onCropCancel.bind(this); @@ -31,7 +30,7 @@ var Crop = { getMousePos: Crop.getMousePos.bind(this) }; this.resizeCropBox = new Resizeable.initialize(this.cropBox,options); - Event.observe(this.cropBox,'dblclick',this.onCropStop.bind(this)); + Event.observe(this.cropBox,'dblclick',this.onCropOk.bind(this)); this.setListeners(); this.isVisible = false; this.setVisible(this.isVisible); @@ -97,11 +96,6 @@ var Crop = { return {x: x,y: y}; }, - onCropStop: function(event) { - Element.hide($('cropOk'),$('cropCancel')); - this.doCrop(); - }, - doCrop: function() { if(this.isEnabled) { newWidth = this.cropBox.getWidth() @@ -110,11 +104,13 @@ var Crop = { startLeft = this.cropBox.getLeft() ; if(newWidth > 35 && newHeight > 35) { imageTransformation.crop(startTop,startLeft,newWidth,newHeight,Crop.cropCallback.bind(this)); + this.disable(); } else { - alert('Crop area too small'); + alert('Crop area too small'); + return false; } - this.disable(); $('image').style.visibility = 'visible';//hack for IE for not selecting image during crop + return true; } }, @@ -142,9 +138,7 @@ var Crop = { onCropOk: function() { if(this.isEnabled) { - Element.hide($('cropOk'),$('cropCancel')); - this.doCrop(); - effects.disableRotate(); + if(this.doCrop()) Element.hide($('cropOk'),$('cropCancel')); } },