var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; // $(function(){ // window.ink = window.ink || {}; // window.ink.fn = window.ink.fn || {}; // var windowHeight = $(window).height(); // var windowWidth = $(window).width(); // var imageHeight; // function cheapoParallax() { // // Scroll about half of the way up. // var scrollDistanceRatio = ($(window).scrollTop()/windowHeight); // if (scrollDistanceRatio < 1) { // var new_top = scrollDistanceRatio * imageHeight * 0.4 * -1; // $(".parallax_image").css({"top": new_top, "opacity": 1}); // } else { // $(".parallax_image").css({"opacity": 0}); // } // } // function cheapoParallaxSetup() { // windowHeight = $(window).height(); // windowWidth = $(window).width(); // // alert(windowHeight + "," + windowWidth); // if ($(".type_4").length === 0) { // if (windowWidth == 1024) { // // iPad Landscape // imageHeight = 550; // // Just not figuring out why media queries are being a bitch tonight. // $(".post .text_and_title").css({"padding-top": 20}); // } else { // if (windowWidth == 568) { // imageHeight = 360; // } else { // if (windowWidth < 600 ) { // // mobile // imageHeight = 160; // } else { // if (windowWidth > windowHeight) { // imageHeight = windowHeight*windowWidth / 1500; // } else { // imageHeight = windowHeight * 0.4; // } // } // } // } // $(".single_post .text_and_title").css({"margin-top": imageHeight}); // // $(window).scrollTop(64); // cheapoParallax(); // $(window).scroll(cheapoParallax); // } // } // if ($(".single_post .text_and_title").length > 0) { // cheapoParallaxSetup(); // $(window).resize(cheapoParallaxSetup); // } // window.ink.event = function(type, data) { // if (!data) { // data = {}; // } // if (window.ink.dev_mode) { // console.log("event"); // console.log(type); // console.log(data); // console.log(window.ink.uid); // console.log(window.ink.page_url); // } else { // if (window.ink.uid && window.ink.page_url) { // firebaseRef.child("events").push({ // "uid": window.ink.uid, // "timestamp": new Date().getTime(), // "url": window.ink.page_url, // "type": type, // "data": data, // }); // firebaseRef.child("users").child(window.ink.uid).child("events").push({ // "uid": window.ink.uid, // "timestamp": new Date().getTime(), // "url": window.ink.page_url, // "type": type, // "data": data, // }); // } else { // setTimeout(function(){ // window.ink.event(type, data); // }, 250); // } // } // }; // window.ink.mark_piece = function(mark, truthy) { // if (window.ink.dev_mode) { // console.log("mark piece"); // console.log(window.ink.uid); // console.log(window.ink.page_url); // console.log(window.ink.loaded); // console.log("marking " + mark + " " + window.ink.page_url); // } else { // if (!window.ink.loaded || !window.ink.uid || !window.ink.page_url) { // setTimeout(function(){window.ink.mark_piece(mark, truthy);}, 250); // return; // } // if (truthy === undefined) { // truthy = true; // } // var data = {}; // data[mark] = truthy; // firebaseRef // .child("users") // .child(window.ink.uid) // .child("pieces") // .child(window.ink.page_url) // .update(data); // // data = {}; // // data[window.ink.uid] = truthy; // firebaseRef // .child("pieces") // .child(window.ink.page_url) // .child(mark) // .child(window.ink.uid) // .set(true); // } // }; // window.ink.loaded = false; // window.firebaseRef = new Firebase('https://inkandfeet.firebaseio.com'); // firebaseRef.onAuth(function(authData) { // if (window.location.href.indexOf("inkandfeet") == -1) { // window.ink.dev_mode = true; // } else { // window.ink.dev_mode = false; // } // if (authData) { // // Client is logged in, so check if it's anonymous or a real user // if (authData.provider === 'anonymous') { // // user is anonymous // // console.log(authData.uid) // $.jStorage.set('uid', authData.uid); // window.ink.uid = authData.uid; // window.fire = firebaseRef.child("users").child(authData.uid); // window.ink.loaded = true; // // save authData.uid to some local session info, to keep track of data // } else { // // user is logged in // // transfer any data that you had stored from the anonymous session to // // this new authUser.uid // // console.log(authData.uid) // $.jStorage.set('uid', authData.uid); // window.ink.uid = authData.uid; // window.fire = firebaseRef.child("users").child(authData.uid); // window.ink.loaded = true; // } // if (window.ink.loaded) { // // ?utm_source=Ink+and+Feet+Letter&utm_campaign=7fe17eef0c-Ink_and_Feet_2015_10_04&utm_medium=email&utm_term=0_ec93255dd4-7fe17eef0c-209471669&goal=0_ec93255dd4-7fe17eef0c-209471669 // window.fire.child("profile").once('value', function(dataSnapshot) { // window.ink.profile = {}; // if (dataSnapshot) { // window.ink.profile = dataSnapshot.val(); // } // window.ink.profile_loaded = true; // if (window.ink.profile && window.ink.profile.subscribed) { // $(".letters .share").show(); // $(".letters .signup_blurb").hide(); // } // }, function(err) { // window.ink.profile_loaded = true; // }); // if (getUrlParameter('fb')) { // // Store FB referrals for tracking. // window.ink.event("facebook_referral", {"page_name": getUrlParameter('fb')}); // } else { // if (getUrlParameter('utm_source')) { // window.ink.event("utm_referral", { // "source": getUrlParameter('utm_source'), // "campaign": getUrlParameter('utm_campaign') || "", // "medium": getUrlParameter('utm_medium') || "", // "term": getUrlParameter('utm_term') || "", // }); // firebaseRef.child("users").child(authData.uid).child("profile").update({ // "mailchimp_term": getUrlParameter('utm_term') || "", // "mailchimp_campaign": getUrlParameter('utm_campaign') || "", // "mailchimp_source": getUrlParameter('utm_source') || "", // "subscribed": true, // }); // } // } // } // } else { // // Client is unauthenticated // // console.log("unauthenticated") // // This would be a good spot to create the anonymous login // firebaseRef.authAnonymously(function(error, authData) { // if (error) { // // handle login failure // console.log(error); // } else { // // you are now anonymously logged in, but you really don't need to do anything // // here, because your onAuth() listener is already going to catch this auth change // } // }); // } // }); // ink.event('loaded'); // window.ink.handleSubscribeClick = function () { // window.ink.ouibounce_showing = false; // var parent = $(this).parents("form"); // var email = $("#ck_emailField", parent).val(); // var first_name = $("#ck_firstNameField", parent).val(); // if (!first_name) { // first_name = ""; // } // if (email) { // $("#mce-error-response", parent).html(""); // if (!first_name) { // ink.event('subscribe_start', {"location": "modal"}); // } else { // ink.event('subscribe_start', {"location": "bottom"}); // } // firebaseRef.child("users").child(window.ink.uid).child("profile").update({ // "uid": window.ink.uid, // "email": email, // "first_name": first_name, // "subscribe_started": true, // "subscribed_at": new Date().getTime(), // }); // return true; // } else { // $("#mce-error-response", parent).html("Missing email or first name!"); // return false; // } // }; // window.ink.handleFormChange = function() { // var form = $(this).parents("form"); // // console.log("changed") // var email = $("#ck_emailField", form).val(); // if (email === "") { // email = false; // } // var first_name = $("#ck_firstNameField", form).val(); // if (first_name === "") { // first_name = false; // } // // console.log(email) // // console.log(first_name) // $("#ck_emailField", form).toggleClass("valid", !((!email || email.indexOf("@") == -1 || email.indexOf(".") === -1))); // $("#ck_firstNameField", form).toggleClass("valid", !(!first_name)); // $("#ck_emailField", form).parents(".field_block").toggleClass("valid", !((!email || email.indexOf("@") == -1 || email.indexOf(".") === -1))); // $("#ck_firstNameField", form).parents(".field_block").toggleClass("valid", !(!first_name)); // $(".subscribe_btn", form).toggleClass("valid", !(!first_name || !email || email.indexOf("@") == -1 || email.indexOf(".") === -1)); // }; // $(".one_line_signup .subscribe_btn").on('click', window.ink.handleSubscribeClick); // $(".one_line_signup input").on('change', window.ink.handleFormChange); // $(".one_line_signup input").on('keyup', window.ink.handleFormChange); // window.ink.handleFormChange(); // });