From: <san...@us...> - 2010-08-12 06:45:54
|
Revision: 11117 http://wonder.svn.sourceforge.net/wonder/?rev=11117&view=rev Author: santoash Date: 2010-08-12 06:45:47 +0000 (Thu, 12 Aug 2010) Log Message: ----------- changed to logic to zoom only when there is two different versions of image are present Modified Paths: -------------- branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.html branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.wod branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb/components/misc/ERDZoomableImage.java Modified: branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.html =================================================================== --- branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.html 2010-08-12 00:15:50 UTC (rev 11116) +++ branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.html 2010-08-12 06:45:47 UTC (rev 11117) @@ -2,44 +2,53 @@ <script> var ZoomableImage = { openImageFromURL: function(url, height, width) - { - var myWidth = (screen.availWidth > 800) ? (screen.availWidth - 100) : screen.availWidth; // if 800x600 or less, take up - var myHeight = (screen.availHeight > 600) ? (screen.availHeight - 100) : (screen.availHeight - 70); // the whole screen. - var myLeft = Math.round((screen.availWidth - myWidth) / 2); - var myTop = Math.round((screen.availHeight - myHeight) / 2)-25; - - - if (myTop < 0) { myTop = 0; } // bugfix for Opera - if (screen.availHeight < 600) { myTop-=20; } - var horizontalScrollbar = true; - var verticalScrollbar = true; - - if(width > 0 && width < myWidth) { - myWidth = width; - //horizontalScrollbar = false; - } - - if(height > 0 && height < myHeight) { - myHeight = height; - //verticalScrollbar = false; - } - - var scrollbars = "yes"; - //if(!horizontalScrollbar && !verticalScrollbar) scrollbars = "no"; + { + var myWidth = (screen.availWidth > 800) ? (screen.availWidth - 100) : screen.availWidth; // if 800x600 or less, take up + var myHeight = (screen.availHeight > 600) ? (screen.availHeight - 100) : (screen.availHeight - 70); // the whole screen. + var myLeft = Math.round((screen.availWidth - myWidth) / 2); + var myTop = Math.round((screen.availHeight - myHeight) / 2)-25; + + + if (myTop < 0) { myTop = 0; } // bugfix for Opera + if (screen.availHeight < 600) { myTop-=20; } + var horizontalScrollbar = true; + var verticalScrollbar = true; + + if(width > 0 && width < myWidth) { + myWidth = width; + //horizontalScrollbar = false; + } + + if(height > 0 && height < myHeight) { + myHeight = height; + //verticalScrollbar = false; + } + + var scrollbars = "yes"; + //if(!horizontalScrollbar && !verticalScrollbar) scrollbars = "no"; console.info("myheight:" + myHeight); - console.info("mywidth:" + myWidth); + console.info("mywidth:" + myWidth); console.info("screen.width:" + screen.availWidth); - var openCurrentImageWindow = window.open(url, 'FullSizeImage', 'scrollbars='+scrollbars+',titlebar=no,location=no,status=no,toolbar=no,resizable=yes,width='+ myWidth +',height='+ myHeight +',top='+myTop+',left='+myLeft); - openCurrentImageWindow.focus(); - return false; - } + var openCurrentImageWindow = window.open(url, 'FullSizeImage', 'scrollbars='+scrollbars+',titlebar=no,location=no,status=no,toolbar=no,resizable=yes,width='+ myWidth +',height='+ myHeight +',top='+myTop+',left='+myLeft); + openCurrentImageWindow.focus(); + return false; + } }; </script> </webobject> <webobject name = "ValidThumbnailSrcExist"> -<webobject name="ZoomImageLink"> - <webobject name="Thumbnail"></webobject> + <!-- zoom case --> + <webobject name = "EnableZoom"> + <webobject name="ZoomImageLink"> + <webobject name="Thumbnail"></webobject> + </webobject> + </webobject> + <!-- no zoom case --> + <webobject name = "DisableZoom"> + <webobject name="Thumbnail"></webobject> + </webobject> </webobject> -</webobject> + +<!-- no image case --> <webobject name = "ValidThumbnailSrcDoesntExist"><webobject name="NoImageString"></webobject></webobject> Modified: branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.wod =================================================================== --- branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.wod 2010-08-12 00:15:50 UTC (rev 11116) +++ branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Components/Nonlocalized.lproj/ERDZoomableImage.wo/ERDZoomableImage.wod 2010-08-12 06:45:47 UTC (rev 11117) @@ -25,4 +25,13 @@ NoImageString : WOString { value = noImageString; +} + +EnableZoom : WOConditional { + condition = enableZoom; +} + +DisableZoom : WOConditional { + condition = enableZoom; + negate = true; } \ No newline at end of file Modified: branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb/components/misc/ERDZoomableImage.java =================================================================== --- branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb/components/misc/ERDZoomableImage.java 2010-08-12 00:15:50 UTC (rev 11116) +++ branches/Wonder_2_0_0_Branch/Wonder/Common/Frameworks/ERDirectToWeb/Sources/er/directtoweb/components/misc/ERDZoomableImage.java 2010-08-12 06:45:47 UTC (rev 11117) @@ -96,12 +96,31 @@ } /** + * @return {@link Boolean} true, if {@link ERDZoomableImage#thumnailSrc()} returns an empty or null string + * false, otherwise + */ + public boolean isThumbnailSrcNullOrEmpty() { + return ERXStringUtilities.stringIsNullOrEmpty(thumnailSrc()); + } + + /** * controlled by key: enableZoomForImage + * and if either thumbnailSrc or height or width is present (there is no point zooming without these properties passed in) * @return {@link Boolean} - true, if zooming is allowed. false, otherwise. */ public Boolean enableZoom() { - return ERXValueUtilities.booleanValue(valueForBinding("enableZoomForImage")); + String thumbnailSrc = thumbnailSrcNoFallBack(); + boolean isThumbnailSrcOrHeightOrWidthPresent = (thumbnailSrc != null && thumbnailSrc.length() >0) || valueForBinding("height") != null || valueForBinding("width") != null; + return ERXValueUtilities.booleanValue(valueForBinding("enableZoomForImage")) && isThumbnailSrcOrHeightOrWidthPresent; } + + String thumbnailSrcNoFallBack() { + return (String) valueForBinding("thumbnailSrc"); + } + + public Boolean disableZoom() { + return !enableZoom(); + } public String jsToZoomImage() { StringBuffer sb = new StringBuffer(); @@ -122,4 +141,11 @@ public String noImageString() { return (String) valueForBinding("noImageString"); } + + /** + * @return String to use when imageSrc() turns out to be null + */ + public String noImageString() { + return (String) valueForBinding("noImageString"); + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |