package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery; import java.util.List; import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONString; import com.google.gwt.user.client.ui.HTMLPanel; public class ImagesGallery { HTMLPanel galleryPanel = new HTMLPanel("
"); private List listImages; private native void showGallery(JavaScriptObject json_array_images) /*-{ console.log("showing: " + json_array_images) var waitForJQuery = setInterval( function() { if (typeof $wnd.$ != 'undefined') { $wnd .$("#nanogallery") .nanogallery2( { thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=250px, XS resolution=200px, SM resolution=200px thumbnailWidth : 'auto', // RESPONSIVE THUMBNAIL WIDTH: default=250px, XS resolution=150px, SM resolution=200px thumbnailAlignment : 'left', thumbnailBorderHorizontal : 0, thumbnailBorderVertical : 0, thumbnailGutterWidth : '10 XS10 SM10', thumbnailGutterHeight : '10 XS10 SM10', // THUMBNAIL TOOLS & LABEL thumbnailLabel : { display : true, position : 'onBottom', align : 'left' }, thumbnailToolbarImage : { bottomLeft : 'display' }, // replace the default DISPLAY tool icon icons : { thumbnailDisplay : ' display' }, // DISPLAY ANIMATION galleryDisplayTransition : 'slideUp', galleryDisplayTransitionDuration : 1000, thumbnailDisplayTransition : 'scaleDown', thumbnailDisplayTransitionDuration : 300, thumbnailDisplayInterval : 50, // THUMBNAIL'S HOVER ANIMATION //thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em', thumbnailHoverEffect2 : 'image_scale_1.00_1.20_1000|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px', touchAnimation : true, touchAutoOpenDelay : 800, // GALLERY THEME galleryTheme : { thumbnail : { borderRadius : '2px', background : '#fff', titleShadow : 'none', titleColor : 'gray', labelBackground : '#f3f3f3' }, thumbnailIcon : { color : '#000', shadow : 'none' }, }, viewerToolbar : { display : true, standard : 'minimizeButton, label', minimized : 'minimizeButton, label, fullscreenButton, downloadButton' }, viewerTools : { topLeft : 'pageCounter', topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton' }, // DEEP LINKING locationHash : false, items : json_array_images }) clearInterval(waitForJQuery); } }, 200); }-*/; public ImagesGallery(List immagini) { this.listImages = immagini; } public HTMLPanel getGalleryPanel() { return galleryPanel; } public void fillGallery() { JSONArray jsonArray = new JSONArray(); int index = 0; for (UploadedImageDV image : listImages) { for (WorkspaceContentDV imageContent : image.getListWsContent()) { JSONObject json = new JSONObject(); json.put("src", new JSONString(imageContent.getLink())); json.put("srct", new JSONString(imageContent.getLink())); List listAuthors = image.getResponsabili(); String txtAuthors = listAuthors.size()>1 ? "Authors ": "Author "; for (String author : listAuthors) { txtAuthors+= " "+author +","; } String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); txtAuthors = txtAuthors.substring(0,txtAuthors.length()-1); json.put("title", new JSONString(image.getDidascalia())); json.put("description", new JSONString(description)); json.put("downloadURL", new JSONString(imageContent.getLink())); jsonArray.set(index, json); index++; } } showGallery(jsonArray.getJavaScriptObject()); } }