mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
focus field on image click
This commit is contained in:
parent
e40c4483a9
commit
c1ea7f6d52
1 changed files with 19 additions and 3 deletions
|
|
@ -40,7 +40,7 @@ _html = """
|
||||||
.fname { font-size: 10px; vertical-align: middle; padding: 0;
|
.fname { font-size: 10px; vertical-align: middle; padding: 0;
|
||||||
font-family: "%s"; }
|
font-family: "%s"; }
|
||||||
#dupes { font-size: 12px; }
|
#dupes { font-size: 12px; }
|
||||||
img { max-width: 100%%; }
|
img { max-width: 90%%; }
|
||||||
body { margin: 5px; }
|
body { margin: 5px; }
|
||||||
</style><script>
|
</style><script>
|
||||||
%s
|
%s
|
||||||
|
|
@ -199,7 +199,7 @@ function setFields(fields, focusTo) {
|
||||||
txt += "<div id=f{0} onkeydown='onKey();' onmouseup='onKey();'".format(i);
|
txt += "<div id=f{0} onkeydown='onKey();' onmouseup='onKey();'".format(i);
|
||||||
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
|
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
|
||||||
txt += "ondragover='onDragOver(this);' ";
|
txt += "ondragover='onDragOver(this);' ";
|
||||||
txt += "contentEditable=true>{0}</div>".format(f);
|
txt += "contentEditable=true class=field>{0}</div>".format(f);
|
||||||
txt += "</td></tr>";
|
txt += "</td></tr>";
|
||||||
}
|
}
|
||||||
$("#fields").html("<table cellpadding=0 width=100%%>"+txt+"</table>");
|
$("#fields").html("<table cellpadding=0 width=100%%>"+txt+"</table>");
|
||||||
|
|
@ -242,7 +242,23 @@ document.body.onmousedown = function () {
|
||||||
|
|
||||||
document.body.onmouseup = function () {
|
document.body.onmouseup = function () {
|
||||||
mouseDown--;
|
mouseDown--;
|
||||||
}});
|
}
|
||||||
|
|
||||||
|
document.onclick = function (evt) {
|
||||||
|
var src = window.event.srcElement;
|
||||||
|
if (src.tagName == "IMG") {
|
||||||
|
// image clicked; find contenteditable parent
|
||||||
|
var p = src;
|
||||||
|
while (p = p.parentNode) {
|
||||||
|
if (p.className == "field") {
|
||||||
|
$("#"+p.id).focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
</script></head><body>
|
</script></head><body>
|
||||||
<div id="fields"></div>
|
<div id="fields"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue