mirror of
https://github.com/atom/atom.git
synced 2026-02-05 20:25:04 -05:00
Config panel handles binding for Editors
This commit is contained in:
committed by
Corey Johnson & Kevin Sawicki
parent
1b4fbdb065
commit
cedea831f7
@@ -5,6 +5,7 @@ module.exports =
|
||||
class ConfigPanel extends View
|
||||
initialize: ->
|
||||
@bindFormFields()
|
||||
@bindEditors()
|
||||
|
||||
bindFormFields: ->
|
||||
for input in @find('input[id]').toArray()
|
||||
@@ -28,3 +29,18 @@ class ConfigPanel extends View
|
||||
!!input.attr('checked')
|
||||
else
|
||||
value
|
||||
|
||||
bindEditors: ->
|
||||
for editor in @find('.editor[id]').views()
|
||||
do (editor) =>
|
||||
name = editor.attr('id')
|
||||
type = editor.attr('type')
|
||||
|
||||
@observeConfig name, (value) ->
|
||||
editor.setText(value.toString())
|
||||
|
||||
editor.getBuffer().on 'contents-modified', ->
|
||||
value = editor.getText()
|
||||
if type == 'int' then value = parseInt(value)
|
||||
if type == 'float' then value = parseFloat(value)
|
||||
config.set name, value
|
||||
|
||||
Reference in New Issue
Block a user