1
0
Fork 0
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:
Fred Chasen 2014-04-01 14:29:14 -07:00
parent 8def78b89b
commit aee761061d
7 changed files with 39 additions and 11 deletions

View file

@ -26,13 +26,27 @@ EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like searc
})(window, jQuery);
EPUBJS.Reader = function(path, _options) {
EPUBJS.Reader = function(bookPath, _options) {
var reader = this;
var book;
var plugin;
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 || {}, {
bookPath : bookPath,
restore : true,
reload : false,
bookmarks : null,
@ -45,7 +59,7 @@ EPUBJS.Reader = function(path, _options) {
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()) {
this.applySavedSettings();
@ -56,7 +70,7 @@ EPUBJS.Reader = function(path, _options) {
};
this.book = book = new EPUBJS.Book({
bookPath: path,
bookPath: this.settings.bookPath,
restore: this.settings.restore,
reload: this.settings.reload,
contained: this.settings.contained,

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

View file

@ -26,13 +26,27 @@ EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like searc
})(window, jQuery);
EPUBJS.Reader = function(path, _options) {
EPUBJS.Reader = function(bookPath, _options) {
var reader = this;
var book;
var plugin;
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 || {}, {
bookPath : bookPath,
restore : true,
reload : false,
bookmarks : null,
@ -45,7 +59,7 @@ EPUBJS.Reader = function(path, _options) {
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()) {
this.applySavedSettings();
@ -56,7 +70,7 @@ EPUBJS.Reader = function(path, _options) {
};
this.book = book = new EPUBJS.Book({
bookPath: path,
bookPath: this.settings.bookPath,
restore: this.settings.restore,
reload: this.settings.reload,
contained: this.settings.contained,