From cb72d8c6c2999c981c95d4fe3c19d3338e4cf580 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 25 Oct 2016 21:08:26 +0100 Subject: [PATCH] close #29 --- _embed/public/css/styles.css | 35 ++--- _embed/public/js/application.js | 37 +++--- _embed/templates/actions.tmpl | 42 +++--- _embed/templates/base.tmpl | 229 +++++++++++++++----------------- 4 files changed, 173 insertions(+), 170 deletions(-) diff --git a/_embed/public/css/styles.css b/_embed/public/css/styles.css index 0db84589..3368741b 100644 --- a/_embed/public/css/styles.css +++ b/_embed/public/css/styles.css @@ -264,7 +264,7 @@ textarea { body { font-family: 'Roboto', sans-serif; padding-top: 5em; - background-color: #fcfcfc; + background-color: #ffffff; text-rendering: optimizespeed; } @@ -473,6 +473,8 @@ header { z-index: 999; padding: 1.7em 0; background-color: #2196f3; + border-bottom: 1px solid rgba(0, 0, 0, 0.075); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } header h1 { @@ -481,7 +483,9 @@ header h1 { } header a, -header a:hover { +header a:hover, +#toolbar a, +#toolbar a:hover { color: inherit; } @@ -680,8 +684,7 @@ header .only-side { display: none; } -header #prev:hover+.prev-links, -header .prev-links:hover { +.action:hover ul { display: flex; } @@ -689,9 +692,9 @@ header .prev-links:hover { border-radius: 0; } -header .prev-links { +.action ul { position: absolute; - top: 4em; + top: 3.1em; left: 0; color: #7d7d7d; list-style: none; @@ -703,37 +706,39 @@ header .prev-links { flex-direction: column-reverse; display: none; transition: .2s ease all; - min-width: 12em; + min-width: 3em; + z-index: 99999; } -header .prev-links:before { +.action ul:before { top: -16px; left: 1em; right: auto; border: 8px solid transparent; - border-bottom-color: #68efad; + border-bottom-color: #ffffff; content: ''; position: absolute; } -header .prev-links a { - padding: .5em; +.action ul a { + padding: .3em .5em; border-bottom: 1px solid #f5f5f5; transition: .2s ease all; + text-align: left; } -header .prev-links a:first-child { +.action ul a:first-child { border: 0; border-bottom-right-radius: .2em; border-bottom-left-radius: .2em; } -header .prev-links a:last-child { +.action ul a:last-child { border-top-right-radius: .2em; border-top-left-radius: .2em; } -header .prev-links a:hover { +.action ul a:hover { background-color: #f5f5f5; } @@ -1181,4 +1186,4 @@ i.spin { column-count: 1; column-gap: 0; } -} +} \ No newline at end of file diff --git a/_embed/public/js/application.js b/_embed/public/js/application.js index 12c73c70..4ba2ed56 100644 --- a/_embed/public/js/application.js +++ b/_embed/public/js/application.js @@ -151,22 +151,6 @@ var preventDefault = function(event) { event.preventDefault(); } -// Download file event -var downloadEvent = function(event) { - if (this.classList.contains('disabled')) { - return false; - } - if (selectedItems.length) { - Array.from(selectedItems).forEach(item => { - window.open(item + "?download=true"); - }); - return false; - } - - window.open(window.location + "?download=true"); - return false; -} - // Remove the last directory of an url var RemoveLastDirectoryPartOf = function(url) { var arr = url.split('/'); @@ -466,6 +450,8 @@ document.addEventListener("changed-selected", function(event) { document.getElementById("rename").classList.remove("disabled"); } + redefineDownloadURLs(); + return false; } @@ -473,6 +459,22 @@ document.addEventListener("changed-selected", function(event) { return false; }); +var redefineDownloadURLs = function() { + let files = ""; + + for (let i = 0; i < selectedItems.length; i++) { + files += selectedItems[i].replace(window.location.pathname, "") + ","; + } + + files = files.substring(0, files.length - 1); + files = encodeURIComponent(files); + + let links = document.querySelectorAll("#download ul a"); + Array.from(links).forEach(link => { + link.href = "?download=" + link.dataset.format + "&files=" + files; + }); +} + var searchEvent = function(event) { let value = this.value; let box = document.querySelector('#search div'); @@ -891,7 +893,6 @@ document.addEventListener("DOMContentLoaded", function(event) { document.getElementById("delete").addEventListener("click", deleteEvent); } - document.getElementById("download").addEventListener("click", downloadEvent); document.getElementById("open-nav").addEventListener("click", event => { document.querySelector("header > div:nth-child(2)").classList.toggle("active"); }); @@ -908,4 +909,4 @@ document.addEventListener("DOMContentLoaded", function(event) { } return false; -}); \ No newline at end of file +}); diff --git a/_embed/templates/actions.tmpl b/_embed/templates/actions.tmpl index 069598f2..a42d11d1 100644 --- a/_embed/templates/actions.tmpl +++ b/_embed/templates/actions.tmpl @@ -1,18 +1,28 @@ {{ define "actions" }} -
- open_in_new See raw -
- {{ if and .IsDir .User.AllowEdit }} -
- mode_edit -
- {{ end }} -
- file_download Download -
- {{ if .User.AllowEdit }} -
- delete Delete -
- {{ end }} +
+ open_in_new See raw +
+{{ if and .IsDir .User.AllowEdit }} +
+ mode_edit +
+{{ end }} +
+ + file_download Download + + {{ if .IsDir }} + + {{ end }} +
+{{ if .User.AllowEdit }} +
+ delete Delete +
+{{ end }} {{ end }} diff --git a/_embed/templates/base.tmpl b/_embed/templates/base.tmpl index 86f4e844..679795e7 100644 --- a/_embed/templates/base.tmpl +++ b/_embed/templates/base.tmpl @@ -1,139 +1,126 @@ -{{ $absURL := .Config.AbsoluteURL }} - - - {{.Name}} - - - - - - {{ if ne .User.StyleSheet "" }} - - {{ end }} - - -
-
- {{ $lnk := .PreviousLink }} - - - - {{ if ne $lnk ""}} - - {{ end }} - -
- menu -
- -

