@@ -472,8 +472,14 @@ L.wait = () => {
472472} ;
473473
474474
475+ L . openNewWindow = ( Href ) => {
476+ const WO = window . open ( Href ) ;
477+ return WO ? WO : location . href = Href ;
478+ } ;
479+
480+
475481L . play = ( ) => {
476- if ( S [ 'start-in-new-window' ] ) return window . open ( location . href ) ;
482+ if ( S [ 'start-in-new-window' ] ) return L . openNewWindow ( location . href ) ;
477483 L . Played = true ;
478484 R . resetStage ( ) ;
479485 L . wait . resolve ( ) ;
@@ -944,7 +950,7 @@ L.coordinateLinkages = (BasePath, RootElement, InNav) => {
944950 if ( A . Destination ) new Promise ( resolve => A . InNav ? I . Panel . toggle ( ) . then ( resolve ) : resolve ( ) ) . then ( ( ) => {
945951 if ( L . Opened ) return R . focusOn ( { Destination : A . Destination , Duration : 0 } ) . then ( Destination => I . History . add ( { UI : B , SumUp : false , Destination : Destination } ) ) ;
946952 if ( ! L . Waiting ) return false ;
947- if ( S [ 'start-in-new-window' ] ) return window . open ( location . href + ( location . hash ? ',' : '#' ) + 'jo(nav:' + A . NavANumber + ')' ) ;
953+ if ( S [ 'start-in-new-window' ] ) return L . openNewWindow ( location . href + ( location . hash ? ',' : '#' ) + 'jo(nav:' + A . NavANumber + ')' ) ;
948954 S [ 'to' ] = A . Destination ;
949955 L . play ( ) ;
950956 } ) ;
@@ -1005,31 +1011,37 @@ L.loadItem = (Item, Opt = {}) => { // !!!! Don't Call Directly. Use L.loadSpread
10051011 }
10061012 ItemBox . classList . remove ( 'loaded' ) ;
10071013 return new Promise ( ( resolve , reject ) => {
1008- if ( Item . BlobURL ) return resolve ( { } ) ;
1014+ if ( Item . BlobURL ) { resolve ( { } ) ; return ; }
10091015 if ( / \. ( h t m l ? | x h t ( m l ) ? | x m l ) $ / i. test ( Item . Path ) ) { // (X)HTML
1010- if ( ! B . ExtractionPolicy ) return resolve ( { // Extracted
1011- URL : O . fullPath ( Item . Path )
1012- } ) ;
1013- return O . file ( Item , { Preprocess : true } ) . then ( Item => resolve ( { // Archived
1014- HTML : Item . Content . replace ( / ^ < \? .+ ?\? > / , '' )
1015- } ) ) . catch ( reject ) ;
1016+ if ( ! B . ExtractionPolicy /*!!!!!!!!*/ && ! sML . UA . Gecko /*!!!!!!!!*/ ) { // Extracted (exclude Gecko from here, because of such books as styled only with -webkit/epub- prefixed properties. It's NOT Gecko's fault.)
1017+ resolve ( {
1018+ URL : O . fullPath ( Item . Path )
1019+ } ) ; return ;
1020+ }
1021+ O . file ( Item , { Preprocess : true } ) . then ( Item => { // Archived (or Gecko. It's NOT Gecko's fault...)
1022+ resolve ( {
1023+ HTML : Item . Content . replace ( / ^ < \? .+ ?\? > / , '' )
1024+ } )
1025+ } ) . catch ( reject ) ; return ;
10161026 }
10171027 if ( / \. ( g i f | j p e ? g | p n g ) $ / i. test ( Item . Path ) ) { // Bitmap-in-Spine
1018- return O . file ( Item , { URI : true } ) . then ( Item => resolve ( {
1019- Head : ( Item . Ref [ 'rendition:layout' ] == 'pre-paginated' && B . ICBViewport ) ? `<meta name="viewport" content="width=${ B . ICBViewport . Width } , height=${ B . ICBViewport . Height } " />` : '' ,
1020- Body : `<img class="bibi-spine-item-image" alt="" src="${ Item . URI } " />` // URI is BlobURL or URI
1021- } ) ) . catch ( reject )
1028+ O . file ( Item , { URI : true } ) . then ( Item => {
1029+ resolve ( {
1030+ Head : ( Item . Ref [ 'rendition:layout' ] == 'pre-paginated' && B . ICBViewport ) ? `<meta name="viewport" content="width=${ B . ICBViewport . Width } , height=${ B . ICBViewport . Height } " />` : '' ,
1031+ Body : `<img class="bibi-spine-item-image" alt="" src="${ Item . URI } " />` // URI is BlobURL or URI
1032+ } )
1033+ } ) . catch ( reject ) ; return ;
10221034 }
10231035 if ( / \. ( s v g ) $ / i. test ( Item . Path ) ) { // SVG-in-Spine
1024- return O . file ( Item , { Preprocess : true } ) . then ( Item => {
1036+ O . file ( Item , { Preprocess : true } ) . then ( Item => {
10251037 const StyleSheetRE = / < \? x m l - s t y l e s h e e t \s * ( .+ ?) \s * \? > / g, MatchedStyleSheets = Item . Content . match ( StyleSheetRE ) ;
10261038 let StyleSheets = '' , Content = Item . Content ;
10271039 if ( MatchedStyleSheets ) StyleSheets = MatchedStyleSheets . map ( SS => SS . replace ( StyleSheetRE , `<link rel="stylesheet" $1 />` ) ) . join ( '' ) , Content = Content . replace ( StyleSheetRE , '' ) ;
10281040 resolve ( {
10291041 Head : ( ! B . ExtractionPolicy ? `<base href="${ O . fullPath ( Item . Path ) } " />` : '' ) + StyleSheets ,
10301042 Body : Content
10311043 } ) ;
1032- } ) . catch ( reject )
1044+ } ) . catch ( reject ) ; return ;
10331045 }
10341046 resolve ( { } ) ;
10351047 } ) . then ( Source => new Promise ( resolve => {
@@ -1432,9 +1444,9 @@ R.renderReflowableItem = (Item) => {
14321444 let PaginateWith = '' ;
14331445 if ( ! Item . Outsourcing ) {
14341446 if ( O . PaginateWithCSSShapes ) {
1435- if ( S . RVM == 'paged' && Item . HTML [ 'offset' + C . L_SIZE_L ] > PageCL ) PaginateWith = 'S' ; // VM:Paged WM:Vertical LA:Horizontal
1436- else if ( Item . HTML [ 'offset' + C . L_SIZE_B ] > PageCB ) PaginateWith = 'C' ; // VM:Paged/Horizontal WM:Horizontal LA:Horizontal / VM:Vertical WM:Vertical LA:Vertical
1437- } else if ( S . RVM == 'paged' || Item . HTML [ 'offset' + C . L_SIZE_B ] > PageCB ) PaginateWith = 'C' ; // VM:Paged/Horizontal WM:Horizontal LA:Horizontal / VM:Paged/Vertical WM:Vertical LA:Vertical
1447+ if ( S . RVM == 'paged' && Item . HTML [ 'offset' + C . L_SIZE_L ] > PageCL ) PaginateWith = 'S' ; // VM:Paged WM:Vertical LA:Horizontal
1448+ else if ( Item . HTML [ 'offset' + C . L_SIZE_B ] > PageCB ) PaginateWith = 'C' ; // VM:Paged/Horizontal WM:Horizontal LA:Horizontal // VM: Vertical WM:Vertical LA:Vertical
1449+ } else if ( S . RVM == 'paged' || Item . HTML [ 'offset' + C . L_SIZE_B ] > PageCB ) PaginateWith = 'C' ; // VM:Paged/Horizontal WM:Horizontal LA:Horizontal // VM:Paged/Vertical WM:Vertical LA:Vertical
14381450 }
14391451 switch ( PaginateWith ) {
14401452 case 'S' :
@@ -3593,7 +3605,7 @@ I.BookmarkManager = { create: () => { if(!S['use-bookmarks']) return;
35933605 action : ( ) => {
35943606 if ( L . Opened ) return R . focusOn ( { Destination : Bmk } ) . then ( Destination => I . History . add ( { UI : BookmarkManager , SumUp : false /*true*/ , Destination : Destination } ) ) ;
35953607 if ( ! L . Waiting ) return false ;
3596- if ( S [ 'start-in-new-window' ] ) return window . open ( location . href + ( location . hash ? ',' : '#' ) + 'jo(si-ppis:' + Bmk [ 'SI-PPiS' ] + ')' ) ;
3608+ if ( S [ 'start-in-new-window' ] ) return L . openNewWindow ( location . href + ( location . hash ? ',' : '#' ) + 'jo(si-ppis:' + Bmk [ 'SI-PPiS' ] + ')' ) ;
35973609 S [ 'to' ] = { 'SI-PPiS' : Bmk [ 'SI-PPiS' ] } ;
35983610 L . play ( ) ;
35993611 } ,
0 commit comments