move parseBackgroundImage to Util; add tests

This commit is contained in:
Andy Edinborough
2012-12-28 12:33:57 -06:00
parent 62cb111956
commit a4b7d04e80
3 changed files with 69 additions and 20 deletions

View File

@ -31,6 +31,26 @@ _html2canvas.Util.backgroundImage = function (src) {
return src;
};
_html2canvas.Util.parseBackgroundImage = function (value) {
var rxBackgroundImage = /([a-z\-]+)\((("[^"]+)|([^)]+))\)/i,
match, results = [], n = 0;
if(!value) { return results; }
while( n++ < 100 && !!(match = value.match(rxBackgroundImage)) ) {
var def = match[2];
if(def.substr( 0, 1 ) === '"') {
def = def.substr(1, def.length-2);
}
results.push({
method: match[1],
definition: def,
value: match[0]
});
value = value.replace( match[0], '' );
}
return results;
};
_html2canvas.Util.Bounds = function getBounds (el) {
var clientRect,
bounds = {};