Skip to content

Commit 1059314

Browse files
committed
Added a sublime-project file for Sublime Text 2 that contains the detected linting and standards set. Allows Sublime Text 2 to automatically follow the standards and have live linting enabled. Trimmed useless whitespace.
1 parent 16022b8 commit 1059314

File tree

11 files changed

+728
-670
lines changed

11 files changed

+728
-670
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ image.jpg
1010
/.project
1111
/.settings/
1212
.envrc
13+
*.sublime-workspace

html2canvas.sublime-project

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": ".",
6+
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"],
7+
"file_exclude_patterns": ["*.sublime-workspace"]
8+
}
9+
],
10+
"settings":
11+
{
12+
// The number of spaces a tab is considered equal to
13+
"tab_size": 4,
14+
15+
// Set to true to insert spaces when tab is pressed
16+
"translate_tabs_to_spaces": true,
17+
18+
// If translate_tabs_to_spaces is true, use_tab_stops will make tab and
19+
// backspace insert/delete up to the next tabstop
20+
"use_tab_stops": false,
21+
22+
// Set to false to disable detection of tabs vs. spaces on load
23+
"detect_indentation": false,
24+
25+
// Set to true to removing trailing white space on save
26+
"trim_trailing_white_space_on_save": true,
27+
28+
// Set to true to ensure the last line of the file ends in a newline
29+
// character when saving
30+
"ensure_newline_at_eof_on_save": false,
31+
32+
// Linting
33+
"jshint_options": {
34+
"eqeqeq": false,
35+
36+
"laxbreak": true,
37+
"undef": true,
38+
"newcap": true,
39+
"noarg": true,
40+
"strict": false,
41+
"trailing": true,
42+
"onecase": true,
43+
44+
"boss": true,
45+
"eqnull": true,
46+
47+
"onevar": false,
48+
49+
"evil": true,
50+
"regexdash": true,
51+
"browser": true,
52+
"wsh": true,
53+
"trailing": true,
54+
"sub": true
55+
}
56+
}
57+
}

src/Core.js

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,62 +20,62 @@ function h2clog(a) {
2020
_html2canvas.Util = {};
2121

2222
_html2canvas.Util.backgroundImage = function (src) {
23-
23+
2424
if (/data:image\/.*;base64,/i.test( src ) || /^(-webkit|-moz|linear-gradient|-o-)/.test( src )) {
2525
return src;
2626
}
27-
27+
2828
if (src.toLowerCase().substr( 0, 5 ) === 'url(http://github.com/"'%3C/span%3E%3Cspan%20class=pl-kos%3E) {
2929
src = src.substr( 5 );
30-
src = src.substr( 0, src.length - 2 );
30+
src = src.substr( 0, src.length - 2 );
3131
} else {
3232
src = src.substr( 4 );
33-
src = src.substr( 0, src.length - 1 );
33+
src = src.substr( 0, src.length - 1 );
3434
}
3535

36-
return src;
36+
return src;
3737
};
3838

3939
_html2canvas.Util.Bounds = function getBounds (el) {
4040
var clientRect,
4141
bounds = {};
42-
43-
if (el.getBoundingClientRect){
42+
43+
if (el.getBoundingClientRect){
4444
clientRect = el.getBoundingClientRect();
4545

46-
46+
4747
// TODO add scroll position to bounds, so no scrolling of window necessary
4848
bounds.top = clientRect.top;
4949
bounds.bottom = clientRect.bottom || (clientRect.top + clientRect.height);
5050
bounds.left = clientRect.left;
51-
51+
5252
// older IE doesn't have width/height, but top/bottom instead
5353
bounds.width = clientRect.width || (clientRect.right - clientRect.left);
5454
bounds.height = clientRect.height || (clientRect.bottom - clientRect.top);
55-
55+
5656
return bounds;
57-
58-
}
57+
58+
}
5959
};
6060

6161
_html2canvas.Util.getCSS = function (el, attribute) {
6262
// return $(el).css(attribute);
63-
63+
6464
var val;
65-
65+
6666
function toPX( attribute, val ) {
6767
var rsLeft = el.runtimeStyle && el.runtimeStyle[ attribute ],
6868
left,
6969
style = el.style;
70-
70+
7171
// Check if we are not dealing with pixels, (Opera has issues with this)
7272
// Ported from jQuery css.js
7373
// From the awesome hack by Dean Edwards
7474
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
7575

7676
// 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+
7979
if ( !/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test( val ) && /^-?\d/.test( val ) ) {
8080

8181
// Remember the original values
@@ -95,37 +95,37 @@ _html2canvas.Util.getCSS = function (el, attribute) {
9595
}
9696

9797
}
98-
98+
9999
if (!/^(thin|medium|thick)$/i.test( val )) {
100100
return Math.round(parseFloat( val )) + "px";
101-
}
102-
101+
}
102+
103103
return val;
104-
104+
105105
}
106-
107-
106+
107+
108108
if ( window.getComputedStyle ) {
109109
val = document.defaultView.getComputedStyle(el, null)[ attribute ];
110-
110+
111111
if ( attribute === "backgroundPosition" ) {
112-
112+
113113
val = (val.split(",")[0] || "0 0").split(" ");
114-
114+
115115
val[ 0 ] = ( val[0].indexOf( "%" ) === -1 ) ? toPX( attribute + "X", val[ 0 ] ) : val[ 0 ];
116116
val[ 1 ] = ( val[1] === undefined ) ? val[0] : val[1]; // IE 9 doesn't return double digit always
117117
val[ 1 ] = ( val[1].indexOf( "%" ) === -1 ) ? toPX( attribute + "Y", val[ 1 ] ) : val[ 1 ];
118-
}
119-
118+
}
119+
120120
} else if ( el.currentStyle ) {
121-
// IE 9>
121+
// IE 9>
122122
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" ] ) ];
125125
} else {
126126

127127
val = toPX( attribute, el.currentStyle[ attribute ] );
128-
128+
129129
if (/^(border)/i.test( attribute ) && /^(medium|thin|thick)$/i.test( val )) {
130130
switch (val) {
131131
case "thin":
@@ -138,7 +138,7 @@ _html2canvas.Util.getCSS = function (el, attribute) {
138138
val = "5px";
139139
break;
140140
}
141-
}
141+
}
142142
}
143143

144144

@@ -147,61 +147,61 @@ _html2canvas.Util.getCSS = function (el, attribute) {
147147

148148

149149

150-
150+
151151
return val;
152-
153152

154-
153+
154+
155155
//return $(el).css(attribute);
156-
157-
156+
157+
158158
};
159159

160160

161161
_html2canvas.Util.BackgroundPosition = function ( el, bounds, image ) {
162162
// TODO add support for multi image backgrounds
163-
163+
164164
var bgposition = _html2canvas.Util.getCSS( el, "backgroundPosition" ) ,
165165
topPos,
166166
left,
167167
percentage,
168168
val;
169-
169+
170170
if (bgposition.length === 1){
171171
val = bgposition;
172-
172+
173173
bgposition = [];
174-
174+
175175
bgposition[0] = val;
176176
bgposition[1] = val;
177-
}
177+
}
178178

179-
180179

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);
183183
left = ((bounds.width * percentage)-(image.width*percentage));
184-
184+
185185
}else{
186186
left = parseInt(bgposition[0],10);
187187
}
188188

189-
if (bgposition[1].toString().indexOf("%") !== -1){
189+
if (bgposition[1].toString().indexOf("%") !== -1){
190190

191-
percentage = (parseFloat(bgposition[1])/100);
191+
percentage = (parseFloat(bgposition[1])/100);
192192
topPos = ((bounds.height * percentage)-(image.height*percentage));
193-
}else{
194-
topPos = parseInt(bgposition[1],10);
193+
}else{
194+
topPos = parseInt(bgposition[1],10);
195195
}
196196

197-
198197

199-
198+
199+
200200
return {
201201
top: topPos,
202202
left: left
203203
};
204-
204+
205205
};
206206

207207
_html2canvas.Util.Extend = function (options, defaults) {
@@ -219,7 +219,7 @@ _html2canvas.Util.Children = function(el) {
219219
try {
220220
children = $(el).contents();
221221
//children = (el.nodeName && el.nodeName.toUpperCase() === "IFRAME") ? el.contentDocument || el.contentWindow.document : el.childNodes ;
222-
222+
223223
} catch (ex) {
224224
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
225225
children = [];

0 commit comments

Comments
 (0)