﻿// (c) 2010 CodePlex Foundation
(function(){var b="ExtendedHoverMenu";function a(){var e="hidden",d="hiding",c="shown",b="showing",g="mouseout",f="mouseover",a=null;Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.HoverMenuBehavior=function(c){var b=this;Sys.Extended.UI.HoverMenuBehavior.initializeBase(b,[c]);b._hoverBehavior=a;b._popupBehavior=a;b._mouseEnterHandler=a;b._mouseLeaveHandler=a;b._unhoverHandler=a;b._hoverHandler=a;b._inHover=a;b._oldClass=a;b._popupElement=a;b._onShowJson=a;b._onHideJson=a;b._popupElement=a;b._hoverCssClass=a;b._offsetX=0;b._offsetY=0;b._popDelay=100;b._hoverDelay=0;b._popupPosition=a};Sys.Extended.UI.HoverMenuBehavior.prototype={initialize:function(){var b=this;Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(b,"initialize");b._hoverHandler=Function.createDelegate(b,b._onHover);b._unhoverHandler=Function.createDelegate(b,b._onUnhover);b._mouseEnterHandler=Function.createDelegate(b,b._onmouseover);b._mouseLeaveHandler=Function.createDelegate(b,b._onmouseout);var c=b.get_element();$addHandler(c,f,b._mouseEnterHandler);$addHandler(c,g,b._mouseLeaveHandler);if(b._popupElement){b._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:b.get_id()+"_PopupBehavior"},a,a,b._popupElement);if(b._popupPosition)b._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Absolute);else b._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Center);b._onShowJson&&b._popupBehavior.set_onShow(b._onShowJson);b._onHideJson&&b._popupBehavior.set_onHide(b._onHideJson);b._hoverBehavior=$create(Sys.Extended.UI.HoverBehavior,{id:b.get_id()+"_HoverBehavior",hoverDelay:b._hoverDelay,unhoverDelay:b._popDelay,hoverElement:b._popupElement},a,a,c);b._hoverBehavior.add_hover(b._hoverHandler);b._hoverBehavior.add_unhover(b._unhoverHandler)}},dispose:function(){var b=this;b._onShowJson=a;b._onHideJson=a;if(b._popupBehavior){b._popupBehavior.dispose();b._popupBehavior=a}if(b._popupElement)b._popupElement=a;b._mouseEnterHandler&&$removeHandler(b.get_element(),f,b._mouseEnterHandler);b._mouseLeaveHandler&&$removeHandler(b.get_element(),g,b._mouseLeaveHandler);if(b._hoverBehavior){if(b._hoverHandler){b._hoverBehavior.remove_hover(b._hoverHandler);b._hoverHandler=a}if(b._unhoverHandler){b._hoverBehavior.remove_hover(b._unhoverHandler);b._unhoverHandler=a}b._hoverBehavior.dispose();b._hoverBehavior=a}Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(b,"dispose")},_getLeftOffset:function(){var a=this,c=$common.getLocation(a.get_element()).x,d=$common.getLocation(a.get_popupElement().offsetParent).x,b=0;switch(a._popupPosition){case Sys.Extended.UI.HoverMenuPopupPosition.Left:b=-1*a._popupElement.offsetWidth;break;case Sys.Extended.UI.HoverMenuPopupPosition.Right:b=a.get_element().offsetWidth}return b+c-d+a._offsetX},_getTopOffset:function(){var a=this,c=$common.getLocation(a.get_element()).y,d=$common.getLocation(a.get_popupElement().offsetParent).y,b=0;switch(a._popupPosition){case Sys.Extended.UI.HoverMenuPopupPosition.Top:b=-1*a._popupElement.offsetHeight;break;case Sys.Extended.UI.HoverMenuPopupPosition.Bottom:b=a.get_element().offsetHeight}return c-d+b+a._offsetY},_onHover:function(){var a=this;if(a._inHover)return;var b=new Sys.CancelEventArgs;a.raiseShowing(b);if(b.get_cancel())return;a._inHover=true;a.populate();a._popupBehavior.show();if($common.getCurrentStyle(a._popupElement,"display")=="none")a._popupElement.style.display="block";a._popupBehavior.set_x(a._getLeftOffset());a._popupBehavior.set_y(a._getTopOffset());a.raiseShown(Sys.EventArgs.Empty)},_onUnhover:function(){var a=this,b=new Sys.CancelEventArgs;a.raiseHiding(b);if(b.get_cancel())return;a._inHover=false;a._resetCssClass();a._popupBehavior.hide();a.raiseHidden(Sys.EventArgs.Empty)},_onmouseover:function(){var a=this,b=a.get_element();if(a._hoverCssClass&&b.className!=a._hoverCssClass){a._oldClass=b.className;b.className=a._hoverCssClass}},_onmouseout:function(){this._resetCssClass()},_resetCssClass:function(){var a=this,b=a.get_element();if(!a._inHover&&a._hoverCssClass&&b.className==a._hoverCssClass)b.className=a._oldClass},get_onShow:function(){return this._popupBehavior?this._popupBehavior.get_onShow():this._onShowJson},set_onShow:function(b){var a=this;if(a._popupBehavior)a._popupBehavior.set_onShow(b);else a._onShowJson=b;a.raisePropertyChanged("onShow")},get_onShowBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onShowBehavior():a},onShow:function(){this._popupBehavior&&this._popupBehavior.onShow()},get_onHide:function(){return this._popupBehavior?this._popupBehavior.get_onHide():this._onHideJson},set_onHide:function(b){var a=this;if(a._popupBehavior)a._popupBehavior.set_onHide(b);else a._onHideJson=b;a.raisePropertyChanged("onHide")},get_onHideBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onHideBehavior():a},onHide:function(){this._popupBehavior&&this._popupBehavior.onHide()},get_popupElement:function(){return this._popupElement},set_popupElement:function(b){var a=this;if(a._popupElement!=b){a._popupElement=b;a.get_isInitialized()&&a._hoverBehavior&&a._hoverBehavior.set_hoverElement(a._popupElement);a.raisePropertyChanged("popupElement")}},get_HoverCssClass:function(){return this._hoverCssClass},set_HoverCssClass:function(a){if(this._hoverCssClass!=a){this._hoverCssClass=a;this.raisePropertyChanged("HoverCssClass")}},get_OffsetX:function(){return this._offsetX},set_OffsetX:function(a){if(this._offsetX!=a){this._offsetX=a;this.raisePropertyChanged("OffsetX")}},get_OffsetY:function(){return this._offsetY},set_OffsetY:function(a){if(this._offsetY!=a){this._offsetY=a;this.raisePropertyChanged("OffsetY")}},get_PopupPosition:function(){return this._popupPosition},set_PopupPosition:function(a){if(this._popupPosition!=a){this._popupPosition=a;this.raisePropertyChanged("PopupPosition")}},get_PopDelay:function(){return this._popDelay},set_PopDelay:function(a){if(this._popDelay!=a){this._popDelay=a;this.raisePropertyChanged("PopDelay")}},get_HoverDelay:function(){return this._hoverDelay},set_HoverDelay:function(a){if(this._hoverDelay!=a){this._hoverDelay=a;this.raisePropertyChanged("HoverDelay")}},add_showing:function(a){this.get_events().addHandler(b,a)},remove_showing:function(a){this.get_events().removeHandler(b,a)},raiseShowing:function(c){var a=this.get_events().getHandler(b);a&&a(this,c)},add_shown:function(a){this.get_events().addHandler(c,a)},remove_shown:function(a){this.get_events().removeHandler(c,a)},raiseShown:function(b){var a=this.get_events().getHandler(c);a&&a(this,b)},add_hiding:function(a){this.get_events().addHandler(d,a)},remove_hiding:function(a){this.get_events().removeHandler(d,a)},raiseHiding:function(b){var a=this.get_events().getHandler(d);a&&a(this,b)},add_hidden:function(a){this.get_events().addHandler(e,a)},remove_hidden:function(a){this.get_events().removeHandler(e,a)},raiseHidden:function(b){var a=this.get_events().getHandler(e);a&&a(this,b)}};Sys.Extended.UI.HoverMenuBehavior.registerClass("Sys.Extended.UI.HoverMenuBehavior",Sys.Extended.UI.DynamicPopulateBehaviorBase);Sys.registerComponent(Sys.Extended.UI.HoverMenuBehavior,{name:"hoverMenu"});Sys.Extended.UI.HoverMenuPopupPosition=function(){throw Error.invalidOperation();};Sys.Extended.UI.HoverMenuPopupPosition.prototype={Center:0,Top:1,Left:2,Bottom:3,Right:4};Sys.Extended.UI.HoverMenuPopupPosition.registerEnum("Sys.Extended.UI.HoverMenuPopupPosition")}if(window.Sys&&Sys.loader)Sys.loader.registerScript(b,["ExtendedDynamicPopulate","ExtendedHover","ExtendedAnimationBehavior","ExtendedPopup"],a);else a()})();