mirror of
https://github.com/wassname/nvatom.git
synced 2026-08-12 12:10:23 +08:00
Initialize a package using Atom's package generator
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
fs = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class NotationalVelocityView
|
||||
constructor: (serializeState) ->
|
||||
# Create root element
|
||||
@element = document.createElement('div')
|
||||
@element.classList.add('notational-velocity', 'overlay', 'from-top')
|
||||
|
||||
# Create message element
|
||||
message = document.createElement('div')
|
||||
message.textContent = "The NotationalVelocity package is Alive! It's ALIVE!"
|
||||
message.classList.add('message')
|
||||
@element.appendChild(message)
|
||||
|
||||
# Register command that toggles this view
|
||||
atom.commands.add 'atom-workspace', 'notational-velocity:toggle': => @toggle()
|
||||
|
||||
# Returns an object that can be retrieved when package is activated
|
||||
serialize: ->
|
||||
|
||||
# Tear down any state and detach
|
||||
destroy: ->
|
||||
@element.remove()
|
||||
|
||||
# Toggle the visibility of this view
|
||||
toggle: ->
|
||||
console.log 'NotationalVelocityView was toggled!'
|
||||
|
||||
@readdir()
|
||||
|
||||
if @element.parentElement?
|
||||
@element.remove()
|
||||
else
|
||||
atom.workspaceView.append(@element)
|
||||
|
||||
# read filenames in a specific directory
|
||||
readdir: ->
|
||||
fs.readdir '.', (error, filenames) =>
|
||||
if error
|
||||
throw error
|
||||
for filename in filenames
|
||||
console.log filename
|
||||
@@ -0,0 +1,13 @@
|
||||
NotationalVelocityView = require './notational-velocity-view'
|
||||
|
||||
module.exports =
|
||||
notationalVelocityView: null
|
||||
|
||||
activate: (state) ->
|
||||
@notationalVelocityView = new NotationalVelocityView(state.notationalVelocityViewState)
|
||||
|
||||
deactivate: ->
|
||||
@notationalVelocityView.destroy()
|
||||
|
||||
serialize: ->
|
||||
notationalVelocityViewState: @notationalVelocityView.serialize()
|
||||
Reference in New Issue
Block a user