Skip to content

Instantly share code, notes, and snippets.

Avatar

Oleg aligator28

View GitHub Profile
@aligator28
aligator28 / request.js
Created Feb 9, 2018 — forked from sheharyarn/request.js
Axios Request Wrapper for React
View request.js
/**
* Axios Request Wrapper
* ---------------------
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
*/
import axios from 'axios'
@aligator28
aligator28 / admin-redirect.php
Created Feb 11, 2017 — forked from kharissulistiyo/admin-redirect.php
Admin Page Redirection After WordPress Theme Activated
View admin-redirect.php
/**
* WordPress snippet
* Admin page redirection
* Put this inside theme setup function
*/
global $pagenow;
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) {
@aligator28
aligator28 / jquery-scroll-bottom.js
Created Jan 9, 2017 — forked from toshimaru/jquery-scroll-bottom.js
Detect the scrolling to bottom of the page using jQuery.
View jquery-scroll-bottom.js
$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});
@aligator28
aligator28 / js image preloading
Created Oct 31, 2016
Images preloading javascript (предзагрузка изображений js)
View js image preloading
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rotate Image</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="row" id="img1"></div>
@aligator28
aligator28 / Add categories to custom post type Wordpress (добавить категории к пользовательскому типу поста)
Last active Oct 20, 2016
Добавить категории к кастом пост тайпу (categories for custom post type) Wordpress
View Add categories to custom post type Wordpress (добавить категории к пользовательскому типу поста)
// add these to functions.php or in Sage to sage/lib/some-file-name.php (do not forget to add in functions.php to load this file)
<?php
//
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if( is_category() ) {
$post_type = get_query_var('post_type');
if($post_type)
View navigation for sage.php
//this is header.php
//do not forget to write in functions.php
//$sage_includes = [
'lib/bootsrap_menu_nav_walker.php',
];
<nav class="navbar navbar-light bg-faded">
<a class="navbar-brand" href="<?= esc_url(home_url('/')); ?>"><?php bloginfo('name'); ?></a>
<button class="navbar-toggler hidden-md-up" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
@aligator28
aligator28 / smooth scroll - плавный скролл по якорям
Created Oct 9, 2016
Плавный скролл по якорям (Smooth scroll)
View smooth scroll - плавный скролл по якорям
$('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);
@aligator28
aligator28 / Dynamic javascript loading
Created Oct 5, 2016
Dynamic javascript loading, Динамическая загрузка js
View Dynamic javascript loading
// var script = document.createElement('script');
// script.src = 'http://cdn.jsdelivr.net/jquery.validation/1.15.1/jquery.validate.min.js';
// script.onload = function () {
// };
// document.head.appendChild(script); //or something of the likes
@aligator28
aligator28 / index.html
Created Sep 14, 2016
Движок сайта с перелистыванием страниц во время скроллинга (красиво!)
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Scroll</title>
</head>
<body>
<div class="pages _1page" data-id="1">
<img src="https://unsplash.it/800/600/?random" alt="fashion">
@aligator28
aligator28 / input file in ie on change event
Created Jul 26, 2016
input file fires twice in IE срабатывает дважды - решение проблемы
View input file in ie on change event
$('#imageUpload') - это поле типа файл
$('#imageUpload').change() - эти методы срабатывают в ИЕ дважды
$('#imageUpload').on('change')
а вот правильное решение
$('#imageUpload').one('change', function(event){
console.log('change');
});
You can’t perform that action at this time.