Make download into a button

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-02-24 16:28:12 +01:00
parent a6bb203a4b
commit b068a4c055
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -169,6 +169,15 @@ export default class ImageView extends React.Component {
});
}
onDownloadClick = (ev) => {
ev.preventDefault();
ev.stopPropagation();
const a = document.createElement("a");
a.href = this.props.src;
a.download = this.props.name;
a.click();
}
onPanelClick = (ev) => {
this.props.onFinished();
}
@ -281,13 +290,11 @@ export default class ImageView extends React.Component {
title={_t("Zoom in")}
onClick={ this.onZoomInClick }>
</AccessibleTooltipButton>
<a
<AccessibleTooltipButton
className="mx_ImageView_button mx_ImageView_button_download"
href={ this.props.src }
download={ this.props.name }
title={_t("Download")}
target="_blank" rel="noopener">
</a>
onClick={ this.onDownloadClick }>
</AccessibleTooltipButton>
<AccessibleTooltipButton
className="mx_ImageView_button mx_ImageView_button_close"
title={_t("Close")}