Skip to content

Commit

Permalink
set applicateion name and version to the epubReadingSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Schneiderman committed Dec 19, 2013
1 parent e95f6c7 commit 95d4665
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 25 deletions.
13 changes: 10 additions & 3 deletions lib/EpubReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ define(['jquery', 'bootstrap', 'URIjs', 'Readium', 'storage/Settings', 'ReaderSe
loadReaderUIPrivate();
currLayoutIsSynthetic = true;

ReadiumSDK.on(ReadiumSDK.Events.READER_INITIALIZED, function() {

navigator.epubReadingSystem.name = "epub-js-viewer";
navigator.epubReadingSystem.version = "0.0.1";

});

readium = new Readium("#epub-reader-container", './lib/thirdparty/');

SettingsDialog.initDialog(readium.reader);

Settings.get('reader', function(readerSettings){
Expand All @@ -118,11 +126,10 @@ define(['jquery', 'bootstrap', 'URIjs', 'Readium', 'storage/Settings', 'ReaderSe
}
loadEbook(url);
});




}


var unloadReaderUI = function(){
$(window).off('resize');
}
Expand Down
96 changes: 75 additions & 21 deletions lib/Readium.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,67 @@ ReadiumSDK = {
PAGINATION_CHANGED: "PaginationChanged",
SETTINGS_APPLIED: "SettingsApplied",
CONTENT_DOCUMENT_LOADED: "ContentDocumentLoaded",
CURRENT_VIEW_PAGINATION_CHANGED: "CurrentViewPaginationChanged", // used internally
MEDIA_OVERLAY_STATUS_CHANGED: "MediaOverlayStatusChanged",
MEDIA_OVERLAY_TTS_SPEAK: "MediaOverlayTTSSpeak",
MEDIA_OVERLAY_TTS_STOP: "MediaOverlayTTSStop"
}
},

InternalEvents: {
CURRENT_VIEW_PAGINATION_CHANGED: "CurrentViewPaginationChanged",
}

};


//This is default implementation of reading system object that will be available for the publication's javascript to analyze at runtime
//To extend/modify/replace this object reading system should subscribe ReadiumSDK.Events.READER_INITIALIZED and apply changes in reaction to this event
navigator.epubReadingSystem = {
name: "",
version: "0.0.0",
layoutStyle: "paginated",

hasFeature: function (feature, version) {

// for now all features must be version 1.0 so fail fast if the user has asked for something else
if (version && version !== "1.0") {
return false;
}

if (feature === "dom-manipulation") {
// Scripts may make structural changes to the document’s DOM (applies to spine-level scripting only).
return true;
}
if (feature === "layout-changes") {
// Scripts may modify attributes and CSS styles that affect content layout (applies to spine-level scripting only).
return true;
}
if (feature === "touch-events") {
// The device supports touch events and the Reading System passes touch events to the content.
return false;
}
if (feature === "mouse-events") {
// The device supports mouse events and the Reading System passes mouse events to the content.
return true;
}
if (feature === "keyboard-events") {
// The device supports keyboard events and the Reading System passes keyboard events to the content.
return true;
}

if (feature === "spine-scripting") {
//Spine-level scripting is supported.
return true;
}

return false;
}
};


_.extend(ReadiumSDK, Backbone.Events);



