src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js
function _getValidBezierParams(match) {
        var param,
            // take ease-in-out as default value in case there are no params yet (or they are invalid)
            def = [ ".42", "0", ".58", "1" ],
            oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
            originalString = match[0],
            i;

        if (match) {
            match = match[1].split(",");
        }

        if (match) {
            for (i = 0; i <= 3; i++) {
                if (match[i]) {
                    match[i] = match[i].trim();
                    param = _convertToNumber(match[i]);

                    // Verify the param is a number
                    // If not, replace it with the default value
                    if (!param.isNumber) {
                        match[i] = undefined;

                    // Verify x coordinates are in 0-1 range
                    // If not, set them to the closest value in range
                    } else if (i === 0 || i === 2) {
                        if (param.value < 0) {
                            match[i] = "0";
                        } else if (param.value > 1) {
                            match[i] = "1";
                        }
                    }
                }

                if (!match[i]) {
                    match[i] = def[i];
                }
            }
        } else {
            match = def;
        }
        match = match.splice(0, 4); // make sure there are only 4 params
        match = "cubic-bezier(" + match.join(", ") + ")";
        match = match.match(BEZIER_CURVE_VALID_REGEX);

        if (match) {
            match.index = oldIndex; // re-set the index here to get the right context
            match.originalString = originalString;
            return match;
        }
        return null;
    }
function _getValidBezierParams(match) {
        var param,
            // take ease-in-out as default value in case there are no params yet (or they are invalid)
            def = [ ".42", "0", ".58", "1" ],
            oldIndex = match.index, // we need to store the old match.index to re-set the index afterwards
            originalString = match[0],
            i;

        if (match) {
            match = match[1].split(",");
        }

        if (match) {
            for (i = 0; i <= 3; i++) {
                if (match[i]) {
                    match[i] = match[i].trim();
                    param = _convertToNumber(match[i]);

                    // Verify the param is a number
                    // If not, replace it with the default value
                    if (!param.isNumber) {
                        match[i] = undefined;

                    // Verify x coordinates are in 0-1 range
                    // If not, set them to the closest value in range
                    } else if (i === 0 || i === 2) {
                        if (param.value < 0) {
                            match[i] = "0";
                        } else if (param.value > 1) {
                            match[i] = "1";
                        }
                    }
                }

                if (!match[i]) {
                    match[i] = def[i];
                }
            }
        } else {
            match = def;
        }
        match = match.splice(0, 4); // make sure there are only 4 params
        match = "cubic-bezier(" + match.join(", ") + ")";
        match = match.match(BEZIER_CURVE_VALID_REGEX);

        if (match) {
            match.index = oldIndex; // re-set the index here to get the right context
            match.originalString = originalString;
            return match;
        }
        return null;
    }
function _getValidBezierParams ( match ) { var param , // take ease-in-out as default value in case there are no params yet (or they are invalid) def = [ ".42" , "0" , ".58" , "1" ] , oldIndex = match . index , // we need to store the old match.index to re-set the index afterwards originalString = match [ 0 ] , i ; if ( match ) { match = match [ 1 ] . split ( "," ) ; } if ( match ) { for ( i = 0 ; i <= 3 ; i ++ ) { if ( match [ i ] ) { match [ i ] = match [ i ] . trim ( ) ; param = _convertToNumber ( match [ i ] ) ; // Verify the param is a number // If not, replace it with the default value if ( ! param . isNumber ) { match [ i ] = undefined ; // Verify x coordinates are in 0-1 range // If not, set them to the closest value in range } else if ( i === 0 || i === 2 ) { if ( param . value < 0 ) { match [ i ] = "0" ; } else if ( param . value > 1 ) { match [ i ] = "1" ; } } } if ( ! match [ i ] ) { match [ i ] = def [ i ] ; } } } else { match = def ; } match = match . splice ( 0 , 4 ) ; // make sure there are only 4 params match = "cubic-bezier(" + match . join ( ", " ) + ")" ; match = match . match ( BEZIER_CURVE_VALID_REGEX ) ; if ( match ) { match . index = oldIndex ; // re-set the index here to get the right context match . originalString = originalString ; return match ; } return null ; }
Get valid params for an invalid cubic-bezier.

@param {RegExp.match} match (Invalid) matches from cubicBezierMatch()
@return {?RegExp.match} Valid match or null if the output is not valid
Get valid params for an invalid cubic - bezier .