src/extensions/default/QuickView/main.js
function normalizeGradientExpressionForQuickview(expression) {
            if (expression.indexOf("px") > 0) {
                var paramStart = expression.indexOf("(") + 1,
                    paramEnd = expression.lastIndexOf(")"),
                    parameters = expression.substring(paramStart, paramEnd),
                    params = splitStyleProperty(parameters),
                    lowerBound = 0,
                    upperBound = $previewContainer.width(),
                    args,
                    thisSize,
                    i;

                // find lower bound
                for (i = 0; i < params.length; i++) {
                    args = params[i].split(" ");

                    if (hasLengthInPixels(args)) {
                        thisSize = parseFloat(args[1]);

                        upperBound = Math.max(upperBound, thisSize);
                        // we really only care about converting negative
                        //  pixel values -- so take the smallest negative pixel
                        //  value and use that as baseline for display purposes
                        if (thisSize < 0) {
                            lowerBound = Math.min(lowerBound, thisSize);
                        }
                    }
                }

                // convert negative lower bound to positive and adjust all pixel values
                //  so that -20px is now 0px and 100px is now 120px
                lowerBound = Math.abs(lowerBound);

                // Offset the upperbound by the lowerBound to give us a corrected context
                upperBound += lowerBound;

                // convert to %
                for (i = 0; i < params.length; i++) {
                    args = params[i].split(" ");
                    if (isGradientColorStop(args) && hasLengthInPixels(args)) {
                        if (upperBound === 0) {
                            thisSize = 0;
                        } else {
                            thisSize = ((parseFloat(args[1]) + lowerBound) / upperBound) * 100;
                        }
                        args[1] = thisSize + "%";
                    }
                    params[i] = args.join(" ");
                }

                // put it back together.
                expression = expression.substring(0, paramStart) + params.join(", ") + expression.substring(paramEnd);
            }
            return expression;
        }
function normalizeGradientExpressionForQuickview(expression) {
            if (expression.indexOf("px") > 0) {
                var paramStart = expression.indexOf("(") + 1,
                    paramEnd = expression.lastIndexOf(")"),
                    parameters = expression.substring(paramStart, paramEnd),
                    params = splitStyleProperty(parameters),
                    lowerBound = 0,
                    upperBound = $previewContainer.width(),
                    args,
                    thisSize,
                    i;

                // find lower bound
                for (i = 0; i < params.length; i++) {
                    args = params[i].split(" ");

                    if (hasLengthInPixels(args)) {
                        thisSize = parseFloat(args[1]);

                        upperBound = Math.max(upperBound, thisSize);
                        // we really only care about converting negative
                        //  pixel values -- so take the smallest negative pixel
                        //  value and use that as baseline for display purposes
                        if (thisSize < 0) {
                            lowerBound = Math.min(lowerBound, thisSize);
                        }
                    }
                }

                // convert negative lower bound to positive and adjust all pixel values
                //  so that -20px is now 0px and 100px is now 120px
                lowerBound = Math.abs(lowerBound);

                // Offset the upperbound by the lowerBound to give us a corrected context
                upperBound += lowerBound;

                // convert to %
                for (i = 0; i < params.length; i++) {
                    args = params[i].split(" ");
                    if (isGradientColorStop(args) && hasLengthInPixels(args)) {
                        if (upperBound === 0) {
                            thisSize = 0;
                        } else {
                            thisSize = ((parseFloat(args[1]) + lowerBound) / upperBound) * 100;
                        }
                        args[1] = thisSize + "%";
                    }
                    params[i] = args.join(" ");
                }

                // put it back together.
                expression = expression.substring(0, paramStart) + params.join(", ") + expression.substring(paramEnd);
            }
            return expression;
        }
function normalizeGradientExpressionForQuickview ( expression ) { if ( expression . indexOf ( "px" ) > 0 ) { var paramStart = expression . indexOf ( "(" ) + 1 , paramEnd = expression . lastIndexOf ( ")" ) , parameters = expression . substring ( paramStart , paramEnd ) , params = splitStyleProperty ( parameters ) , lowerBound = 0 , upperBound = $previewContainer . width ( ) , args , thisSize , i ; // find lower bound for ( i = 0 ; i < params . length ; i ++ ) { args = params [ i ] . split ( " " ) ; if ( hasLengthInPixels ( args ) ) { thisSize = parseFloat ( args [ 1 ] ) ; upperBound = Math . max ( upperBound , thisSize ) ; // we really only care about converting negative //  pixel values -- so take the smallest negative pixel //  value and use that as baseline for display purposes if ( thisSize < 0 ) { lowerBound = Math . min ( lowerBound , thisSize ) ; } } } // convert negative lower bound to positive and adjust all pixel values //  so that -20px is now 0px and 100px is now 120px lowerBound = Math . abs ( lowerBound ) ; // Offset the upperbound by the lowerBound to give us a corrected context upperBound += lowerBound ; // convert to % for ( i = 0 ; i < params . length ; i ++ ) { args = params [ i ] . split ( " " ) ; if ( isGradientColorStop ( args ) && hasLengthInPixels ( args ) ) { if ( upperBound === 0 ) { thisSize = 0 ; } else { thisSize = ( ( parseFloat ( args [ 1 ] ) + lowerBound ) / upperBound ) * 100 ; } args [ 1 ] = thisSize + "%" ; } params [ i ] = args . join ( " " ) ; } // put it back together. expression = expression . substring ( 0 , paramStart ) + params . join ( ", " ) + expression . substring ( paramEnd ) ; } return expression ; }
Normalizes px color stops to %
Normalizes px color stops to %