(v, recObj)
| 6688 | |
| 6689 | // @private Parses position-related complex strings like "top left" or "50px 10px" or "70% 20%", etc. which are used for things like transformOrigin or backgroundPosition. Optionally decorates a supplied object (recObj) with the following properties: "ox" (offsetX), "oy" (offsetY), "oxp" (if true, "ox" is a percentage not a pixel value), and "oxy" (if true, "oy" is a percentage not a pixel value) |
| 6690 | _parsePosition = function(v, recObj) { |
| 6691 | if (v === "contain" || v === "auto" || v === "auto auto") { |
| 6692 | return v + " "; |
| 6693 | } |
| 6694 | if (v == null || v === "") { //note: Firefox uses "auto auto" as default whereas Chrome uses "auto". |
| 6695 | v = "0 0"; |
| 6696 | } |
| 6697 | var a = v.split(" "), |
| 6698 | x = (v.indexOf("left") !== -1) ? "0%" : (v.indexOf("right") !== -1) ? "100%" : a[0], |
| 6699 | y = (v.indexOf("top") !== -1) ? "0%" : (v.indexOf("bottom") !== -1) ? "100%" : a[1]; |
| 6700 | if (y == null) { |
| 6701 | y = (x === "center") ? "50%" : "0"; |
| 6702 | } else if (y === "center") { |
| 6703 | y = "50%"; |
| 6704 | } |
| 6705 | if (x === "center" || (isNaN(parseFloat(x)) && (x + "").indexOf("=") === -1)) { //remember, the user could flip-flop the values and say "bottom center" or "center bottom", etc. "center" is ambiguous because it could be used to describe horizontal or vertical, hence the isNaN(). If there's an "=" sign in the value, it's relative. |
| 6706 | x = "50%"; |
| 6707 | } |
| 6708 | v = x + " " + y + ((a.length > 2) ? " " + a[2] : ""); |
| 6709 | if (recObj) { |
| 6710 | recObj.oxp = (x.indexOf("%") !== -1); |
| 6711 | recObj.oyp = (y.indexOf("%") !== -1); |
| 6712 | recObj.oxr = (x.charAt(1) === "="); |
| 6713 | recObj.oyr = (y.charAt(1) === "="); |
| 6714 | recObj.ox = parseFloat(x.replace(_NaNExp, "")); |
| 6715 | recObj.oy = parseFloat(y.replace(_NaNExp, "")); |
| 6716 | recObj.v = v; |
| 6717 | } |
| 6718 | return recObj || v; |
| 6719 | }, |
| 6720 | |
| 6721 | /** |
| 6722 | * @private Takes an ending value (typically a string, but can be a number) and a starting value and returns the change between the two, looking for relative value indicators like += and -= and it also ignores suffixes (but make sure the ending value starts with a number or +=/-= and that the starting value is a NUMBER!) |
no outgoing calls
no test coverage detected