js cleaning
Former-commit-id: 9bcc591d7198b05a80208bf2f0ea886dbb0d20ef [formerly d839fcb715067f316de578009c491f5bc8bd4d26] [formerly 6d3d299a509857f18c40b2ac8216b670175cb982 [formerly 1fb4fab095
]]
Former-commit-id: fe8cfe5dcf92995224b4f8c6bf5552f56e25c790 [formerly b7f7f69d5c94b44cfa8acb00af9b4d7dab1eb42b]
Former-commit-id: 17de9bc37c2e5b1fb1d5d7fc07018242dd114e99
pull/726/head
parent
7200072cd8
commit
a2d66f44ea
|
@ -92,8 +92,8 @@ function addFrontMatterItemPrompt (parent) {
|
||||||
|
|
||||||
closePrompt(event)
|
closePrompt(event)
|
||||||
|
|
||||||
let name = value.substring(0, value.lastIndexOf(':')),
|
let name = value.substring(0, value.lastIndexOf(':'))
|
||||||
type = value.substring(value.lastIndexOf(':') + 1, value.length)
|
let type = value.substring(value.lastIndexOf(':') + 1, value.length)
|
||||||
|
|
||||||
if (type !== '' && type !== 'array' && type !== 'object') {
|
if (type !== '' && type !== 'array' && type !== 'object') {
|
||||||
name = value
|
name = value
|
||||||
|
@ -131,19 +131,19 @@ function addFrontMatterItemPrompt (parent) {
|
||||||
function addFrontMatterItem (event) {
|
function addFrontMatterItem (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let parent = event.currentTarget.parentNode,
|
let parent = event.currentTarget.parentNode
|
||||||
type = parent.dataset.type
|
let type = parent.dataset.type
|
||||||
|
|
||||||
// If the block is an array
|
// If the block is an array
|
||||||
if (type === 'array') {
|
if (type === 'array') {
|
||||||
let id = parent.id + '[]',
|
let id = parent.id + '[]'
|
||||||
count = parent.querySelectorAll('.group > div').length,
|
let count = parent.querySelectorAll('.group > div').length
|
||||||
fieldsets = parent.getElementsByTagName('fieldset')
|
let fieldsets = parent.getElementsByTagName('fieldset')
|
||||||
|
|
||||||
if (fieldsets.length > 0) {
|
if (fieldsets.length > 0) {
|
||||||
let itemType = fieldsets[0].dataset.type,
|
let itemType = fieldsets[0].dataset.type
|
||||||
itemID = parent.id + '[' + fieldsets.length + ']',
|
let itemID = parent.id + '[' + fieldsets.length + ']'
|
||||||
itemName = fieldsets.length
|
let itemName = fieldsets.length
|
||||||
|
|
||||||
makeFromBaseTemplate(itemID, itemType, itemName, parent)
|
makeFromBaseTemplate(itemID, itemType, itemName, parent)
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,7 +153,7 @@ function addFrontMatterItem (event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'object' || type == 'parent') {
|
if (type === 'object' || type === 'parent') {
|
||||||
let clone = document.importNode(templates.question.content, true)
|
let clone = document.importNode(templates.question.content, true)
|
||||||
clone.querySelector('form').id = tempID
|
clone.querySelector('form').id = tempID
|
||||||
clone.querySelector('h3').innerHTML = 'New field'
|
clone.querySelector('h3').innerHTML = 'New field'
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var listing = {
|
var listing = {
|
||||||
selectMultiple: false
|
selectMultiple: false,
|
||||||
}
|
reload: function (callback) {
|
||||||
|
let request = new window.XMLHttpRequest()
|
||||||
listing.reload = function (callback) {
|
|
||||||
let request = new XMLHttpRequest()
|
|
||||||
|
|
||||||
request.open('GET', window.location)
|
request.open('GET', window.location)
|
||||||
request.setRequestHeader('Minimal', 'true')
|
request.setRequestHeader('Minimal', 'true')
|
||||||
|
@ -22,9 +20,8 @@ listing.reload = function (callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
itemDragStart: function (event) {
|
||||||
listing.itemDragStart = function (event) {
|
|
||||||
let el = event.target
|
let el = event.target
|
||||||
|
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
@ -35,9 +32,8 @@ listing.itemDragStart = function (event) {
|
||||||
|
|
||||||
event.dataTransfer.setData('id', el.id)
|
event.dataTransfer.setData('id', el.id)
|
||||||
event.dataTransfer.setData('name', el.querySelector('.name').innerHTML)
|
event.dataTransfer.setData('name', el.querySelector('.name').innerHTML)
|
||||||
}
|
},
|
||||||
|
itemDragOver: function (event) {
|
||||||
listing.itemDragOver = function (event) {
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
let el = event.target
|
let el = event.target
|
||||||
|
|
||||||
|
@ -48,9 +44,8 @@ listing.itemDragOver = function (event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
el.style.opacity = 1
|
el.style.opacity = 1
|
||||||
}
|
},
|
||||||
|
itemDrop: function (e) {
|
||||||
listing.itemDrop = function (e) {
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
let el = e.target,
|
let el = e.target,
|
||||||
|
@ -73,9 +68,8 @@ listing.itemDrop = function (e) {
|
||||||
webdav.move(oldLink, newLink)
|
webdav.move(oldLink, newLink)
|
||||||
.then(() => listing.reload())
|
.then(() => listing.reload())
|
||||||
.catch(e => console.log(e))
|
.catch(e => console.log(e))
|
||||||
}
|
},
|
||||||
|
documentDrop: function (event) {
|
||||||
listing.documentDrop = function (event) {
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
let dt = event.dataTransfer,
|
let dt = event.dataTransfer,
|
||||||
files = dt.files,
|
files = dt.files,
|
||||||
|
@ -100,9 +94,8 @@ listing.documentDrop = function (event) {
|
||||||
file.style.opacity = 1
|
file.style.opacity = 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
rename: function (event) {
|
||||||
listing.rename = function (event) {
|
|
||||||
if (!selectedItems.length || selectedItems.length > 1) {
|
if (!selectedItems.length || selectedItems.length > 1) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -113,15 +106,15 @@ listing.rename = function (event) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let link = item.dataset.url,
|
let link = item.dataset.url
|
||||||
field = item.querySelector('.name'),
|
let field = item.querySelector('.name')
|
||||||
name = field.innerHTML
|
let name = field.innerHTML
|
||||||
|
|
||||||
let submit = (event) => {
|
let submit = (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let newName = event.currentTarget.querySelector('input').value,
|
let newName = event.currentTarget.querySelector('input').value
|
||||||
newLink = removeLastDirectoryPartOf(link) + '/' + newName
|
let newLink = removeLastDirectoryPartOf(link) + '/' + newName
|
||||||
|
|
||||||
closePrompt(event)
|
closePrompt(event)
|
||||||
buttons.setLoading('rename')
|
buttons.setLoading('rename')
|
||||||
|
@ -155,9 +148,8 @@ listing.rename = function (event) {
|
||||||
document.querySelector('.prompt').classList.add('active')
|
document.querySelector('.prompt').classList.add('active')
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
},
|
||||||
|
handleFiles: function (files, base) {
|
||||||
listing.handleFiles = function (files, base) {
|
|
||||||
buttons.setLoading('upload')
|
buttons.setLoading('upload')
|
||||||
|
|
||||||
let promises = []
|
let promises = []
|
||||||
|
@ -178,6 +170,7 @@ listing.handleFiles = function (files, base) {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
listing.unselectAll = function () {
|
listing.unselectAll = function () {
|
||||||
let items = document.getElementsByClassName('item')
|
let items = document.getElementsByClassName('item')
|
||||||
|
@ -201,18 +194,11 @@ listing.handleSelectionChange = function (event) {
|
||||||
fileAction.classList.remove('disabled')
|
fileAction.classList.remove('disabled')
|
||||||
|
|
||||||
if (selectedNumber > 1) {
|
if (selectedNumber > 1) {
|
||||||
buttons.open.classList.add('disabled')
|
|
||||||
buttons.rename.classList.add('disabled')
|
buttons.rename.classList.add('disabled')
|
||||||
buttons.info.classList.add('disabled')
|
buttons.info.classList.add('disabled')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedNumber == 1) {
|
if (selectedNumber == 1) {
|
||||||
if (document.getElementById(selectedItems[0]).dataset.dir == 'true') {
|
|
||||||
buttons.open.classList.add('disabled')
|
|
||||||
} else {
|
|
||||||
buttons.open.classList.remove('disabled')
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons.info.classList.remove('disabled')
|
buttons.info.classList.remove('disabled')
|
||||||
buttons.rename.classList.remove('disabled')
|
buttons.rename.classList.remove('disabled')
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,13 +83,6 @@
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if .IsDir }}
|
|
||||||
<div tabindex="0" role="button" aria-label="See raw" class="action" id="open">
|
|
||||||
<i class="material-icons" title="See raw">open_in_new</i>
|
|
||||||
<span>See raw</span>
|
|
||||||
</div>
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{- if and (.User.AllowEdit) (.IsDir) }}
|
{{- if and (.User.AllowEdit) (.IsDir) }}
|
||||||
<div tabindex="0" role="button" aria-label="Move" class="action" id="move">
|
<div tabindex="0" role="button" aria-label="Move" class="action" id="move">
|
||||||
<i class="material-icons" title="Move">forward</i>
|
<i class="material-icons" title="Move">forward</i>
|
||||||
|
@ -139,13 +132,6 @@
|
||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if not .IsDir }}
|
|
||||||
<div tabindex="0" role="button" aria-label="See raw" class="action" id="open">
|
|
||||||
<i class="material-icons" title="See raw">open_in_new</i>
|
|
||||||
<span>See raw</span>
|
|
||||||
</div>
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{- if and .User.AllowEdit (not .IsDir) }}
|
{{- if and .User.AllowEdit (not .IsDir) }}
|
||||||
<div tabindex="0" role="button" aria-label="Delete" class="action" id="delete">
|
<div tabindex="0" role="button" aria-label="Delete" class="action" id="delete">
|
||||||
<i class="material-icons" title="Delete">delete</i><span>Delete</span>
|
<i class="material-icons" title="Delete">delete</i><span>Delete</span>
|
||||||
|
|
Loading…
Reference in New Issue