| 1544 | } |
| 1545 | |
| 1546 | function stringParse(string) { |
| 1547 | var inst = color(), |
| 1548 | rgba = inst._rgba = []; |
| 1549 | |
| 1550 | string = string.toLowerCase(); |
| 1551 | |
| 1552 | each(stringParsers, |
| 1553 | function (i, parser) { |
| 1554 | var parsed, |
| 1555 | match = parser.re.exec(string), |
| 1556 | values = match && parser.parse(match), |
| 1557 | spaceName = parser.space || "rgba"; |
| 1558 | |
| 1559 | if (values) { |
| 1560 | parsed = inst[spaceName](values); |
| 1561 | |
| 1562 | // If this was an rgba parse the assignment might happen twice |
| 1563 | // oh well.... |
| 1564 | inst[spaces[spaceName].cache] = parsed[spaces[spaceName].cache]; |
| 1565 | rgba = inst._rgba = parsed._rgba; |
| 1566 | |
| 1567 | // Exit each( stringParsers ) here because we matched |
| 1568 | return false; |
| 1569 | } |
| 1570 | }); |
| 1571 | |
| 1572 | // Found a stringParser that handled it |
| 1573 | if (rgba.length) { |
| 1574 | // If this came from a parsed string, force "transparent" when alpha is 0 |
| 1575 | // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) |
| 1576 | if (rgba.join() === "0,0,0,0") { |
| 1577 | jQuery.extend(rgba, colors.transparent); |
| 1578 | } |
| 1579 | return inst; |
| 1580 | } |
| 1581 | |
| 1582 | // Named colors |
| 1583 | return colors[string]; |
| 1584 | } |
| 1585 | |
| 1586 | color.fn = jQuery.extend(color.prototype, |
| 1587 | { |