Skip to content

Instantly share code, notes, and snippets.

/*
Cross-browser (including IE8-10)
Más info: http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/
*/
.absolute-center {
/* height: must be declared */
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
@jquimera
jquimera / README.md
Created March 12, 2018 23:40 — forked from barneycarroll/README.md
Lock and unlock a page's scroll position.

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
@jquimera
jquimera / ajax-action.php
Created January 26, 2018 16:11 — forked from danielpataki/ajax-action.php
Ajax in WordPress
add_action( 'wp_ajax_button_click', 'user_clicked' );
function user_clicked() {
update_user_meta( get_current_user_id(), 'clicked_link', 'yes' );
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
@jquimera
jquimera / README.md
Created January 25, 2018 23:12 — forked from barrysteyn/README.md
C/C++ Examples For Understanding

Introduction

These toy examples are for helping with understanding C/C++. There is an excellent C++ samples site which demonstrates many useful things.

@jquimera
jquimera / anchor-scroll-with-offset.js
Created January 20, 2018 21:24 — forked from HoundstoothSTL/anchor-scroll-with-offset.js
Anchor scroll with fixed header offset
(function($) {
$('a[href*=#]:not([href=#])').click(function()
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname)
{
var target = $(this.hash),
headerHeight = $(".primary-header").height() + 5; // Get fixed header height
@jquimera
jquimera / wordpress-dropdown-naviation.js
Created January 19, 2018 19:27 — forked from Narga/wordpress-dropdown-naviation.js
Wordpress - Dropdown Navigation jQuery Code
if(!jQuery.browser.msie){jQuery("ul.topnav").css({opacity:"0.95"});} // IE - 2nd level Fix
jQuery(".topnav > li > ul").css({display: "none"}); // Opera Fix
jQuery("ul.sub-menu").parent().append("<div>&nbsp;</div>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.sub-menu li.menu-item").append("<span>&#187;</span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
jQuery("ul.menu li a").hover(function() { //When trigger is clicked...
//Following events are applied to the subnav itself (moving subnav up and down)
jQuery(this).parent().find("ul.sub-menu").slideDown('fast').show(400); //Drop down the subnav on hover
jQuery(this).parent().hover(function() {
}, function(){
jQuery(this).parent().find("ul.sub-menu").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
@jquimera
jquimera / jquery.equalHeights.js
Created January 19, 2018 16:21 — forked from davetayls/jquery.equalHeights.js
Equal heights reloaded with window resize
/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 *
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
 *
@jquimera
jquimera / eventThrottler.js
Created January 19, 2018 14:41 — forked from cferdinandi/eventThrottler.js
A technique for throttling listener events (like resize or scroll) for better performance. https://developer.mozilla.org/en-US/docs/Web/Reference/Events/resize
var eventTimeout; // Set timeout variable
/**
* The function that runs the event actions
*/
var actualEventHandler = function () {
// handle the event...
};
/**
@jquimera
jquimera / node-cms.md
Created January 17, 2018 15:08 — forked from eyecatchup/node-cms.md
[WIP] List of Node-based content management systems (CMS)
// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbar = document.querySelector(".site-header");
var navbarHeight = navbar.offsetHeight;
window.addEventListener("scroll", function(){
didScroll = true;