define("readiumSDK", ["backbone"], (function (global) {
return function () {
var ret, fn;
Expand Down Expand Up @@ -6776,6 +6827,7 @@ ReadiumSDK.Views.OnePageView = Backbone.View.extend({
Backbone.View.prototype.remove.call(this);
},


onIFrameLoad: function(success) {

if(success) {
Expand Down Expand Up @@ -7379,12 +7431,12 @@ ReadiumSDK.Views.FixedView = Backbone.View.extend({

return new ReadiumSDK.Views.OnePageView({

iframeLoader: this.iframeLoader,
spine: this.spine,
bookStyles: this.bookStyles,
class: cssclass,
contentAlignment: contentAlignment
});
iframeLoader: this.iframeLoader,
spine: this.spine,
bookStyles: this.bookStyles,
class: cssclass,
contentAlignment: contentAlignment
});
},

isReflowable: function() {
Expand Down Expand Up @@ -7483,7 +7535,7 @@ ReadiumSDK.Views.FixedView = Backbone.View.extend({
this.updateContentMetaSize();
this.resizeBook();

this.trigger(ReadiumSDK.Events.CURRENT_VIEW_PAGINATION_CHANGED, { paginationInfo: this.getPaginationInfo(), initiator: initiator, spineItem: paginationRequest_spineItem, elementId: paginationRequest_elementId } );
this.trigger(ReadiumSDK.InternalEvents.CURRENT_VIEW_PAGINATION_CHANGED, { paginationInfo: this.getPaginationInfo(), initiator: initiator, spineItem: paginationRequest_spineItem, elementId: paginationRequest_elementId } );
},

onViewportResize: function() {
Expand Down Expand Up @@ -7712,7 +7764,9 @@ ReadiumSDK.Views.FixedView = Backbone.View.extend({
}

if(!pageView.isDisplaying()) {
this.$el.append(pageView.render().$el);
pageView.render();
this.$el.append(pageView.$el);

context.isElementAdded = true;
}

Expand Down Expand Up @@ -8215,7 +8269,7 @@ ReadiumSDK.Views.ReflowableView = Backbone.View.extend({

this.paginationInfo.pageOffset = (this.paginationInfo.columnWidth + this.paginationInfo.columnGap) * this.paginationInfo.visibleColumnCount * this.paginationInfo.currentSpreadIndex;
this.redraw();
this.trigger(ReadiumSDK.Events.CURRENT_VIEW_PAGINATION_CHANGED, { paginationInfo: this.getPaginationInfo(), initiator: initiator, spineItem: paginationRequest_spineItem, elementId: paginationRequest_elementId } );
this.trigger(ReadiumSDK.InternalEvents.CURRENT_VIEW_PAGINATION_CHANGED, { paginationInfo: this.getPaginationInfo(), initiator: initiator, spineItem: paginationRequest_spineItem, elementId: paginationRequest_elementId } );
},

openPagePrev: function (initiator) {
Expand Down Expand Up @@ -8733,22 +8787,20 @@ ReadiumSDK.Views.IFrameLoader = function() {

iframe.onload = function() {

//console.debug("epubReadingSystem (TOP):");
//console.debug(navigator.epubReadingSystem);

// Forward the epubReadingSystem object to the IFRAME
try
{
iframe.contentWindow.navigator["epubReadingSystem"] = navigator.epubReadingSystem;
iframe.contentWindow.navigator.epubReadingSystem = navigator.epubReadingSystem;
console.debug("epubReadingSystem name:"
+ iframe.contentWindow.navigator.epubReadingSystem.name
+ " version:"
+ iframe.contentWindow.navigator.epubReadingSystem.version
+ " is loaded to iframe");
}
catch(ex)
{
console.log("epubReadingSystem INJECTION ERROR! " + ex.message);
}

//console.debug("epubReadingSystem (IFRAME):");
//console.debug(iframe.contentWindow.navigator.epubReadingSystem);

isWaitingForFrameLoad = false;
callback.call(context, true);

Expand Down Expand Up @@ -8870,7 +8922,7 @@ ReadiumSDK.Views.ReaderView = function(options) {

});

_currentView.on(ReadiumSDK.Events.CURRENT_VIEW_PAGINATION_CHANGED, function( pageChangeData ){
_currentView.on(ReadiumSDK.InternalEvents.CURRENT_VIEW_PAGINATION_CHANGED, function( pageChangeData ){

//we call on onPageChanged explicitly instead of subscribing to the ReadiumSDK.Events.PAGINATION_CHANGED by
//mediaOverlayPlayer because we hve to guarantee that mediaOverlayPlayer will be updated before the host
Expand All @@ -8880,6 +8932,7 @@ ReadiumSDK.Views.ReaderView = function(options) {
self.trigger(ReadiumSDK.Events.PAGINATION_CHANGED, pageChangeData);
});


_currentView.render();
}

Expand All @@ -8898,7 +8951,8 @@ ReadiumSDK.Views.ReaderView = function(options) {
return;
}

_currentView.off(ReadiumSDK.Events.CURRENT_VIEW_PAGINATION_CHANGED);
_currentView.off(ReadiumSDK.InternalEvents.CURRENT_VIEW_PAGINATION_CHANGED);

_currentView.remove();
_currentView = undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion readium-js

0 comments on commit 95d4665

Please sign in to comment.