mirror of
https://github.com/atom/atom.git
synced 2026-02-08 13:45:09 -05:00
This allows it to operate independently of the project and mirror the availability of the root view and project.
51 lines
1.3 KiB
CoffeeScript
51 lines
1.3 KiB
CoffeeScript
{View} = require 'space-pen'
|
|
$ = require 'jquery'
|
|
Git = require 'git'
|
|
fs = require 'fs'
|
|
|
|
module.exports =
|
|
class FileView extends View
|
|
|
|
@content: ({file} = {}) ->
|
|
@li class: 'file entry', =>
|
|
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
|
@span '', class: 'highlight'
|
|
|
|
file: null
|
|
|
|
initialize: ({@file, @project} = {}) ->
|
|
@subscribe $(window), 'focus', => @updateStatus()
|
|
|
|
extension = fs.extension(@getPath())
|
|
if fs.isReadmePath(@getPath())
|
|
@fileName.addClass('readme-icon')
|
|
else if fs.isCompressedExtension(extension)
|
|
@fileName.addClass('compressed-icon')
|
|
else if fs.isImageExtension(extension)
|
|
@fileName.addClass('image-icon')
|
|
else if fs.isPdfExtension(extension)
|
|
@fileName.addClass('pdf-icon')
|
|
else if fs.isBinaryExtension(extension)
|
|
@fileName.addClass('binary-icon')
|
|
else
|
|
@fileName.addClass('text-icon')
|
|
|
|
@updateStatus()
|
|
|
|
updateStatus: ->
|
|
@removeClass('ignored modified new')
|
|
return unless git?
|
|
|
|
path = @getPath()
|
|
if git.isPathIgnored(path)
|
|
@addClass('ignored')
|
|
else
|
|
status = git.getPathStatus(path)
|
|
if git.isStatusModified(status)
|
|
@addClass('modified')
|
|
else if git.isStatusNew(status)
|
|
@addClass('new')
|
|
|
|
getPath: ->
|
|
@file.path
|