Skip to content

Instantly share code, notes, and snippets.

View Korveld's full-sized avatar

Kirill Titov Korveld

View GitHub Profile
@Korveld
Korveld / Disable br and p tags in contat form 7
Last active September 9, 2020 10:10
Disable br and p tags in contat form 7
<?php
add_filter('wpcf7_autop_or_not', '__return_false');
@Korveld
Korveld / Count up and down with buttons
Last active September 9, 2020 10:09
Count up and down with buttons
jQuery(document).ready(function ($) {
$('.counter__input').on('keypress keyup blur', function (e) {
$(this).val( $(this).val().replace(/[^\d].+/, "") )
if ((e.which < 48 || e.which > 57)) {
e.preventDefault()
}
})
var addInput = '.counter__input' //This is the id of the input you are changing
@Korveld
Korveld / Bootstrap forms validation
Last active September 9, 2020 10:09
Bootstrap forms validation
window.addEventListener('load', function() {
var modalSuccess = document.getElementsByClassName('modal__success')[0]
var forms = document.getElementsByClassName('needs-validation')
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(e) {
if (form.checkValidity() === false) {
form.classList.add('was-validated')
} else {
@Korveld
Korveld / Faq accordion script
Last active September 9, 2020 10:09
Faq accordion script
jQuery(document).ready(function ($) {
var part = $('.part')
var partHeader = $('.part__header')
var partContent = $('.part__content')
partHeader.on('click', function (e) {
e.preventDefault()
var partClose = function () {
@Korveld
Korveld / sublime text 3 - mac fix to install plugins
Last active September 9, 2020 10:09
sublime text 3 - mac fix to install plugins
"downloader_precedence": {
"windows": ["wininet"],
"osx": ["curl", "urllib"],
"linux": ["urllib", "curl", "wget"]
},
@Korveld
Korveld / Slick slider space between slides
Last active September 9, 2020 10:09
Slick slider space between slides
/* the slides */
.slick-slide {
margin: 0 10px;
}
/* the parent */
.slick-list {
margin: 0 -10px;
}
@Korveld
Korveld / Slick slider count slides
Created September 10, 2020 09:53
Slick slider count slides
// If slides to show more than one
$('.compare__items-row').on('init reInit afterChange', function(event, slick, currentSlide, nextSlide) {
var i = (currentSlide ? currentSlide : 0) + 1
var slidesToShow = slick.slickGetOption('slidesToShow')
var curPage = parseInt((i-1)/slidesToShow) + 1
var lastPage = parseInt((slick.slideCount-1)/slidesToShow) + 1
$('.compare__slider-info--current').text(curPage)
$('.compare__slider-info--all').text(lastPage)
})
@Korveld
Korveld / Preview an image before it is uploaded on input file upload
Last active October 8, 2020 07:46
Preview an image before it is uploaded on input file upload
var readURL = function(input) {
if (input.files && input.files[0]) {
var reader = new FileReader()
reader.onload = function(e) {
$('.photo__img-wrap img').attr('src', e.target.result)
}
reader.readAsDataURL(input.files[0])
}
}
@Korveld
Korveld / Horizontal scrolling via drag and mousewheel with custom scrollbar
Last active December 27, 2020 20:47
Horizontal scrolling via drag and mousewheel with custom scrollbar
/*
Plugins
Perfect Scrollbar: https://github.com/mdbootstrap/perfect-scrollbar
jQuery Mouse Wheel: https://github.com/jquery/jquery-mousewheel
*/
var drag = $('.js-drag')
var ps = new PerfectScrollbar('.js-drag');
drag.mousewheel(function(event, delta) {
@Korveld
Korveld / PowerShell remove certain letters from multiple files
Created January 4, 2021 11:54
PowerShell remove certain letters from multiple files
get-childitem *.jpg | foreach { rename-item $_ $_.Name.Replace("-min", "") }