This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const changeTab = (currentTab) => { | |
const emptyEl = document.createElement('div'); | |
const tabContainer = currentTab.closest('.tab-container'); | |
if (!tabContainer) return; | |
const activeTab = tabContainer.querySelector('.tab-title[aria-selected="true"]') || emptyEl; | |
activeTab.removeAttribute('aria-selected'); | |
activeTab.setAttribute('tabindex', '-1'); | |
currentTab.setAttribute('aria-selected', 'true'); | |
currentTab.removeAttribute('tabindex'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const fileLoaderContainers = document.querySelectorAll('.file-loader'); | |
const renderFileLoader = function(fileLoaderContainer) { | |
const wrapper = fileLoaderContainer.querySelector('.file-loader__wrapper'); | |
const btnAdd = fileLoaderContainer.querySelector('.js-fileloader-open'); | |
if (!wrapper || !btnAdd) { | |
return; | |
} | |
const inputFileLoader = wrapper.querySelector('.file-loader__item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const tooltipToggle = (btn) => { | |
const content = btn.nextElementSibling; | |
if (!content) return; | |
content.classList.toggle('active'); | |
if (content.classList.contains('active')) { | |
const closeContent = ({target}) => { | |
if (!content.contains(target) ) { | |
content.classList.remove('active'); | |
document.removeEventListener('click', closeContent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ResizeObserver from 'resize-observer-polyfill'; | |
export class RotateNumber { | |
constructor(selector) { | |
this.$el = typeof selector === 'string' ? document.querySelector(selector) : selector; | |
if (!(this.$el instanceof HTMLElement)) { | |
return; | |
} | |
this.digits = this.$el.querySelectorAll('.payout__container'); | |
this.maxNumberValue = 9; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const accordionToggle = (selector) => { | |
const accordion = document.querySelector(selector); | |
if (!accordion) return; | |
let previousContent = null; | |
let previousTitle = null; | |
accordion.addEventListener('click', (e) => { | |
const accTitle = e.target.closest('.accordion__title'); | |
if (accTitle) { | |
const accContent = accTitle.nextElementSibling; | |
if (previousContent) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Range { | |
constructor(selector) { | |
this.$el = this.getHtmlElement(selector); | |
if (!this.$el) return; | |
this.min = +this.$el.dataset.min ?? 0; | |
this.max = +this.$el.dataset.max ?? 100; | |
this.dom = this.mapDOM(this.$el); | |
this.eventNames = { | |
pointerdown: 'pointerdown', | |
pointermove: 'pointermove', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const container = document.querySelector('.accordion-container'); | |
const titles = document.querySelectorAll('.accordion-title'); | |
titles.forEach(t => { | |
t.addEventListener('click', ({currentTarget}) => { | |
const contentHeight = currentTarget.nextElementSibling.offsetHeight; | |
container.style.setProperty('--content-height', `${-contentHeight}px`); | |
const accordion = currentTarget.parentElement; | |
if (accordion.classList.contains('accordion-active')) { | |
accordion.classList.remove('accordion-active', 'move-sibling-accordion'); | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function supportsImgType(type) { | |
const img = document.createElement('img'); | |
await document.createElement('picture').append( | |
Object.assign(document.createElement('source'), { | |
srcset: 'data:,x', // валидный урл не дергающий сеть | |
type, | |
}), | |
img | |
); | |
return !!img.currentSrc; // если браузер умеет, заполнит значение currentSrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Dbrange { | |
constructor(selector) { | |
this.$el = this.getHtmlElement(selector); | |
if (!this.$el) return; | |
this.dom = this.mapDOM(this.$el); | |
this.eventNames = { | |
pointerdown: 'pointerdown', | |
pointermove: 'pointermove', | |
pointerup: 'pointerup', | |
}; |
NewerOlder