Merge remote-tracking branch 'epub_theme/epub_themes' into Develop
This commit is contained in:
commit
07d4e60655
19
cps/static/css/epub_themes.css
Normal file
19
cps/static/css/epub_themes.css
Normal file
|
@ -0,0 +1,19 @@
|
|||
.lightTheme {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.darkTheme {
|
||||
background: #202124;
|
||||
color: #fff
|
||||
}
|
||||
|
||||
.sepiaTheme {
|
||||
background: #ece1ca;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.blackTheme {
|
||||
background: #000;
|
||||
color: #fff
|
||||
}
|
|
@ -567,6 +567,36 @@ input:-moz-placeholder { color: #454545; }
|
|||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.md-content .themes button {
|
||||
display: inline-block;
|
||||
border: none;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
margin-top: 5%;
|
||||
margin-right: 1%;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.md-content .themes button.darkTheme {
|
||||
background-color: #202124;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.md-content .themes button.whiteTheme {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.md-content .themes button.sepiaTheme {
|
||||
background-color: #ece1ca;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.md-content .themes button.blackTheme {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Effect 1: Fade in and scale up */
|
||||
.md-effect-1 .md-content {
|
||||
-webkit-transform: scale(0.7);
|
||||
|
|
|
@ -13,6 +13,11 @@ var reader;
|
|||
bookmarks: calibre.bookmark ? [calibre.bookmark] : []
|
||||
});
|
||||
|
||||
reader.rendition.themes.register("lightTheme", "/static/css/epub_themes.css");
|
||||
reader.rendition.themes.register("darkTheme", "/static/css/epub_themes.css");
|
||||
reader.rendition.themes.register("sepiaTheme", "/static/css/epub_themes.css");
|
||||
reader.rendition.themes.register("blackTheme", "/static/css/epub_themes.css");
|
||||
|
||||
if (calibre.useBookmarks) {
|
||||
reader.on("reader:bookmarked", updateBookmark.bind(reader, "add"));
|
||||
reader.on("reader:unbookmarked", updateBookmark.bind(reader, "remove"));
|
||||
|
|
|
@ -70,6 +70,15 @@
|
|||
<div class="modal md-effect-1" id="settings-modal">
|
||||
<div class="md-content">
|
||||
<h3>{{_('Settings')}}</h3>
|
||||
<div class="themes" id="themes">
|
||||
Choose a theme below: <br />
|
||||
|
||||
<!-- Hardcoded a tick in the light theme button because it is the "default" theme. Need to find a way to do this dynamically on startup-->
|
||||
<button type="button" id="lightTheme" class="lightTheme" onclick="selectTheme(this.id)"><span id="lightSelected">✓</span>{{_('Light')}}</button>
|
||||
<button type="button" id="darkTheme" class="darkTheme" onclick="selectTheme(this.id)"><span id="darkSelected"> </span>{{_('Dark')}}</button>
|
||||
<button type="button" id="sepiaTheme" class="sepiaTheme" onclick="selectTheme(this.id)"><span id="sepiaSelected"> </span>{{_('Sepia')}}</button>
|
||||
<button type="button" id="blackTheme" class="blackTheme" onclick="selectTheme(this.id)"><span id="blackSelected"> </span>{{_('Black')}}</button>
|
||||
</div>
|
||||
<div>
|
||||
<p>
|
||||
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">{{_('Reflow text when sidebars are open.')}}
|
||||
|
@ -91,6 +100,35 @@
|
|||
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
|
||||
useBookmarks: "{{ g.user.is_authenticated | tojson }}"
|
||||
};
|
||||
|
||||
function selectTheme(id) {
|
||||
tickSpans = document.getElementById("themes").querySelectorAll("span");
|
||||
|
||||
// Remove tick mark from all theme buttons
|
||||
for(var i = 0; i < tickSpans.length; i++) {
|
||||
document.getElementById(tickSpans[i].id).textContent = "";
|
||||
}
|
||||
|
||||
// Add tick mark to the button corresponding to the currently selected theme
|
||||
document.getElementById(id).querySelector("span").textContent = "✓";
|
||||
|
||||
// Apply theme to epubjs iframe
|
||||
reader.rendition.themes.select(id);
|
||||
|
||||
// Apply theme to rest of the page. TODO - Do this smarter
|
||||
if (id == "darkTheme") {
|
||||
document.getElementById("main").style.backgroundColor = "#202124";
|
||||
}
|
||||
else if (id == "lightTheme") {
|
||||
document.getElementById("main").style.backgroundColor = "white";
|
||||
}
|
||||
else if (id == "sepiaTheme") {
|
||||
document.getElementById("main").style.backgroundColor = "#ece1ca";
|
||||
}
|
||||
else if (id == "blackTheme") {
|
||||
document.getElementById("main").style.backgroundColor = "black";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/libs/reader.min.js') }}"></script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user