/*
Top Newsmenu Data Object
*/
jQuery.extend(msnbc.document.settings, {
topNewsmenuData : [
{
id : "#section_more",
bindId: "#section_drop",
css: "x2p5",
datasource : "REL_JSON_ID_json",
omnProject: "sharktank",
omnSection: "sectionMore"
},
{
id : "#subsection_more",
bindId: "#subsection_drop",
css: "x2p5",
datasource : "REL_JSON_ID_topmenuJSON",
omnProject: "sharktank",
omnSection: "subsectionMore"
},
{
id : "#cover_more",
bindId: "#cover_drop",
css: "x1p5",
datasource : "msnbc.document.settings.CoverMore_Json",
omnProject: "sharktank",
omnSection: "coverMore"
},
{
id : "#search_more",
bindId : "#search_drop"
},
{
id : "#msn_more",
bindId : "#msn_drop"
}
]
});
/*
Create cover_more JSON object
*/
jQuery.extend(msnbc.document.settings, {
CoverMore_Json : {"nm": {"ul": "http://www.msnbc.msn.com/id/","el": [
{"s": "Today","i": 0, "l":[{"u":"http://today.msnbc.msn.com","v":"","t":"f"}]},
{"s": "Nightly News","i": 0, "l":[{"i":3032619,"v":"","t":"f"}]},
{"s": "Dateline","i": 0, "l":[{"i":3032600,"v":"","t":"f"}]},
{"s": "Meet the Press","i": 0, "l":[{"i":3032608,"v":"","t":"f"}]},
{"s": "Hardball","i": 0, "l":[{"i":3032608,"v":"","t":"f"}]},
{"s": "Countdown","i": 0, "l":[{"i":3036677,"v":"","t":"f"}]},
{"s": "Rachel Maddow Show","i": 0, "l":[{"i":26315908,"v":"","t":"f"}]},
{"s": "More msnbc tv","i": 0, "l":[{"i":26315908,"v":"","t":"f"}]},
{"s": "Newsvine","i": 0, "l":[{"u":"http://www.newsvine.com","v":"","t":"f"}]},
{"s": "NBC Sports","i": 0, "l":[{"u":"http://nbcsports.msnbc.com","v":"","t":"f"}]}]
}}
});
msnbc.components.topNewsmenu = msnbc.components.Component.extend({
// SETUP : MAIN ENTRY POINT
setup: function(){
// Get Data
this.newsmenuData = msnbc.document.settings.topNewsmenuData;
//Loop through the data, rendring the defined flyouts
var me = this;
$.each(this.newsmenuData, function(i, item) {
var iFrameObj = new msnbc.components.iframeFlyoutRendering();
iFrameObj.renderIframe($(item.id));
if (item.datasource)
{
me.renderFlyouts(item.id, msnbc.namespace(item.datasource), item.omnProject, item.omnSection);
}
if (item.bindId)
{
me.bindEvents(item.bindId, item.id, item.iframeId);
}
if (item.css && item.id)
{
$(item.id).addClass(item.css);
}
});
},
// RENDER Flyout Information
renderFlyouts: function(parentid, json, omnitureProject, omnitureSection){
//Render DHTML
var renderedContent = "
";
var me=this;
var renderctr = 0;
$.each(json.nm.el, function(i, item)
{
if (item.s)
{
if (item.l[0].i || item.l[0].u)
{
//If there is a front associated with this section, it will be listed at the first location
renderedContent += me.renderLI(item.l[0].i, item.s, json.nm.ul, item.l[0].u, omnitureProject, omnitureSection, item.l, renderctr++);
}
else
{
//No front associated, use the first story
renderedContent += me.renderLI(item.l[1].i, item.s, json.nm.ul, item.l[1].u, omnitureProject, omnitureSection, item.l, renderctr++);
}
}
});
renderedContent += "
";
$(parentid).html(renderedContent);
},
//RENDER Headlines
renderHeadlines: function (stories, baseURL, omn_prj, omn_sn, ctr){
//Show first level headlines as a default
var ulClass = "menuHeadlines ";
if (ctr==0)
{
ulClass += " show";
}
//Render sub ULs
var strUL = "";
var me = this;
$.each(stories, function (i, story)
{
if (i<6 && i!=0 && story.i)
{
strUL += "- " + me.renderHref(baseURL, story.v, story.i, story.u, 2) + "
";
}
});
strUL += "
";
return strUL;
},
//RENDER Link Item with omniture and Href information
renderLI: function(id, txt, baseURL, externalURL, omn_prj, omn_sn, stories, ctr){
if (txt == 'Video' || txt == 'Photos')
{
return "";
}
else
{
var li;
if (ctr == 0)
{
li = "";
}
return li + this.renderHref(baseURL, txt, id, externalURL, 1) + this.renderHeadlines(stories, baseURL, omn_prj, omn_sn, ctr) + "";
}
},
renderHref: function(baseURL, text, id, externalURL, depth)
{
//Get URL
var url = baseURL + id;
if (externalURL)
{
url = externalURL;
}
if (text == 'Technology & Science'){text = 'Tech & Science';}
return "" + text + "";
},
//BIND events to event handlers
bindEvents: function(parentid, id, iFrameId) {
var hideMenuTimeout;
var iFrameObj = new msnbc.components.iframeFlyoutRendering();
//Bind click event to dropdown
/*$(parentid).hover(
function () {
$(id).addClass('show');
},
function () {return;}
);*/
//Show flyout on click. Hide flyout on hover-off
$(parentid).click(function(event)
{
if ($(parentid).hasClass('menuActivate'))
{
$(id).removeClass('show');
$(id).find('.menuSelected').removeClass('menuSelected');
$(id).find('.menuHeadlines').removeClass('show');
$(id + " > UL > LI:first-child").addClass('menuSelected');
$(id + " > UL > LI:first-child").children('UL').addClass('show');
$(parentid).removeClass('menuActivate');
iFrameObj.hide('#'+iFrameId);
}
else
{
clearTimeout(hideMenuTimeout);
$(parentid).addClass('menuActivate');
$(id).addClass('show');
iFrameObj.show('#'+iFrameId);
}
});
$(parentid).hover(
function (){clearTimeout(hideMenuTimeout);},
function (){
hideMenuTimeout = setTimeout(function(){
$(id).removeClass('show');
$(id).find('.menuSelected').removeClass('menuSelected');
$(id).find('.menuHeadlines').removeClass('show');
$(id + " > UL > LI:first-child").addClass('menuSelected');
$(id + " > UL > LI:first-child").children('UL').addClass('show');
$(parentid).removeClass('menuActivate');
iFrameObj.hide('#'+iFrameId);
}, 750);
}
);
//Bind hover-off event to flyout div
$(id).hover(
function(){clearTimeout(hideMenuTimeout);},
function(){
hideMenuTimeout = setTimeout(function(){
$(id).removeClass('show');
$(id).find('.menuSelected').removeClass('menuSelected');
$(id).find('.menuHeadlines').removeClass('show');
$(id + " > UL > LI:first-child").addClass('menuSelected');
$(id + " > UL > LI:first-child").children('UL').addClass('show');
$(parentid).removeClass('menuActivate');
iFrameObj.hide('#'+iFrameId);
}, 750);
});
$(id + " > UL > LI").hover(
function(){
$(id).find('.menuSelected').removeClass('menuSelected');
$(id).find('.menuHeadlines').removeClass('show');
$(this).children('UL').addClass('show');
$(this).addClass('menuSelected');
},
function(){return;}
);
}
});
/* Newsmenu Object */
window.NewsmenuObject = Class.extend({
init:function(){},
Initialize:function(){},
SetOmnitureProjectName:function(){},
GetSectionData:function(){}
});