pgaskin / ePubViewer

ePub viewer with dictionary, themes, search, offline support, and more
http://pgaskin.net/ePubViewer
MIT License
350 stars 78 forks source link

Question about theme. #2

Closed bleedweedsuz closed 6 years ago

bleedweedsuz commented 6 years ago

i saw your answer from epub.js i modified this https://github.com/geek1011/ePubViewer/blob/5b4d4990350d0548a7634b7a4d95aa0f39e262ab/script.js#L408-L461 to this for my app my question is i have to call this function from every time chapter changes what should i do? do i have to call all the time page changes or i m missing something?

let rules = {
        "body": {
            "background": "#888888",
            "color": "#525252"
        },
        "p": {
            "font-family": "Aerial",
            "font-size": "12px",
        },
        "a": {
            "color": "inherit !important",
            "text-decoration": "none !important",
            "-webkit-text-fill-color": "inherit !important"
        },
        "a:link": {
            "color": "#909090",
            "text-decoration": "none !important",
            "-webkit-text-fill-color": "#909090"
        },
        "a:link:hover": {
            "background": "rgba(0, 0, 0, 0.1) !important"
        },
        "img": {
            "max-width": "100% !important"
        },
    };

    if(this.Rendition){
        this.Rendition.getContents().forEach(c => c.addStylesheetRules(rules));
    }
bleedweedsuz commented 6 years ago

Oh! i found your other code Rendition.hooks.content.register(this.ChangeThemeFunction.bind(this)); this fix my problem

pgaskin commented 6 years ago

Yep. You need to call it: