From c77dc479db2a5423a29e0bcecd03dd089d6c31ab Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Tue, 2 May 2023 03:48:12 +0300 Subject: [PATCH] Create one file select and doubleclick/click events --- resources/sys/finder/finder.js | 13 +++++++++++-- resources/sys/wde/file-view.css | 15 +++++++++++++++ resources/sys/wde/file-view.js | 25 ++++++++++++++++--------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/resources/sys/finder/finder.js b/resources/sys/finder/finder.js index 095deef..8eb95e3 100644 --- a/resources/sys/finder/finder.js +++ b/resources/sys/finder/finder.js @@ -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) { diff --git a/resources/sys/wde/file-view.css b/resources/sys/wde/file-view.css index dc12843..2b65b45 100644 --- a/resources/sys/wde/file-view.css +++ b/resources/sys/wde/file-view.css @@ -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; +} \ No newline at end of file diff --git a/resources/sys/wde/file-view.js b/resources/sys/wde/file-view.js index 150f41f..5ef7c1b 100644 --- a/resources/sys/wde/file-view.js +++ b/resources/sys/wde/file-view.js @@ -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) + } }) }