Skip to content

Instantly share code, notes, and snippets.

View Korobeynik's full-sized avatar

Yura Korobeynik Korobeynik

View GitHub Profile
@Korobeynik
Korobeynik / index.html
Last active June 5, 2019 13:20
Event delegation
<body>
<div id="content">
<p>lorem 1</p>
<p>lorem 2</p>
<p>lorem 3</p>
<p>lorem 4</p>
<p>lorem 5</p>
</div>
<script>
$('a[href^="#"]').click(function(e) {
e.preventDefault();
var target = this.hash;
$('html, body').animate({
scrollTop: $(target).offset().top
}, 500);
return false;
})
</script>
@Korobeynik
Korobeynik / common.js
Created April 19, 2018 14:26
WP Ajax, some examples
$(function() {
//item_service--white
$('#menu-header-menu a').click( function (){
$('#menuButton').toggleClass('is-active');
$('.headerNavigation').toggleClass('collapsed');
});
@Korobeynik
Korobeynik / Loop_wp.php
Last active July 19, 2018 08:41
wp ACF repeater while
<div class="partners"><?php the_field('partners_title') ?></div>
<?php if(get_field('partners')): ?>
<div class="partners_logo container">
<?php while(has_sub_field('partners')): ?>
<a href="<?php the_sub_field('partners_link'); ?>">
<img src="<?php the_sub_field('partners_logo'); ?>" alt="">
</a>
<?php endwhile; ?>
</div>
<?php endif; ?>
@Korobeynik
Korobeynik / js, wordpress
Created March 1, 2018 09:17
Как выделить активный пункт меню
$(function () {
$('#menu a').each(function () {
var location = window.location.href;
var link = this.href;
if(location == link) {
$(this).addClass('active');
}
});
});
var price = 28.99;
var discount = 10;
var total = price - (price * (discount / 100));
if (total > 25) {
freeShipping();
}
@Korobeynik
Korobeynik / wp.php
Created November 29, 2017 10:42
Displaying the menu and removing extra classes
<?php
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var)
{
return is_array($var) ? array_intersect($var, array('current-menu-item')) : '';
<?php
/**
* The template for displaying the front page.
*
* This is the template that displays on the front page only.
*
* @package alessa
*/
get_header(); ?>
@Korobeynik
Korobeynik / common.js
Created November 24, 2017 09:36
JS features
window.onload = function() {
let clipLink = document.getElementById('clip_link').onclick = function(event){
CopyLink();
return false;
}
let watchBtn = document.querySelector('#watch');
function showWatchBtn () {
@Korobeynik
Korobeynik / button.sass
Created March 30, 2017 22:18 — forked from agragregra/button.sass
Button Sass Styles (Universal Starter)
.button
display: inline-block
border: none
color: #fff
text-decoration: none
background-color: $accent
padding: 15px 45px
font-size: 13px
text-transform: uppercase
font-weight: 600