Skip to content

Instantly share code, notes, and snippets.

View dkruchok's full-sized avatar

Dima Kruchok dkruchok

View GitHub Profile
<?php
$post = $wp_query->post;
if (in_category('cat_label_1')) {
include(TEMPLATEPATH.'/single-cat_label_1.php');
} elseif (in_category('cat_label_2')) {
include(TEMPLATEPATH.'/single-cat_label_2.php');
}
?>
@dkruchok
dkruchok / Scroll detect
Created May 21, 2015 18:44
Фиксривованый хедер после скрола в низ
$(window).scroll(function() {
if ($(document).scrollTop() > 130) {
$("body").addClass("top_menu_small");
} else {
$("body").removeClass("top_menu_small");
}
});
@dkruchok
dkruchok / Custom hover hide block
Created May 21, 2015 18:57
Всплывашка блока при наведении.
<div class="cont">
<ul>
<li>
<a href="#">
<h3>title</h3>
</a>
<div class="hide_block">
<div class="hide_block_inner">
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae.</div>
@dkruchok
dkruchok / jq for iphone
Created May 21, 2015 19:00
Iphone click function
$(document).on('touchstart click', '.class', function() {
$(".menu_container").fadeIn(600)
});
$(document).on('touchstart click', '.class to close', function() {
$(".menu_container").fadeOut(600)
});
@dkruchok
dkruchok / slider for current
Created May 21, 2015 19:02
My custom slider for current picture
var small = $(".from litle a img"),
big = $(".to big img");
small.each(function(i, el) {
var next = i + 1 == small.size() ? 0 : i + 1;
$(el)
.click(
function(event) {
event.preventDefault();
if (big.data("next") == next) return;
big.fadeTo(500, 0.1, function() {
@dkruchok
dkruchok / common.js
Created May 22, 2015 12:27
Выезд меню сбоку боди
/* Push the body and the nav over by 285px over
$('.nav.burger a').click(function() {
$('.hidden_menu').animate({
left: "0px"
}, 200);
$('body').animate({
left: "285px"
}, 200);
});*/
@dkruchok
dkruchok / loop wp
Last active October 20, 2015 22:23
WP Loop with query
<?php
if ( have_posts() ) : // если имеются записи в блоге.
query_posts('cat=3'); // указываем ID рубрик, которые необходимо вывести.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; // завершаем цикл.
endif;
/* Сбрасываем настройки цикла. Если ниже по коду будет идти еще один цикл, чтобы не было сбоя. */
wp_reset_query();
@dkruchok
dkruchok / Valid DISPLAY NONE
Created June 2, 2015 10:50
Valid DISPLAY NONE
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}
@dkruchok
dkruchok / Scroll to ID
Created June 3, 2015 10:32
Scroll to ID
/*Scroll to ID*/
// handle links with @href started with '#' only
$(document).on('click', '.pages-smaller ul li a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
@dkruchok
dkruchok / User Webcam and Audio
Created June 21, 2015 11:25
User Webcam and Audio
/* Get user WebCam*/
<script>
navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
if (navigator.getUserMedia) {
navigator.getUserMedia (