From f6ba3d89cbcf3bc722b132b6ca98bfd40acf6e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Satoru=20MATSUSHIMA=20=28=E2=84=A0=29?= Date: Wed, 8 Jan 2020 21:47:04 +0900 Subject: [PATCH] Enhance compatibility. --- __src/bibi/and/jo.js | 1 + __src/bibi/resources/scripts/bibi.heart.js | 50 ++++++++++++-------- __src/bibi/resources/scripts/bibi.js | 19 +++++++- __src/bibi/resources/styles/_#globals.scss | 2 +- __src/bibi/wardrobe/_dress-codes/_stage.scss | 2 +- __src__back-compat/bib/i.js | 2 +- bibi.info.js | 12 +++-- package.json | 2 +- 8 files changed, 61 insertions(+), 29 deletions(-) diff --git a/__src/bibi/and/jo.js b/__src/bibi/and/jo.js index 10620d95..7267ba72 100644 --- a/__src/bibi/and/jo.js +++ b/__src/bibi/and/jo.js @@ -1,6 +1,7 @@ (() => { 'use strict'; if(window['bibi:jo']) return; + if(!Array.prototype.includes) Array.prototype.includes = function(I) { for(let l = this.length, i = 0; i < l; i++) if(this[i] == I) return true; return false; }; const Jo = window['bibi:jo'] = { 'version': '____Bibi-Version____', CSS: require('./jo.scss'), Status: '', diff --git a/__src/bibi/resources/scripts/bibi.heart.js b/__src/bibi/resources/scripts/bibi.heart.js index 5b52391f..09de1eca 100644 --- a/__src/bibi/resources/scripts/bibi.heart.js +++ b/__src/bibi/resources/scripts/bibi.heart.js @@ -472,8 +472,14 @@ L.wait = () => { }; +L.openNewWindow = (Href) => { + const WO = window.open(Href); + return WO ? WO : location.href = Href; +}; + + L.play = () => { - if(S['start-in-new-window']) return window.open(location.href); + if(S['start-in-new-window']) return L.openNewWindow(location.href); L.Played = true; R.resetStage(); L.wait.resolve(); @@ -944,7 +950,7 @@ L.coordinateLinkages = (BasePath, RootElement, InNav) => { if(A.Destination) new Promise(resolve => A.InNav ? I.Panel.toggle().then(resolve) : resolve()).then(() => { if(L.Opened) return R.focusOn({ Destination: A.Destination, Duration: 0 }).then(Destination => I.History.add({ UI: B, SumUp: false, Destination: Destination })); if(!L.Waiting) return false; - if(S['start-in-new-window']) return window.open(location.href + (location.hash ? ',' : '#') + 'jo(nav:' + A.NavANumber + ')'); + if(S['start-in-new-window']) return L.openNewWindow(location.href + (location.hash ? ',' : '#') + 'jo(nav:' + A.NavANumber + ')'); S['to'] = A.Destination; L.play(); }); @@ -1005,23 +1011,29 @@ L.loadItem = (Item, Opt = {}) => { // !!!! Don't Call Directly. Use L.loadSpread } ItemBox.classList.remove('loaded'); return new Promise((resolve, reject) => { - if(Item.BlobURL) return resolve({}); + if(Item.BlobURL) { resolve({}); return; } if(/\.(html?|xht(ml)?|xml)$/i.test(Item.Path)) { // (X)HTML - if(!B.ExtractionPolicy) return resolve({ // Extracted - URL: O.fullPath(Item.Path) - }); - return O.file(Item, { Preprocess: true }).then(Item => resolve({ // Archived - HTML: Item.Content.replace(/^<\?.+?\?>/, '') - })).catch(reject); + 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.) + resolve({ + URL: O.fullPath(Item.Path) + }); return; + } + O.file(Item, { Preprocess: true }).then(Item => { // Archived (or Gecko. It's NOT Gecko's fault...) + resolve({ + HTML: Item.Content.replace(/^<\?.+?\?>/, '') + }) + }).catch(reject); return; } if(/\.(gif|jpe?g|png)$/i.test(Item.Path)) { // Bitmap-in-Spine - return O.file(Item, { URI: true }).then(Item => resolve({ - Head: (Item.Ref['rendition:layout'] == 'pre-paginated' && B.ICBViewport) ? `` : '', - Body: `` // URI is BlobURL or URI - })).catch(reject) + O.file(Item, { URI: true }).then(Item => { + resolve({ + Head: (Item.Ref['rendition:layout'] == 'pre-paginated' && B.ICBViewport) ? `` : '', + Body: `` // URI is BlobURL or URI + }) + }).catch(reject); return; } if(/\.(svg)$/i.test(Item.Path)) { // SVG-in-Spine - return O.file(Item, { Preprocess: true }).then(Item => { + O.file(Item, { Preprocess: true }).then(Item => { const StyleSheetRE = /<\?xml-stylesheet\s*(.+?)\s*\?>/g, MatchedStyleSheets = Item.Content.match(StyleSheetRE); let StyleSheets = '', Content = Item.Content; if(MatchedStyleSheets) StyleSheets = MatchedStyleSheets.map(SS => SS.replace(StyleSheetRE, ``)).join(''), Content = Content.replace(StyleSheetRE, ''); @@ -1029,7 +1041,7 @@ L.loadItem = (Item, Opt = {}) => { // !!!! Don't Call Directly. Use L.loadSpread Head: (!B.ExtractionPolicy ? `` : '') + StyleSheets, Body: Content }); - }).catch(reject) + }).catch(reject); return; } resolve({}); }).then(Source => new Promise(resolve => { @@ -1432,9 +1444,9 @@ R.renderReflowableItem = (Item) => { let PaginateWith = ''; if(!Item.Outsourcing) { if(O.PaginateWithCSSShapes) { - if(S.RVM == 'paged' && Item.HTML['offset'+ C.L_SIZE_L] > PageCL) PaginateWith = 'S'; // VM:Paged WM:Vertical LA:Horizontal - 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 - } 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 + if(S.RVM == 'paged' && Item.HTML['offset'+ C.L_SIZE_L] > PageCL) PaginateWith = 'S'; // VM:Paged WM:Vertical LA:Horizontal + 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 + } 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 } switch(PaginateWith) { case 'S': @@ -3593,7 +3605,7 @@ I.BookmarkManager = { create: () => { if(!S['use-bookmarks']) return; action: () => { if(L.Opened) return R.focusOn({ Destination: Bmk }).then(Destination => I.History.add({ UI: BookmarkManager, SumUp: false/*true*/, Destination: Destination })); if(!L.Waiting) return false; - if(S['start-in-new-window']) return window.open(location.href + (location.hash ? ',' : '#') + 'jo(si-ppis:' + Bmk['SI-PPiS'] + ')'); + if(S['start-in-new-window']) return L.openNewWindow(location.href + (location.hash ? ',' : '#') + 'jo(si-ppis:' + Bmk['SI-PPiS'] + ')'); S['to'] = { 'SI-PPiS': Bmk['SI-PPiS'] }; L.play(); }, diff --git a/__src/bibi/resources/scripts/bibi.js b/__src/bibi/resources/scripts/bibi.js index b8221aa7..cf60dece 100644 --- a/__src/bibi/resources/scripts/bibi.js +++ b/__src/bibi/resources/scripts/bibi.js @@ -24,7 +24,22 @@ document.addEventListener('DOMContentLoaded', () => { break; } else BookStyleElement = BookStyleElement.nextElementSibling; } - Bibi.BookStyleURL = URL.createObjectURL(new Blob([BookStyleCSS], { type: 'text/css' })) - Bibi.hello(); + Bibi.BookStyleURL = URL.createObjectURL(new Blob([BookStyleCSS], { type: 'text/css' })); + if(!sML.UA.Trident) Bibi.hello(); else { + const BibiStyles = document.head.querySelectorAll('#bibi-style, #bibi-dress'); + document.documentElement.style.display = 'none'; + sML.forEach(BibiStyles)(BibiStyle => { + BibiStyle.OriginalHref = BibiStyle.getAttribute('href'); + BibiStyle.href = ''; + }); + setTimeout(() => { + sML.forEach(BibiStyles)(BibiStyle => { + BibiStyle.href = BibiStyle.OriginalHref; + delete BibiStyle.OriginalHref; + }); + document.documentElement.style.display = ''; + Bibi.hello(); + }, 0); + } }); }); \ No newline at end of file diff --git a/__src/bibi/resources/styles/_#globals.scss b/__src/bibi/resources/styles/_#globals.scss index 269b6278..59c12221 100644 --- a/__src/bibi/resources/styles/_#globals.scss +++ b/__src/bibi/resources/styles/_#globals.scss @@ -116,7 +116,7 @@ $INVARIABLE__Spinner_ZIndex: 99999999999; @mixin GLOBAL__FontIcon_BaseStyles($SCOPED__FamilyName, $SCOPED__FontSize: 100%, $SCOPED__LineHeight: 1) { font: #{$SCOPED__FontSize} / #{$SCOPED__LineHeight} $SCOPED__FamilyName; - -ms-font-feature-settings: 'liga' 1; font-feature-settings: 'liga'; text-transform: none; + font-feature-settings: "kern", "liga", "clig", "calt"; -ms-font-feature-settings: "kern", "liga", "clig", "calt"; text-transform: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizelegibility; speak: none; direction: ltr; letter-spacing: 0; white-space: nowrap; word-wrap: normal; overflow-wrap: normal; } diff --git a/__src/bibi/wardrobe/_dress-codes/_stage.scss b/__src/bibi/wardrobe/_dress-codes/_stage.scss index a4d6d3c6..2abaea3b 100644 --- a/__src/bibi/wardrobe/_dress-codes/_stage.scss +++ b/__src/bibi/wardrobe/_dress-codes/_stage.scss @@ -50,7 +50,7 @@ $PoweredBy_Height: 39px; $PoweredBy_BackgroundColor__VeilOpened: rgba(white, .6); $PoweredBy-A-Logo_OpacityOfWhite__VeilOpened: 0; $PoweredBy-A-Logo_OpacityOfBlack__VeilOpened: .69; -$PoweredBy-A_BackgroundColor__VeilOpened: rgba(white, 0); +$PoweredBy-A_BackgroundColor__VeilOpened: rgba(white, .84); $PoweredBy-A-Logo_OpacityOfWhite__VeilOpened__Hover: 0; $PoweredBy-A-Logo_OpacityOfBlack__VeilOpened__Hover: .96; $PoweredBy-A_BackgroundColor__VeilOpened__Hover: rgba(white, 1); diff --git a/__src__back-compat/bib/i.js b/__src__back-compat/bib/i.js index b595fffe..bc7e6e56 100644 --- a/__src__back-compat/bib/i.js +++ b/__src__back-compat/bib/i.js @@ -1 +1 @@ -require('../../__src/bibi/and/jo.js'); \ No newline at end of file +window['bibi:jo'] || (BiBiJS => BiBiJS && BiBiJS.src && /\/bib\/i\.js$/.test(BiBiJS.src) && (JoJS => { JoJS.src = BiBiJS.getAttribute('src').replace(/bib\/i\.js$/, 'bibi/and/jo.js'); JoJS.onload = () => (Jo => Jo.Status || Jo.embed())(window['bibi:jo']); document.head.appendChild(JoJS); })(document.createElement('script')))(document.currentScript || (Scripts => Scripts[Scripts.length - 1])(document.getElementsByTagName('script'))); \ No newline at end of file diff --git a/bibi.info.js b/bibi.info.js index 7ba8a8b8..17df0df9 100644 --- a/bibi.info.js +++ b/bibi.info.js @@ -1,5 +1,5 @@ /*! - * (℠) + * (邃 ) * # Additional Webpack Config for Bibi * */ @@ -7,7 +7,7 @@ 'use strict'; const Bibi = { - 'version': '1.0.0', + 'version': '1.0.1', 'author': { 'name': 'Satoru MATSUSHIMA' }, @@ -31,7 +31,7 @@ Bibi.WithBCK = (Bibi.Arguments['bc'] || Bibi.ForPack); // ============================================================================================================================= const _banner = (Name, Credit, Extra, Mark) => '/*!' + ` - *` + (!Mark ? '' : ` (℠)`) + ` + *` + (!Mark ? '' : ` (邃 )`) + ` * # ${ Name } *` + (!Credit ? '' : (Credit == 'default' ? ` * * Copyright (c) ${ Bibi.author.name } - ${ Bibi.homepage } @@ -95,7 +95,11 @@ Bibi.Banners = { // ----------------------------------------------------------------------------------------------------------------------------- '/and/jo.js': _banner(`Jo | Helper for Embedding Bibi-Frames in Webpage.`, 'default', null, true), - '^bib/i.js': _banner(`Jo | Helper for Embedding Bibi-Frames in Webpage.`, 'default', null, true), + + '^bib/i.js': _banner(`bib/i.js (BCK)`, ` + * * Calling: + * - Jo | Helper for Embedding Bibi-Frames in Webpage. - bibi/and/jo.js +`, null, true), // ----------------------------------------------------------------------------------------------------------------------------- diff --git a/package.json b/package.json index 8d50f9b1..a2418a93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bibi", - "version": "1.0.0", + "version": "1.0.1", "author": { "name": "Satoru MATSUSHIMA" },