Skip to content

Commit 7395ad1

Browse files
author
Daniel Dotsenko
committed
'return this' is clearer than poking into upper closure and returning var
1 parent 41ee830 commit 7395ad1

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

jspdf.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
365365
*/
366366
addPage: function() {
367367
_addPage()
368-
return _jsPDF
368+
return this
369369
},
370370
/**
371371
* Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
@@ -420,14 +420,14 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
420420
str +
421421
') Tj\nET'
422422
)
423-
return _jsPDF
423+
return this
424424
},
425425
line: function(x1, y1, x2, y2) {
426426
out(
427427
f2(x1 * k) + ' ' + f2((pageHeight - y1) * k) + ' m ' +
428428
f2(x2 * k) + ' ' + f2((pageHeight - y2) * k) + ' l S'
429429
)
430-
return _jsPDF
430+
return this
431431
},
432432
/**
433433
* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
@@ -492,7 +492,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
492492
}
493493
// stroking / filling / both the path
494494
out(style)
495-
return _jsPDF
495+
return this
496496
},
497497
rect: function(x, y, w, h, style) {
498498
var op = getStyle(style)
@@ -504,7 +504,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
504504
, 're'
505505
, op
506506
].join(' '))
507-
return _jsPDF
507+
return this
508508
},
509509
triangle: function(x1, y1, x2, y2, x3, y3, style) {
510510
this.lines(
@@ -517,7 +517,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
517517
, [1,1]
518518
, style
519519
)
520-
return _jsPDF;
520+
return this;
521521
},
522522
ellipse: function(x, y, rx, ry, style) {
523523
var op = getStyle(style)
@@ -564,35 +564,35 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
564564
,'c'
565565
, op
566566
].join(' '))
567-
return _jsPDF
567+
return this
568568
},
569569
circle: function(x, y, r, style) {
570570
return this.ellipse(x, y, r, r, style)
571571
},
572572
setProperties: function(properties) {
573573
documentProperties = properties
574-
return _jsPDF
574+
return this
575575
},
576576
addImage: function(imageData, format, x, y, w, h) {
577-
return _jsPDF
577+
return this
578578
},
579579
setFontSize: function(size) {
580580
fontSize = size
581-
return _jsPDF
581+
return this
582582
},
583583
setFont: function(name) {
584584
var _name = name.toLowerCase()
585585
activeFontKey = getFont(_name, fontType)
586586
// if font is not found, the above line blows up and we never go further
587587
fontName = _name
588-
return _jsPDF
588+
return this
589589
},
590590
setFontType: function(type) {
591591
var _type = type.toLowerCase()
592592
activeFontKey = getFont(fontName, _type)
593593
// if font is not found, the above line blows up and we never go further
594594
fontType = _type
595-
return _jsPDF
595+
return this
596596
},
597597
getFontList: function(){
598598
// TODO: iterate over fonts array or return copy of fontmap instead in case more are ever added.
@@ -604,7 +604,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
604604
},
605605
setLineWidth: function(width) {
606606
out((width * k).toFixed(2) + ' w')
607-
return _jsPDF
607+
return this
608608
},
609609
setDrawColor: function(r,g,b) {
610610
var color
@@ -614,7 +614,7 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
614614
color = [f3(r/255), f3(g/255), f3(b/255), 'RG'].join(' ')
615615
}
616616
out(color)
617-
return _jsPDF
617+
return this
618618
},
619619
setFillColor: function(r,g,b) {
620620
var color
@@ -624,15 +624,15 @@ var jsPDF = function(/** String */ orientation, /** String */ unit, /** String *
624624
color = [f3(r/255), f3(g/255), f3(b/255), 'rg'].join(' ')
625625
}
626626
out(color)
627-
return _jsPDF
627+
return this
628628
},
629629
setTextColor: function(r,g,b) {
630630
if ((r===0 && g===0 && b===0) || (typeof g === 'undefined')) {
631631
textColor = f3(r/255) + ' g'
632632
} else {
633633
textColor = [f3(r/255), f3(g/255), f3(b/255), 'rg'].join(' ')
634634
}
635-
return _jsPDF
635+
return this
636636
},
637637
CapJoinStyles: {
638638
0:0, 'butt':0, 'but':0, 'bevel':0

0 commit comments

Comments
 (0)