Create one file select and doubleclick/click events
This commit is contained in:
parent
8e2d014317
commit
c77dc479db
@ -29,7 +29,7 @@ class Finder{
|
||||
newWindow.innerHTML = html
|
||||
|
||||
this.fileView = new FileView(newWindow.querySelector(".FileTileView"), (event) =>{
|
||||
this.Click(event, false)
|
||||
this.Open(event, false)
|
||||
})
|
||||
this.OpenDir(this.path)
|
||||
|
||||
@ -70,7 +70,7 @@ class Finder{
|
||||
args[2].innerHTML = html
|
||||
|
||||
this.fileView = new FileView(args[2].querySelector(".FileTileView"), (event) =>{
|
||||
this.Click(event, true)
|
||||
this.Open(event, true)
|
||||
})
|
||||
this.OpenDir(this.path)
|
||||
})
|
||||
@ -98,11 +98,20 @@ class Finder{
|
||||
this.fileView.OpenFolder(this.path)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} event
|
||||
* @param {boolean} inNewWindow
|
||||
*/
|
||||
Click(event, inNewWindow){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MouseEvent} event
|
||||
* @param {boolean} inNewWindow
|
||||
*/
|
||||
Open(event, inNewWindow){
|
||||
let fileType = event.target.getAttribute("fileType")
|
||||
let fileName = event.target.getAttribute("name")
|
||||
switch (fileType) {
|
||||
|
@ -39,6 +39,11 @@
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.FileTileView .Selected{
|
||||
/* inherits: ; */
|
||||
/* background-color: black; */
|
||||
}
|
||||
|
||||
.FileTileView .Icon{
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
@ -54,6 +59,16 @@
|
||||
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
|
||||
}
|
||||
|
||||
.FileTileView .Selected .Icon{
|
||||
filter: brightness(0.4);
|
||||
}
|
||||
|
||||
.FileTileView .Lable{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.FileTileView .Selected .Lable{
|
||||
white-space: nowrap;
|
||||
color: white;
|
||||
background-color: black;
|
||||
}
|
@ -1,21 +1,28 @@
|
||||
class FileView{
|
||||
parentElem = undefined
|
||||
selected = []
|
||||
/**
|
||||
* @param {HTMLElement} fileViewElem
|
||||
* @param {Function} clickCallback
|
||||
* @param {Function} doubleClickCallback
|
||||
*/
|
||||
constructor(fileViewElem, clickCallback){
|
||||
constructor(fileViewElem, doubleClickCallback){
|
||||
//TODO check all params
|
||||
this.parentElem = fileViewElem
|
||||
|
||||
// this.OpenFolder(path)
|
||||
|
||||
// let scrollDiv = fileViewElem.children[1]
|
||||
// console.log(scrollDiv)
|
||||
// let scrollBar = new WdeScrollBar(fileViewElem.children[1].children[0], fileViewElem.children[0])
|
||||
|
||||
fileViewElem.addEventListener('click', (event) => {
|
||||
clickCallback(event)
|
||||
|
||||
console.log(event)
|
||||
if (event.detail === 1){
|
||||
this.selected.forEach(element => {
|
||||
// console.log
|
||||
element.classList.remove("Selected")
|
||||
});
|
||||
this.selected = []
|
||||
this.selected.push(event.target)
|
||||
event.target.classList.add("Selected")
|
||||
} else if (event.detail === 2) {
|
||||
doubleClickCallback(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user