archive/app/views/archives/download_file.html.erb

147 lines
7.5 KiB
Plaintext
Raw Normal View History

2020-07-21 03:56:35 +00:00
<% if @ext == 'pdf' %>
2020-12-22 05:23:37 +00:00
<%= render partial: 'archives/viewer' %>
2020-07-21 03:56:35 +00:00
<% else %>
2020-05-20 03:52:25 +00:00
<html lang="<%= I18n.locale.to_s%>" style="margin: 0em; padding: 0em; width: 100%; height: 100%; overflow: hidden; background-color: rgb(230, 230, 230);">
2020-05-17 13:30:39 +00:00
<head>
<meta name="viewport" content="width=device-width, minimum-scale=0.1">
<title><%=@filename%></title>
<link href="/assets/archive/download_file.css" rel="stylesheet" media="all">
</head>
<body>
2021-06-17 09:48:05 +00:00
<h1 style="display: none;"><%=@filename%></h1>
2020-05-20 03:52:25 +00:00
<% if @ext != "png" && @ext != "jpg" && @ext != "bmp" %>
<object data="<%=@url%>" height="100%" type="application/<%=@ext%>" width="100%">
<iframe height="100%" src="<%=@url%>" title="<%=@filename%>" width="100%"></iframe>
2020-06-24 09:45:32 +00:00
<img alt="<%=@filename%>" src="<%=@url%>">
2020-05-20 03:52:25 +00:00
</object>
<% else %>
<img alt="<%=@filename%>" src="<%=@url%>">
<script type="text/javascript">
var img = document.getElementsByTagName('img')[0];
var width = img.width;
var height = img.height;
window.innerWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
window.innerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var window_width = window.innerWidth;
var window_height = window.innerHeight;
var zoom_in_cursor,zoom_out_cursor;
var IE_ver = 11;
if(navigator.userAgent.search("MSIE") != -1){
IE_ver = Number(navigator.userAgent.split("MSIE")[1].split(";")[0]);
}
if(IE_ver <= 8){
img.style.marginTop = "-"+img.height/2+"px";
img.style.marginLeft = "-"+img.width/2+"px";
}else{
img.style.transform= "translate(-50%, -50%)";
img.style["-ms-transform"]= "translate(-50%, -50%)";
img.style["-moz-transform"]= "translate(-50%, -50%)";
}
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
zoom_in_cursor = 'url("/assets/archive/zoomin.cur"), auto';
zoom_out_cursor = 'url("/assets/archive/zoomout.cur"), auto';
}else{
zoom_in_cursor = 'zoom-in';
zoom_out_cursor = 'zoom-out';
}
if(height > window_height && (height / width) > (window_height / window_width) ){
img.height = window_height;
img.width = window_height / height * width;
img.style.cursor = zoom_in_cursor;
if(IE_ver <= 8){
img.style.marginTop = "-"+img.height/2+"px";
img.style.marginLeft = "-"+img.width/2+"px";
}
img.onclick=function(e){
var event = e || window.event;
if(img.style.cursor == zoom_in_cursor){
var cursor_x = event.clientX;
var cursor_y = event.clientY;
img.height = height;
img.width = width;
img.style.cursor = zoom_out_cursor;
document.getElementsByTagName('html')[0].style.overflow = "";
img.style.transform= "none";
img.style["-ms-transform"]= "none";
img.style["-moz-transform"]= "none";
img.style.top= "0";
img.style.left= "0";
if(IE_ver <= 8){
img.style.marginTop = "0";
img.style.marginLeft = "0";
}
window.scroll(
(((cursor_x - (window_width - window_height / height * width)/2) * height / window_height) - window_width / 2),
((cursor_y * height / window_height) - window_height / 2)
);
}else{
img.height = window_height;
img.width = window_height / height * width;
img.style.cursor = zoom_in_cursor;
document.getElementsByTagName('html')[0].style.overflow = "hidden";
if(IE_ver <= 8){
img.style.marginTop = "-"+img.height/2+"px";
img.style.marginLeft = "-"+img.width/2+"px";
}else{
img.style.transform= "translate(-50%, -50%)";
img.style["-ms-transform"]= "translate(-50%, -50%)";
img.style["-moz-transform"]= "translate(-50%, -50%)";
}
img.style.top= "50%";
img.style.left= "50%";
window.scroll(0, 0);
}
};
}else if(width > window_width){
img.width = window_width;
img.height = window_width / width * height;
img.style.cursor = zoom_in_cursor;
if(IE_ver <= 8){
img.style.marginTop = "-"+img.height/2+"px";
img.style.marginLeft = "-"+img.width/2+"px";
}
img.onclick=function(e){
var event = e || window.event;
if(img.style.cursor == zoom_in_cursor){
var cursor_x = event.clientX;
var cursor_y = event.clientY;
img.height = height;
img.width = width;
img.style.cursor = zoom_out_cursor;
document.getElementsByTagName('html')[0].style.overflow = "";
img.style.transform= "none";
img.style["-ms-transform"]= "none";
img.style["-moz-transform"]= "none";
img.style.top= "0";
img.style.left= "0";
if(IE_ver <= 8){
img.style.marginTop = "0";
img.style.marginLeft = "0";
}
window.scroll( ((cursor_x * height / window_height) - window_width / 2),
(((cursor_y - (window_height - window_width / width * height)/2) * height / window_height) - window_height / 2)
);
}else{
img.width = window_width;
img.height = window_width / width * height;
img.style.cursor = zoom_in_cursor;
document.getElementsByTagName('html')[0].style.overflow = "hidden";
if(IE_ver <= 8){
img.style.marginTop = "-"+img.height/2+"px";
img.style.marginLeft = "-"+img.width/2+"px";
}else{
img.style.transform= "translate(-50%, -50%)";
img.style["-ms-transform"]= "translate(-50%, -50%)";
img.style["-moz-transform"]= "translate(-50%, -50%)";
}
img.style.top= "50%";
img.style.left= "50%";
window.scroll(0, 0);
}
};
}
</script>
2020-05-20 03:52:25 +00:00
<% end %>
2020-05-17 13:30:39 +00:00
</body>
2020-07-21 03:56:35 +00:00
</html>
<% end %>