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 / wordpress snippet
Created January 24, 2017 12:47
wordpress snippet
<?php echo date('Y'); ?> - copy дата футер
<?php echo the_time(''); ?> - время публикации
function custom_expert_lenght{
return 45;
}
add_filter('expert_lenght','custom_expert_lenght'); - длина символов в превью блога
//в самой view
<?php echo the_excerpt() ;?>
@morethenlife
morethenlife / scroll position
Created April 27, 2016 07:53
scroll position
var top_show = 150;
var delay = 1000;
$(document).ready(function() {
$(window).scroll(function () {
if ($(this).scrollTop() > top_show) $('#top').fadeIn();
else $('#top').fadeOut();
});
$('#top').click(function () {
$('body, html').animate({
scrollTop: 0
@morethenlife
morethenlife / проверка класса в блоке
Created February 11, 2016 12:28
проверка класса в блоке
$('.form').each(function () {
if ( $("group__input").hasClass("icon__invalid") ) {
$(".group__label").addClass("group__label_color");
}
});
@morethenlife
morethenlife / redirect mobile-version
Created January 23, 2016 11:44
redirect mobile-version
/// REDIRECT TO m.truvile.ru
(function(window) {
var width = -1;
//var height = -1;
if (window.screen.width) {
width = parseInt(window.screen.width);
}
@morethenlife
morethenlife / data atribite
Created January 21, 2016 12:00
data atribite
$('.event').on('click', function() {
var event_number = $(this).data('event');
$('.wrapper_popup_services[data-article="' + event_number + '"]').addClass('popup_close_open').removeClass('popup_close');
$('.popup_servises').addClass('servises_delay');
});
@morethenlife
morethenlife / fixed menu
Created January 21, 2016 10:15
fixed menu
// Фикмированная шапка при скролле
$("#header").removeClass("nav_header--clone");
$(window).scroll(function(){
if ($(this).scrollTop() > 300) {
$("#header").addClass("nav_header--clone").fadeIn('slow');
} else {
$("#header").removeClass("nav_header--clone").fadeIn('slow');
};
});
@morethenlife
morethenlife / resize jquery
Created December 13, 2015 22:48
resize jquery
(function($) {
var $window = $(window),
$html = $('.header_s');
$window.resize(function resize(){
if ($window.width() < 480) {
return $html.addClass('mobile_bg');
}
$html.removeClass('mobile');
@morethenlife
morethenlife / Липкая навигация
Created September 15, 2015 14:48
Липкая навигация
$(document).ready(function(){
var $menu = $("#nav_top");
$(window).scroll(function(){
if ( $(this).scrollTop() > 200 && $menu.hasClass("default") ){
$menu.fadeOut('fast',function(){
$(this).removeClass("default")
.addClass("fixed transbg")
@morethenlife
morethenlife / липкий слайдер
Created June 2, 2015 10:21
липкий слайдер
js:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var HeaderTop = $('#header').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > HeaderTop ) {
$('#header').css({position: 'fixed', top: '0px'});
} else {
@morethenlife
morethenlife / jquery заметки
Last active August 16, 2018 16:31
jquery заметки
$(document).ready(function)(){
//вызов функции после полной прогрузки DOM дерева
};
var $j = jQuery.noConflict(); //используеться в том случае если подключенны стороние библиотеки
//вывод нужных элементов на страницу
document .images
document .links
document .forms