filebrowser/_assets/_old/js/common_old.js

80 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-06-25 08:11:25 +00:00
var buttons = {
previousState: {}
}
buttons.setLoading = function (name) {
if (typeof this[name] === 'undefined') return
let i = this[name].querySelector('i')
this.previousState[name] = i.innerHTML
i.style.opacity = 0
setTimeout(function () {
i.classList.add('spin')
i.innerHTML = 'autorenew'
i.style.opacity = 1
}, 200)
}
// Changes an element to done animation
buttons.setDone = function (name, success = true) {
let i = this[name].querySelector('i')
i.style.opacity = 0
let thirdStep = () => {
i.innerHTML = this.previousState[name]
i.style.opacity = null
if (selectedItems.length === 0 && document.getElementById('listing')) {
document.sendCostumEvent('changed-selected')
}
}
let secondStep = () => {
i.style.opacity = 0
setTimeout(thirdStep, 200)
}
let firstStep = () => {
i.classList.remove('spin')
i.innerHTML = success
? 'done'
: 'close'
i.style.opacity = 1
setTimeout(secondStep, 1000)
}
setTimeout(firstStep, 200)
return false
}
2017-06-30 15:04:01 +00:00
listing.addDoubleTapEvent = function () {
let items = document.getElementsByClassName('item'),
touches = {
id: '',
count: 0
2017-06-25 08:11:25 +00:00
}
2017-06-30 15:04:01 +00:00
Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => {
if (touches.id != file.id) {
touches.id = file.id
touches.count = 1
2017-06-25 08:11:25 +00:00
2017-06-30 15:04:01 +00:00
setTimeout(() => {
touches.count = 0
}, 300)
2017-06-25 08:11:25 +00:00
2017-06-30 15:04:01 +00:00
return
}
2017-06-25 08:11:25 +00:00
2017-06-30 15:04:01 +00:00
touches.count++
2017-06-25 08:11:25 +00:00
2017-06-30 15:04:01 +00:00
if (touches.count > 1) {
window.location = file.dataset.url
}
2017-06-25 08:11:25 +00:00
})
})
2017-06-30 15:04:01 +00:00
}