mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Add search parameter overides to reader
This commit is contained in:
parent
8def78b89b
commit
aee761061d
7 changed files with 39 additions and 11 deletions
|
@ -26,13 +26,27 @@ EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like searc
|
||||||
|
|
||||||
})(window, jQuery);
|
})(window, jQuery);
|
||||||
|
|
||||||
EPUBJS.Reader = function(path, _options) {
|
EPUBJS.Reader = function(bookPath, _options) {
|
||||||
var reader = this;
|
var reader = this;
|
||||||
var book;
|
var book;
|
||||||
var plugin;
|
var plugin;
|
||||||
var $viewer = $("#viewer");
|
var $viewer = $("#viewer");
|
||||||
|
var search = window.location.search;
|
||||||
|
var parameters;
|
||||||
|
|
||||||
|
// Overide options with search parameters
|
||||||
|
if(search) {
|
||||||
|
parameters = search.slice(1).split("&");
|
||||||
|
parameters.forEach(function(p){
|
||||||
|
var split = p.split("=");
|
||||||
|
var name = split[0];
|
||||||
|
var value = split[1] || '';
|
||||||
|
_options[name] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.settings = _.defaults(_options || {}, {
|
this.settings = _.defaults(_options || {}, {
|
||||||
|
bookPath : bookPath,
|
||||||
restore : true,
|
restore : true,
|
||||||
reload : false,
|
reload : false,
|
||||||
bookmarks : null,
|
bookmarks : null,
|
||||||
|
@ -45,7 +59,7 @@ EPUBJS.Reader = function(path, _options) {
|
||||||
history: true
|
history: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setBookKey(path); //-- This could be username + path or any unique string
|
this.setBookKey(bookPath); //-- This could be username + path or any unique string
|
||||||
|
|
||||||
if(this.settings.restore && this.isSaved()) {
|
if(this.settings.restore && this.isSaved()) {
|
||||||
this.applySavedSettings();
|
this.applySavedSettings();
|
||||||
|
@ -56,7 +70,7 @@ EPUBJS.Reader = function(path, _options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.book = book = new EPUBJS.Book({
|
this.book = book = new EPUBJS.Book({
|
||||||
bookPath: path,
|
bookPath: this.settings.bookPath,
|
||||||
restore: this.settings.restore,
|
restore: this.settings.restore,
|
||||||
reload: this.settings.reload,
|
reload: this.settings.reload,
|
||||||
contained: this.settings.contained,
|
contained: this.settings.contained,
|
||||||
|
|
File diff suppressed because one or more lines are too long
2
build/reader.min.js
vendored
2
build/reader.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
reader/js/reader.min.js
vendored
2
reader/js/reader.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -26,13 +26,27 @@ EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like searc
|
||||||
|
|
||||||
})(window, jQuery);
|
})(window, jQuery);
|
||||||
|
|
||||||
EPUBJS.Reader = function(path, _options) {
|
EPUBJS.Reader = function(bookPath, _options) {
|
||||||
var reader = this;
|
var reader = this;
|
||||||
var book;
|
var book;
|
||||||
var plugin;
|
var plugin;
|
||||||
var $viewer = $("#viewer");
|
var $viewer = $("#viewer");
|
||||||
|
var search = window.location.search;
|
||||||
|
var parameters;
|
||||||
|
|
||||||
|
// Overide options with search parameters
|
||||||
|
if(search) {
|
||||||
|
parameters = search.slice(1).split("&");
|
||||||
|
parameters.forEach(function(p){
|
||||||
|
var split = p.split("=");
|
||||||
|
var name = split[0];
|
||||||
|
var value = split[1] || '';
|
||||||
|
_options[name] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.settings = _.defaults(_options || {}, {
|
this.settings = _.defaults(_options || {}, {
|
||||||
|
bookPath : bookPath,
|
||||||
restore : true,
|
restore : true,
|
||||||
reload : false,
|
reload : false,
|
||||||
bookmarks : null,
|
bookmarks : null,
|
||||||
|
@ -45,7 +59,7 @@ EPUBJS.Reader = function(path, _options) {
|
||||||
history: true
|
history: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setBookKey(path); //-- This could be username + path or any unique string
|
this.setBookKey(bookPath); //-- This could be username + path or any unique string
|
||||||
|
|
||||||
if(this.settings.restore && this.isSaved()) {
|
if(this.settings.restore && this.isSaved()) {
|
||||||
this.applySavedSettings();
|
this.applySavedSettings();
|
||||||
|
@ -56,7 +70,7 @@ EPUBJS.Reader = function(path, _options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.book = book = new EPUBJS.Book({
|
this.book = book = new EPUBJS.Book({
|
||||||
bookPath: path,
|
bookPath: this.settings.bookPath,
|
||||||
restore: this.settings.restore,
|
restore: this.settings.restore,
|
||||||
reload: this.settings.reload,
|
reload: this.settings.reload,
|
||||||
contained: this.settings.contained,
|
contained: this.settings.contained,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue