Skip to content

Commit

Permalink
Skips vendor native setup (#137)
Browse files Browse the repository at this point in the history
* 4.2.3

* Skips vendor-native fullscreen setup if on mobile device

* Fixes reference to super_methods, bumps version
  • Loading branch information
shaneriley authored Sep 2, 2019
1 parent c43daf7 commit b85ad8f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion BookReader/BookReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function BookReader(options) {
this.setup(options);
}

BookReader.version = "4.2.2";
BookReader.version = "4.2.4";

// Mode constants
BookReader.constMode1up = 1;
Expand Down
28 changes: 20 additions & 8 deletions BookReader/plugins/plugin.vendor-fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
* Toggles browser's native fullscreen mode if available
*/


(function(BR) {
var event_namespace = ".bookreader_vendor-fullscreen";
var event_namespace = '.bookreader_vendor-fullscreen';
var super_methods = {};
function isMobile() {
return (typeof window.orientation !== 'undefined') || (navigator.userAgent.indexOf('IEMobile') !== -1);
};

jQuery.extend(BR.defaultOptions, {
enableVendorFullscreenPlugin: true
});

BR.prototype.setup = (function(super_) {
super_methods.setup = super_;
return function(options) {
super_.call(this, options);

Expand All @@ -19,6 +23,7 @@
})(BR.prototype.setup);

BR.prototype.getInitialMode = (function(super_) {
super_methods.getInitialMode = super_;
return function(params) {
var nextMode = super_.call(this, params);
if (this.isVendorFullscreenActive) {
Expand All @@ -29,6 +34,12 @@
})(BR.prototype.getInitialMode);

BR.prototype.init = (function(super_) {
if (isMobile()) {
for (var method in super_methods) {
BR.prototype[method] = super_methods[method];
}
return;
}
return function() {
super_.call(this);

Expand Down Expand Up @@ -138,8 +149,8 @@
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.mozExitFullScreen) {
document.mozExitFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
Expand All @@ -166,10 +177,11 @@
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenEnabled
*/
BR.util.fullscreenAllowed = function() {
return document.fullscreenEnabled === true ||
document.webkitFullscreenEnabled === true ||
document.mozFullScreenEnabled === true ||
document.msFullScreenEnavled === true;
return (document.fullscreenEnabled ||
document.webkitFullscreenEnabled ||
document.mozFullScreenEnabled ||
document.msFullScreenEnabled) &&
!isMobile();
};

/**
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 4.2.4
- Skips initialization of vendor fullscreen plugin when on a mobile device

# 4.2.3
- Creates vendor native fullscreen plugin and example use page

# 4.2.2
- Adds options for flipSpeed and flipDelay, the latter used for autoplay

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ See `BookReaderDemo/demo-simple.html` and `BookReaderDemo/BookReaderJSSimple.js`

A basic plugin system is used. See the examples in the plugins directory. The general idea is that they are mixins that augment the BookReader prototype. See the plugins directory for all the included plugins, but here are some examples:

- plugins.autoplay.js - autoplay mode. Flips pages at set intervals.
- plugins.chapters.js - render chapter markers
- plugins.search.js - add search ui, and callbacks
- plugins.tts.js - add tts (read aloud) ui, sound library, and callbacks
- plugins.url.js - automatically updates the browser url
- plugins.resume.js - uses cookies to remember the current page
- plugins.mobile_nav.js - adds responsive mobile nav to BookReader
- plugin.autoplay.js - autoplay mode. Flips pages at set intervals.
- plugin.chapters.js - render chapter markers
- plugin.search.js - add search ui, and callbacks
- plugin.tts.js - add tts (read aloud) ui, sound library, and callbacks
- plugin.url.js - automatically updates the browser url
- plugin.resume.js - uses cookies to remember the current page
- plugin.mobile_nav.js - adds responsive mobile nav to BookReader
- plugin.vendor-fullscreen.js - replaces fullscreen mode with vendor native fullscreen

## Embedding

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bookreader",
"version": "4.2.2",
"version": "4.2.4",
"description": "The Internet Archive BookReader.",
"repository": {
"type": "git",
Expand Down

0 comments on commit b85ad8f

Please sign in to comment.