Skip to content

Instantly share code, notes, and snippets.

View ray-peters's full-sized avatar

Ray Peters ray-peters

  • San Francisco, CA
View GitHub Profile
/**
* uberGlobalize.js
* @version 3.0.0
* @author Ray Peters <[email protected]>
*
*/
(function( $ ) {
var getDaysLeftInMonth = function(){
var now = new Date(),
thisMonth = now.getMonth(),
thisYear = now.getFullYear(),
daysInThisMonth = new Date( thisYear, ( thisMonth + 1 ), 0 ).getDate();
return ( daysInThisMonth - now.getDate() );
};
/**
* @brief OPT Parallax
* @author Ray Peters <[email protected]>
*/
;( function(){
/* Configurations */
var SETTINGS = {
BLOCKS_TO_MERGE: [ 2, 3 ],
BACKGROUND_IMAGE_URL: "https://i.ontraport.com/3.213.da5584f8a40b8a942445752f118aa207.JPEG"
$.fn.isOnScreen = function(){
var element = this.get( 0 ),
bounds = element.getBoundingClientRect();
return ( ( bounds.top < window.innerHeight ) && ( bounds.bottom > 0 ) );
};
var COUNT = 100,
links = [
"http://www.quranjam.com/Jam/UserImages/whale.jpg",
"http://i633.photobucket.com/albums/uu56/cjay57/Creepy%20Fish/989826_f496.jpg",
"http://i.dailymail.co.uk/i/pix/2012/10/24/article-2222115-15A0CDA8000005DC-378_634x426.jpg",
"http://www.kidson66.com/Scout16.jpg",
"https://thejesterscorner.files.wordpress.com/2012/12/scary-whale.jpeg?w=1200",
"http://media.giphy.com/media/t5CTQBicJcWha/giphy.gif"
];
/* name your links like: http://mypage.com/jump-to-block-3 or http://mypage.com/jump-to-block-6 */
/* place this in footer scripts */
$( document ).ready( function() {
var $containers = $( ".row[opt-type='block']" );
for ( var i = 0, l = $containers.length, deepLink; i < l; ++i ) {
deepLink = ( "op-container--" + i );
$containers.eq( i ).attr( "id", deepLink ).attr( "name", deepLink );
}
/* place this in footer scripts */
$( document ).ready( function() {
$(".container:has(form[action*='form_processor.php'])" )
.attr( "id", "signup-form" )
.attr( "name", "signup-form" );
$( "a[href*='jump-to-signup-form']" ).attr( "href", "#signup-form" );
} );
/* name your link URL something like: http://jump-to-signup-form.com */
/**
* How to use:
* Step 1: Navigate to the given template you're curious about and paste this in the console.
* Step 2: ???
* Step 3: Profit
*
* @author Jonathan Preston <[email protected]>, Ray Peters <[email protected]>
*/
@ray-peters
ray-peters / allImagesLoaded.js
Last active September 10, 2015 22:29
Emits an event when all the images have finished loading
$( document ).ready( function(){
// Interesting thing happens when you have so many images on the page.
// Count them and wait for every onload event to fire.
var $images = $( "img" ),
imagesLoadedHandler = function(){
var totalImagesToLoad = $images.length,
imageLoadedCount = 0;
return function(){
@ray-peters
ray-peters / generic-uberglobalize.js
Last active February 17, 2016 21:31
generic uber globalize
(function(){
// jQuery is required to run this snippet
// They are provided above from reliable CDNs if your page doesn't already have them added.
var _uberGlobalize = ( function(){
var cloudFlareCDN = "//cdnjs.cloudflare.com/ajax/libs/globalize/0.1.1/cultures",
currentCulture = "",
previousCulture = "",
getCurrencySymbol = function( culture ) {
// Defaults to USD buck symbol