var html = "
" +"
" +" " +" " +" \"www.cleanairpartners.net\"" +" " +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" +"
" // elements absolutely positioned to be in the same place no matter the tab. +"
" +" \"\"" +" " +" " +" " +" " +" " +" " +"
" +" \"\"" +"
" +"
" +" \"\"" +"
" +"
" +" \"\"" +"
" +"
" +" \"\"" +"
" +"
" +"
" +" Metro Baltimore" +"
" +"
" +"
" +"
" +"
" +"
" +" " +" Sun
11/19" +"
" +"
" +"
" +" " +" Mon
11/20" +"
" +"
" +"
" +" " +" Tue
11/21" +"
" +"
" +"
" +"
" +"
" +"
" +" Metro Washington" +"
" +"
" +"
" +"
" +"
" +"
" +" " +" Sun
11/19" +"
" +"
" +"
" +" " +" Mon
11/20" +"
" +"
" +"
" +" " +" Tue
11/21" +"
" +"
" +"
" +"
" +"
" +"
" +" Western Maryland" +"
" +"
" +"
" +"
" +"
" +"
" +" " +" Sun
11/19" +"
" +"
" +"
" +" " +" Mon
11/20" +"
" +"
" +"
" +" " +" Tue
11/21" +"
" +"
" +"
" +"
" +"
" +"
" +" Eastern Shore" +"
" +"
" +"
" +"
" +"
" +"
" +" " +" Sun
11/19" +"
" +"
" +"
" +" " +" Mon
11/20" +"
" +"
" +"
" +" " +" Tue
11/21" +"
" +"
" +"
" +"
" +"
" +"
" +"
" //+"
" +"
" +"
" +"
" +"
" +"
" +" Commit to leaving your vehicle parked for at least one day each week." +"
" +"
" +"
"; (function () { sti = {}; sti.Util = { isArray : function (obj) { if (typeof(obj) === "object" && obj.constructor) { //returns true is it is an array if (obj.constructor.toString().indexOf("Array") === -1) { return false; } else { return true; } } return false; }, isString : function (input) { return typeof(input) === 'string'; } }; var Util = sti.Util; sti.Dom = { removeClass : function (el, classToRemove) { var classNamesArray = el.className.split(' '), classNames = "", separator = ""; for (var i = 0; i < classNamesArray.length; i++) { if (classNamesArray[i] !== classToRemove) { classNames += separator + classNamesArray[i]; separator = " "; } } el.className = classNames; }, addClass : function (el, classToAdd) { var _el = this.getElementById(el); if (_el.className.length === 0) _el.className = classToAdd; else _el.className += " " + classToAdd; }, getElementById : function (id) { var getElement = function (obj) { if (Util.isString(obj)) { return document.getElementById(obj); } else { return obj; } }; if (Util.isArray(id)) { var elArray = []; for (var i = 0; i < id.length; i++) { elArray.push(getElement(id)); } return elArray; } else { return getElement(id); } }, addListener : function (el,eventType,fn,scope) { var _el = this.getElementById(el); var callbackWrapper = function(e) { if (scope) { fn.call(scope,e); } else { fn(e); } }; if (_el.addEventListener) { _el.addEventListener(eventType,callbackWrapper,false); } else if (_el.attachEvent) { _el.attachEvent('on'+eventType,callbackWrapper); } }, setStyle : function (el,property,value) { var _el = this.getElementById(el); _el.style[property] = value; }, loadCssFile : function (filename) { var headEl = document.getElementsByTagName("head")[0]; var fileRef = document.createElement("link"); fileRef.setAttribute("rel", "stylesheet"); fileRef.setAttribute("type", "text/css"); fileRef.setAttribute("href", filename); headEl.appendChild(fileRef); } }; var $ = sti.Dom.getElementById, Dom = sti.Dom; sti.AirQualityRegion = function(code) { this._code = code; this._mapEl = null; this._boxEl = null; this._state = false; this._on3Day = false; } sti.AirQualityRegion.prototype = { _hideAqiBox : function () { Dom.setStyle(this._boxEl,'visibility','hidden'); }, _showAqiBox : function () { Dom.setStyle(this._boxEl,'visibility','visible'); }, _handleMouseOver : function (e, code) { if (this._on3Day === false && this._state === false) { this._showAqiBox(); this._state = true; } }, _handleMouseOut : function (e, code) { if (this._on3Day === false && this._state === true) { this._hideAqiBox(code); this._state = false; } }, onDomReady : function() { this._mapEl = $('aqfwidget_map-area-' + this._code); this._boxEl = $("aqfwidget_aqiBox-" + this._code); //map region hover event registration Dom.addListener(this._mapEl, 'mouseover',this._handleMouseOver,this); Dom.addListener(this._mapEl, 'mouseout',this._handleMouseOut,this); //aqi box hover event registration Dom.addListener(this._boxEl, 'mouseover', this._handleMouseOver,this); Dom.addListener(this._boxEl, 'mouseout', this._handleMouseOut,this); }, onTabChange : function(is3DayTab) { this._on3Day = is3DayTab; if (is3DayTab === true) { this._showAqiBox(); } else { this._hideAqiBox(); } } }; var AirQualityRegion = sti.AirQualityRegion; sti.AirQualityForecastWidget = function (id, options) { this._id = id; Dom.loadCssFile("http://widget.cleanairpartners.net/css/airqualitywidget/widget.css"); this._regions = []; this._regionCodes = ['wm','mw','mb','es']; for (var i = 0; i < this._regionCodes.length; i++) { this._regions[this._regionCodes[i]] = new AirQualityRegion(this._regionCodes[i]); } }; sti.AirQualityForecastWidget.prototype = { _handle3DayTabClick : function (e) { var switcherEl = $('aqfwidget_wpr'); Dom.removeClass(switcherEl, 'aqfwidget_activeTab-today'); Dom.addClass(switcherEl, 'aqfwidget_activeTab-3Day'); for (var i = 0; i < this._regionCodes.length; i++) { var code = this._regionCodes[i]; this._regions[code].onTabChange(true); } }, _handleTodayTabClick : function (e) { var switcherEl = $('aqfwidget_wpr'); Dom.removeClass(switcherEl, 'aqfwidget_activeTab-3Day'); Dom.addClass(switcherEl, 'aqfwidget_activeTab-today'); for (var i = 0; i < this._regionCodes.length; i++) { var code = this._regionCodes[i]; this._regions[code].onTabChange(false); } }, _handleInfoIconHover : function (e) { Dom.setStyle("aqfwidget_infoDisplay",'display','block'); }, _handleInfoIconMouseOut : function (e) { Dom.setStyle("aqfwidget_infoDisplay",'display','none'); }, //added for footer hover _handleFooterHover : function (e) { Dom.setStyle("aqfwidget_footerDisplay",'display','block'); }, _handleFooterMouseOut : function (e) { Dom.setStyle("aqfwidget_footerDisplay",'display','none'); }, _injectWidgetHtmlIntoDom : function (el) { el.innerHTML = html; }, init : function () { var el = $(this._id); this._injectWidgetHtmlIntoDom(el); //click event registration Dom.addListener("aqfwidget_3DayTab",'click',this._handle3DayTabClick,this); Dom.addListener("aqfwidget_todayTab-inactive",'click',this._handleTodayTabClick,this); //hover event registration Dom.addListener("aqfwidget_infoIcon",'mouseover',this._handleInfoIconHover,this); Dom.addListener("aqfwidget_infoIcon",'mouseout',this._handleInfoIconMouseOut,this); //added for footer hover, showing tips Dom.addListener("aqfwidget_footer",'mouseover',this._handleFooterHover,this); Dom.addListener("aqfwidget_footer",'mouseout',this._handleFooterMouseOut,this); for (var i = 0; i < this._regionCodes.length; i++) { var code = this._regionCodes[i]; this._regions[code].onDomReady(); } } }; })();