Former-commit-id: 18a1b6540895d83370677bea474ac7dd8cfa1bd2
This commit is contained in:
Henrique Dias
2017-01-02 12:20:20 +00:00
parent df4a030843
commit abcaf3aba7
8 changed files with 129 additions and 84 deletions

View File

@@ -14,7 +14,8 @@ listing.reload = function(callback) {
if (request.readyState == 4) {
if (request.status == 200) {
document.querySelector('body main').innerHTML = request.responseText;
listing.addDoubleTapEvent();
if (typeof callback == 'function') {
callback();
}
@@ -311,11 +312,42 @@ listing.newFilePrompt = function(event) {
listing.updateColumns = function(event) {
let columns = Math.floor(document.getElementById('listing').offsetWidth / 300),
items = getCSSRule('#listing.mosaic .item');
items = getCSSRule(['#listing.mosaic .item', '.mosaic#listing .item']);
items.style.width = `calc(${100/columns}% - 1em)`;
}
listing.addDoubleTapEvent = function() {
let items = document.getElementsByClassName('item'),
touches = {
id: '',
count: 0
};
Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => {
console.log("hey")
if (touches.id != file.id) {
touches.id = file.id;
touches.count = 1;
setTimeout(() => {
touches.count = 0;
}, 500)
return;
}
touches.count++;
if (touches.count > 1) {
window.location = file.dataset.url;
}
});
});
}
// Keydown events
window.addEventListener('keydown', (event) => {
if (event.keyCode == 27) {
@@ -346,6 +378,7 @@ window.addEventListener("resize", () => {
document.addEventListener('DOMContentLoaded', event => {
listing.updateColumns();
listing.addDoubleTapEvent();
buttons.rename = document.getElementById("rename");
buttons.upload = document.getElementById("upload");
@@ -400,29 +433,5 @@ document.addEventListener('DOMContentLoaded', event => {
document.addEventListener("drop", listing.documentDrop, false);
}
let touches = {
id: '',
count: 0
};
Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => {
if (touches.id != file.id) {
touches.id = file.id;
touches.count = 1;
setTimeout(() => {
touches.count = 0;
}, 500)
return;
}
touches.count++;
if (touches.count > 1) {
window.location = file.dataset.url;
}
});
});
});