Permalink
Browse files

global reviewer override, fix fading in previewer/clayout

you can use the debug console to define custom html/css/js to be added
to the bottom of the reviewer on all note types, so to increase the fade
time on the question you'd use

mw.col.conf["reviewExtra"]="<script>qFade=500;</script>"
mw.col.setMod()

also make sure the fading for question/answer is used correctly in
previewer, and use answer fading in clayout to speed it up
  • Loading branch information...
dae committed Aug 10, 2017
1 parent 85d4511 commit 55b782581d39f3a4b184ff3f24a59d51ad8c9e83
Showing with 13 additions and 7 deletions.
  1. +4 −2 aqt/browser.py
  2. +4 −3 aqt/clayout.py
  3. +5 −2 aqt/reviewer.py
View
@@ -1118,7 +1118,7 @@ def _setupPreviewWebview(self):
jsinc = ["jquery.js","browsersel.js",
"mathjax/conf.js", "mathjax/MathJax.js",
"reviewer.js"]
self._previewWeb.stdHtml(self.mw.reviewer._revHtml,
self._previewWeb.stdHtml(self.mw.reviewer.revHtml(),
css=["reviewer.css"],
head=base, js=jsinc)
@@ -1146,6 +1146,7 @@ def _renderScheduledPreview(self, cardChanged=False):
return
c = self.card
self._updatePreviewButtons()
func = "_showQuestion"
if not c or not self.singleCard:
txt = _("(please select 1 card)")
bodyclass = ""
@@ -1155,6 +1156,7 @@ def _renderScheduledPreview(self, cardChanged=False):
# need to force reload even if answer
txt = c.q(reload=True)
if self._previewState == "answer":
func = "_showAnswer"
txt = c.a()
txt = re.sub("\[\[type:[^]]+\]\]", "", txt)
@@ -1167,7 +1169,7 @@ def _renderScheduledPreview(self, cardChanged=False):
txt = mungeQA(self.col, txt)
self._previewWeb.eval(
"_showQuestion(%s,'%s');" % (json.dumps(txt), bodyclass))
f"{func}({json.dumps(txt)},'{bodyclass}');")
# Card deletion
######################################################################
View
@@ -174,10 +174,10 @@ def setupWebviews(self):
jsinc = ["jquery.js","browsersel.js",
"mathjax/conf.js", "mathjax/MathJax.js",
"reviewer.js"]
pform.frontWeb.stdHtml(self.mw.reviewer._revHtml,
pform.frontWeb.stdHtml(self.mw.reviewer.revHtml(),
css=["reviewer.css"],
head=base, js=jsinc)
pform.backWeb.stdHtml(self.mw.reviewer._revHtml,
pform.backWeb.stdHtml(self.mw.reviewer.revHtml(),
css=["reviewer.css"],
head=base, js=jsinc)
@@ -290,7 +290,8 @@ def _renderPreview(self):
q = ti(mungeQA(self.mw.col, c.q(reload=True)))
a = ti(mungeQA(self.mw.col, c.a()), type='a')
self.pform.frontWeb.eval("_showQuestion(%s,'%s');" % (json.dumps(q), bodyclass))
# use _showAnswer to avoid the longer delay
self.pform.frontWeb.eval("_showAnswer(%s,'%s');" % (json.dumps(q), bodyclass))
self.pform.backWeb.eval("_showAnswer(%s, '%s');" % (json.dumps(a), bodyclass))
clearAudioQueue()
View
@@ -117,16 +117,19 @@ def replayAudio(self, previewer=None):
# Initializing the webview
##########################################################################
_revHtml = """
def revHtml(self):
extra = self.mw.col.conf.get("reviewExtra", "")
return f"""
<img src="qrc:/icons/rating.png" id=star class=marked>
<div id=qa></div>
{extra}
"""
def _initWeb(self):
self._reps = 0
base = self.mw.baseHTML()
# main window
self.web.stdHtml(self._revHtml,
self.web.stdHtml(self.revHtml(),
head=base,
css=["reviewer.css"],
js=["jquery.js",

0 comments on commit 55b7825

Please sign in to comment.