Skip to content

Instantly share code, notes, and snippets.

View morethenlife's full-sized avatar
🏠
Working from home

Roman Kopka morethenlife

🏠
Working from home
View GitHub Profile
@morethenlife
morethenlife / index.html
Created December 24, 2019 13:57 — forked from Sharifur/index.html
Vertical slider w/ parallax — Swiper + GSAP
<div id="js-cta-slider" class="cta__slider-wrapper swiper-container">
<div class="swiper-wrapper cta__slider">
<!-- SLIDER ITEM -->
<div class="cta__slider-item swiper-slide">
<picture class="media-wrapper slide-inner">
<img src="http://deghq.com/yapp/front-labs/codepen-assets/slide-4.jpg" alt="Degordian">
</picture>
</div>
<!-- SLIDER ITEM -->
<?php if( have_rows('faqs') ): ?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php $i=1; while ( have_rows('faqs') ) : the_row(); ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-<?php echo $i; ?>">
<h2 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('question'); ?>
</a>
</h2>
@morethenlife
morethenlife / Отправка формы ajax
Last active May 29, 2019 12:18
Отправка формы ajax
<!-- mail.php-->
<?php
//Принимаем постовые данные
$name=$_POST['name'];
$phone=$_POST['phone'];
//Тут указываем, на какой ящик посылать письмо
$to = "morflot88@gmail.com";
//Далее идет тема и само сообщение
// Тема письма
@morethenlife
morethenlife / правильное склонение
Created March 13, 2019 16:27
правильное склонение
function num2str(n, text_forms) {
n = Math.abs(n) % 100; var n1 = n % 10;
if (n > 10 && n < 20) { return text_forms[2]; }
if (n1 > 1 && n1 < 5) { return text_forms[1]; }
if (n1 == 1) { return text_forms[0]; }
return text_forms[2];
}
@morethenlife
morethenlife / smooth scroll
Created March 22, 2018 08:46
smooth scroll
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
@morethenlife
morethenlife / custom scrollbar
Created March 11, 2018 17:46
custom scrollbar
#style-3::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}
#style-3::-webkit-scrollbar
{
width: 6px;
background-color: #F5F5F5;
@morethenlife
morethenlife / SIDEBAR ACCORDION MULTILEVEL MENU
Created February 13, 2018 08:29
SIDEBAR ACCORDION MULTILEVEL MENU
/*
====================================
SIDEBAR ACCORDION MULTILEVEL MENU
====================================
*/
(function($) {
"use strict";
$.fn.navSidebarMultiLevel = function() {
@morethenlife
morethenlife / isMobile
Created February 12, 2018 13:58
isMobile
// делаете переменную в начале кода
var isMobile = false;
// проверка на размер экрана (размер я брал вроде с Bootstrap-а)
$(document).ready( function() {
if ($('body').width() <= 400) {
isMobile = true;
}
// и потом если нужен код только для телефона:
if (isMobile) {
...
@morethenlife
morethenlife / Парсим URL средствами JavaScript
Created April 24, 2017 12:36
Парсим URL средствами JavaScript
function parse_url(href) {
var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);
return match && {
protocol: match[1],
host: match[2],
hostname: match[3],
port: match[4],
pathname: match[5],
search: match[6],
hash: match[7]
@morethenlife
morethenlife / snippet js
Created February 3, 2017 13:14
snippet js
$(window).load(function () {
$('.b-nav-panel').on('click', function (even) {
even.stopPropagation(); //запретили подъем события по дереву DOM
});
});