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) {
this.renderer.style(style, val, prefixed);
this.renderer.setStyle(style, val, prefixed);
this.settings.styles[style] = val;
}
EPUBJS.Book.prototype.applyStyles = function() {
for (style in this.settings.styles) {
this.setStyle(style, this.settings.styles[style]);
}
EPUBJS.Book.prototype.removeStyle = function(style, val, prefixed) {
this.renderer.removeStyle(style);
delete this.settings.styles[style] = '';
}
removeStyle
//-- Get pre-registered hooks
EPUBJS.Book.prototype.getHooks = function(){
var book = this,

View file

@ -166,8 +166,6 @@ EPUBJS.Renderer.prototype.crossBrowserColumnCss = function(){
}
EPUBJS.Renderer.prototype.setIframeSrc = function(url){
var renderer = this,
promise = new RSVP.Promise();
@ -182,6 +180,8 @@ EPUBJS.Renderer.prototype.setIframeSrc = function(url){
renderer.docEl = renderer.doc.documentElement;
renderer.bodyEl = renderer.doc.body;
renderer.applyStyles();
renderer.formatSpread();
//-- Trigger registered hooks before displaying
@ -286,12 +286,25 @@ EPUBJS.Renderer.prototype.fixedLayout = function(){
this.displayedPages = 1;
}
EPUBJS.Renderer.prototype.style = function(style, val, prefixed){
EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){
if(prefixed) {
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(){