@@ -10,18 +10,19 @@ DV._.extend(DV.Schema.helpers, {
1010 var doc = this . viewer . schema . document ;
1111 var pagesHTML = this . constructPages ( ) ;
1212 var description = ( doc . description ) ? doc . description : null ;
13- var storyURL = doc . resources . related_article ;
13+ var storyURL = doc . resources . related_article ;
14+ var options = this . viewer . options ;
1415
1516 var headerHTML = JST . header ( {
16- options : this . viewer . options ,
17+ options : options ,
1718 id : doc . id ,
1819 story_url : storyURL ,
1920 title : doc . title || ''
2021 } ) ;
21- var footerHTML = JST . footer ( { options : this . viewer . options } ) ;
22+ var footerHTML = JST . footer ( { options : options } ) ;
2223
2324 var pdfURL = doc . resources . pdf ;
24- pdfURL = pdfURL && this . viewer . options . pdf !== false ? '<a target="_blank" href="' + pdfURL + '">Original Document (PDF) »</a>' : '' ;
25+ pdfURL = pdfURL && options . pdf !== false ? '<a target="_blank" href="' + pdfURL + '">Original Document (PDF) »</a>' : '' ;
2526
2627 var contribs = doc . contributor && doc . contributor_organization &&
2728 ( '' + doc . contributor + ', ' + doc . contributor_organization ) ;
@@ -30,7 +31,7 @@ DV._.extend(DV.Schema.helpers, {
3031 var printNotesURL = ( showAnnotations ) && doc . resources . print_annotations ;
3132
3233 var viewerOptions = {
33- options : this . viewer . options ,
34+ options : options ,
3435 pages : pagesHTML ,
3536 header : headerHTML ,
3637 footer : footerHTML ,
@@ -39,21 +40,41 @@ DV._.extend(DV.Schema.helpers, {
3940 story_url : storyURL ,
4041 print_notes_url : printNotesURL ,
4142 descriptionContainer : JST . descriptionContainer ( { description : description } ) ,
42- autoZoom : this . viewer . options . zoom == 'auto' ,
43+ autoZoom : options . zoom == 'auto' ,
4344 mini : false
4445 } ;
4546
46- var width = this . viewer . options . width ;
47- var height = this . viewer . options . height ;
48- if ( width && height ) {
47+ if ( options . responsive ) {
48+ if ( ! options . height ) {
49+ var winHeight = DV . jQuery ( window ) . height ( ) ;
50+ var toSubtract = options . responsiveOffset == null ? 100 : options . responsiveOffset ;
51+ options . height = winHeight - toSubtract ;
52+ }
53+ }
54+
55+ var width = options . width ;
56+ var height = options . height ;
57+ if ( width && height && ! options . responsive ) {
4958 if ( width < 500 ) {
50- this . viewer . options . mini = true ;
59+ options . mini = true ;
5160 viewerOptions . mini = true ;
5261 }
53- DV . jQuery ( this . viewer . options . container ) . css ( {
62+ DV . jQuery ( options . container ) . css ( {
63+ position : 'relative' ,
64+ width : options . width ,
65+ height : options . height
66+ } ) ;
67+ }
68+
69+ if ( options . responsive ) {
70+ DV . jQuery ( options . container ) . css ( {
5471 position : 'relative' ,
55- width : this . viewer . options . width ,
56- height : this . viewer . options . height
72+ height : options . height
73+ } ) ;
74+
75+ var viewer = this . viewer ;
76+ DV . jQuery ( window ) . resize ( function ( ) {
77+ viewer . helpers . responsiveRedraw ( ) ;
5778 } ) ;
5879 }
5980
@@ -174,21 +195,22 @@ DV._.extend(DV.Schema.helpers, {
174195 // Hide the overflow of the body, unless we're positioned.
175196 var containerEl = DV . jQuery ( this . viewer . options . container ) ;
176197 var position = containerEl . css ( 'position' ) ;
177- if ( position != 'relative' && position != 'absolute' && ! this . viewer . options . fixedSize ) {
198+ if ( position != 'relative' && position != 'absolute' && ! this . viewer . options . fixedSize && ! this . viewer . options . responsive ) {
178199 DV . jQuery ( "html, body" ) . css ( { overflow : 'hidden' } ) ;
179200 // Hide the border, if we're a full-screen viewer in the body tag.
180201 if ( containerEl . offset ( ) . top == 0 ) {
181202 this . viewer . elements . viewer . css ( { border : 0 } ) ;
182203 }
183204 }
205+ this . viewer . helpers . _prevWidth = this . viewer . elements . viewer . width ( ) ;
184206
185207 // Hide and show navigation flags:
186208 var showAnnotations = this . showAnnotations ( ) ;
187209 var showPages = this . models . document . totalPages > 1 ;
188210 var showSearch = ( this . viewer . options . search !== false ) &&
189211 ( this . viewer . options . text !== false ) &&
190212 ( ! this . viewer . options . width || this . viewer . options . width >= 540 ) ;
191- var noFooter = ( ! showAnnotations && ! showPages && ! showSearch && ! this . viewer . options . sidebar ) ;
213+ var noFooter = ( ! showAnnotations && ! showPages && ! showSearch && ! this . viewer . options . sidebarVisible ) ;
192214
193215
194216 // Hide annotations, if there are none:
@@ -224,7 +246,7 @@ DV._.extend(DV.Schema.helpers, {
224246 // Remove and re-render the nav controls.
225247 // Don't show the nav controls if there's no sidebar, and it's a one-page doc.
226248 this . viewer . $ ( '.DV-navControls' ) . remove ( ) ;
227- if ( showPages || this . viewer . options . sidebar ) {
249+ if ( showPages || this . viewer . options . sidebarVisible ) {
228250 var navControls = JST . navControls ( {
229251 totalPages : this . viewer . schema . data . totalPages ,
230252 totalAnnotations : this . viewer . schema . data . totalAnnotations
@@ -243,9 +265,7 @@ DV._.extend(DV.Schema.helpers, {
243265 }
244266 }
245267
246- if ( this . viewer . options . sidebar ) {
247- this . viewer . $ ( '.DV-sidebar' ) . show ( ) ;
248- }
268+ this . viewer . elements . viewer . toggleClass ( 'DV-hideSidebar' , ! this . viewer . options . sidebarVisible ) ;
249269
250270 // Check if the zoom is showing, and if not, shorten the width of search
251271 DV . _ . defer ( DV . _ . bind ( function ( ) {
0 commit comments