// jQuery domIsReady Plugin by John Terenzio (http://terenz.io) (function($){$.domIsReady=false;$(document).ready(function(){$.domIsReady=true;});})(jQuery); /**/ function GetUpdateDateTime(ticks){ var dt= new DateTime(); var d = dt.T2D(ticks); var time = Math.floor((new Date().getTime() - new Date(parseInt((ticks - 621355968000000000)/10000)).getTime())/(60*1000)); if(time < 60*24){ document.write(getTimestampTitle(ticks)); } else { document.write(dt.SD2S(d,d.getTime())); } } function topics_init(){ // hide TSM for E pages if($("#top-stories .grid").children().length==0){ $("#cover").addClass("empty"); } // trim H3s that are too long if($(".grid h3").height()>150){ $(".grid h3 a").css("font-size","85%"); }; // trim search ads that are too long $("#Sidebar1-sponsored .adCall p").each(function(i){ if(i>2){ $(this).hide(); } }); $("#summary #Mainline1-sponsored .listing p").each(function(i){ if(i>0){ $(this).hide(); } }); $("#summary .freebase #Mainline1-sponsored .adCall p").each(function(i) { if (i > 0) { $(this).hide(); } }); $("#summary .pinned_content #Mainline1-sponsored .adCall p").each(function(i) { if (i > 0) { $(this).hide(); } }); var imageFlavor = []; imageFlavor["thumb-m"] = "92;116" imageFlavor["grid-4x2"] = "308;246" imageFlavor["grid-4x3"] = "308;390" imageFlavor["vsmall"] = "148;160" // set height and width of external image for(var i in imageFlavor) { var dNode = ".grid .ext_" + i; var width = parseInt(imageFlavor[i].substring(0, imageFlavor[i].indexOf(";"))); var height = parseInt(imageFlavor[i].substring(imageFlavor[i].indexOf(";")+1, imageFlavor[i].length)); var widthStr = width.toString() + "px"; var heightStr = height.toString() +"px"; $(dNode).each(function() { if ($(this).width() / $(this).height() >= width / height) { $(this).css({ 'width': widthStr }); $(this).removeClass(); } else if($(this).width() / $(this).height() < width / height) { $(this).css({ 'height': heightStr }); $(this).removeClass(); } }); } // adjust TSM height $("#cover .tsm #cell1 div.story:last, #cover .tsm #cell2 div.story:last, #cover .tsm #cell3 div.story:last, #cover .tsm #Sidebar1-sponsored .adCall p:eq(2), #cover .tsm #cell3 #Sidebar1-sponsored a:eq(2)").each(function(){ if($(this).position().top+$(this).height() > $(".tsm").height()){ $("body:not(.IE) .tsm").height($(this).position().top+$(this).height()+10); $(".IE .tsm").height($(this).position().top+$(this).height()+30); } }); // adjust summary grid height $("#cover #summary #cell1 div.story:last, #cover #summary #cell2 div.story:last, #cover #summary #cell3 div.story:last, #cover #summary #Sidebar1-sponsored .adCall p:eq(2), #cover #summary #cell3 #Sidebar1-sponsored a:eq(2)").each(function(){ try{ if($(this).position().top+$(this).height() > $("#summary").height()){ $("body:not(.IE) #summary").height($(this).position().top+$(this).height()+10); $(".IE #summary").height($(this).position().top+$(this).height()+30); }} catch(e){} }); var image_loaded = null; // prep for thickbox if($("#summaries .img-thumb-m a").hasClass("thickbox")) { return; } else { $("#summaries .img-thumb-m a:not([href*=javascript])").addClass("thickbox"); $("#summaries .img-thumb-m a[rel=relatedImages]").removeAttr("rel"); } // more related photos to beside ad if no video if(1>=$("#more_video").children().length){ $("#video_image #more_images").css({ "clear":"none", "margin-top":"-41px", "width":"250px" }); $("#video_image #more_images .img-thumb-m").css({ "height":"160px" }); } // place caption $(".img-thumb-m a.thickbox").click(function(){ var parent = ($(this).parent().parent().parent().is(".img-thumb-m")) ? $(this).parent().parent().parent() : $(this).parent().parent().parent().parent(); var credit = parent.find("cite").clone(); var caption = parent.find("p.abstr").clone(); var ctr = 1; image_loaded = setInterval(function(){ if ($("img#TB_Image").length) { clearInterval(image_loaded ); $("#TB_caption").prepend(credit); $("#TB_secondLine").prepend(caption ); } else if (ctr == 1000) { clearInterval(image_loaded ); } ctr++; },500); }); // use abstract as title $(".img-thumb-m").each(function(){ var title_txt=$(this).find(".text .abstr").text(); $(this).attr("title",title_txt); $(this).find(".img img").attr("title",title_txt); }); // hide 1x1 AP images $(".img img").each(function(){ if($(this).height()==1 && $(this).width()==1){ $(this).parent().parent().parent().hide(); } }); // hide broken images $("#more_images .img-thumb-m img").each(function(){ if(30>$(this).height() && 90>$(this).width()){ $(this).parent().parent().parent().parent().hide(); } }); // hide title for no images if($("#more_images div").length==0){ $("#more_images").hide(); }; // trim headline count if( ($("#more_images div").length==0 && $("#more_video div").length>0) || ($("#more_images div").length>0 && $("#more_video div").length==0) || ($("#summaries .top").length.length==0) ){ $("#more_headlines .story").each(function(n){ if(n>9){ $(this).hide(); } }); } // show summary component if there is content there // hide sponsorship ads right above articles if there is summary component if ($("#summary").eq(0).find(".freebase #cell2").attr('id') == 'cell2') { $("#summary").css("display", "block"); $("#summaries").find("#Mainline1-sponsored").hide(); } if ($("#top-stories .tsm #Mainline1-sponsored").length !=0) { $("#summaries").find("#Mainline1-sponsored").hide(); } if ($("#top-stories .pinned_content #Mainline1-sponsored").length !=0) { $("#summaries").find("#Mainline1-sponsored").hide(); } // trim related topic count if market ticker there if($("#mkt-badge").length!=0){ $("#bantopBadge div#mkt-tickr").css("padding","2px 0"); $("#bantop #bantopBadge").show(); $("#breadcrumbs").css("width","55%"); $(".relatedBreadcrumbs").css("white-space","nowrap"); $($(".relatedBreadcrumbs li").get().reverse()).each(function(){ var bcw = $("#breadcrumbs").width(); var pos_li = ($(this).position().left+$(this).width()+20); if(pos_li>=bcw){ if($(this).prev().is("span.title")){ $(".relatedBreadcrumbs").hide(); } $(this).remove(); } }); } } if(!window.topicsInitialized) { $(document).ready(function() { var image_load = "true"; topics_init(); }); $(window).load(function(){ var image_load = "true"; topics_init(); }); topicsInitialized = true; }