From 4bd1d42e8edf31710bd1605a90f7cb6c838f5db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Ferreira?= Date: Mon, 2 Jan 2017 20:22:54 +0000 Subject: [PATCH] Some changes --- _embed/public/css/fonts.css | 3 +- _embed/public/css/styles.css | 47 ++++++++++++++++++- _embed/public/js/common.js | 71 +++++++++++++++++++++++++--- _embed/templates/base.tmpl | 89 +++++++++++++++++++++++------------- 4 files changed, 168 insertions(+), 42 deletions(-) diff --git a/_embed/public/css/fonts.css b/_embed/public/css/fonts.css index c8e74f4e..93202bfd 100644 --- a/_embed/public/css/fonts.css +++ b/_embed/public/css/fonts.css @@ -117,6 +117,7 @@ src: local('Material Icons'), local('MaterialIcons-Regular'), url(material/icons.woff2) format('woff2'); } +.prompt .file-list ul li:before, .material-icons { font-family: 'Material Icons'; font-weight: normal; @@ -133,4 +134,4 @@ text-rendering: optimizeLegibility; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'liga'; -} \ No newline at end of file +} diff --git a/_embed/public/css/styles.css b/_embed/public/css/styles.css index ce506c42..0fce5116 100644 --- a/_embed/public/css/styles.css +++ b/_embed/public/css/styles.css @@ -471,7 +471,7 @@ header .actions { #bottom-bar>*:first-child { margin-right: auto; - max-width: calc(100% - 21em); + max-width: calc(100% - 25em); width: 100%; } @@ -919,6 +919,49 @@ header .actions { background-color: #e9eaeb; } +/* * * * * * * * * * * * * * * * + * PROMPT - MOVE * + * * * * * * * * * * * * * * * */ + +.prompt .file-list { + flex-direction: initial; +} + +.prompt .file-list ul { + list-style: none; + margin: 0; + padding: 0; + width: 100%; +} + +.prompt .file-list ul li { + width: 100%; + user-select: none; +} + +.prompt .file-list ul li[aria-selected=true] { + background: #2196f3 !important; + color: #fff !important; + transition: .1s ease all; +} + +.prompt .file-list ul li:hover { + background-color: #e9eaeb; + cursor: pointer; +} + +.prompt .file-list ul li:before { + content: "folder"; + color: #6f6f6f; + vertical-align: middle; + padding: 0 .25em; + line-height: 2em; +} + +.prompt .file-list ul li[aria-selected=true]:before { + color: white; +} + /* * * * * * * * * * * * * * * * * HELP * @@ -1041,4 +1084,4 @@ footer a:hover { -webkit-transform: rotate(-360deg); transform: rotate(-360deg); } -} \ No newline at end of file +} diff --git a/_embed/public/js/common.js b/_embed/public/js/common.js index a520648a..d9d069a3 100644 --- a/_embed/public/js/common.js +++ b/_embed/public/js/common.js @@ -102,7 +102,7 @@ function getCSSRule(rules) { if (cssRule.selectorText.toLowerCase() == rules[i]) found = true; } } - + return found; }); @@ -161,9 +161,7 @@ function logoutEvent(event) { } function openEvent(event) { - if (event.currentTarget.classList.contains('disabled')) { - return false; - } + if (event.currentTarget.classList.contains('disabled')) return false; let link = '?raw=true'; @@ -177,6 +175,64 @@ function openEvent(event) { return false; } +function selectMoveFolder(event) { + if(event.target.getAttribute("aria-selected") === "true") { + event.target.setAttribute("aria-selected", false); + return; + } else { + if(document.querySelector(".file-list li[aria-selected=true]")) { + document.querySelector(".file-list li[aria-selected=true]").setAttribute("aria-selected", false); + } + event.target.setAttribute("aria-selected", true); + return; + } +} + +function moveSelected(event) { + event.preventDefault(); +} + +function loadNextFolder(event) { +} + +function moveEvent(event) { + if(event.currentTarget.classList.contains("disabled")) return; + + let request = new XMLHttpRequest(); + + request.open("GET", window.location.pathname, true); + request.setRequestHeader("Accept", "application/json"); + request.send(); + request.onreadystatechange = function() { + if(request.readyState == 4) { + if(request.status == 200) { + let clone = document.importNode(templates.move.content, true); + + clone.querySelector("p").innerHTML = `Choose new house for your file(s)/folder(s):`; + + for(let f of JSON.parse(request.response)) { + if(f.URL.split("/").length == 3) { + if(selectedItems.includes(btoa(f.URL.split("/")[1]))) continue; + let newNode = document.createElement("li"); + newNode.innerHTML = f.URL.split("/")[1]; + newNode.setAttribute("aria-selected", false); + + newNode.addEventListener("dblclick", loadNextFolder); + newNode.addEventListener("click", selectMoveFolder); + newNode.addEventListener("submit", moveSelected); + + clone.querySelector("div.file-list ul").appendChild(newNode); + } + } + + document.body.appendChild(clone); + document.querySelector(".overlay").classList.add("active"); + document.querySelector(".prompt").classList.add("active"); + } + } + } +} + function deleteSelected(single) { return function(event) { event.preventDefault(); @@ -238,7 +294,7 @@ function deleteEvent(event) { clone.querySelector('.ok').innerHTML = 'Delete'; clone.querySelector('form').addEventListener('submit', deleteSelected(single)); - document.querySelector('body').appendChild(clone) + document.body.appendChild(clone); document.querySelector('.overlay').classList.add('active'); document.querySelector('.prompt').classList.add('active'); @@ -414,13 +470,16 @@ document.addEventListener("DOMContentLoaded", function(event) { buttons.open = document.getElementById("open"); buttons.delete = document.getElementById("delete"); buttons.previous = document.getElementById("previous"); + buttons.move = document.getElementById("move"); // Attach event listeners buttons.logout.addEventListener("click", logoutEvent); buttons.open.addEventListener("click", openEvent); + buttons.move.addEventListener("click", moveEvent); templates.question = document.querySelector('#question-template'); templates.info = document.querySelector('#info-template'); + templates.move = document.querySelector("#move-template"); if (user.AllowEdit) { buttons.delete.addEventListener("click", deleteEvent); @@ -465,4 +524,4 @@ document.addEventListener("DOMContentLoaded", function(event) { setupSearch(); return false; -}); \ No newline at end of file +}); diff --git a/_embed/templates/base.tmpl b/_embed/templates/base.tmpl index b4f297f2..a716b8db 100644 --- a/_embed/templates/base.tmpl +++ b/_embed/templates/base.tmpl @@ -12,10 +12,10 @@ {{- if ne .User.StyleSheet "" -}} {{- end -}} - + @@ -44,10 +44,10 @@ exit_to_app - +
- {{- if ne .Name "/"}} + {{- if ne .Name "/"}} {{- end }} - + {{ if ne .Name "/"}}

{{ .Name }}

{{ end }}
- +
{{- if and (not .IsDir) (.User.AllowEdit) }} {{- if .Editor}} @@ -70,59 +70,65 @@
{{- end }} {{- end }} - +
save
{{- end }} - +
open_in_new
- + + {{- if .User.AllowEdit }} +
+ forward +
+ {{- end }} + {{- if and .IsDir .User.AllowEdit }}
mode_edit
{{- end }} - + {{- if .User.AllowEdit }}
deleteDelete
{{- end }}
- +
more_vert
- -
+ +
{{- if .IsDir }}
{{- if eq .Display "mosaic" }} view_listSwitch view - {{- else }} + {{- else }} view_moduleSwitch view {{- end }}
- +
check_circleSelect
{{- end }} - + {{- if and (.User.AllowNew) (.IsDir) }}
file_uploadUpload
{{- end }} - +
{{- if not .IsDir}}{{ end }} file_downloadDownload {{- if not .IsDir}}{{ end }} - + {{- if .IsDir }} {{- end }}
- +
infoInfo
- +
- - + +

Multiple selection enabled

clear
- +
{{- template "content" . }}
- +
- + {{- if and (.User.AllowNew) (.IsDir) }}
@@ -163,7 +169,7 @@
{{- end }} - + - + - + + +

Help

- + - +

Not available yet

- + - +