mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Plugin does a lot of things we thought Pane would.
This commit is contained in:
parent
012fc4826d
commit
620538a6b5
@ -6,52 +6,17 @@ class Pane
|
||||
|
||||
html: null
|
||||
|
||||
keymap: ->
|
||||
showing: false
|
||||
|
||||
constructor: (options={}) ->
|
||||
for option, value of options
|
||||
@[option] = value
|
||||
|
||||
for shortcut, method of @keymap()
|
||||
bindKey @, shortcut, method
|
||||
|
||||
@initialize options
|
||||
|
||||
get: (key, defaultValue) ->
|
||||
try
|
||||
object = JSON.parse(localStorage[@storageNamespace()] ? "{}")
|
||||
catch error
|
||||
error.message += "\nGetting #{key}"
|
||||
console.log(error)
|
||||
|
||||
object[key] ? defaultValue
|
||||
|
||||
set: (key, value) ->
|
||||
try
|
||||
object = JSON.parse(localStorage[@storageNamespace()] ? "{}")
|
||||
catch error
|
||||
error.message += "\nSetting #{key}: #{value}"
|
||||
console.log(error)
|
||||
|
||||
# Putting data in
|
||||
if value == undefined
|
||||
delete object[key]
|
||||
else
|
||||
object[key] = value
|
||||
localStorage[@storageNamespace()] = JSON.stringify(object)
|
||||
constructor: (@window) ->
|
||||
|
||||
toggle: ->
|
||||
if @showing
|
||||
@html.parent().detach()
|
||||
else
|
||||
# This require should be at the top of the file, BUT it doesn't work.
|
||||
# Would like to figure out why.
|
||||
{activeWindow} = require 'app'
|
||||
activeWindow.addPane this
|
||||
@window.addPane this
|
||||
|
||||
@showing = not @showing
|
||||
|
||||
# Override these in your subclass
|
||||
initialize: ->
|
||||
|
||||
storageNamespace: -> @.constructor.name
|
@ -1,11 +1,40 @@
|
||||
{bindKey} = require 'keybinder'
|
||||
|
||||
module.exports =
|
||||
class Plugin
|
||||
constructor: (@window) ->
|
||||
console.log "Loaded Plugin: " + @.constructor.name
|
||||
|
||||
# Called after the window is fully loaded
|
||||
initialize: ->
|
||||
for shortcut, method of @keymap()
|
||||
bindKey @, shortcut, method
|
||||
|
||||
pane: ->
|
||||
|
||||
keymap: ->
|
||||
|
||||
storageNamespace: -> @.constructor.name
|
||||
|
||||
get: (key, defaultValue) ->
|
||||
try
|
||||
object = JSON.parse(localStorage[@storageNamespace()] ? "{}")
|
||||
catch error
|
||||
error.message += "\nGetting #{key}"
|
||||
console.log(error)
|
||||
|
||||
object[key] ? defaultValue
|
||||
|
||||
set: (key, value) ->
|
||||
try
|
||||
object = JSON.parse(localStorage[@storageNamespace()] ? "{}")
|
||||
catch error
|
||||
error.message += "\nSetting #{key}: #{value}"
|
||||
console.log(error)
|
||||
|
||||
# Putting data in
|
||||
if value == undefined
|
||||
delete object[key]
|
||||
else
|
||||
object[key] = value
|
||||
localStorage[@storageNamespace()] = JSON.stringify(object)
|
||||
|
||||
# Called when @window is closed
|
||||
destroy: ->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user