/*global YAHOO,recursiveGetOffsetTop,unescape */ YAHOO.namespace("azcat"); YAHOO.azcat.topNav = function () { return { init: function () { // Animation object var oAnim; // Admin Menu object var oMenu = new YAHOO.widget.MenuBar("navigation", { autosubmenudisplay: true, hidedelay: 375, lazyload: true, iframe: !!YAHOO.env.ua.ie}); // Custom onClick for dealing with javascript: function onMenuItemClick(p_sType, p_aArgs, p_oMenu) { var oEvent = p_aArgs[0]; var oItem = this; var oTarget = YAHOO.util.Event.getTarget(oEvent); if (oItem && !oItem.cfg.getProperty("disabled")) { var oItemCfg = oItem.cfg; var sURL = oItemCfg.getProperty("url"); if (sURL.search(/^javascript:/) === 0) { var fOnclick = new Function("event", unescape(sURL)); fOnclick.call(this, oEvent); YAHOO.util.Event.preventDefault(oEvent); } } } // Utility function used to setup animation for submenus function setupMenuAnimation(p_oMenu) { if (!p_oMenu.animationSetup) { var aItems = p_oMenu.getItemGroups(); if (aItems && aItems[0]) { var i = aItems[0].length - 1; var oSubitem; var oSubmenu; do { oSubitem = p_oMenu.getItem(i); oSubitem.clickEvent.subscribe(onMenuItemClick, oSubitem, true); //This will run before the standard onClick. The standard onClick will not run after the preventDefault. oSubmenu = oSubitem.cfg.getProperty("submenu"); if (oSubmenu) { // do the onShow animation oSubmenu.beforeShowEvent.subscribe(onMenuBeforeShow, oSubmenu, true); oSubmenu.showEvent.subscribe(onMenuShow, oSubmenu, true); // This runs AFTER the onShow method subscribe above. } } while (i--); } p_oMenu.animationSetup = true; } } // "beforeshow" event handler for each submenu of the menu bar function onMenuBeforeShow(p_sType, p_sArgs, p_oMenu) { var topPadding; if (oAnim && oAnim.isAnimated()) { oAnim.stop(); oAnim = null; } if (this.parent.parent.parent && this instanceof YAHOO.widget.Menu) { if (YAHOO.env.ua.ie) { topPadding = 3; } else { topPadding = 1; } var moveIt = recursiveGetOffsetTop(this.element) - recursiveGetOffsetTop(this._getFirstEnabledItem().element) - topPadding; YAHOO.util.Dom.setStyle(this.element, "top", parseInt(YAHOO.util.Dom.getStyle(this.element, 'top'), 10) + moveIt + "px"); if (this.iframe) { // Move the Iframe as well. YAHOO.util.Dom.setStyle(this.iframe, "top", parseInt(YAHOO.util.Dom.getStyle(this.iframe, 'top'), 10) + moveIt + "px"); } } YAHOO.util.Dom.setStyle(this.element, "overflow", "hidden"); YAHOO.util.Dom.setStyle(this.body, "marginTop", ("-" + this.body.offsetHeight + "px")); } // "show" event handler for each submenu of the menu bar function onMenuShow(p_sType, p_sArgs, p_oMenu) { oAnim = new YAHOO.util.Anim( this.body, { marginTop: { to: 0 } }, 0.1, YAHOO.util.Easing.easeOut); oAnim.animate(); var me = this; function onTween() { me.cfg.refireEvent("iframe"); } function onAnimationComplete() { YAHOO.util.Dom.setStyle(me.body, "marginTop", ("0px")); YAHOO.util.Dom.setStyle(me.element, "overflow", "visible"); setupMenuAnimation(me); } /* Refire the event handler for the "iframe" configuration property with each tween so that the size and position of the iframe shim remain in sync with the menu. */ if (this.cfg.getProperty("iframe") == true) { oAnim.onTween.subscribe(onTween); } oAnim.onComplete.subscribe(onAnimationComplete); } function onMenuBeforeRender(p_sType, p_sArgs, p_oMenu) { var menu = {"bottom_menu": [], "main_menu": [{"url": "/index_html", "text": "Home"}, {"url": "/clients", "text": "Residential Pick-Up", "submenu": {"id": "/clients", "itemdata": [{"url": "/clients/village_of_andrew", "text": "Village of Andrew", "submenu": {"id": "/clients/village_of_andrew", "itemdata": [{"url": "/clients/village_of_andrew/schedule", "text": "Schedule"}, {"url": "/clients/village_of_andrew/program_details", "text": "Program Details"}, {"url": "/clients/village_of_andrew/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/copy2_of_town_of_beaumont", "text": "Town of Beaumont", "submenu": {"id": "/clients/copy2_of_town_of_beaumont", "itemdata": [{"url": "/clients/copy2_of_town_of_beaumont/schedule", "text": "Schedule"}, {"url": "/clients/copy2_of_town_of_beaumont/program_details", "text": "Program Details"}, {"url": "/clients/copy2_of_town_of_beaumont/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/village_of_breton", "text": "Village of Breton", "submenu": {"id": "/clients/village_of_breton", "itemdata": [{"url": "/clients/village_of_breton/schedule", "text": "Schedule"}, {"url": "/clients/village_of_breton/program_details", "text": "Program Details"}, {"url": "/clients/village_of_breton/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_devon", "text": "Town of Devon", "submenu": {"id": "/clients/town_of_devon", "itemdata": [{"url": "/clients/town_of_devon/schedule", "text": "Schedule"}, {"url": "/clients/town_of_devon/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/town_of_devon/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_drayton_valley", "text": "Town of Drayton Valley", "submenu": {"id": "/clients/town_of_drayton_valley", "itemdata": [{"url": "/clients/town_of_drayton_valley/schedule", "text": "Schedule"}, {"url": "/clients/town_of_drayton_valley/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/town_of_drayton_valley/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/city_of_grande_prairie", "text": "City of Grande Prairie", "submenu": {"id": "/clients/city_of_grande_prairie", "itemdata": [{"url": "/clients/city_of_grande_prairie/schedule", "text": "Schedule"}, {"url": "/clients/city_of_grande_prairie/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/city_of_grande_prairie/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/city_of_leduc", "text": "City of Leduc", "submenu": {"id": "/clients/city_of_leduc", "itemdata": [{"url": "/clients/city_of_leduc/schedule", "text": "Schedule"}, {"url": "/clients/city_of_leduc/program_details", "text": "Program Details"}, {"url": "/clients/city_of_leduc/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_legal", "text": "Town of Legal", "submenu": {"id": "/clients/town_of_legal", "itemdata": [{"url": "/clients/town_of_legal/schedule", "text": "Schedule"}, {"url": "/clients/town_of_legal/program_details", "text": "Program Details"}, {"url": "/clients/town_of_legal/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_mayerthorpe", "text": "Town of Mayerthorpe", "submenu": {"id": "/clients/town_of_mayerthorpe", "itemdata": [{"url": "/clients/town_of_mayerthorpe/schedule", "text": "Schedule"}, {"url": "/clients/town_of_mayerthorpe/program_details", "text": "Program Details"}, {"url": "/clients/town_of_mayerthorpe/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/village_of_new_sarepta", "text": "Village of New Sarepta", "submenu": {"id": "/clients/village_of_new_sarepta", "itemdata": [{"url": "/clients/village_of_new_sarepta/schedule", "text": "Schedule"}, {"url": "/clients/village_of_new_sarepta/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/village_of_new_sarepta/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_onoway", "text": "Town of Onoway", "submenu": {"id": "/clients/town_of_onoway", "itemdata": [{"url": "/clients/town_of_onoway/schedule", "text": "Schedule"}, {"url": "/clients/town_of_onoway/program_details", "text": "Program Details"}, {"url": "/clients/town_of_onoway/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/parkland_village", "text": "Parkland Village", "submenu": {"id": "/clients/parkland_village", "itemdata": [{"url": "/clients/parkland_village/schedule", "text": "Schedule"}, {"url": "/clients/parkland_village/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/parkland_village/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/summer_villages_of_pigeon_lake", "text": "Summer Villages of Pigeon Lake", "submenu": {"id": "/clients/summer_villages_of_pigeon_lake", "itemdata": [{"url": "/clients/summer_villages_of_pigeon_lake/schedule", "text": "Schedule"}, {"url": "/clients/summer_villages_of_pigeon_lake/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/summer_villages_of_pigeon_lake/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_redwater", "text": "Town of Redwater", "submenu": {"id": "/clients/town_of_redwater", "itemdata": [{"url": "/clients/town_of_redwater/schedule", "text": "Schedule"}, {"url": "/clients/town_of_redwater/program_details", "text": "Program Details"}, {"url": "/clients/town_of_redwater/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/village_of_sangudo", "text": "Village of Sangudo", "submenu": {"id": "/clients/village_of_sangudo", "itemdata": [{"url": "/clients/village_of_sangudo/schedule", "text": "Schedule"}, {"url": "/clients/village_of_sangudo/program_details", "text": "Program Details"}, {"url": "/clients/village_of_sangudo/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/city_of_st._albert", "text": "City of St. Albert", "submenu": {"id": "/clients/city_of_st._albert", "itemdata": [{"url": "/clients/city_of_st._albert/schedule", "text": "Schedule"}, {"url": "/clients/city_of_st._albert/program_details", "text": "Program Details"}, {"url": "/clients/city_of_st._albert/copy_of_frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_stony_plain", "text": "Town of Stony Plain", "submenu": {"id": "/clients/town_of_stony_plain", "itemdata": [{"url": "/clients/town_of_stony_plain/schedule", "text": "Schedule"}, {"url": "/clients/town_of_stony_plain/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/town_of_stony_plain/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/strathcona_county_~incl._sherwood_park~", "text": "Strathcona County", "submenu": {"id": "/clients/strathcona_county_~incl._sherwood_park~", "itemdata": [{"url": "/clients/strathcona_county_~incl._sherwood_park~/schedule", "text": "Schedule"}, {"url": "/clients/strathcona_county_~incl._sherwood_park~/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/strathcona_county_~incl._sherwood_park~/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/village_of_wabamun", "text": "Village of Wabamun", "submenu": {"id": "/clients/village_of_wabamun", "itemdata": [{"url": "/clients/village_of_wabamun/schedule", "text": "Schedule"}, {"url": "/clients/village_of_wabamun/copy_of_program_details", "text": "Program Details"}, {"url": "/clients/village_of_wabamun/frequently_asked_questions", "text": "FAQ"}]}}, {"url": "/clients/town_of_whitecourt", "text": "Town of Whitecourt", "submenu": {"id": "/clients/town_of_whitecourt", "itemdata": [{"url": "/clients/town_of_whitecourt/schedule", "text": "Schedule"}, {"url": "/clients/town_of_whitecourt/program_details", "text": "Program Details"}, {"url": "/clients/town_of_whitecourt/copy_of_frequently_asked_questions", "text": "FAQ"}]}}]}}, {"url": "/municipal_services", "text": "Municipal Services", "submenu": {"id": "/municipal_services", "itemdata": [{"url": "/municipal_services/blue_bag", "text": "Blue Bag"}, {"url": "/municipal_services/organic_collection", "text": "Organic Collection"}, {"url": "/municipal_services/waste_collection", "text": "Waste Collection"}]}}, {"url": "/in_the_news", "text": "In the News", "submenu": {"id": "/in_the_news", "itemdata": [{"url": "/in_the_news/i~m_dreaming_of_a...green_christmas~", "text": "Green Christmas"}, {"url": "/in_the_news/environmentally_conscious_trio_launches_business_curb-side_recycling_for_households", "text": "Launch"}]}}, {"url": "/advocacy", "text": "Advocacy", "submenu": {"id": "/advocacy", "itemdata": [{"url": "/advocacy/doing_your_part", "text": "Doing Your Part"}, {"url": "/advocacy/where_do_recyclables_go", "text": "Where do recyclables go?"}, {"url": "/advocacy/current_info_~_stats", "text": "Current Info & Stats"}]}}, {"url": "/careers", "text": "Careers"}], "utility_menu": [{"url": "/contact", "text": "Contact"}, {"url": "/about_us", "text": "About"}, {"url": "/sitemap", "text": "Sitemap"}]}; menu = menu.main_menu; this.addItems(menu); setupMenuAnimation(this); } // Subscribe to the "render" event oMenu.beforeRenderEvent.subscribe(onMenuBeforeRender, oMenu, true); // render the menu bar oMenu.render(); oMenu.show(); } }; }(); // Initialize and render the menu when it is available in the DOM YAHOO.util.Event.onAvailable("navigation", YAHOO.azcat.topNav.init);