1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

apply styles after chapter load and added remove method

This commit is contained in:
Fred Chasen 2013-06-30 23:29:17 -07:00
parent 8fb857a574
commit 3fef8b0091
2 changed files with 24 additions and 9 deletions

View file

@ -584,17 +584,19 @@ EPUBJS.Book.prototype.fromStorage = function(stored) {
*/ */
EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) { EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) {
this.renderer.style(style, val, prefixed); this.renderer.setStyle(style, val, prefixed);
this.settings.styles[style] = val; this.settings.styles[style] = val;
} }
EPUBJS.Book.prototype.applyStyles = function() { EPUBJS.Book.prototype.removeStyle = function(style, val, prefixed) {
for (style in this.settings.styles) { this.renderer.removeStyle(style);
this.setStyle(style, this.settings.styles[style]);
} delete this.settings.styles[style] = '';
} }
removeStyle
//-- Get pre-registered hooks //-- Get pre-registered hooks
EPUBJS.Book.prototype.getHooks = function(){ EPUBJS.Book.prototype.getHooks = function(){
var book = this, var book = this,

View file

@ -166,8 +166,6 @@ EPUBJS.Renderer.prototype.crossBrowserColumnCss = function(){
} }
EPUBJS.Renderer.prototype.setIframeSrc = function(url){ EPUBJS.Renderer.prototype.setIframeSrc = function(url){
var renderer = this, var renderer = this,
promise = new RSVP.Promise(); promise = new RSVP.Promise();
@ -182,6 +180,8 @@ EPUBJS.Renderer.prototype.setIframeSrc = function(url){
renderer.docEl = renderer.doc.documentElement; renderer.docEl = renderer.doc.documentElement;
renderer.bodyEl = renderer.doc.body; renderer.bodyEl = renderer.doc.body;
renderer.applyStyles();
renderer.formatSpread(); renderer.formatSpread();
//-- Trigger registered hooks before displaying //-- Trigger registered hooks before displaying
@ -286,12 +286,25 @@ EPUBJS.Renderer.prototype.fixedLayout = function(){
this.displayedPages = 1; this.displayedPages = 1;
} }
EPUBJS.Renderer.prototype.style = function(style, val, prefixed){ EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){
if(prefixed) { if(prefixed) {
style = EPUBJS.core.prefixed(style); style = EPUBJS.core.prefixed(style);
} }
this.bodyEl.style[style] = val; if(this.bodyEl) this.bodyEl.style[style] = val;
}
EPUBJS.Renderer.prototype.removeStyle = function(style){
if(this.bodyEl) this.bodyEl.style[style] = '';
}
EPUBJS.Renderer.prototype.applyStyles = function() {
var style = this.book.settings.styles;
for (style in styles) {
this.setStyle(style, styles[style]);
}
} }
EPUBJS.Renderer.prototype.gotoChapterEnd = function(){ EPUBJS.Renderer.prototype.gotoChapterEnd = function(){