-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigator.epubReadingSystem injected in EPUB content documents with delay #13
Comments
Have you tried to query the epubReadingSystem object after body.onload or On Saturday, November 30, 2013, Eric Schrijver wrote:
|
Hello Daniel, I’ve now tried both The problem then might be with require.js: because its asynchronous, Readium won’t necessarily be loaded when the book’s JavaScript loads. I’ll try and see if I can get the synchronous version to work. |
The epubReadingSystem object is "injected" into the iframe's window.navigator after the DOM content document is loaded (iframe.onload event). See: https://github.com/readium/readium-shared-js/blob/develop/js/views/iframe_loader.js |
Thanks for the pointer. |
I've used a combination of tricks in my EPUB3 experiments to detect reading On Tue, Dec 3, 2013 at 10:57 AM, Eric Schrijver notifications@github.comwrote:
|
There is an event ReadiumSDK.Events.READER_INITIALIZED that is fired when reader is initialized. |
Thanks Boris, this is a useful event to know about from the perspective of an app developer. However, the problem at hand here is that content authors need to be able to access the ePubReadingSystem object from Javascript code contained within XHTML5 spine items, in a platform-agnostic way (i.e. not by hooking into Readium-specific events or objects). The ePubReadingSystem API is useful for content authors who need to determine Reading System capabilities, or simply to detect that a given HTML page is being rendered in the context of a Reading System (rather than within a regular web browser). |
Daniel, I the context of specific content document the reader fires ReadiumSDK.Events.CONTENT_DOCUMENT_LOADED event and passes out to subscriber the $ifram object and spineItem object. |
@bormind |
Daniel, I did some reading on ePubReadingSystem and now I understand it a little bit better. And I think we have a bigger problem - the ePubReadingSystem is relevant not only for browser based but for any reading system. and we should move the ePubReadingSystem object initialization to the shared-js. This will resolve the current issue with initialization too. |
@bormind it's already in shared-js, but the object gets injected on the iframe.onload event...which is after dom-ready / document loaded, I think. https://github.com/readium/readium-shared-js/blob/develop/js/views/iframe_loader.js |
Yes, I know. But this is wrong. We create ePubReadingSystem in readium.js and store it in navigation object. Then we inject it to the iframe's child window when iframe's content is rendered. This creates reverse dependency and require duplication of ePubReadingSystem creation in other reading systems (Launchers). |
@bormind in Readium-Chrome, ePubReadingSystem.js used to define the object instance once, this JS file was then boostrapped via reader.html (or other "require" mechanism), then the object got injected into loading iframe. Note that because the ePubReadingSystem object contains an app-specific name + version number, it needs to be updated/intercepted by the application before it gets used inside iframes by content documents (spine items or out-of-spine XHTML). |
Hello Daniel and Boris, Thanks for your comments.
Indeed, that would be great! (Though making ePubs feels a bit like the days of the old days of HTML, it would be great if we could get by without reader sniffing). I’m not sure, by the way, that the epubReadingSystem gets correctly inserted into the iFrame in Readium.js—it appears to be present in the host frame rather than the iFrame: Readium Chrome:
Readium.js Viewer:
But I guess I should switch to the devel branch to really follow what’s going on? Cheers, |
develop branch, yes. |
Eric, for sure the develop branch is the one to use. Please clone readium-js-viewer recursively to correctly pull all the dependencies (sub-projects). Now, the epubReadingSystem is not yet fixed in develop branch. It will be in the few days. We have a code freeze for develop branch right now. The fix will remove the ePubReadingSystem definition from readium.js - it doesn't belong there. Instead default ePubReadingSystem will be set in readium-shared-js. But reading system should override the defaults with appropriate settings. The right place to do this is in the subscription to ReadiumSDK.Events.READER_INITIALIZED event. Example will be provided in readium-js-viewer. |
Boris, let's make sure that with this approach the ePubReadingSystem object On Monday, December 9, 2013, Boris Schneiderman wrote:
|
Daniel, you are absolutely right - I think there is a better way to set ePubReadingSystem than using ifrme's onload. Because READER_INITIALIZED is triggered before iframes are created (they are created on opening spine items). If reading system will use reader's READER_INITIALIZED event to set ePubReadingSystem (or with defaults set in readium-shared-js) we will be able to pass the ePubReadingSystem to iframe's window.navigation. when iframe is just created and not when iframe is loaded with the document. Boris. |
…e }}. Does not work in the bundled readium-js-viewer. Does work in the Readium Chrome extension. Bug report: readium/readium-js-viewer#13 Checks for the existence of the navigator.epubReadingSystem property; so the reader knows if they knows something about themself: if not, they leave the text alone.
Issue moved here: |
An XHTML spine document with the following body:
Will have an alert pop up in the Readium Chrome extension, whereas in the readium-js viewer we get an error:
The text was updated successfully, but these errors were encountered: