Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 86a9e70

Browse files
WliuWliu
Wliu
authored and
Wliu
committed
file-view.coffee -> file-view.js
1 parent a8ad1db commit 86a9e70

File tree

2 files changed

+53
-44
lines changed

2 files changed

+53
-44
lines changed

lib/file-view.coffee

Lines changed: 0 additions & 44 deletions
This file was deleted.

lib/file-view.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const {CompositeDisposable} = require('atom')
2+
const getIconServices = require('./get-icon-services')
3+
4+
module.exports =
5+
class FileView {
6+
constructor(file) {
7+
this.file = file
8+
this.subscriptions = new CompositeDisposable()
9+
this.subscriptions.add(this.file.onDidDestroy(() => this.subscriptions.dispose()))
10+
11+
this.element = document.createElement('li')
12+
this.element.setAttribute('is', 'tree-view-file')
13+
this.element.draggable = true
14+
this.element.classList.add('file', 'entry', 'list-item')
15+
16+
this.fileName = document.createElement('span')
17+
this.fileName.classList.add('name', 'icon')
18+
this.element.appendChild(this.fileName)
19+
this.fileName.textContent = this.file.name
20+
this.fileName.title = this.file.name
21+
this.fileName.dataset.name = this.file.name
22+
this.fileName.dataset.path = this.file.path
23+
24+
this.updateIcon()
25+
this.subscriptions.add(this.file.onDidStatusChange(() => this.updateStatus()))
26+
this.subscriptions.add(getIconServices().onDidChange(() => this.updateIcon()))
27+
this.updateStatus()
28+
}
29+
30+
updateIcon() {
31+
getIconServices().updateFileIcon(this)
32+
this.element.getPath = this.getPath.bind(this)
33+
this.element.isPathEqual = this.isPathEqual.bind(this)
34+
this.element.file = this.file
35+
this.element.fileName = this.fileName
36+
this.element.updateStatus = this.updateStatus.bind(this)
37+
}
38+
39+
updateStatus() {
40+
this.element.classList.remove('status-ignored', 'status-ignored-name', 'status-modified', 'status-added')
41+
if (this.file.status != null) {
42+
this.element.classList.add(`status-${this.file.status}`)
43+
}
44+
}
45+
46+
getPath() {
47+
return this.fileName.dataset.path
48+
}
49+
50+
isPathEqual(pathToCompare) {
51+
return this.file.isPathEqual(pathToCompare)
52+
}
53+
}

0 commit comments

Comments
 (0)