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