Skip to content

Instantly share code, notes, and snippets.

/* 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 );
}
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"
];
$.fn.isOnScreen = function(){
var element = this.get( 0 ),
bounds = element.getBoundingClientRect();
return ( ( bounds.top < window.innerHeight ) && ( bounds.bottom > 0 ) );
};
/**
* @brief OPT Parallax
* @author Ray Peters <rpeters@ontraport.com>
*/
;( function(){
/* Configurations */
var SETTINGS = {
BLOCKS_TO_MERGE: [ 2, 3 ],
BACKGROUND_IMAGE_URL: "https://i.ontraport.com/3.213.da5584f8a40b8a942445752f118aa207.JPEG"
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() );
};
/**
* uberGlobalize.js
* @version 3.0.0
* @author Ray Peters <rpeters@ontraport.com>
*
*/
(function( $ ) {
@ray-peters
ray-peters / random-test.js
Created January 7, 2016 22:50
Testing what throws do to the event loop
var queueJob = function(){
var total = 0;
return function( count ) {
count || ( count = 1 );
for ( var i = 0; i < count; ++i ) {
setTimeout( function(){
++total;
console.log( "job: ", total );
$( document ).ready(
function() {
//$('*[opt-id="74478fdc-1885-0eba-36ab-4387fd0c15bb"]').hide();
//$("a[href='http://ontraport.com/fakelink']").attr('href', 'javascript:show_chapters()');
var navIsOn = false;
$( document.body ).on( "click", "a[href='http://ontraport.com/fakelink']", function( ev ){
if ( navIsOn ) {
hide_chapters();
navIsOn = false;
@ray-peters
ray-peters / ng-file-upload-fix.js
Created March 4, 2016 20:25
Fix for ng-file-upload - Create and segment invalids via an error blacklist. Do not mark files invalid because of maxLength.
function separateInvalids() {
var skipErrors = [ "maxFiles" ];
valids = [];
invalids = [];
angular.forEach(allNewFiles, function (file) {
if (file.$error) {
if ( skipErrors.indexOf( file.$error ) !== -1 ) return;
invalids.push(file);
/**
* Overlays iframes to prevent capturing mousewheels while
* scrolling down a long page. Click to destroy.
*
* @author Ray Peters <me@raypeters.com>
*/
;( function(){
$(function(){
$( "iframe" ).each( function(){
addOverlay( $( this ) );