- {{ if ne .Name "/"}} - {{ .Name }} -

+{{ $absURL := .Config.AbsoluteURL }} + + {{.Name}} + + + + + {{ if ne .User.StyleSheet "" }} + {{ end }} -
- -
-
- {{ $lnk := .PreviousLink }} - {{ if ne $lnk ""}} - - {{ end }} + + +
+
+ {{ $lnk := .PreviousLink }} - {{ if ne $lnk ""}} - - {{ end }} +
+ menu +
-

- - File Manager - -

-
- - {{ if .IsDir}} - - {{ if .User.AllowCommands }} - - {{ end }} - -
- view_headline Switch view + {{ if ne .Name "/"}}

{{ .Name }}

{{ end }}
- {{ if .User.AllowNew }} -
- file_upload Upload + +
+
+ {{ $lnk := .PreviousLink }} + {{ if ne $lnk ""}}{{ end }} + + {{ if ne $lnk ""}}{{ end }} + +

File Manager

+
+ + {{ if .IsDir}} + {{ if .User.AllowCommands }} + + {{ end }} + +
+ view_headline Switch view +
+ + {{ if .User.AllowNew }} +
+ file_upload Upload +
+ {{ end }} + + + {{ else }} + {{ template "actions" . }} + {{ end }} + +
+ exit_to_app Logout +
- {{ end }} - {{ else }} - {{ template "actions" . }} - {{ end }} +
+
-
- exit_to_app Logout -
-
-
-
- - {{ if .IsDir }} -
+ {{ if .IsDir }} +
-
- arrow_back -
-

- 0 - selected.

+
+ arrow_back +
+

+ 0 + selected.

- {{ template "actions" . }} + {{ template "actions" . }}
-
- {{ end }} +
+ {{ end }} -
- {{ template "content" . }} - {{ .Config.Token }} -
+
+ {{ template "content" . }} + {{ .Config.Token }} +
- + - - - - - - - {{ if .Config.HugoEnabled }}{{ end }} - + + + + + + + {{ if .Config.HugoEnabled }}{{ end }} +