               # not updating unless value is longer than 4 digits including commas
               # still some issues moving the comma after input/delete
               # need to add support for delete/backspace if comma is present
+              # issue where formatting is not occurring when entered too quickly
               if scope.rawScoreUpdating == false
                 beginUpdate(scope, elem)
 

    makeMaxDigits = (maxDigits) ->
        validRegex = new RegExp "^-?\\d{0,#{maxDigits}}(\\.\\d*)?$"
        (val) -> validRegex.test val

    makeIsValid = (options) ->
        validations = []

NumberModule = angular.module('smart-number', [])

NumberModule.directive 'smartNumber',
['smartNumberConfig', (smartNumberConfig) ->

    defaultOptions = smartNumberConfig.defaultOptions
    controlKeys = [0,8,13] # 0 = tab, 8 = backspace , 13 = enter

    getOptions = (scope, attrs) ->
        options = angular.copy defaultOptions
        if attrs.smartNumberOptions?
            for own option, value of scope.$eval(attrs.smartNumberOptions)
                options[option] = value
        options
    
