Skip to content

Instantly share code, notes, and snippets.

@aligator28
aligator28 / Показываем (скрываем) элементы страницы js
Created July 26, 2016 11:34
Показываем и скрываем неопределенное количество элементов страницы на javascript (jquery) - переключение табов
@extends('fx.index')
@section('content')
<link rel="stylesheet" type="text/css" href="{{ url('fx/css/obsidian.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url('fx/css/examples.css') }}">
<div class="row">
<div class="col-md-12">
<h2>code examples</h2>
<h4 id="php_title" data-val="php">PHP</h4>
<h4 id="js_title" data-val="js">JavaScript</h4>
@aligator28
aligator28 / input file in ie on change event
Created July 26, 2016 16:00
input file fires twice in IE срабатывает дважды - решение проблемы
$('#imageUpload') - это поле типа файл
$('#imageUpload').change() - эти методы срабатывают в ИЕ дважды
$('#imageUpload').on('change')
а вот правильное решение
$('#imageUpload').one('change', function(event){
console.log('change');
});
@aligator28
aligator28 / index.html
Created September 14, 2016 14:55
Движок сайта с перелистыванием страниц во время скроллинга (красиво!)
<!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 / Dynamic javascript loading
Created October 5, 2016 11:20
Dynamic javascript loading, Динамическая загрузка js
// 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 / smooth scroll - плавный скролл по якорям
Created October 9, 2016 08:14
Плавный скролл по якорям (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 / Add categories to custom post type Wordpress (добавить категории к пользовательскому типу поста)
Last active October 20, 2016 13:05
Добавить категории к кастом пост тайпу (categories for 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)
@aligator28
aligator28 / js image preloading
Created October 31, 2016 16:35
Images preloading javascript (предзагрузка изображений js)
<!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 / jquery-scroll-bottom.js
Created January 9, 2017 22:41 — forked from toshimaru/jquery-scroll-bottom.js
Detect the scrolling to bottom of the page using jQuery.
$(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 / admin-redirect.php
Created February 11, 2017 08:56 — forked from kharissulistiyo/admin-redirect.php
Admin Page Redirection After WordPress Theme Activated
/**
* WordPress snippet
* Admin page redirection
* Put this inside theme setup function
*/
global $pagenow;
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) {
html {
font-size: 62.5%;
/* 62.5% of the base size of 16px = 10px./
}
body {