@@ -138,16 +138,43 @@ export class Navbar {
138138 * Switch navbar controls on mobile and desktop
139139 */
140140 switchNavbarControls ( ) {
141- // we don't want navbar controls switching with liner-notes
142- if ( this . br . options . bookType !== 'linerNotes' ) {
143- if ( this . br . refs . $brContainer . prop ( 'clientWidth' ) < 640 ) {
141+ if ( this . br . refs . $brContainer . prop ( 'clientWidth' ) < 640 ) {
142+ this . showMinimumNavPageNum ( ) ;
143+ // we don't want navbar controls switching with liner-notes
144+ if ( this . br . options . bookType !== 'linerNotes' ) {
144145 this . showMinimumNavbarControls ( ) ;
145- } else {
146+ }
147+ } else {
148+ this . showMaximumNavPageNum ( ) ;
149+ // we don't want navbar controls switching with liner-notes
150+ if ( this . br . options . bookType !== 'linerNotes' ) {
146151 this . showMaximumNavbarControls ( ) ;
147152 }
148153 }
149154 }
150155
156+ /**
157+ * Switch Book Nav page number display to minimum/mobile
158+ */
159+ showMinimumNavPageNum ( ) {
160+ const minElement = document . querySelector ( '.BRcurrentpage.BRmin' ) ;
161+ const maxElement = document . querySelector ( '.BRcurrentpage.BRmax' ) ;
162+
163+ if ( minElement ) minElement . classList . remove ( 'hide' ) ;
164+ if ( maxElement ) maxElement . classList . add ( 'hide' ) ;
165+ }
166+
167+ /**
168+ * Switch Book Nav page number display to maximum/desktop
169+ */
170+ showMaximumNavPageNum ( ) {
171+ const minElement = document . querySelector ( '.BRcurrentpage.BRmin' ) ;
172+ const maxElement = document . querySelector ( '.BRcurrentpage.BRmax' ) ;
173+
174+ if ( minElement ) minElement . classList . add ( 'hide' ) ;
175+ if ( maxElement ) maxElement . classList . remove ( 'hide' ) ;
176+ }
177+
151178 /**
152179 * Switch Book Navbar controls to minimised
153180 * NOTE: only `this.minimumControls` and `this.maximumControls` switch on resize
@@ -203,7 +230,10 @@ export class Navbar {
203230 <div class="BRpager"></div>
204231 <div class="BRnavline"></div>
205232 </div>
206- <p><span class='BRcurrentpage'></span></p>
233+ <p>
234+ <span class="BRcurrentpage BRmax"></span>
235+ <span class="BRcurrentpage BRmin"></span>
236+ </p>
207237 </li>
208238 ${ this . _renderControls ( ) }
209239 </ul>
@@ -246,9 +276,10 @@ export class Navbar {
246276 /**
247277 * Returns the textual representation of the current page for the navbar
248278 * @param {number } index
279+ * @param {boolean } [useMaxFormat = false]
249280 * @return {string }
250281 */
251- getNavPageNumString ( index ) {
282+ getNavPageNumString ( index , useMaxFormat = false ) {
252283 const { br } = this ;
253284 // Accessible index starts at 0 (alas) so we add 1 to make human
254285 const pageNum = br . book . getPageNum ( index ) ;
@@ -268,15 +299,17 @@ export class Navbar {
268299 this . maxPageNum = maxPageNum ;
269300 }
270301
271- return getNavPageNumHtml ( index , numLeafs , pageNum , pageType , this . maxPageNum ) ;
302+ return getNavPageNumHtml ( index , numLeafs , pageNum , pageType , this . maxPageNum , useMaxFormat ) ;
303+
272304 }
273305
274306 /**
275307 * Renders the navbar string to the DOM
276308 * @param {number } index
277309 */
278310 updateNavPageNum ( index ) {
279- this . $root . find ( '.BRcurrentpage' ) . html ( this . getNavPageNumString ( index ) ) ;
311+ this . $root . find ( '.BRcurrentpage.BRmax' ) . html ( this . getNavPageNumString ( index , true ) ) ;
312+ this . $root . find ( '.BRcurrentpage.BRmin' ) . html ( this . getNavPageNumString ( index ) ) ;
280313 }
281314
282315 /**
@@ -298,14 +331,23 @@ export class Navbar {
298331 * @param {number|string } pageNum
299332 * @param {* } pageType - Deprecated
300333 * @param {number } maxPageNum
334+ * @param {boolean } [useMaxFormat = false]
301335 * @return {string }
302336 */
303- export function getNavPageNumHtml ( index , numLeafs , pageNum , pageType , maxPageNum ) {
337+ export function getNavPageNumHtml ( index , numLeafs , pageNum , pageType , maxPageNum , useMaxFormat = false ) {
304338 const pageIsAsserted = pageNum [ 0 ] != 'n' ;
339+ const pageIndex = index + 1 ;
340+
341+ if ( ! pageIsAsserted ) {
342+ pageNum = '—' ;
343+ }
344+
345+ if ( useMaxFormat === true ) {
346+ return `Page ${ pageNum } (${ pageIndex } /${ numLeafs } )` ;
347+ }
305348
306349 if ( ! pageIsAsserted ) {
307- const pageIndex = index + 1 ;
308- return `(${ pageIndex } of ${ numLeafs } )` ; // Page (8 of 10)
350+ return `(${ pageIndex } of ${ numLeafs } )` ;
309351 }
310352
311353 const bookLengthLabel = ( maxPageNum && parseFloat ( pageNum ) ) ? ` of ${ maxPageNum } ` : '' ;
0 commit comments