@@ -144,26 +144,24 @@ function getContent (page) {
144
144
// Creates page section
145
145
// --------------------
146
146
function createSection ( section , content , options ) {
147
- var opts = options
148
147
options = options [ section ] || { }
149
148
var c = content [ section ] || { }
150
149
var o = options . contents
150
+ var _paginationOffset = Math . floor ( options . paginationOffset )
151
+ var paginationOffset = isNaN ( options . paginationOffset ) ? 0 : _paginationOffset
152
+
151
153
if ( typeof o !== 'object' ) o = { default : o }
152
154
153
155
return {
154
156
height : options . height ,
155
157
contents : phantom . callback ( function ( pageNum , numPages ) {
156
158
var html = o [ pageNum ] || c [ pageNum ]
157
159
158
- var pageNumFinal = pageNum , numPagesFinal = numPages ;
159
- if ( opts . paginationStartPage && opts . paginationStartPage > 1 ) {
160
- var pageOffset = opts . paginationStartPage - 1 ;
161
- pageNumFinal = ( pageNumFinal - pageOffset > 0 ? pageNumFinal - pageOffset : '' ) ;
162
- numPagesFinal -= pageOffset ;
163
- }
160
+ var pageNumFinal = pageNum + paginationOffset
161
+ var numPagesFinal = numPages + paginationOffset
164
162
165
- if ( pageNum === 1 && ! html ) html = o . first || c . first
166
- if ( pageNum === numPages && ! html ) html = o . last || c . last
163
+ if ( pageNumFinal === 1 && ! html ) html = o . first || c . first
164
+ if ( numPagesFinal === numPages && ! html ) html = o . last || c . last
167
165
return ( html || o . default || c . default || '' )
168
166
. replace ( / { { page} } / g, pageNumFinal )
169
167
. replace ( / { { pages} } / g, numPagesFinal ) + content . styles
0 commit comments