removed jQuery.css dependancy and few general CSS bug fixes

This commit is contained in:
MoyuScript
2012-03-03 19:18:39 +02:00
parent d479774986
commit 67c5af1822
7 changed files with 129 additions and 92 deletions

View File

@ -34,11 +34,16 @@
width:50px;
height:50px;
}
#paddingPercentage div {
width:50px;
height:50px;
}
</style>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture" style="display:none;">
<div id="qunit-fixture" style="visibility:none; height:1px; overflow:scroll;">
<div id="borders">
<div style="border-width: 1px 0;"></div>
<div style="border-width: 1em 0;"></div>
@ -55,13 +60,17 @@
<div style="padding: 1px 0;"></div>
<div style="padding: 1em 0;"></div>
<div style="padding: thin medium thick;"></div>
<div style="padding: 5% 6px 12%;"></div>
<div style="padding: 5em 5ex 5in 5cm;"></div>
<div style="padding: 500em 500ex 500in 500cm;"></div>
<div style="padding: 5mm 5pt 5pc 5px;"></div>
<div style="padding: 500mm 500pt 500pc 500px;"></div>
<div style="padding: 1px 5%;"></div>
<div style="padding: 15% 0 3%;"></div>
</div>
<div id="backgroundPosition">
<div style="background-position: 1px 0;"></div>
<div style="background-position: 1em 0;"></div>

View File

@ -1,9 +1,3 @@
/*
* @author Niklas von Hertzen <niklas at hertzen.com>
* @created 3.3.2012
* @website http://hertzen.com
*/
module("CSS");
$(function() {
@ -76,7 +70,7 @@ $(function() {
} else if (expect === "thick") {
expect = "5px";
}
QUnit.equal( _html2canvas.Util.getCSS(el, prop), expect, "div #" + (i + 1) + " property " + prop + " equals " + $(el).css(prop) );
QUnit.equal( _html2canvas.Util.getCSS(el, prop), expect, "div #" + (i + 1) + " property " + prop + " equals " + expect );
});
});
@ -97,6 +91,8 @@ $(function() {
});
});
var propsToTest3 = ["backgroundPosition"],
@ -109,11 +105,17 @@ $(function() {
var img = new Image();
img.width = 50;
img.height = 50;
var item = _html2canvas.Util.getCSS(el, prop),
pos = _html2canvas.Util.BackgroundPosition(el, _html2canvas.Util.Bounds(el), img);
var split = $(el).css(prop).split(" ");
var item = _html2canvas.Util.getCSS(el, prop),
pos = _html2canvas.Util.BackgroundPosition(el, _html2canvas.Util.Bounds(el), img),
split;
if ( window.getComputedStyle ) {
split = $(el).css(prop).split(" ");
} else {
split = [$(el).css(prop+"X"),$(el).css(prop+"Y")]
}
var testEl = $('<div />').css({
'position': 'absolute',
'left': split[0],
@ -125,8 +127,8 @@ $(function() {
QUnit.equal( pos.left, parseFloat(testEl.css('left'), 10), "div #" + (i + 1) + " background-position-x equals " + pos.left + " from " + item );
QUnit.equal( pos.top, parseFloat(testEl.css('top'), 10), "div #" + (i + 1) + " background-position-y equals " + pos.top );
QUnit.equal( pos.left, Math.round(parseFloat(testEl.css('left'), 10)), "div #" + (i + 1) + " background-position-x equals " + pos.left + " from " + item );
QUnit.equal( pos.top, Math.round(parseFloat(testEl.css('top'), 10)), "div #" + (i + 1) + " background-position-y equals " + pos.top );
testEl.remove();

View File

@ -5,7 +5,7 @@
Released under MIT License
*/
var h2cSelector = document.body, h2cOptions;
var h2cSelector, h2cOptions;
(function(document, window) {
var scrStart = '<script type="text/javascript" src="', scrEnd = '"></script>';
document.write(scrStart + '../external/jquery-1.6.2.js' + scrEnd);
@ -17,7 +17,9 @@ var h2cSelector = document.body, h2cOptions;
if (window.setUp) {
window.setUp();
}
h2cSelector = [document.body];
setTimeout(function() {
$(h2cSelector).html2canvas($.extend({
flashcanvas: "../external/flashcanvas.min.js",
logging: true,