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.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.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.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:
*
*
*
This is a filmstrip element
*
This is a filmstrip element
*
This is a filmstrip element
*
*
*
* where filmstripOuter is overflow:hidden, and filmstripInner is a very wide position:absolute div that is moved
* within filmstripOuter.
*
* @param {jQuery} container jQuery of the div containing the filmstrip -- .filmstripOuter in the example above
* @param {jQuery} leftButton jQuery of the which when clicked moves the filmstrip to the left. Often a.arrow-left.
* @param {jQuery} rightButton jQuery of the which when clicked moves the filmstrip to the right. Often a.arrow-right.
* @param {Number} leftOffset optional; gives the amount of horizontal offset on the left side of the main container
* @param {Number} rightOffset optional; gives the amount of horizontal offset on the right side of the main container
* @param {jQuery} innerContainer optional; jQuery of the div containing the items -- .filmstripInner in the example above
* @param {String} itemsSelector optional; CSS selector for the items within the filmstrip ('.filmstripInner div' in the example above).
* if null, we'll default to using the children of .filmstripInner as the filmstrip elements
*/
tf.filmstrip = function(container, leftButton, rightButton, leftEnabledClass, rightEnabledClass, leftOffset, rightOffset, minPos, maxPos,
slideChangeCallback, innerContainer, itemsSelector) {
var currentPos = minPos || 0,
innerDiv = innerContainer || container.children().eq(0);
leftEnabledClass = leftEnabledClass || "arrowEnabled";
rightEnabledClass = rightEnabledClass || "arrowEnabled";
leftOffset = leftOffset || 0;
rightOffset = rightOffset || 0;
minPos = currentPos;
maxPos = maxPos || 0;
var scrollLeft = function(leftOffset, rightOffset) {
var targetOffset = offset() - container.width() + leftOffset + rightOffset;
while (currentPos > minPos && offset() > targetOffset)
currentPos--;
redisplay(true);
}
var scrollRight = function(leftOffset, rightOffset) {
var targetOffset = offset() + container.width() - leftOffset - rightOffset;
while (canGoRight() &&
//one more step would not be too far. (When scrolling
//right, don't go past items that were partially shown.)
offset() + items().eq(currentPos).outerWidth() <= targetOffset)
currentPos++;
redisplay(true);
}
leftButton.click(function() {
scrollLeft(leftOffset, rightOffset)
return false;
});
rightButton.click(function() {
scrollRight(leftOffset, rightOffset)
return false;
});
function setPosition(newPos, fromUserAction) {
currentPos = newPos;
redisplay(fromUserAction);
}
function redisplay(fromUserAction) {
//Other code may have changed contents
if (currentPos && lastPos() && currentPos > lastPos()) {
currentPos = minPos;
redisplay(false);
}
var pos = {
left: leftOffset - offset()
};
innerDiv.stop().animate(pos, 100);
updateArrows();
if(slideChangeCallback)
slideChangeCallback(currentPos, fromUserAction);
}
function updateArrows() {
leftButton.toggleClass(leftEnabledClass, currentPos > minPos);
rightButton.toggleClass(rightEnabledClass, canGoRight());
}
function offset() {
if (items().length) {
return items().eq(currentPos).position().left;
}
return 0;
}
function canGoRight() {
var last = items().eq(lastPos());
if (!last.length)
return false;
var lastNotFullyShown = last.position().left + last.outerWidth(true) >
offset() + container.width() - leftOffset - rightOffset;
var morePositions = currentPos < items().length - 1;
return lastNotFullyShown && morePositions;
}
function items() {
if (itemsSelector) {
return $(itemsSelector);
} else {
return innerDiv.children();
}
}
function lastPos() {
return items().length - maxPos - 1;
}
function makeVisible(item) {
var index = items().index(item);
if(index == -1)
return;
if(item.position().left < offset()) {
// need to scroll left to bring it in view
setPosition(index, true);
} else {
var changed = false;
while(item.position().left + item.outerWidth(true) >
offset() + container.width() - leftOffset - rightOffset) {
// need to scroll right to bring it in view
currentPos++;
changed = true;
}
if(changed)
redisplay(true);
}
}
return { set: setPosition, redisplay: redisplay, makeVisible: makeVisible
, scrollLeft: scrollLeft, scrollRight: scrollRight };
};
;;
// lib/jquery.min.js
// @include lib/jquery.ui.min.js
// @include lib/jquery.inview.min.js
// @include tags/infiniteScroll.js
// @include common.js
// @include genericUI.js
// @include components/commentsObj.js
// @include widgetCommon/commentBox.js
/**
* Meant to be included in any page that will use a "My Trefis" feed.
*
* Class will self init from the include (see end of file)
*
* Should be used like:
*
* ...
*
*