tf = window.tf || {}; /** * Loads a JS file lazily, such that it doesn't block the onload event in any way. * This was hacked together using the following references: * Google Analytics' async code: http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html * LABjs's async bootstrapper: https://gist.github.com/603980 * using window.onload to avoid blocking onload event: http://friendlybit.com/js/lazy-loading-asyncronous-javascript/ * * @param {String} src URL of the JS file to load * @param {Function} callback a function which will be called with no arguments when the JS file has been loaded * and executed. Can be null. */ tf.loadLazily = function(src, callback) { var s = document.createElement("script"), p = document.getElementsByTagName("script")[0], d; s.type = "text/javascript"; s.async = true; s.src = src; s.onload = s.onreadystatechange = function () { if ((s.readyState && s.readyState !== "complete" && s.readyState !== "loaded") || d) return false; s.onload = s.onreadystatechange = null; d = 1; callback&&callback(); }; p.parentNode.insertBefore(s, p); }; ;; // lib/jquery-1.10.2.min.js // @include common.js // @include showOverlay.js // @include tf/initPopup.js (function() { var ape_popup = "addapricePopup", ape_popupinit; tf = window.tf || {}; tf.apePopup = function(symbol) { if (!ape_popupinit) { ape_popupinit=1; tf.initPopup(ape_popup); } $("#"+ape_popup+" iframe") .removeAttr("src") .attr("src", getHost() + "/addapriceWidget" + (symbol?"?ticker=" + symbol:"")); $("#" + ape_popup) .css("margin-top", (tf.scrollY() + 50) + "px") .show(); showOverlay(); } })(); ;; // lib/jquery-1.10.2.min.js function initArtPopin() { var // tells whether the popin is currently visible popinVisible, // tells whether the popin has content and can be shown popinEnabled, // tells whether the user has closed the popup, causing it not to appear anymore on this page popinClosed ; setTimeout(function() {popinEnabled=1}, 1000); function updatePopin() { var postQuery = $(".post"), windowQuery = $(window), popinQuery = $("#artPopin"), shouldBeVisible = !popinClosed && popinEnabled && postQuery.offset().top + postQuery.height() < windowQuery.scrollTop() + windowQuery.height(); if(shouldBeVisible ? !popinVisible : popinVisible) { popinQuery.animate( {right: shouldBeVisible ? -1 : -450}, shouldBeVisible ? 200 : 400); popinVisible = shouldBeVisible; } setTimeout(updatePopin, 200); } updatePopin(); $("#artPopin button").click(function() { popinClosed = 1; }); } ;; // lib/jquery-1.10.2.min.js tf = window.tf || {}; /** * Adds click listeners for a horizontally scrolling filmstrip, as seen on the article page or home page. * * Meant to be used with an HTML structure like the following: *