mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
move webview js into separate file
This commit is contained in:
parent
cd76281695
commit
66500f5262
2 changed files with 18 additions and 19 deletions
|
@ -173,7 +173,8 @@ border-radius:5px; font-family: Helvetica }"""
|
||||||
family = self.font().family()
|
family = self.font().family()
|
||||||
fontspec = 'font-size:14px;font-family:%s;'%\
|
fontspec = 'font-size:14px;font-family:%s;'%\
|
||||||
family
|
family
|
||||||
jstxt = "\n".join(self.bundledScript(fname) for fname in js)
|
jstxt = "\n".join([self.bundledScript("webview.js")]+
|
||||||
|
[self.bundledScript(fname) for fname in js])
|
||||||
|
|
||||||
html="""
|
html="""
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
|
@ -182,24 +183,6 @@ body { zoom: %f; %s }
|
||||||
%s
|
%s
|
||||||
%s</style>
|
%s</style>
|
||||||
%s
|
%s
|
||||||
<script>
|
|
||||||
// prevent backspace key from going back a page
|
|
||||||
document.addEventListener("keydown", function(evt) {
|
|
||||||
if (evt.keyCode != 8) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var isText = 0;
|
|
||||||
var nn = evt.target.nodeName;
|
|
||||||
if (nn == "INPUT" || nn == "TEXTAREA") {
|
|
||||||
isText = 1;
|
|
||||||
} else if (nn == "DIV" && evt.target.contentEditable) {
|
|
||||||
isText = 1;
|
|
||||||
}
|
|
||||||
if (!isText) {
|
|
||||||
evt.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
%s
|
%s
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
16
web/webview.js
Normal file
16
web/webview.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// prevent backspace key from going back a page
|
||||||
|
document.addEventListener("keydown", function (evt) {
|
||||||
|
if (evt.keyCode !== 8) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var isText = 0;
|
||||||
|
var nn = evt.target.nodeName;
|
||||||
|
if (nn === "INPUT" || nn === "TEXTAREA") {
|
||||||
|
isText = 1;
|
||||||
|
} else if (nn === "DIV" && evt.target.contentEditable) {
|
||||||
|
isText = 1;
|
||||||
|
}
|
||||||
|
if (!isText) {
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue