mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
removed last jQuery dependencies
should be fully jQuery free now!
This commit is contained in:
parent
9f76f94a82
commit
343b86705f
45
src/Core.js
45
src/Core.js
@ -218,12 +218,49 @@ _html2canvas.Util.Extend = function (options, defaults) {
|
||||
return defaults;
|
||||
};
|
||||
|
||||
_html2canvas.Util.Children = function(el) {
|
||||
// $(el).contents() !== el.childNodes, Opera / IE have issues with that
|
||||
|
||||
/*
|
||||
* 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 = $(el).contents();
|
||||
//children = (el.nodeName && el.nodeName.toUpperCase() === "IFRAME") ? el.contentDocument || el.contentWindow.document : el.childNodes ;
|
||||
|
||||
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);
|
||||
|
24
src/Parse.js
24
src/Parse.js
@ -442,6 +442,25 @@ _html2canvas.Parse = function ( images, options ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
function elementIndex( el ) {
|
||||
var i = -1,
|
||||
count = 1,
|
||||
childs = el.parentNode.childNodes;
|
||||
|
||||
if ( el.parentNode ) {
|
||||
while( childs[ ++i ] !== el ) {
|
||||
if ( childs[ i ].nodeType === 1 ) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function renderListItem(element, stack, elBounds) {
|
||||
|
||||
|
||||
@ -456,8 +475,7 @@ _html2canvas.Parse = function ( images, options ) {
|
||||
|
||||
if (/^(decimal|decimal-leading-zero|upper-alpha|upper-latin|upper-roman|lower-alpha|lower-greek|lower-latin|lower-roman)$/i.test(type)) {
|
||||
|
||||
// TODO remove jQuery dependency
|
||||
currentIndex = $(element).index()+1;
|
||||
currentIndex = elementIndex( element );
|
||||
|
||||
switch(type){
|
||||
case "decimal":
|
||||
@ -879,7 +897,7 @@ _html2canvas.Parse = function ( images, options ) {
|
||||
);*/
|
||||
|
||||
|
||||
// console.log($(el).css('background-image'));
|
||||
|
||||
bgw = bounds.width - bgp.left;
|
||||
bgh = bounds.height - bgp.top;
|
||||
bgsx = bgp.left;
|
||||
|
Loading…
Reference in New Issue
Block a user