small refactor of file-explorer

pull/1/head
serapath 7 years ago
parent 0dadc77904
commit 0954680d0c
  1. 12
      src/app/files/file-explorer.js

@ -99,13 +99,13 @@ function fileExplorer (appAPI, files) {
})) : undefined })) : undefined
} }
}, },
formatSelf: function (key, data) { formatSelf: function (key, data, li) {
var isRoot = data.path.indexOf('/') === -1 var isRoot = data.path.indexOf('/') === -1
return yo`<label class="${data.children ? css.folder : css.file}" return yo`<label class="${data.children ? css.folder : css.file}"
data-path="${data.path}" data-path="${data.path}"
style="${isRoot ? 'font-weight:bold;' : ''}" style="${isRoot ? 'font-weight:bold;' : ''}"
onload=${function (el) { adaptEnvironment(el, focus, hover) }} onload=${function (el) { adaptEnvironment(el, focus, hover, li) }}
onunload=${function (el) { unadaptEnvironment(el, focus, hover) }} onunload=${function (el) { unadaptEnvironment(el, focus, hover, li) }}
onclick=${editModeOn} onclick=${editModeOn}
onkeydown=${editModeOff} onkeydown=${editModeOff}
onblur=${editModeOff} onblur=${editModeOff}
@ -356,8 +356,7 @@ function fileExplorer (appAPI, files) {
/* /*
HELPER FUNCTIONS HELPER FUNCTIONS
*/ */
function adaptEnvironment (label, focus, hover) { function adaptEnvironment (label, focus, hover, li) {
var li = getLiFrom(label)
li.style.position = 'relative' li.style.position = 'relative'
var span = li.firstChild var span = li.firstChild
// add focus // add focus
@ -368,8 +367,7 @@ function adaptEnvironment (label, focus, hover) {
span.addEventListener('mouseout', hover) span.addEventListener('mouseout', hover)
} }
function unadaptEnvironment (label, focus, hover) { function unadaptEnvironment (label, focus, hover, li) {
var li = getLiFrom(label)
var span = li.firstChild var span = li.firstChild
li.style.position = undefined li.style.position = undefined
// remove focus // remove focus

Loading…
Cancel
Save