removed last jQuery dependencies

should be fully jQuery free now!
This commit is contained in:
Niklas von Hertzen 2012-06-26 01:17:03 +03:00
parent 9f76f94a82
commit 343b86705f
2 changed files with 291 additions and 236 deletions

View File

@ -218,12 +218,49 @@ _html2canvas.Util.Extend = function (options, defaults) {
return 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; var children;
try { 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) { } catch (ex) {
h2clog("html2canvas.Util.Children failed with exception: " + ex.message); h2clog("html2canvas.Util.Children failed with exception: " + ex.message);

View File

@ -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) { 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)) { 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 = elementIndex( element );
currentIndex = $(element).index()+1;
switch(type){ switch(type){
case "decimal": case "decimal":
@ -879,7 +897,7 @@ _html2canvas.Parse = function ( images, options ) {
);*/ );*/
// console.log($(el).css('background-image'));
bgw = bounds.width - bgp.left; bgw = bounds.width - bgp.left;
bgh = bounds.height - bgp.top; bgh = bounds.height - bgp.top;
bgsx = bgp.left; bgsx = bgp.left;