Support setting number fields to 0

Previously entering 0 would end up as '0' in the config
value instead of as a numeric value.
This commit is contained in:
Kevin Sawicki
2013-04-30 23:10:22 -07:00
parent 1afe4f0cd9
commit 536beb0d40
2 changed files with 18 additions and 2 deletions

View File

@@ -32,8 +32,12 @@ class ConfigPanel extends View
parseValue: (type, value) ->
switch type
when 'int' then value = parseInt(value) or value
when 'float' then value = parseFloat(value) or value
when 'int'
intValue = parseInt(value)
value = intValue unless isNaN(intValue)
when 'float'
floatValue = parseFloat(value)
value = floatValue unless isNaN(floatValue)
value = undefined if value == ''
value