summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAlexey Fansky <alexey.fansky@effective-soft.com>2014-12-22 12:05:53 -0800
committerVaadin Code Review <review@vaadin.com>2015-01-27 08:24:10 +0000
commitb8d69b6b397ba2d669aa16e297d900e5e079d1e9 (patch)
tree04e22692c8d5b5b69ca17f6f7b1cb3ddb3a7c9aa /client
parenteceb044f0d9c60e2a37a7a778d20f68341c9dae8 (diff)
downloadvaadin-framework-b8d69b6b397ba2d669aa16e297d900e5e079d1e9.tar.gz
vaadin-framework-b8d69b6b397ba2d669aa16e297d900e5e079d1e9.zip
FileDownloader opens file in a new tab (iOS) (#15366)
Opening files in a new tab because iframe with a file isn't opened in iOS. Change-Id: I7f8af4b9348ade0f845e3a656c7287490b9482cf
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/extensions/FileDownloaderConnector.java36
1 files changed, 22 insertions, 14 deletions
diff --git a/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java b/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java
index 66fc30575b..bed6622a6c 100644
--- a/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java
+++ b/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java
@@ -23,11 +23,14 @@ import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.BrowserInfo;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.server.FileDownloader;
+import com.vaadin.shared.VBrowserDetails;
import com.vaadin.shared.ui.Connect;
@Connect(FileDownloader.class)
@@ -47,22 +50,27 @@ public class FileDownloaderConnector extends AbstractExtensionConnector
public void onClick(ClickEvent event) {
final String url = getResourceUrl("dl");
if (url != null && !url.isEmpty()) {
- if (iframe != null) {
- // make sure it is not on dom tree already, might start
- // multiple downloads at once
- iframe.removeFromParent();
- }
- iframe = Document.get().createIFrameElement();
+ BrowserInfo browser = BrowserInfo.get();
+ if (browser.isIOS()) {
+ Window.open(url, "_blank", "");
+ } else {
+ if (iframe != null) {
+ // make sure it is not on dom tree already, might start
+ // multiple downloads at once
+ iframe.removeFromParent();
+ }
+ iframe = Document.get().createIFrameElement();
- Style style = iframe.getStyle();
- style.setVisibility(Visibility.HIDDEN);
- style.setHeight(0, Unit.PX);
- style.setWidth(0, Unit.PX);
+ Style style = iframe.getStyle();
+ style.setVisibility(Visibility.HIDDEN);
+ style.setHeight(0, Unit.PX);
+ style.setWidth(0, Unit.PX);
- iframe.setFrameBorder(0);
- iframe.setTabIndex(-1);
- iframe.setSrc(url);
- RootPanel.getBodyElement().appendChild(iframe);
+ iframe.setFrameBorder(0);
+ iframe.setTabIndex(-1);
+ iframe.setSrc(url);
+ RootPanel.getBodyElement().appendChild(iframe);
+ }
}
}