//////////////////////////////////////////////////////////////////////////////// // // Dave Ramsey - FBN Theme Hour Widget // // Authors: Andrew Kallemeyn, Phil Harvey // Date: July 2008 // Copyright (c) The Lampo Group, Inc. All rights reserved. // //////////////////////////////////////////////////////////////////////////////// var lampo = { util: { loadCSS: function(url) { var head = document.getElementsByTagName('head')[0]; var l = document.createElement('link'); l.rel = 'stylesheet'; l.type = 'text/css'; l.href = url; head.appendChild(l); }, mergeHash: function(dest, source) { for(var property in source) { dest[property] = source[property]; } return dest; }, getOptions: function(options, defaults) { return lampo.util.mergeHash(defaults || {}, options || {}); } }, browser: { IE: !!(window.attachEvent && !window.opera) }, fbnth: { Widget: function(themes, options) { this.options = lampo.util.getOptions(options, lampo.fbnth.Widget.defaults); // dynamically load our style sheet (think "CSS on-demand" ;) lampo.util.loadCSS(options.stylesheet); this.buildDOM(); this.themes = themes; this.setTitle(this.options.title, this.options.landing_page_url); this.setIntro(this.options.intro); this.setThemes(this.themes); this.setFooter(this.options.footer_title, this.options.landing_page_url); this.CSS = lampo.fbnth.Widget.CSS; this.CSS_Class = lampo.fbnth.Widget.CSS.Classes; } } }; lampo.fbnth.Widget.prototype = { setTitle: function(title, link) { var titleDiv = this.element.parts.title; titleDiv.innerHTML = ''; var h = document.createElement('h3'); var a = document.createElement('a'); a.innerHTML = title; a.href = link; h.appendChild(a); titleDiv.appendChild(h); }, setIntro: function(introHTML) { var introDiv = this.element.parts.intro; introDiv.innerHTML = introHTML; }, setThemes: function(arThemes) { var themeListDiv = this.element.parts.theme_list; ul = document.createElement('ul'); for (i=0; i < this.themes.length; i++) { arTheme = this.themes[i]; themeSubmissionURL = this.options.submission_base_url + arTheme.contentID; synopsis = arTheme.synopsis + ' Tell us about it!'; li = document.createElement('li'); a = document.createElement('a'); themeTitle = document.createTextNode(arTheme.title); p = document.createElement('p'); a.href = themeSubmissionURL; p.innerHTML = synopsis; a.appendChild(themeTitle); li.appendChild(a); li.appendChild(p); ul.appendChild(li); } themeListDiv.appendChild(ul); }, setFooter: function(title, link) { var footerDiv = this.element.parts.footer; footerDiv.innerHTML = ''; var a = document.createElement('a'); a.innerHTML = title; a.href = link; footerDiv.appendChild(a); }, buildDOM: function() { /* dynamically create our html structure: step 1: write a div tag out to the document, in place, as an anchor step 2: get a reference to the div we just wrote out step 3: using DOM functions, create all the necessary elements on the fly and add it to the first div step 4: render contents */ var CSS = lampo.fbnth.Widget.CSS.Elements; var CSS_Class = lampo.fbnth.Widget.CSS.Classes; document.write('
'); var widgetDiv = document.getElementById(CSS.Widget); var widgetHeader = document.createElement('div'); widgetHeader.id = CSS.WidgetHeader; var widgetIntro = document.createElement('div'); widgetIntro.id = CSS.WidgetIntro; var widgetThemeList = document.createElement('div'); widgetThemeList.id = CSS.WidgetThemeList; var widgetFooter = document.createElement('div'); widgetFooter.id = CSS.WidgetFooter; // assemble the elements widgetDiv.appendChild(widgetHeader); widgetDiv.appendChild(widgetIntro); widgetDiv.appendChild(widgetThemeList); widgetDiv.appendChild(widgetFooter); // References this.element = widgetDiv; this.element.parts = {}; this.element.parts.title = widgetHeader; this.element.parts.intro = widgetIntro; this.element.parts.theme_list = widgetThemeList; this.element.parts.footer = widgetFooter; } }; lampo.fbnth.Widget.getInstance = function() { return window.fbnth_widget; }; lampo.fbnth.Widget.CSS = { Classes: {}, Elements: { Widget: 'dr_fbnth', WidgetHeader: 'dr_fbnth_hdr', WidgetIntro: 'dr_fbnth_intro', WidgetThemeList: 'dr_fbnth_themes', WidgetFooter: 'dr_fbnth_ftr' } }; /* create widget */ try { var introHTML = "

The Dave Ramsey Show on Fox Business has some special theme hours coming up, and we want your questions and stories.

We're currently looking for stories about:

"; window.fbnth_widget = new lampo.fbnth.Widget( [ {contentID: 11299, title: "Giving", synopsis:"Send Us Your Stories On Giving"}, {contentID: 114366, title: "Changing Your Family Tree", synopsis:"Changing Your Family Tree"} ], { stylesheet: "http://www.daveramsey.com/etc/widgets/fbnth/fbnth_widget.css.cfm", title: "Submit Your Story!", intro: introHTML, footer_title: "Submit Your Stories", landing_page_url: "http://www.daveramsey.com/etc/theme_hour/", submission_base_url: "http://www.daveramsey.com/etc/theme_hour/index.cfm?FuseAction=dspSubmissionForm&intCategoryItemId=" }); } catch(ex) {alert(ex);}