Some changes

This commit is contained in:
Fábio Ferreira 2017-01-02 20:22:54 +00:00
parent cbad4a55b9
commit 4bd1d42e8e
4 changed files with 168 additions and 42 deletions

View File

@ -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;

View File

@ -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 *

View File

@ -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);

View File

@ -80,6 +80,12 @@
<i class="material-icons" title="See raw">open_in_new</i>
</div>
{{- if .User.AllowEdit }}
<div class="action" id="move">
<i class="material-icons" title="Move">forward</i>
</div>
{{- end }}
{{- if and .IsDir .User.AllowEdit }}
<div class="action" id="rename">
<i class="material-icons" title="Edit">mode_edit</i>
@ -186,6 +192,23 @@
</div>
</template>
<template id="move-template">
<form class="prompt">
<h3>Move</h3>
<p></p>
<div class="file-list">
<ul>
</ul>
</div>
<div>
<button type="submit" autofocus class="ok">OK</button>
<button class="cancel" onclick="closePrompt(event);">Cancel</button>
</div>
</form>
</template>
<div class="help">
<h3>Help</h3>