mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Remove some unnecessary jQuery, replace some toggles with classList.toggle
This commit is contained in:
parent
27a1e81088
commit
5b24e5c522
1 changed files with 9 additions and 17 deletions
|
@ -167,11 +167,8 @@ function onInput(): void {
|
||||||
function updateButtonState(): void {
|
function updateButtonState(): void {
|
||||||
const buts = ["bold", "italic", "underline", "superscript", "subscript"];
|
const buts = ["bold", "italic", "underline", "superscript", "subscript"];
|
||||||
for (const name of buts) {
|
for (const name of buts) {
|
||||||
if (document.queryCommandState(name)) {
|
const elem = document.querySelector(`#${name}`) as HTMLElement;
|
||||||
$(`#${name}`).addClass("highlighted");
|
elem.classList.toggle("highlighted", document.queryCommandState(name));
|
||||||
} else {
|
|
||||||
$(`#${name}`).removeClass("highlighted");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: forecolor
|
// fixme: forecolor
|
||||||
|
@ -179,12 +176,8 @@ function updateButtonState(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEditorButton(buttonid: string): void {
|
function toggleEditorButton(buttonid: string): void {
|
||||||
const button = $(buttonid);
|
const button = $(buttonid)[0];
|
||||||
if (button.hasClass("highlighted")) {
|
button.classList.toggle("highlighted");
|
||||||
button.removeClass("highlighted");
|
|
||||||
} else {
|
|
||||||
button.addClass("highlighted");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFormat(cmd: string, arg?: any, nosave: boolean = false): void {
|
function setFormat(cmd: string, arg?: any, nosave: boolean = false): void {
|
||||||
|
@ -400,11 +393,8 @@ function setFields(fields: [string, string][]): void {
|
||||||
|
|
||||||
function setBackgrounds(cols: "dupe"[]) {
|
function setBackgrounds(cols: "dupe"[]) {
|
||||||
for (let i = 0; i < cols.length; i++) {
|
for (let i = 0; i < cols.length; i++) {
|
||||||
if (cols[i] === "dupe") {
|
const element = document.querySelector(`#f${i}`)
|
||||||
$(`#f${i}`).addClass("dupe");
|
element.classList.toggle("dupe", cols[i] === "dupe")
|
||||||
} else {
|
|
||||||
$(`#f${i}`).removeClass("dupe");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +436,9 @@ let filterHTML = function (
|
||||||
extendedMode: boolean
|
extendedMode: boolean
|
||||||
): string {
|
): string {
|
||||||
// wrap it in <top> as we aren't allowed to change top level elements
|
// wrap it in <top> as we aren't allowed to change top level elements
|
||||||
const top = $.parseHTML(`<ankitop>${html}</ankitop>`)[0] as Element;
|
const top = document.createElement("ankitop")
|
||||||
|
top.innerHTML = html;
|
||||||
|
|
||||||
if (internal) {
|
if (internal) {
|
||||||
filterInternalNode(top);
|
filterInternalNode(top);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue