diff --git a/host_app_reference_files/host_app_feedback.js b/host_app_reference_files/host_app_feedback.js deleted file mode 100644 index d377ed208..000000000 --- a/host_app_reference_files/host_app_feedback.js +++ /dev/null @@ -1,35 +0,0 @@ -// LauncherOSX -// -// Created by Boris Schneiderman. -// Copyright (c) 2012-2013 The Readium Foundation. -// -// The Readium SDK is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//This is demo file that does nothing -//Host application has to override this file and provide it's own logic for handling ReadiumSDK events -//See LauncherOSX and LauncherIOS for examples -ReadiumSDK.HostAppFeedback = function() { - - ReadiumSDK.on("ReaderInitialized", function(){ - ReadiumSDK.reader.on("PaginationChanged", this.onPaginationChanged, this); - }, this); - - this.onPaginationChanged = function(paginationInfo) { - - console.log("Pagination Chenged!"); - - }; - -}(); - diff --git a/host_app_reference_files/reader.css b/host_app_reference_files/reader.css deleted file mode 100755 index 29c008839..000000000 --- a/host_app_reference_files/reader.css +++ /dev/null @@ -1,71 +0,0 @@ -html { - height: 100%; - margin: 0; -} - -body { - height: 100%; - width: 100%; - margin: 0; - padding: 20px; - position: absolute; - overflow: hidden; - box-sizing:border-box; - -moz-box-sizing:border-box; /* Firefox */ - -webkit-box-sizing:border-box; /* Safari */ -} - -#viewport_reflowable { - height: 100%; - width: 100%; - margin: 0; - padding: 0; - opacity: 1; - visibility: visible; - overflow: hidden; -} - -#viewport_fixed { - position: absolute; - left: 10px; - right: 10px; - top: 10px; - bottom: 10px; - opacity: 1; - visibility: visible; - overflow: hidden; -} - -iframe { - border-width: 0; -} - -.fixed_iframe { - width: 100%; - height: 100%; -} - -.left_page { - - left: 0; - width: 50%; - height: 100%; -} - -.right_page { - left: 50%; - width: 50%; - height: 100%; -} - -.center_page { - left: 0; - width: 100%; - height: 100%; -} - -.fixed-page-wrap { - - position: absolute; -} - diff --git a/host_app_reference_files/reader.html b/host_app_reference_files/reader.html deleted file mode 100644 index 556a696c7..000000000 --- a/host_app_reference_files/reader.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/js/readium_sdk.js b/js/readium_sdk.js index 8c25a3602..e566cb423 100644 --- a/js/readium_sdk.js +++ b/js/readium_sdk.js @@ -49,12 +49,63 @@ 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); + + diff --git a/js/views/fixed_view.js b/js/views/fixed_view.js index 6af5fd90d..359e5cbe4 100644 --- a/js/views/fixed_view.js +++ b/js/views/fixed_view.js @@ -62,12 +62,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() { @@ -166,7 +166,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() { @@ -395,7 +395,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; } diff --git a/js/views/iframe_loader.js b/js/views/iframe_loader.js index 19db34e70..059f19b43 100644 --- a/js/views/iframe_loader.js +++ b/js/views/iframe_loader.js @@ -25,22 +25,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); diff --git a/js/views/one_page_view.js b/js/views/one_page_view.js index 4067a8728..dd36f8445 100644 --- a/js/views/one_page_view.js +++ b/js/views/one_page_view.js @@ -76,6 +76,7 @@ ReadiumSDK.Views.OnePageView = Backbone.View.extend({ Backbone.View.prototype.remove.call(this); }, + onIFrameLoad: function(success) { if(success) { diff --git a/js/views/reader_view.js b/js/views/reader_view.js index 937e73ee4..27a709a8c 100644 --- a/js/views/reader_view.js +++ b/js/views/reader_view.js @@ -92,7 +92,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 @@ -102,6 +102,7 @@ ReadiumSDK.Views.ReaderView = function(options) { self.trigger(ReadiumSDK.Events.PAGINATION_CHANGED, pageChangeData); }); + _currentView.render(); } @@ -120,7 +121,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; } diff --git a/js/views/reflowable_view.js b/js/views/reflowable_view.js index b88f83909..d357e2dd2 100644 --- a/js/views/reflowable_view.js +++ b/js/views/reflowable_view.js @@ -370,7 +370,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) {