mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Refactoring
This commit is contained in:
parent
88dd1e41c0
commit
67850f2cee
13
src/Core.js
13
src/Core.js
@ -5,7 +5,6 @@ previousElement,
|
|||||||
computedCSS,
|
computedCSS,
|
||||||
html2canvas;
|
html2canvas;
|
||||||
|
|
||||||
|
|
||||||
function h2clog(a) {
|
function h2clog(a) {
|
||||||
if (_html2canvas.logging && window.console && window.console.log) {
|
if (_html2canvas.logging && window.console && window.console.log) {
|
||||||
window.console.log(a);
|
window.console.log(a);
|
||||||
@ -14,17 +13,9 @@ function h2clog(a) {
|
|||||||
|
|
||||||
_html2canvas.Util = {};
|
_html2canvas.Util = {};
|
||||||
|
|
||||||
_html2canvas.Util.isElementVisible = function (element) {
|
_html2canvas.Util.trimText = (function(isNative){
|
||||||
return (
|
|
||||||
_html2canvas.Util.getCSS( element, 'display' ) !== "none" &&
|
|
||||||
_html2canvas.Util.getCSS( element, 'visibility' ) !== "hidden" &&
|
|
||||||
!element.hasAttribute( "data-html2canvas-ignore" )
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
_html2canvas.Util.trimText = (function(native){
|
|
||||||
return function(input){
|
return function(input){
|
||||||
if(native) { return native.apply( input ); }
|
if(isNative) { return isNative.apply( input ); }
|
||||||
else { return ((input || '') + '').replace( /^\s+|\s+$/g , '' ); }
|
else { return ((input || '') + '').replace( /^\s+|\s+$/g , '' ); }
|
||||||
};
|
};
|
||||||
})( String.prototype.trim );
|
})( String.prototype.trim );
|
||||||
|
@ -103,12 +103,22 @@ _html2canvas.Preload = function( options ) {
|
|||||||
loadPseudoElement(element, ":after");
|
loadPseudoElement(element, ":after");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadGradientImage(backgroundImage, bounds) {
|
||||||
|
var img = _html2canvas.Generate.Gradient(backgroundImage, bounds);
|
||||||
|
|
||||||
|
if (img !== undefined){
|
||||||
|
images[backgroundImage] = {
|
||||||
|
img: img,
|
||||||
|
succeeded: true
|
||||||
|
};
|
||||||
|
images.numTotal++;
|
||||||
|
images.numLoaded++;
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadBackgroundImages(background_image, el) {
|
function loadBackgroundImages(background_image, el) {
|
||||||
var background_images,
|
var background_images, bounds;
|
||||||
src,
|
|
||||||
img,
|
|
||||||
bounds;
|
|
||||||
// opera throws exception on external-content.html
|
|
||||||
|
|
||||||
background_images = _html2canvas.Util.parseBackgroundImage(background_image);
|
background_images = _html2canvas.Util.parseBackgroundImage(background_image);
|
||||||
for(var imageIndex = background_images.length; imageIndex-- > 0;) {
|
for(var imageIndex = background_images.length; imageIndex-- > 0;) {
|
||||||
@ -121,25 +131,12 @@ _html2canvas.Preload = function( options ) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (background_image.method === 'url') {
|
if (background_image.method === 'url') {
|
||||||
src = background_image.args[0];
|
methods.loadImage(background_image.args[0]);
|
||||||
methods.loadImage(src);
|
|
||||||
|
|
||||||
} else if(background_image.method.match(/\-?gradient$/)) {
|
} else if(background_image.method.match(/\-?gradient$/)) {
|
||||||
if(bounds === undefined) {
|
if(bounds === undefined) {
|
||||||
bounds = _html2canvas.Util.Bounds(el);
|
bounds = _html2canvas.Util.Bounds(el);
|
||||||
}
|
}
|
||||||
|
loadGradientImage(background_image.value, bounds);
|
||||||
img = _html2canvas.Generate.Gradient( background_image.value, bounds);
|
|
||||||
|
|
||||||
if ( img !== undefined ){
|
|
||||||
images[background_image.value] = {
|
|
||||||
img: img,
|
|
||||||
succeeded: true
|
|
||||||
};
|
|
||||||
images.numTotal++;
|
|
||||||
images.numLoaded++;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user