mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Viewer: Add the epubReadingSystem JS object
This commit is contained in:
parent
bf8c4d6b4b
commit
8c9eeb028f
Binary file not shown.
@ -136,6 +136,16 @@ class CalibreUtils
|
||||
|
||||
# }}}
|
||||
|
||||
setup_epub_reading_system: (name, version, layout, features) -> # {{{
|
||||
window.navigator.epubReadingSystem = {
|
||||
'name':name, 'version':version, 'layoutStyle':layout,
|
||||
'hasFeature': (feature, version=1.0) ->
|
||||
if (version == null or version == 1.0) and feature.toLowerCase() in features
|
||||
return true
|
||||
return false
|
||||
}
|
||||
# }}}
|
||||
|
||||
if window?
|
||||
window.calibre_utils = new CalibreUtils()
|
||||
|
||||
|
@ -7,6 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os, math, json
|
||||
from base64 import b64encode
|
||||
from functools import partial
|
||||
from future_builtins import map
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QSize, QSizePolicy, QUrl, Qt, pyqtProperty, QPainter, QPalette, QBrush,
|
||||
@ -30,7 +31,7 @@ from calibre.gui2.viewer.inspector import WebInspector
|
||||
from calibre.gui2.viewer.gestures import GestureHandler
|
||||
from calibre.gui2.viewer.footnote import Footnotes
|
||||
from calibre.ebooks.oeb.display.webview import load_html
|
||||
from calibre.constants import isxp, iswindows, DEBUG
|
||||
from calibre.constants import isxp, iswindows, DEBUG, __version__
|
||||
# }}}
|
||||
|
||||
def apply_settings(settings, opts):
|
||||
@ -207,6 +208,9 @@ class Document(QWebPage): # {{{
|
||||
evaljs = self.mainFrame().evaluateJavaScript
|
||||
self.loaded_lang = self.js_loader(evaljs, self.current_language,
|
||||
self.hyphenate_default_lang)
|
||||
evaljs('window.calibre_utils.setup_epub_reading_system(%s, %s, %s, %s)' % tuple(map(json.dumps, (
|
||||
'calibre-desktop', __version__, 'paginated' if self.in_paged_mode else 'scrolling',
|
||||
'dom-manipulation layout-changes mouse-events keyboard-events'.split()))))
|
||||
mjpath = P(u'viewer/mathjax').replace(os.sep, '/')
|
||||
if iswindows:
|
||||
mjpath = u'/' + mjpath
|
||||
|
Loading…
x
Reference in New Issue
Block a user