mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -05:00
Merge pull request #936 from hgiesel/editorresize
Leave resizing of editor top buttons to CSS
This commit is contained in:
commit
a1e8e6d9df
3 changed files with 9 additions and 41 deletions
|
|
@ -34,12 +34,10 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
#topbutsOuter {
|
#topbutsOuter {
|
||||||
position: fixed;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
padding: 2px;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
padding: 2px;
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.topbut {
|
.topbut {
|
||||||
|
|
@ -94,10 +92,6 @@ button.highlighted {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#fields {
|
|
||||||
margin-top: 35px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dupe {
|
.dupe {
|
||||||
background: var(--flag1-bg);
|
background: var(--flag1-bg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -606,31 +606,3 @@ let filterNode = function (node: Node, extendedMode: boolean): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let adjustFieldsTopMargin = function (): void {
|
|
||||||
const topHeight = $("#topbuts").height();
|
|
||||||
const margin = topHeight + 8;
|
|
||||||
document.getElementById("fields").style.marginTop = `${margin}px`;
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener("click", (evt: MouseEvent): void => {
|
|
||||||
const src = evt.target as Element;
|
|
||||||
if (src.tagName === "IMG") {
|
|
||||||
// image clicked; find contenteditable parent
|
|
||||||
let p = src;
|
|
||||||
while ((p = p.parentNode as Element)) {
|
|
||||||
if (p.className === "field") {
|
|
||||||
document.getElementById(p.id).focus();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
adjustFieldsTopMargin();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(function (): void {
|
|
||||||
adjustFieldsTopMargin();
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,14 @@ _html = """
|
||||||
html { background: %s; }
|
html { background: %s; }
|
||||||
#topbutsOuter { background: %s; }
|
#topbutsOuter { background: %s; }
|
||||||
</style>
|
</style>
|
||||||
<div id="topbutsOuter">
|
<div>
|
||||||
<div id="topbuts" class="clearfix">
|
<div id="topbutsOuter">
|
||||||
%s
|
<div id="topbuts" class="clearfix">
|
||||||
|
%s
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="fields">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div id="fields">
|
|
||||||
</div>
|
</div>
|
||||||
<div id="dupes" style="display:none;">
|
<div id="dupes" style="display:none;">
|
||||||
<a href="#" onclick="pycmd('dupes');return false;">
|
<a href="#" onclick="pycmd('dupes');return false;">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue