From 2055cfaf9a5ad6bd39f9fadd7ed8512dad923b88 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Mon, 13 Jan 2020 16:24:06 +0100 Subject: [PATCH] restore advertisement --- res/include/img/spinner.svg | 2 +- res/include/script/Viewer.js | 43 ++++++++- res/include/style/viewer.css | 21 ++++- res/template/admin.html | 2 + res/template/file_viewer.html | 5 +- res/template/fragments/analytics.html | 10 --- webcontroller/file_preview.go | 6 +- webcontroller/user_style.go | 120 +++++++++++++++++--------- 8 files changed, 149 insertions(+), 60 deletions(-) diff --git a/res/include/img/spinner.svg b/res/include/img/spinner.svg index df55567..8876a1a 100644 --- a/res/include/img/spinner.svg +++ b/res/include/img/spinner.svg @@ -7,7 +7,7 @@ viewBox="0 0 80 80" xml:space="preserve"> 500 && !Toolbar.visible){ + if($("#filepreview").width() > 600 && !Toolbar.visible){ Toolbar.toggle(); } @@ -36,6 +36,8 @@ var Viewer = { ListNavigator.init(data.data); } + renderSponsors(); + this.initialized = true; }, setFile: function(file){ @@ -104,3 +106,42 @@ document.addEventListener("keydown", function(event){ break; } }); + + +window.addEventListener("resize", renderSponsors); +function renderSponsors() { + var scale = 1; + var scaleWidth = 1; + var scaleHeight = 1; + var minWidth = 728; + var minHeight = 800; + + if (window.innerWidth < minWidth) { + scaleWidth = window.innerWidth/minWidth; + } + if (window.innerHeight < minHeight) { + scaleHeight = window.innerHeight/minHeight; + } + scale = scaleWidth < scaleHeight ? scaleWidth : scaleHeight; + + console.log(scale, scaleWidth, scaleHeight); + + // Because of the scale transformation the automatic margins don't work + // anymore. So we have to maunally calculate the margin. Where we take the + // width of the viewport - the width of the ad to calculate the amount of + // pixels around the ad. We multiply the ad size by the scale we calcualted + // to account for the smaller size. + var offset = (window.innerWidth - (minWidth*scale)) / 2 + if (offset < 0) { + offset = 0 + } + document.querySelector(".sponsors > iframe").style.marginLeft = offset+"px"; + + if (scale == 1) { + document.querySelector(".sponsors > iframe").style.transform = "none"; + document.querySelector(".sponsors").style.height = "90px"; + } else { + document.querySelector(".sponsors > iframe").style.transform = "scale("+scale+")"; + document.querySelector(".sponsors").style.height = (scale*90)+"px"; + } +} diff --git a/res/include/style/viewer.css b/res/include/style/viewer.css index 369e333..1f611e5 100644 --- a/res/include/style/viewer.css +++ b/res/include/style/viewer.css @@ -24,6 +24,7 @@ text-align: left; padding: 8px; z-index: 10; + box-shadow: none; } /* Headerbar components */ @@ -68,7 +69,7 @@ display: none; /* Becomes visible if the page is a list */ width: 100%; background-color: var(--layer_1_color); - box-shadow: 0 0 8px var(--shadow_color); + /* box-shadow: 0 0 8px var(--shadow_color); */ text-align: center; line-height: 1em; overflow-x: scroll; @@ -105,6 +106,19 @@ vertical-align: middle; transition: left 0.5s; overflow: hidden; + box-shadow: inset 2px 2px 8px var(--shadow_color); +} + +/* Sponsors (row 4) */ +.file_viewer > .sponsors { + background-color: var(--layer_1_color); + font-size: 0; + line-height: 0; +} +.file_viewer > .sponsors > iframe { + display: block; + margin: auto; + transform-origin: 0 0; } /* Toolbars */ @@ -120,7 +134,6 @@ top: 0; padding: 0; text-align: left; - box-shadow: 1px 1px var(--layer_1_shadow) 0 var(--shadow_color); transition: left 0.5s; } .file_viewer > .file_viewer_window > .file_viewer_sharebar{ @@ -133,7 +146,7 @@ overflow-x: hidden; float: left; background-color: var(--layer_1_color); - box-shadow: 2px 2px 8px var(--shadow_color); + /* box-shadow: 2px 2px 8px var(--shadow_color); */ text-align: center; z-index: 48; overflow: hidden; @@ -318,7 +331,7 @@ table > tbody > tr {border: none !important;} .bytecounter{ color: var(--text_color); font-size: 16px; - font-family: 'Ubuntu', sans-serif; + font-family: monospace, monospace; line-height: 20px; text-align: right; display: inline-block; diff --git a/res/template/admin.html b/res/template/admin.html index 7a21eb5..56c4248 100644 --- a/res/template/admin.html +++ b/res/template/admin.html @@ -18,6 +18,8 @@ + +
diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index 115485b..c6c9129 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -100,9 +100,12 @@
-
{{template "spinner.svg"}}
+
{{template "spinner.svg" .}}
+
+ +