Skip to content

Commit

Permalink
small refactor of file-explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
serapath committed Jan 8, 2018
1 parent 0dadc77 commit 0954680
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/app/files/file-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ function fileExplorer (appAPI, files) {
})) : undefined
}
},
formatSelf: function (key, data) {
formatSelf: function (key, data, li) {
var isRoot = data.path.indexOf('/') === -1
return yo`<label class="${data.children ? css.folder : css.file}"
data-path="${data.path}"
style="${isRoot ? 'font-weight:bold;' : ''}"
onload=${function (el) { adaptEnvironment(el, focus, hover) }}
onunload=${function (el) { unadaptEnvironment(el, focus, hover) }}
onload=${function (el) { adaptEnvironment(el, focus, hover, li) }}
onunload=${function (el) { unadaptEnvironment(el, focus, hover, li) }}
onclick=${editModeOn}
onkeydown=${editModeOff}
onblur=${editModeOff}
Expand Down Expand Up @@ -356,8 +356,7 @@ function fileExplorer (appAPI, files) {
/*
HELPER FUNCTIONS
*/
function adaptEnvironment (label, focus, hover) {
var li = getLiFrom(label)
function adaptEnvironment (label, focus, hover, li) {
li.style.position = 'relative'
var span = li.firstChild
// add focus
Expand All @@ -368,8 +367,7 @@ function adaptEnvironment (label, focus, hover) {
span.addEventListener('mouseout', hover)
}

function unadaptEnvironment (label, focus, hover) {
var li = getLiFrom(label)
function unadaptEnvironment (label, focus, hover, li) {
var span = li.firstChild
li.style.position = undefined
// remove focus
Expand Down

0 comments on commit 0954680

Please sign in to comment.