| 2783 | } |
| 2784 | |
| 2785 | function stringParse( string ) { |
| 2786 | var inst = color(), |
| 2787 | rgba = inst._rgba = []; |
| 2788 | |
| 2789 | string = string.toLowerCase(); |
| 2790 | |
| 2791 | each( stringParsers, function( i, parser ) { |
| 2792 | var parsed, |
| 2793 | match = parser.re.exec( string ), |
| 2794 | values = match && parser.parse( match ), |
| 2795 | spaceName = parser.space || "rgba"; |
| 2796 | |
| 2797 | if ( values ) { |
| 2798 | parsed = inst[ spaceName ]( values ); |
| 2799 | |
| 2800 | // if this was an rgba parse the assignment might happen twice |
| 2801 | // oh well.... |
| 2802 | inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; |
| 2803 | rgba = inst._rgba = parsed._rgba; |
| 2804 | |
| 2805 | // exit each( stringParsers ) here because we matched |
| 2806 | return false; |
| 2807 | } |
| 2808 | }); |
| 2809 | |
| 2810 | // Found a stringParser that handled it |
| 2811 | if ( rgba.length ) { |
| 2812 | |
| 2813 | // if this came from a parsed string, force "transparent" when alpha is 0 |
| 2814 | // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) |
| 2815 | if ( rgba.join() === "0,0,0,0" ) { |
| 2816 | jQuery.extend( rgba, colors.transparent ); |
| 2817 | } |
| 2818 | return inst; |
| 2819 | } |
| 2820 | |
| 2821 | // named colors |
| 2822 | return colors[ string ]; |
| 2823 | } |
| 2824 | |
| 2825 | color.fn = jQuery.extend( color.prototype, { |
| 2826 | parse: function( red, green, blue, alpha ) { |