msnbc.components.MainArt = msnbc.components.Component.extend({ setup: function(){}, insert: function(selectr, sidebar){ /*get width/height classes and img url*/ var cls = $(selectr).parent() .attr("class") .replace(/[a-z]/g,'') .split(" "); /*build width/height object*/ var dim = { width: parseFloat(cls[0]), height: parseFloat(cls[1]) }; /*isolate markup elements*/ var url = $(selectr).text(); var div = $(selectr).parent(); var aspectratio = dim.width/dim.height; /*adjust class widths for large art*/ url = (aspectratio < 1) ? msnbc.utils.makeAIMS(url,"photoblog500") : msnbc.utils.makeAIMS(url,"grid-8x3"); /*pick vertical art column width based on img width*/ var vertest = (aspectratio > 0.8) ? vertest = 'x3' : vertest = 'x2p5'; /*set column width overall and inject img*/ var col = (aspectratio < 1) ? re = "art " + vertest : 'art x4'; div.html(''); $(div.parent()).attr("class", col); /*adjust margin of sidebar*/ var DebugMode = (window.location.search.indexOf("bug=de") == 1) ? DebugMode = true : DebugMode = false; if (DebugMode == true) {console.log("pre-load() height(): "+$('#main-art').height());} sidebar.css("margin-top",$('#main-art').height()+"px"); $('#main-art img').load(function() { if (DebugMode == true) {console.log("post-load() height(): "+$('#main-art').height());} sidebar.css("margin-top",$('#main-art').height()+"px"); }); } });