Skip to content

Instantly share code, notes, and snippets.

View ozrabal's full-sized avatar
🛸

Piotr Łepkowski ozrabal

🛸
View GitHub Profile
function splitTable(table, maxHeight) {
var header = table.children("thead");
var footer = table.children("tfoot");
if (!header.length)
return;
var headerHeight = header.outerHeight();
var header = header.detach();
var splitIndices = [0];
var rows = table.children("tbody").children();
maxHeight -= headerHeight;
calculateTotal(){
let c;
c = this.state.others.map((item) => {
if(item.spendingAmmount) {
return parseInt(item.spendingAmmount)
}
return 0;
});
let total = 0;
if(c.length) {
@ozrabal
ozrabal / inview.js
Created November 7, 2016 12:22
if element in view then change menu color depends on its color
AA.inView = (function(){
function visibleY(el){
var rect = el.getBoundingClientRect(),
top = rect.top,
height = rect.height,
el = el.parentNode;
do {
rect = el.getBoundingClientRect();
if (top <= rect.bottom === false) return false;
@ozrabal
ozrabal / helper.js
Created November 7, 2016 12:18
add/remove/hasclass in plain js
var hasClass, addClass, removeClass;
if ('classList' in document.documentElement) {
hasClass = function (el, className) { return el.classList.contains(className); };
addClass = function (el, className) { el.classList.add(className); };
removeClass = function (el, className) { el.classList.remove(className); };
} else {
hasClass = function (el, className) {
return new RegExp('\\b'+ className+'\\b').test(el.className);
};
addClass = function (el, className) {
@ozrabal
ozrabal / pwp_cpt_current_item_class.php
Last active November 7, 2016 12:16
Highlight parent menu item when displayed single post from cpt archive
<?php
add_filter( 'nav_menu_css_class', 'pwp_cpt_current_item_class', 10, 2 );
function pwp_cpt_current_item_class( $classes , $item ){
$type = get_post_type_object(get_post_type());
if(!empty($type->rewrite['slug'])) {
if (get_post_type() == $type->name || is_archive($type->rewrite['slug'])) {
$classes = str_replace('current_page_parent', '', $classes);
@ozrabal
ozrabal / index.html
Created October 27, 2016 13:44
Swiper custom slides transform effect
<!-- Swiper -->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="slide-inner" style="background-image: url('http://cs412624.vk.me/v412624691/4117/RWBNZL6CLtU.jpg')"></div>
</div>
<div class="swiper-slide">
<div class="slide-inner" style="background-image: url('http://cs412624.vk.me/v412624691/41ad/atM6w55Z9Xg.jpg')"></div>
</div>
<div class="swiper-slide">
@ozrabal
ozrabal / 0_reuse_code.js
Created September 8, 2016 08:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ozrabal
ozrabal / CSS background change on scroll.markdown
Created September 28, 2015 09:09
CSS background change on scroll