const addInputMaskPhone = () => {
$(document)
.on('input', '.js-input-phone', maskPhone)
.on('focus', '.js-input-phone', maskPhone)
.on('blur', '.js-input-phone', maskPhone)
.on('keydown', '.js-input-phone', maskPhone)
}
let keyCode
function maskPhone(event) {
event.keyCode && (keyCode = event.keyCode)
var pos = this.selectionStart
if (pos < 3) event.preventDefault()
const matrix = '+7 (___) ___-__-__'
let i = 0
const def = matrix.replace(/\D/g, '')
const val = this.value.replace(/\D/g, '')
let newValue = matrix.replace(/[_\d]/g, function (a) {
return i < val.length ? val.charAt(i++) || def.charAt(i) : a
})
i = newValue.indexOf('_')
if (i !== -1) {
i < 5 && (i = 3)
newValue = newValue.slice(0, i)
}
var reg = matrix
.substr(0, this.value.length)
.replace(/_+/g, function (a) {
return '\\d{1,' + a.length + '}'
})
.replace(/[+()]/g, '\\$&')
reg = new RegExp('^' + reg + '$')
if (
!reg.test(this.value) ||
this.value.length < 5 ||
(keyCode > 47 && keyCode < 58)
)
this.value = newValue
if (event.type === 'focusout' && this.value.length < 18) this.value = ''
}
addInputMaskPhone()
.mt-5 {
margin-top: 3rem!important;
}
.gallery__items {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.gallery__item {
width: 50%;
}
@font-face {
font-family: [УКАЗЫВАЕТЕ_НАЗВАНИЕ_ШРИФТА];
src: url('[ПУТЬ_ДО_ФАЙЛА_ШРИФТА.woff]') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
gulp.task('css', (callback) => {
return gulp.src('./src/css/*.css')
.pipe(gulp.dest('./build/css/'))
.pipe(browserSync.stream())
callback()
});
const path = {
css: {
src: srcPath + 'sass/*.sass',
app: appPath + 'css/',
build: buildPath + 'css/',
watch: srcPath + 'sass/**/*.{sass,scss}'
},
}
function css(cb) {
return src(path.css.src, {base: srcPath + 'sass/'})
.pipe(newer(path.css.app + '*.css'))
.pipe(sourcemaps.init())
.pipe(plumber({
errorHandler: function (err) {
notify.onError({
title: 'SASS Error',
message: 'Error <%= error.message %>'
})(err)
this.emit('end')
}
}))
.pipe(sass({
includePaths: './node_modules/'
}))
.pipe(autoprefixer({
cascade: true,
remove: false
}))
.pipe(sourcemaps.write())
.pipe(rename({
suffix: '.min',
extname: '.css'
}))
.pipe(dest(path.css.app))
cb()
}