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 ua = window.navigator.userAgent.toLowerCase(); | |
const isIe = (/trident/gi).test(ua) || (/msie/gi).test(ua); | |
const goToTarget = function (target) { // фолбэк для ie11 | |
const y = target.offsetTop; | |
const moveTo = function () { | |
if (window.pageYOffset < y) { | |
window.scrollBy(0, 60); | |
setTimeout(moveTo); |
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 debounce(func, ms) { | |
let timeout; | |
return () => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
func(); | |
}, ms); | |
}; | |
} |
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 COUNTRY_CODE = 7; | |
const onInputPhoneInput = ({target}) => { | |
const matrix = `+${COUNTRY_CODE} (___) ___-__-__`; | |
let counter = 0; | |
let val = target.value.replace(/\D/g, ''); | |
if (!val.length) { | |
val = `${COUNTRY_CODE}`; | |
} |
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 range = document.querySelector('.range'); | |
const thumb = document.querySelector('.range__thumb'); | |
let isTouch = false; | |
let touch = 'pointerdown'; | |
let touchMove = 'pointermove'; | |
let touchUp = 'pointerup'; | |
if ('ontouchstart' in window) { | |
isTouch = true; | |
touch = 'touchstart'; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Slider Demo</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<wc-slider min="50" max="200" step="0" value="100"></wc-slider> |
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 Template from './template.js'; | |
export default class Dbrange extends HTMLElement { | |
constructor() { | |
super(); | |
this.root = this.attachShadow({mode: 'open'}); | |
this.root.innerHTML = Template.render(); | |
this.dom = Template.mapDOM(this.root); | |
this.eventNames = { | |
pointerdown: 'pointerdown', |
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 showPassword = (btn) => { | |
const input = btn.parentElement.querySelector('input'); | |
if (btn.classList.contains('show')) { | |
btn.classList.remove('show'); | |
input.type = 'password'; | |
} else { | |
btn.classList.add('show'); | |
input.type = 'text'; |
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
<fieldset class="rating"> | |
<legend class="visually-hidden">Звездный рейтинг</legend> | |
<input id="film-1" type="radio" name="film" value="1"> | |
<input id="film-2" type="radio" name="film" value="2"> | |
<input id="film-3" type="radio" name="film" value="3"> | |
<input id="film-4" type="radio" name="film" value="4" checked> | |
<input id="film-5" type="radio" name="film" value="5"> | |
<label for="film-5" aria-label="5 звезд"> | |
<svg width="44" height="43"> |
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
input.addEventListener('keypress', function(e) { | |
if(/\D/.test(e.key)) { | |
e.preventDefault(); | |
} | |
const len = input.value.length; | |
if(len === 1 || len === 4) { | |
setTimeout(() => { | |
input.value += '/'; | |
}) |