mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
Move managers to subfolder, rename single to default
This commit is contained in:
parent
730b06f32b
commit
5c49e4f4b6
5 changed files with 601 additions and 603 deletions
1111
dist/epub.js
vendored
1111
dist/epub.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/epub.js.map
vendored
2
dist/epub.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -31,7 +31,7 @@ ePub.register.view("iframe", require('./managers/views/iframe'));
|
||||||
// ePub.register.view("inline", require('./managers/views/inline'));
|
// ePub.register.view("inline", require('./managers/views/inline'));
|
||||||
|
|
||||||
// Default View Managers
|
// Default View Managers
|
||||||
ePub.register.manager("single", require('./managers/single'));
|
ePub.register.manager("single", require('./managers/default'));
|
||||||
ePub.register.manager("continuous", require('./managers/continuous'));
|
ePub.register.manager("continuous", require('./managers/continuous'));
|
||||||
|
|
||||||
module.exports = ePub;
|
module.exports = ePub;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
var RSVP = require('rsvp');
|
var RSVP = require('rsvp');
|
||||||
var core = require('../core');
|
var core = require('../../core');
|
||||||
var SingleViewManager = require('./single');
|
var DefaultViewManager = require('../default');
|
||||||
|
|
||||||
function ContinuousViewManager(options) {
|
function ContinuousViewManager(options) {
|
||||||
|
|
||||||
SingleViewManager.apply(this, arguments); // call super constructor.
|
DefaultViewManager.apply(this, arguments); // call super constructor.
|
||||||
|
|
||||||
this.name = "continuous";
|
this.name = "continuous";
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ function ContinuousViewManager(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// subclass extends superclass
|
// subclass extends superclass
|
||||||
ContinuousViewManager.prototype = Object.create(SingleViewManager.prototype);
|
ContinuousViewManager.prototype = Object.create(DefaultViewManager.prototype);
|
||||||
ContinuousViewManager.prototype.constructor = ContinuousViewManager;
|
ContinuousViewManager.prototype.constructor = ContinuousViewManager;
|
||||||
|
|
||||||
ContinuousViewManager.prototype.display = function(section, target){
|
ContinuousViewManager.prototype.display = function(section, target){
|
||||||
return SingleViewManager.prototype.display.call(this, section, target)
|
return DefaultViewManager.prototype.display.call(this, section, target)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return this.fill();
|
return this.fill();
|
||||||
}.bind(this));
|
}.bind(this));
|
|
@ -1,15 +1,14 @@
|
||||||
var RSVP = require('rsvp');
|
var RSVP = require('rsvp');
|
||||||
var core = require('../core');
|
var core = require('../../core');
|
||||||
var EpubCFI = require('../epubcfi');
|
var EpubCFI = require('../../epubcfi');
|
||||||
// var Layout = require('../layout');
|
var Mapping = require('../../mapping');
|
||||||
var Mapping = require('../mapping');
|
var Queue = require('../../queue');
|
||||||
var Queue = require('../queue');
|
var Stage = require('../helpers/stage');
|
||||||
var Stage = require('./helpers/stage');
|
var Views = require('../helpers/views');
|
||||||
var Views = require('./helpers/views');
|
|
||||||
|
|
||||||
function SingleViewManager(options) {
|
function DefaultViewManager(options) {
|
||||||
|
|
||||||
this.name = "single";
|
this.name = "default";
|
||||||
this.View = options.view;
|
this.View = options.view;
|
||||||
this.request = options.request;
|
this.request = options.request;
|
||||||
this.renditionQueue = options.queue;
|
this.renditionQueue = options.queue;
|
||||||
|
@ -38,7 +37,7 @@ function SingleViewManager(options) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleViewManager.prototype.render = function(element, size){
|
DefaultViewManager.prototype.render = function(element, size){
|
||||||
|
|
||||||
// Save the stage
|
// Save the stage
|
||||||
this.stage = new Stage({
|
this.stage = new Stage({
|
||||||
|
@ -79,13 +78,13 @@ SingleViewManager.prototype.render = function(element, size){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.addEventListeners = function(){
|
DefaultViewManager.prototype.addEventListeners = function(){
|
||||||
window.addEventListener('unload', function(e){
|
window.addEventListener('unload', function(e){
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.destroy = function(){
|
DefaultViewManager.prototype.destroy = function(){
|
||||||
// this.views.each(function(view){
|
// this.views.each(function(view){
|
||||||
// view.destroy();
|
// view.destroy();
|
||||||
// });
|
// });
|
||||||
|
@ -101,14 +100,14 @@ SingleViewManager.prototype.destroy = function(){
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.onResized = function(e) {
|
DefaultViewManager.prototype.onResized = function(e) {
|
||||||
clearTimeout(this.resizeTimeout);
|
clearTimeout(this.resizeTimeout);
|
||||||
this.resizeTimeout = setTimeout(function(){
|
this.resizeTimeout = setTimeout(function(){
|
||||||
this.resize();
|
this.resize();
|
||||||
}.bind(this), 150);
|
}.bind(this), 150);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.resize = function(width, height){
|
DefaultViewManager.prototype.resize = function(width, height){
|
||||||
|
|
||||||
// Clear the queue
|
// Clear the queue
|
||||||
this.q.clear();
|
this.q.clear();
|
||||||
|
@ -134,11 +133,11 @@ SingleViewManager.prototype.resize = function(width, height){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.createView = function(section) {
|
DefaultViewManager.prototype.createView = function(section) {
|
||||||
return new this.View(section, this.viewSettings);
|
return new this.View(section, this.viewSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.display = function(section, target){
|
DefaultViewManager.prototype.display = function(section, target){
|
||||||
|
|
||||||
var displaying = new RSVP.defer();
|
var displaying = new RSVP.defer();
|
||||||
var displayed = displaying.promise;
|
var displayed = displaying.promise;
|
||||||
|
@ -192,19 +191,19 @@ SingleViewManager.prototype.display = function(section, target){
|
||||||
return displayed;
|
return displayed;
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.afterDisplayed = function(view){
|
DefaultViewManager.prototype.afterDisplayed = function(view){
|
||||||
this.trigger("added", view);
|
this.trigger("added", view);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.afterResized = function(view){
|
DefaultViewManager.prototype.afterResized = function(view){
|
||||||
this.trigger("resize", view.section);
|
this.trigger("resize", view.section);
|
||||||
};
|
};
|
||||||
|
|
||||||
// SingleViewManager.prototype.moveTo = function(offset){
|
// DefaultViewManager.prototype.moveTo = function(offset){
|
||||||
// this.scrollTo(offset.left, offset.top);
|
// this.scrollTo(offset.left, offset.top);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
SingleViewManager.prototype.moveTo = function(offset){
|
DefaultViewManager.prototype.moveTo = function(offset){
|
||||||
var distX = 0,
|
var distX = 0,
|
||||||
distY = 0;
|
distY = 0;
|
||||||
|
|
||||||
|
@ -221,7 +220,7 @@ SingleViewManager.prototype.moveTo = function(offset){
|
||||||
this.scrollTo(distX, distY);
|
this.scrollTo(distX, distY);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.add = function(section){
|
DefaultViewManager.prototype.add = function(section){
|
||||||
var view = this.createView(section);
|
var view = this.createView(section);
|
||||||
|
|
||||||
this.views.append(view);
|
this.views.append(view);
|
||||||
|
@ -234,19 +233,19 @@ SingleViewManager.prototype.add = function(section){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.append = function(section){
|
DefaultViewManager.prototype.append = function(section){
|
||||||
var view = this.createView(section);
|
var view = this.createView(section);
|
||||||
this.views.append(view);
|
this.views.append(view);
|
||||||
return view.display(this.request);
|
return view.display(this.request);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.prepend = function(section){
|
DefaultViewManager.prototype.prepend = function(section){
|
||||||
var view = this.createView(section);
|
var view = this.createView(section);
|
||||||
|
|
||||||
this.views.prepend(view);
|
this.views.prepend(view);
|
||||||
return view.display(this.request);
|
return view.display(this.request);
|
||||||
};
|
};
|
||||||
// SingleViewManager.prototype.resizeView = function(view) {
|
// DefaultViewManager.prototype.resizeView = function(view) {
|
||||||
//
|
//
|
||||||
// if(this.settings.globalLayoutProperties.layout === "pre-paginated") {
|
// if(this.settings.globalLayoutProperties.layout === "pre-paginated") {
|
||||||
// view.lock("both", this.bounds.width, this.bounds.height);
|
// view.lock("both", this.bounds.width, this.bounds.height);
|
||||||
|
@ -256,7 +255,7 @@ SingleViewManager.prototype.prepend = function(section){
|
||||||
//
|
//
|
||||||
// };
|
// };
|
||||||
|
|
||||||
SingleViewManager.prototype.next = function(){
|
DefaultViewManager.prototype.next = function(){
|
||||||
var next;
|
var next;
|
||||||
var view;
|
var view;
|
||||||
var left;
|
var left;
|
||||||
|
@ -305,7 +304,7 @@ SingleViewManager.prototype.next = function(){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.prev = function(){
|
DefaultViewManager.prototype.prev = function(){
|
||||||
var prev;
|
var prev;
|
||||||
var view;
|
var view;
|
||||||
var left;
|
var left;
|
||||||
|
@ -353,7 +352,7 @@ SingleViewManager.prototype.prev = function(){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.current = function(){
|
DefaultViewManager.prototype.current = function(){
|
||||||
var visible = this.visible();
|
var visible = this.visible();
|
||||||
if(visible.length){
|
if(visible.length){
|
||||||
// Current is the last visible view
|
// Current is the last visible view
|
||||||
|
@ -362,7 +361,7 @@ SingleViewManager.prototype.current = function(){
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.currentLocation = function(){
|
DefaultViewManager.prototype.currentLocation = function(){
|
||||||
var view;
|
var view;
|
||||||
var start, end;
|
var start, end;
|
||||||
|
|
||||||
|
@ -376,7 +375,7 @@ SingleViewManager.prototype.currentLocation = function(){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.isVisible = function(view, offsetPrev, offsetNext, _container){
|
DefaultViewManager.prototype.isVisible = function(view, offsetPrev, offsetNext, _container){
|
||||||
var position = view.position();
|
var position = view.position();
|
||||||
var container = _container || this.bounds();
|
var container = _container || this.bounds();
|
||||||
|
|
||||||
|
@ -397,7 +396,7 @@ SingleViewManager.prototype.isVisible = function(view, offsetPrev, offsetNext, _
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.visible = function(){
|
DefaultViewManager.prototype.visible = function(){
|
||||||
// return this.views.displayed();
|
// return this.views.displayed();
|
||||||
var container = this.bounds();
|
var container = this.bounds();
|
||||||
var views = this.views.displayed();
|
var views = this.views.displayed();
|
||||||
|
@ -418,7 +417,7 @@ SingleViewManager.prototype.visible = function(){
|
||||||
return visible;
|
return visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.scrollBy = function(x, y, silent){
|
DefaultViewManager.prototype.scrollBy = function(x, y, silent){
|
||||||
if(silent) {
|
if(silent) {
|
||||||
this.ignore = true;
|
this.ignore = true;
|
||||||
}
|
}
|
||||||
|
@ -436,7 +435,7 @@ SingleViewManager.prototype.scrollBy = function(x, y, silent){
|
||||||
this.onScroll();
|
this.onScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.scrollTo = function(x, y, silent){
|
DefaultViewManager.prototype.scrollTo = function(x, y, silent){
|
||||||
if(silent) {
|
if(silent) {
|
||||||
this.ignore = true;
|
this.ignore = true;
|
||||||
}
|
}
|
||||||
|
@ -458,11 +457,11 @@ SingleViewManager.prototype.scrollTo = function(x, y, silent){
|
||||||
// };
|
// };
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.onScroll = function(){
|
DefaultViewManager.prototype.onScroll = function(){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.bounds = function() {
|
DefaultViewManager.prototype.bounds = function() {
|
||||||
var bounds;
|
var bounds;
|
||||||
|
|
||||||
bounds = this.stage.bounds();
|
bounds = this.stage.bounds();
|
||||||
|
@ -470,7 +469,7 @@ SingleViewManager.prototype.bounds = function() {
|
||||||
return bounds;
|
return bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.applyLayout = function(layout) {
|
DefaultViewManager.prototype.applyLayout = function(layout) {
|
||||||
|
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
|
@ -479,7 +478,7 @@ SingleViewManager.prototype.applyLayout = function(layout) {
|
||||||
// this.manager.layout(this.layout.format);
|
// this.manager.layout(this.layout.format);
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.updateLayout = function() {
|
DefaultViewManager.prototype.updateLayout = function() {
|
||||||
if (!this.stage) {
|
if (!this.stage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +509,7 @@ SingleViewManager.prototype.updateLayout = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.setLayout = function(layout){
|
DefaultViewManager.prototype.setLayout = function(layout){
|
||||||
|
|
||||||
this.viewSettings.layout = layout;
|
this.viewSettings.layout = layout;
|
||||||
|
|
||||||
|
@ -524,7 +523,7 @@ SingleViewManager.prototype.setLayout = function(layout){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SingleViewManager.prototype.updateFlow = function(flow){
|
DefaultViewManager.prototype.updateFlow = function(flow){
|
||||||
var axis = (flow === "paginated") ? "horizontal" : "vertical";
|
var axis = (flow === "paginated") ? "horizontal" : "vertical";
|
||||||
|
|
||||||
this.settings.axis = axis;
|
this.settings.axis = axis;
|
||||||
|
@ -539,6 +538,6 @@ SingleViewManager.prototype.updateFlow = function(flow){
|
||||||
};
|
};
|
||||||
|
|
||||||
//-- Enable binding events to Manager
|
//-- Enable binding events to Manager
|
||||||
RSVP.EventTarget.mixin(SingleViewManager.prototype);
|
RSVP.EventTarget.mixin(DefaultViewManager.prototype);
|
||||||
|
|
||||||
module.exports = SingleViewManager;
|
module.exports = DefaultViewManager;
|
Loading…
Add table
Add a link
Reference in a new issue