@@ -20,62 +20,62 @@ function h2clog(a) {
20
20
_html2canvas . Util = { } ;
21
21
22
22
_html2canvas . Util . backgroundImage = function ( src ) {
23
-
23
+
24
24
if ( / d a t a : i m a g e \/ .* ; b a s e 6 4 , / i. test ( src ) || / ^ ( - w e b k i t | - m o z | l i n e a r - g r a d i e n t | - o - ) / . test ( src ) ) {
25
25
return src ;
26
26
}
27
-
27
+
28
28
if ( src . toLowerCase ( ) . substr ( 0 , 5 ) === 'url(http://github.com/"'%3C/span%3E%3Cspan%20class=pl-kos%3E) {
29
29
src = src . substr ( 5 ) ;
30
- src = src . substr ( 0 , src . length - 2 ) ;
30
+ src = src . substr ( 0 , src . length - 2 ) ;
31
31
} else {
32
32
src = src . substr ( 4 ) ;
33
- src = src . substr ( 0 , src . length - 1 ) ;
33
+ src = src . substr ( 0 , src . length - 1 ) ;
34
34
}
35
35
36
- return src ;
36
+ return src ;
37
37
} ;
38
38
39
39
_html2canvas . Util . Bounds = function getBounds ( el ) {
40
40
var clientRect ,
41
41
bounds = { } ;
42
-
43
- if ( el . getBoundingClientRect ) {
42
+
43
+ if ( el . getBoundingClientRect ) {
44
44
clientRect = el . getBoundingClientRect ( ) ;
45
45
46
-
46
+
47
47
// TODO add scroll position to bounds, so no scrolling of window necessary
48
48
bounds . top = clientRect . top ;
49
49
bounds . bottom = clientRect . bottom || ( clientRect . top + clientRect . height ) ;
50
50
bounds . left = clientRect . left ;
51
-
51
+
52
52
// older IE doesn't have width/height, but top/bottom instead
53
53
bounds . width = clientRect . width || ( clientRect . right - clientRect . left ) ;
54
54
bounds . height = clientRect . height || ( clientRect . bottom - clientRect . top ) ;
55
-
55
+
56
56
return bounds ;
57
-
58
- }
57
+
58
+ }
59
59
} ;
60
60
61
61
_html2canvas . Util . getCSS = function ( el , attribute ) {
62
62
// return $(el).css(attribute);
63
-
63
+
64
64
var val ;
65
-
65
+
66
66
function toPX ( attribute , val ) {
67
67
var rsLeft = el . runtimeStyle && el . runtimeStyle [ attribute ] ,
68
68
left ,
69
69
style = el . style ;
70
-
70
+
71
71
// Check if we are not dealing with pixels, (Opera has issues with this)
72
72
// Ported from jQuery css.js
73
73
// From the awesome hack by Dean Edwards
74
74
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
75
75
76
76
// If we're not dealing with a regular pixel number
77
- // but a number that has a weird ending, we need to convert it to pixels
78
-
77
+ // but a number that has a weird ending, we need to convert it to pixels
78
+
79
79
if ( ! / ^ - ? [ 0 - 9 ] + \. ? [ 0 - 9 ] * (?: p x ) ? $ / i. test ( val ) && / ^ - ? \d / . test ( val ) ) {
80
80
81
81
// Remember the original values
@@ -95,37 +95,37 @@ _html2canvas.Util.getCSS = function (el, attribute) {
95
95
}
96
96
97
97
}
98
-
98
+
99
99
if ( ! / ^ ( t h i n | m e d i u m | t h i c k ) $ / i. test ( val ) ) {
100
100
return Math . round ( parseFloat ( val ) ) + "px" ;
101
- }
102
-
101
+ }
102
+
103
103
return val ;
104
-
104
+
105
105
}
106
-
107
-
106
+
107
+
108
108
if ( window . getComputedStyle ) {
109
109
val = document . defaultView . getComputedStyle ( el , null ) [ attribute ] ;
110
-
110
+
111
111
if ( attribute === "backgroundPosition" ) {
112
-
112
+
113
113
val = ( val . split ( "," ) [ 0 ] || "0 0" ) . split ( " " ) ;
114
-
114
+
115
115
val [ 0 ] = ( val [ 0 ] . indexOf ( "%" ) === - 1 ) ? toPX ( attribute + "X" , val [ 0 ] ) : val [ 0 ] ;
116
116
val [ 1 ] = ( val [ 1 ] === undefined ) ? val [ 0 ] : val [ 1 ] ; // IE 9 doesn't return double digit always
117
117
val [ 1 ] = ( val [ 1 ] . indexOf ( "%" ) === - 1 ) ? toPX ( attribute + "Y" , val [ 1 ] ) : val [ 1 ] ;
118
- }
119
-
118
+ }
119
+
120
120
} else if ( el . currentStyle ) {
121
- // IE 9>
121
+ // IE 9>
122
122
if ( attribute === "backgroundPosition" ) {
123
- // Older IE uses -x and -y
124
- val = [ toPX ( attribute + "X" , el . currentStyle [ attribute + "X" ] ) , toPX ( attribute + "Y" , el . currentStyle [ attribute + "Y" ] ) ] ;
123
+ // Older IE uses -x and -y
124
+ val = [ toPX ( attribute + "X" , el . currentStyle [ attribute + "X" ] ) , toPX ( attribute + "Y" , el . currentStyle [ attribute + "Y" ] ) ] ;
125
125
} else {
126
126
127
127
val = toPX ( attribute , el . currentStyle [ attribute ] ) ;
128
-
128
+
129
129
if ( / ^ ( b o r d e r ) / i. test ( attribute ) && / ^ ( m e d i u m | t h i n | t h i c k ) $ / i. test ( val ) ) {
130
130
switch ( val ) {
131
131
case "thin" :
@@ -138,7 +138,7 @@ _html2canvas.Util.getCSS = function (el, attribute) {
138
138
val = "5px" ;
139
139
break ;
140
140
}
141
- }
141
+ }
142
142
}
143
143
144
144
@@ -147,61 +147,61 @@ _html2canvas.Util.getCSS = function (el, attribute) {
147
147
148
148
149
149
150
-
150
+
151
151
return val ;
152
-
153
152
154
-
153
+
154
+
155
155
//return $(el).css(attribute);
156
-
157
-
156
+
157
+
158
158
} ;
159
159
160
160
161
161
_html2canvas . Util . BackgroundPosition = function ( el , bounds , image ) {
162
162
// TODO add support for multi image backgrounds
163
-
163
+
164
164
var bgposition = _html2canvas . Util . getCSS ( el , "backgroundPosition" ) ,
165
165
topPos ,
166
166
left ,
167
167
percentage ,
168
168
val ;
169
-
169
+
170
170
if ( bgposition . length === 1 ) {
171
171
val = bgposition ;
172
-
172
+
173
173
bgposition = [ ] ;
174
-
174
+
175
175
bgposition [ 0 ] = val ;
176
176
bgposition [ 1 ] = val ;
177
- }
177
+ }
178
178
179
-
180
179
181
- if ( bgposition [ 0 ] . toString ( ) . indexOf ( "%" ) !== - 1 ) {
182
- percentage = ( parseFloat ( bgposition [ 0 ] ) / 100 ) ;
180
+
181
+ if ( bgposition [ 0 ] . toString ( ) . indexOf ( "%" ) !== - 1 ) {
182
+ percentage = ( parseFloat ( bgposition [ 0 ] ) / 100 ) ;
183
183
left = ( ( bounds . width * percentage ) - ( image . width * percentage ) ) ;
184
-
184
+
185
185
} else {
186
186
left = parseInt ( bgposition [ 0 ] , 10 ) ;
187
187
}
188
188
189
- if ( bgposition [ 1 ] . toString ( ) . indexOf ( "%" ) !== - 1 ) {
189
+ if ( bgposition [ 1 ] . toString ( ) . indexOf ( "%" ) !== - 1 ) {
190
190
191
- percentage = ( parseFloat ( bgposition [ 1 ] ) / 100 ) ;
191
+ percentage = ( parseFloat ( bgposition [ 1 ] ) / 100 ) ;
192
192
topPos = ( ( bounds . height * percentage ) - ( image . height * percentage ) ) ;
193
- } else {
194
- topPos = parseInt ( bgposition [ 1 ] , 10 ) ;
193
+ } else {
194
+ topPos = parseInt ( bgposition [ 1 ] , 10 ) ;
195
195
}
196
196
197
-
198
197
199
-
198
+
199
+
200
200
return {
201
201
top : topPos ,
202
202
left : left
203
203
} ;
204
-
204
+
205
205
} ;
206
206
207
207
_html2canvas . Util . Extend = function ( options , defaults ) {
@@ -219,7 +219,7 @@ _html2canvas.Util.Children = function(el) {
219
219
try {
220
220
children = $ ( el ) . contents ( ) ;
221
221
//children = (el.nodeName && el.nodeName.toUpperCase() === "IFRAME") ? el.contentDocument || el.contentWindow.document : el.childNodes ;
222
-
222
+
223
223
} catch ( ex ) {
224
224
h2clog ( "html2canvas.Util.Children failed with exception: " + ex . message ) ;
225
225
children = [ ] ;
0 commit comments