2012-08-27 19:35:29 +00:00
|
|
|
// hijack a link with class "hijax" to show its content in a lightbox instead
|
|
|
|
// allows for ajaxy presentation of things like download links in a way that
|
|
|
|
// degrades gracefully for non-js users
|
|
|
|
var $j = jQuery.noConflict();
|
|
|
|
|
|
|
|
$j(document).ready(function() {
|
2013-02-07 14:10:46 +00:00
|
|
|
$j("#js-page-wrap, #footer").on("click", "a.hijax", function(event) {
|
2012-08-27 19:35:29 +00:00
|
|
|
event.preventDefault();
|
2012-11-14 15:32:03 +00:00
|
|
|
$j("#lightbox").load($j(this).attr("href") + " #lightbox_content", function() {
|
|
|
|
// centering divs of dynamic width: shockingly hard. make sure lightbox is centered on load.
|
|
|
|
var hijaxWidth = $j('#about_expandable').width() + 28;
|
|
|
|
var windowWidth = $j(document).width();
|
|
|
|
var marginWidth = (windowWidth - hijaxWidth)/2;
|
|
|
|
$j('#about_expandable').css({'margin-left': marginWidth});
|
2012-12-31 14:49:09 +00:00
|
|
|
|
|
|
|
// position div vertically relative to top of viewport, to ensure visibility
|
|
|
|
// regardless of where on the page the user clicked to activate it
|
|
|
|
var marginTop = window.pageYOffset;
|
|
|
|
$j('#about_expandable').css({'margin-top': marginTop});
|
2012-11-14 15:32:03 +00:00
|
|
|
});
|
2012-08-27 19:35:29 +00:00
|
|
|
|
2012-09-19 16:08:27 +00:00
|
|
|
if ($j(this).attr("href").substr(-9,8) == "download") {
|
2012-09-25 14:54:31 +00:00
|
|
|
jQuery.getScript('https://platform.readmill.com/send.js');
|
2012-09-19 16:08:27 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 19:35:29 +00:00
|
|
|
// fade-out rest of page elements on expand
|
2013-02-07 14:10:46 +00:00
|
|
|
$j('#feedback, #js-page-wrap, #footer').css({"opacity": "0.07"});
|
2012-12-31 14:49:09 +00:00
|
|
|
$j('#about_expandable').css({'position': 'absolute'});
|
2012-08-27 19:35:29 +00:00
|
|
|
$j('#about_expandable').fadeTo("slow", 1);
|
|
|
|
|
|
|
|
// if we're on a supporter page, personalize our about box
|
|
|
|
// by writing the supporter's name in
|
|
|
|
if ($j(location).attr('pathname').slice(0,11) == '/supporter/') {
|
|
|
|
var ungluer = $j(location).attr('pathname').slice(11, -1);
|
|
|
|
|
|
|
|
if (ungluer != null) {
|
|
|
|
// span.ungluer doesn't exist until the ajax call so we
|
|
|
|
// can't bind to the DOM on document ready; need to use
|
|
|
|
// the ajaxComplete event
|
|
|
|
$j('#lightbox').ajaxComplete(function() {
|
|
|
|
$j('#lightbox span.ungluer').replaceWith(ungluer);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// fade-in normal page elements on collapse
|
2013-02-04 17:09:29 +00:00
|
|
|
$j('#about_collapser').on("click", function(){
|
2013-02-07 14:10:46 +00:00
|
|
|
$j('#js-topsection, .launch_top, .preview, #main-container, #js-rightcol, #js-header, #js-page-wrap, #footer, #feedback').fadeTo("slow", 1);
|
2012-08-27 19:35:29 +00:00
|
|
|
$j('#js-header a').css({"cursor": "pointer"});
|
|
|
|
$j('#about_expandable').css({"display": "none"});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|