"use strict"; var _html2canvas = {}, previousElement, computedCSS, html2canvas; function h2clog(a) { if (_html2canvas.logging && window.console && window.console.log) { window.console.log(a); } } _html2canvas.Util = {}; _html2canvas.Util.backgroundImage = function (src) { if (/data:image\/.*;base64,/i.test( src ) || /^(-webkit|-moz|linear-gradient|-o-)/.test( src )) { return src; } if (src.toLowerCase().substr( 0, 5 ) === 'url("') { src = src.substr( 5 ); src = src.substr( 0, src.length - 2 ); } else { src = src.substr( 4 ); src = src.substr( 0, src.length - 1 ); } return src; }; _html2canvas.Util.parseBackgroundImage = function (value) { var rxBackgroundImage = /([a-z\-]+)\((("[^"]+)|([^)]+))\)/i, method, definition, prefix, prefix_i, block, results = [], c, mode = 0, numParen = 0; var appendResult = function(){ if(method) { if(definition.substr( 0, 1 ) === '"') { definition = definition.substr( 1, definition.length - 2 ); } if(method.substr( 0, 1 ) === '-' && (prefix_i = method.indexOf( '-', 1 ) + 1) > 0) { prefix = method.substr( 0, prefix_i); method = method.substr( prefix_i ); } results.push({ prefix: prefix, method: method, definition: definition, value: block }); } method = prefix = definition = block = ''; }; appendResult(); for(var i = 0, ii = value.length; i if (attribute === "backgroundPosition") { // Older IE uses -x and -y val = [ toPX( attribute + "X", el.currentStyle[ attribute + "X" ] ), toPX( attribute + "Y", el.currentStyle[ attribute + "Y" ] ) ]; } else { val = toPX( attribute, el.currentStyle[ attribute ] ); if (/^(border)/i.test( attribute ) && /^(medium|thin|thick)$/i.test( val )) { switch (val) { case "thin": val = "1px"; break; case "medium": val = "0px"; // this is wrong, it should be 3px but IE uses medium for no border as well.. TODO find a work around break; case "thick": val = "5px"; break; } } } } return val; //return $(el).css(attribute); }; _html2canvas.Util.BackgroundPosition = function ( el, bounds, image ) { // TODO add support for multi image backgrounds var bgposition = _html2canvas.Util.getCSS( el, "backgroundPosition" ) , topPos, left, percentage, val; if (bgposition.length === 1){ val = bgposition; bgposition = []; bgposition[0] = val; bgposition[1] = val; } if (bgposition[0].toString().indexOf("%") !== -1){ percentage = (parseFloat(bgposition[0])/100); left = ((bounds.width * percentage)-(image.width*percentage)); }else{ left = parseInt(bgposition[0],10); } if (bgposition[1].toString().indexOf("%") !== -1){ percentage = (parseFloat(bgposition[1])/100); topPos = ((bounds.height * percentage)-(image.height*percentage)); }else{ topPos = parseInt(bgposition[1],10); } return { top: topPos, left: left }; }; _html2canvas.Util.Extend = function (options, defaults) { for (var key in options) { if (options.hasOwnProperty(key)) { defaults[key] = options[key]; } } return defaults; }; /* * Derived from jQuery.contents() * Copyright 2010, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license */ _html2canvas.Util.Children = function( elem ) { var children; try { children = (elem.nodeName && elem.nodeName.toUpperCase() === "IFRAME") ? elem.contentDocument || elem.contentWindow.document : (function( array ){ var ret = []; if ( array !== null ) { (function( first, second ) { var i = first.length, j = 0; if ( typeof second.length === "number" ) { for ( var l = second.length; j < l; j++ ) { first[ i++ ] = second[ j ]; } } else { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; } } first.length = i; return first; })( ret, array ); } return ret; })( elem.childNodes ); } catch (ex) { h2clog("html2canvas.Util.Children failed with exception: " + ex.message); children = []; } return children; };