mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix dupes, but also make sticky, and centered to draw more attention
This commit is contained in:
parent
bec709c7a9
commit
aed38de228
3 changed files with 46 additions and 29 deletions
|
@ -1,6 +1,10 @@
|
||||||
/* Copyright: Ankitects Pty Ltd and contributors
|
/* Copyright: Ankitects Pty Ltd and contributors
|
||||||
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
||||||
|
|
||||||
|
html {
|
||||||
|
background: var(--bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
#fields {
|
#fields {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -22,6 +26,10 @@
|
||||||
.field {
|
.field {
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
background: var(--frame-bg);
|
background: var(--frame-bg);
|
||||||
|
|
||||||
|
&.dupe {
|
||||||
|
background: var(--flag1-bg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fname {
|
.fname {
|
||||||
|
@ -46,6 +54,8 @@ body {
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
|
||||||
|
background: var(--bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.topbuts > * {
|
.topbuts > * {
|
||||||
|
@ -113,13 +123,21 @@ button.highlighted {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dupe {
|
#dupes {
|
||||||
background: var(--flag1-bg);
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
|
||||||
|
&.is-inactive {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#dupes a {
|
a {
|
||||||
color: var(--link);
|
color: var(--link);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.drawing {
|
.drawing {
|
||||||
zoom: 50%;
|
zoom: 50%;
|
||||||
|
|
|
@ -559,12 +559,15 @@ function adjustFieldAmount(amount: number): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function forField<T>(values: T[], func: (value: T, field: EditorField, index: number) => void): void {
|
function forField<T>(
|
||||||
|
values: T[],
|
||||||
|
func: (value: T, field: EditorField, index: number) => void
|
||||||
|
): void {
|
||||||
const fieldContainer = document.getElementById("fields");
|
const fieldContainer = document.getElementById("fields");
|
||||||
const fields = [...fieldContainer.children] as EditorField[];
|
const fields = [...fieldContainer.children] as EditorField[];
|
||||||
|
|
||||||
for (const [index, field] of fields.entries()) {
|
for (const [index, field] of fields.entries()) {
|
||||||
func(values[index], field, index)
|
func(values[index], field, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,13 +579,20 @@ function setFields(fields: [string, string][]): void {
|
||||||
.getPropertyValue("--text-fg");
|
.getPropertyValue("--text-fg");
|
||||||
|
|
||||||
adjustFieldAmount(fields.length);
|
adjustFieldAmount(fields.length);
|
||||||
forField(fields, ([name, fieldContent], field, index) => field.initialize(index, name, color, fieldContent));
|
forField(fields, ([name, fieldContent], field, index) =>
|
||||||
|
field.initialize(index, name, color, fieldContent)
|
||||||
|
);
|
||||||
|
|
||||||
maybeDisableButtons();
|
maybeDisableButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBackgrounds(cols: "dupe"[]) {
|
function setBackgrounds(cols: ("dupe" | "")[]) {
|
||||||
forField(cols, (value, field) => field.classList.toggle("dupe", value === "dupe"));
|
forField(cols, (value, field) =>
|
||||||
|
field.editingContainer.classList.toggle("dupe", value === "dupe")
|
||||||
|
);
|
||||||
|
document
|
||||||
|
.querySelector("#dupes")
|
||||||
|
.classList.toggle("is-inactive", !cols.includes("dupe"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFonts(fonts: [string, number, boolean][]): void {
|
function setFonts(fonts: [string, number, boolean][]): void {
|
||||||
|
@ -595,14 +605,6 @@ function setNoteId(id: number): void {
|
||||||
currentNoteId = id;
|
currentNoteId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDupes(): void {
|
|
||||||
$("#dupes").show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideDupes(): void {
|
|
||||||
$("#dupes").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
let pasteHTML = function (
|
let pasteHTML = function (
|
||||||
html: string,
|
html: string,
|
||||||
internal: boolean,
|
internal: boolean,
|
||||||
|
|
|
@ -73,8 +73,9 @@ audio = (
|
||||||
|
|
||||||
_html = """
|
_html = """
|
||||||
<style>
|
<style>
|
||||||
html { background: %s; }
|
:root {
|
||||||
#topbutsOuter { background: %s; }
|
--bg-color: %s;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div>
|
<div>
|
||||||
<div id="topbutsOuter">
|
<div id="topbutsOuter">
|
||||||
|
@ -82,11 +83,9 @@ html { background: %s; }
|
||||||
</div>
|
</div>
|
||||||
<div id="fields">
|
<div id="fields">
|
||||||
</div>
|
</div>
|
||||||
|
<div id="dupes" class="is-inactive">
|
||||||
|
<a href="#" onclick="pycmd('dupes');return false;">%s</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="dupes" style="display:none;">
|
|
||||||
<a href="#" onclick="pycmd('dupes');return false;">
|
|
||||||
%s
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -219,7 +218,7 @@ class Editor:
|
||||||
bgcol = self.mw.app.palette().window().color().name() # type: ignore
|
bgcol = self.mw.app.palette().window().color().name() # type: ignore
|
||||||
# then load page
|
# then load page
|
||||||
self.web.stdHtml(
|
self.web.stdHtml(
|
||||||
_html % (bgcol, bgcol, topbuts, tr(TR.EDITING_SHOW_DUPLICATES)),
|
_html % (bgcol, topbuts, tr(TR.EDITING_SHOW_DUPLICATES)),
|
||||||
css=["css/editor.css"],
|
css=["css/editor.css"],
|
||||||
js=["js/vendor/jquery.min.js", "js/editor.js"],
|
js=["js/vendor/jquery.min.js", "js/editor.js"],
|
||||||
context=self,
|
context=self,
|
||||||
|
@ -534,9 +533,7 @@ class Editor:
|
||||||
err = self.note.dupeOrEmpty()
|
err = self.note.dupeOrEmpty()
|
||||||
if err == 2:
|
if err == 2:
|
||||||
cols[0] = "dupe"
|
cols[0] = "dupe"
|
||||||
self.web.eval("showDupes();")
|
|
||||||
else:
|
|
||||||
self.web.eval("hideDupes();")
|
|
||||||
self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
|
self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
|
||||||
|
|
||||||
def showDupes(self):
|
def showDupes(self):
|
||||||
|
|
Loading…
Reference in a new issue