mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
eslint fixes
This commit is contained in:
parent
65bd3945e7
commit
02808f88e6
2 changed files with 20 additions and 13 deletions
|
@ -21,7 +21,7 @@ RELEASE_API = env(
|
||||||
PAGE_LENGTH = env("PAGE_LENGTH", 15)
|
PAGE_LENGTH = env("PAGE_LENGTH", 15)
|
||||||
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
|
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
|
||||||
|
|
||||||
JS_CACHE = "a60e5a55"
|
JS_CACHE = "c7144efb"
|
||||||
|
|
||||||
# email
|
# email
|
||||||
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")
|
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")
|
||||||
|
|
|
@ -48,8 +48,10 @@ class TabGroup {
|
||||||
|
|
||||||
initTabs() {
|
initTabs() {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for (let tab of this.tabs) {
|
for (let tab of this.tabs) {
|
||||||
let isSelected = tab.getAttribute("aria-selected") === "true";
|
let isSelected = tab.getAttribute("aria-selected") === "true";
|
||||||
|
|
||||||
tab.setAttribute("tabindex", isSelected ? "0" : "-1");
|
tab.setAttribute("tabindex", isSelected ? "0" : "-1");
|
||||||
|
|
||||||
tab.addEventListener("click", this.clickEventListener.bind(this));
|
tab.addEventListener("click", this.clickEventListener.bind(this));
|
||||||
|
@ -64,6 +66,7 @@ class TabGroup {
|
||||||
let selectedPanelId = this.tablist
|
let selectedPanelId = this.tablist
|
||||||
.querySelector('[role="tab"][aria-selected="true"]')
|
.querySelector('[role="tab"][aria-selected="true"]')
|
||||||
.getAttribute("aria-controls");
|
.getAttribute("aria-controls");
|
||||||
|
|
||||||
for (let panel of this.panels) {
|
for (let panel of this.panels) {
|
||||||
if (panel.getAttribute("id") !== selectedPanelId) {
|
if (panel.getAttribute("id") !== selectedPanelId) {
|
||||||
panel.setAttribute("hidden", "");
|
panel.setAttribute("hidden", "");
|
||||||
|
@ -82,16 +85,18 @@ class TabGroup {
|
||||||
|
|
||||||
// Handle keydown on tabs
|
// Handle keydown on tabs
|
||||||
keydownEventListener(event) {
|
keydownEventListener(event) {
|
||||||
var key = event.keyCode;
|
const key = event.keyCode;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case this.keys.end:
|
case this.keys.end:
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Activate last tab
|
// Activate last tab
|
||||||
this.activateTab(this.tabs[this.tabs.length - 1]);
|
this.activateTab(this.tabs[this.tabs.length - 1]);
|
||||||
break;
|
break;
|
||||||
case this.keys.home:
|
case this.keys.home:
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Activate first tab
|
// Activate first tab
|
||||||
this.activateTab(this.tabs[0]);
|
this.activateTab(this.tabs[0]);
|
||||||
break;
|
break;
|
||||||
|
@ -107,7 +112,7 @@ class TabGroup {
|
||||||
|
|
||||||
// Handle keyup on tabs
|
// Handle keyup on tabs
|
||||||
keyupEventListener(event) {
|
keyupEventListener(event) {
|
||||||
var key = event.keyCode;
|
const key = event.keyCode;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case this.keys.left:
|
case this.keys.left:
|
||||||
|
@ -121,9 +126,9 @@ class TabGroup {
|
||||||
// only up and down arrow should function.
|
// only up and down arrow should function.
|
||||||
// In all other cases only left and right arrow function.
|
// In all other cases only left and right arrow function.
|
||||||
determineOrientation(event) {
|
determineOrientation(event) {
|
||||||
var key = event.keyCode;
|
const key = event.keyCode;
|
||||||
var vertical = this.tablist.getAttribute("aria-orientation") == "vertical";
|
const vertical = this.tablist.getAttribute("aria-orientation") == "vertical";
|
||||||
var proceed = false;
|
let proceed = false;
|
||||||
|
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
if (key === this.keys.up || key === this.keys.down) {
|
if (key === this.keys.up || key === this.keys.down) {
|
||||||
|
@ -144,14 +149,15 @@ class TabGroup {
|
||||||
// Either focus the next, previous, first, or last tab
|
// Either focus the next, previous, first, or last tab
|
||||||
// depending on key pressed
|
// depending on key pressed
|
||||||
switchTabOnArrowPress(event) {
|
switchTabOnArrowPress(event) {
|
||||||
var pressed = event.keyCode;
|
const pressed = event.keyCode;
|
||||||
|
|
||||||
for (let tab of this.tabs) {
|
for (let tab of this.tabs) {
|
||||||
tab.addEventListener("focus", this.focusEventHandler.bind(this));
|
tab.addEventListener("focus", this.focusEventHandler.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.direction[pressed]) {
|
if (this.direction[pressed]) {
|
||||||
var target = event.target;
|
const target = event.target;
|
||||||
|
|
||||||
if (target.index !== undefined) {
|
if (target.index !== undefined) {
|
||||||
if (this.tabs[target.index + this.direction[pressed]]) {
|
if (this.tabs[target.index + this.direction[pressed]]) {
|
||||||
this.tabs[target.index + this.direction[pressed]].focus();
|
this.tabs[target.index + this.direction[pressed]].focus();
|
||||||
|
@ -185,7 +191,7 @@ class TabGroup {
|
||||||
tab.classList.add("is-active");
|
tab.classList.add("is-active");
|
||||||
|
|
||||||
// Get the value of aria-controls (which is an ID)
|
// Get the value of aria-controls (which is an ID)
|
||||||
var controls = tab.getAttribute("aria-controls");
|
const controls = tab.getAttribute("aria-controls");
|
||||||
|
|
||||||
// Remove hidden attribute from tab panel to make it visible
|
// Remove hidden attribute from tab panel to make it visible
|
||||||
document.getElementById(controls).removeAttribute("hidden");
|
document.getElementById(controls).removeAttribute("hidden");
|
||||||
|
@ -221,11 +227,12 @@ class TabGroup {
|
||||||
// Determine whether there should be a delay
|
// Determine whether there should be a delay
|
||||||
// when user navigates with the arrow keys
|
// when user navigates with the arrow keys
|
||||||
determineDelay() {
|
determineDelay() {
|
||||||
var hasDelay = this.tablist.hasAttribute("data-delay");
|
const hasDelay = this.tablist.hasAttribute("data-delay");
|
||||||
var delay = 0;
|
let delay = 0;
|
||||||
|
|
||||||
if (hasDelay) {
|
if (hasDelay) {
|
||||||
var delayValue = this.tablist.getAttribute("data-delay");
|
const delayValue = this.tablist.getAttribute("data-delay");
|
||||||
|
|
||||||
if (delayValue) {
|
if (delayValue) {
|
||||||
delay = delayValue;
|
delay = delayValue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,7 +245,7 @@ class TabGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
focusEventHandler(event) {
|
focusEventHandler(event) {
|
||||||
var target = event.target;
|
const target = event.target;
|
||||||
|
|
||||||
setTimeout(this.checkTabFocus.bind(this), this.delay, target);
|
setTimeout(this.checkTabFocus.bind(this), this.delay, target);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue