Files
SIG/Scripts/AjaxControlToolkit/Release/HoverMenu.js
rrene 927295c7ba Revert "-- corr"
This reverts commit 5315c47fcd.
2024-11-05 10:55:34 -07:00

1 line
9.3 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.HoverMenuBehavior=function(n){Sys.Extended.UI.HoverMenuBehavior.initializeBase(this,[n]);this._hoverBehavior=null;this._popupBehavior=null;this._mouseEnterHandler=null;this._mouseLeaveHandler=null;this._unhoverHandler=null;this._hoverHandler=null;this._inHover=null;this._oldClass=null;this._popupElement=null;this._onShowJson=null;this._onHideJson=null;this._popupElement=null;this._hoverCssClass=null;this._offsetX=0;this._offsetY=0;this._popDelay=100;this._hoverDelay=0;this._popupPosition=null};Sys.Extended.UI.HoverMenuBehavior.prototype={initialize:function(){Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this,"initialize");this._hoverHandler=Function.createDelegate(this,this._onHover);this._unhoverHandler=Function.createDelegate(this,this._onUnhover);this._mouseEnterHandler=Function.createDelegate(this,this._onmouseover);this._mouseLeaveHandler=Function.createDelegate(this,this._onmouseout);var n=this.get_element();$addHandler(n,"mouseover",this._mouseEnterHandler);$addHandler(n,"mouseout",this._mouseLeaveHandler);this._popupElement&&(this._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:this.get_id()+"_PopupBehavior"},null,null,this._popupElement),this._popupPosition?this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Absolute):this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Center),this._onShowJson&&this._popupBehavior.set_onShow(this._onShowJson),this._onHideJson&&this._popupBehavior.set_onHide(this._onHideJson),this._hoverBehavior=$create(Sys.Extended.UI.HoverBehavior,{id:this.get_id()+"_HoverBehavior",hoverDelay:this._hoverDelay,unhoverDelay:this._popDelay,hoverElement:this._popupElement},null,null,n),this._hoverBehavior.add_hover(this._hoverHandler),this._hoverBehavior.add_unhover(this._unhoverHandler))},dispose:function(){this._onShowJson=null;this._onHideJson=null;this._popupBehavior&&(this._popupBehavior.dispose(),this._popupBehavior=null);this._popupElement&&(this._popupElement=null);this._mouseEnterHandler&&$removeHandler(this.get_element(),"mouseover",this._mouseEnterHandler);this._mouseLeaveHandler&&$removeHandler(this.get_element(),"mouseout",this._mouseLeaveHandler);this._hoverBehavior&&(this._hoverHandler&&(this._hoverBehavior.remove_hover(this._hoverHandler),this._hoverHandler=null),this._unhoverHandler&&(this._hoverBehavior.remove_hover(this._unhoverHandler),this._unhoverHandler=null),this._hoverBehavior.dispose(),this._hoverBehavior=null);Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this,"dispose")},_getLeftOffset:function(){var t=$common.getLocation(this.get_element()).x,i=$common.getLocation(this.get_popupElement().offsetParent).x,n=0;switch(this._popupPosition){case Sys.Extended.UI.HoverMenuPopupPosition.Left:n=-1*this._popupElement.offsetWidth;break;case Sys.Extended.UI.HoverMenuPopupPosition.Right:n=this.get_element().offsetWidth}return n+t-i+this._offsetX},_getTopOffset:function(){var t=$common.getLocation(this.get_element()).y,i=$common.getLocation(this.get_popupElement().offsetParent).y,n=0;switch(this._popupPosition){case Sys.Extended.UI.HoverMenuPopupPosition.Top:n=-1*this._popupElement.offsetHeight;break;case Sys.Extended.UI.HoverMenuPopupPosition.Bottom:n=this.get_element().offsetHeight}return t-i+n+this._offsetY},_onHover:function(){if(!this._inHover){var n=new Sys.CancelEventArgs;(this.raise_showing(n),n.get_cancel())||(this._inHover=!0,this.populate(),this._popupBehavior.show(),$common.getCurrentStyle(this._popupElement,"display")=="none"&&(this._popupElement.style.display="block"),this._popupBehavior.set_x(this._getLeftOffset()),this._popupBehavior.set_y(this._getTopOffset()),this.raise_shown(Sys.EventArgs.Empty))}},_onUnhover:function(){var n=new Sys.CancelEventArgs;(this.raise_hiding(n),n.get_cancel())||(this._inHover=!1,this._resetCssClass(),this._popupBehavior.hide(),this.raise_hidden(Sys.EventArgs.Empty))},_onmouseover:function(){var n=this.get_element();this._hoverCssClass&&n.className!=this._hoverCssClass&&(this._oldClass=n.className,n.className=this._hoverCssClass)},_onmouseout:function(){this._resetCssClass()},_resetCssClass:function(){var n=this.get_element();!this._inHover&&this._hoverCssClass&&n.className==this._hoverCssClass&&(n.className=this._oldClass)},get_onShow:function(){return this._popupBehavior?this._popupBehavior.get_onShow():this._onShowJson},set_onShow:function(n){this._popupBehavior?this._popupBehavior.set_onShow(n):this._onShowJson=n;this.raisePropertyChanged("onShow")},get_onShowBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onShowBehavior():null},onShow:function(){this._popupBehavior&&this._popupBehavior.onShow()},get_onHide:function(){return this._popupBehavior?this._popupBehavior.get_onHide():this._onHideJson},set_onHide:function(n){this._popupBehavior?this._popupBehavior.set_onHide(n):this._onHideJson=n;this.raisePropertyChanged("onHide")},get_onHideBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onHideBehavior():null},onHide:function(){this._popupBehavior&&this._popupBehavior.onHide()},get_popupElement:function(){return this._popupElement},set_popupElement:function(n){this._popupElement!=n&&(this._popupElement=n,this.get_isInitialized()&&this._hoverBehavior&&this._hoverBehavior.set_hoverElement(this._popupElement),this.raisePropertyChanged("popupElement"))},get_hoverCssClass:function(){return this._hoverCssClass},set_hoverCssClass:function(n){this._hoverCssClass!=n&&(this._hoverCssClass=n,this.raisePropertyChanged("hoverCssClass"))},get_HoverCssClass:function(){return Sys.Extended.Deprecated("get_HoverCssClass","get_hoverCssClass"),this.get_hoverCssClass()},set_HoverCssClass:function(n){Sys.Extended.Deprecated("set_HoverCssClass","set_hoverCssClass");this.set_hoverCssClass(n)},get_offsetX:function(){return this._offsetX},set_offsetX:function(n){this._offsetX!=n&&(this._offsetX=n,this.raisePropertyChanged("offsetX"))},get_OffsetX:function(){return Sys.Extended.Deprecated("get_OffsetX()","get_offsetX()"),this.get_offsetX()},set_OffsetX:function(n){Sys.Extended.Deprecated("set_OffsetX(value)","set_offsetX(value)");this.set_offsetX(n)},get_offsetY:function(){return this._offsetY},set_offsetY:function(n){this._offsetY!=n&&(this._offsetY=n,this.raisePropertyChanged("offsetY"))},get_OffsetY:function(){return Sys.Extended.Deprecated("get_OffsetY()","get_offsetY()"),this.get_offsetY()},set_OffsetY:function(n){Sys.Extended.Deprecated("set_OffsetY(value)","set_offsetY(value)");this.set_offsetY(n)},get_popupPosition:function(){return this._popupPosition},set_popupPosition:function(n){this._popupPosition!=n&&(this._popupPosition=n,this.raisePropertyChanged("popupPosition"))},get_PopupPosition:function(){return Sys.Extended.Deprecated("get_PopupPosition()","get_popupPosition()"),this.get_popupPosition()},set_PopupPosition:function(n){Sys.Extended.Deprecated("set_PopupPosition(value)","set_popupPosition(value)");this.set_popupPosition(n)},get_popDelay:function(){return this._popDelay},set_popDelay:function(n){this._popDelay!=n&&(this._popDelay=n,this.raisePropertyChanged("popDelay"))},get_PopDelay:function(){return Sys.Extended.Deprecated("get_PopDelay","get_popDelay"),this.get_popDelay()},set_PopDelay:function(n){Sys.Extended.Deprecated("set_PopDelay","set_popDelay");this.set_popDelay(n)},get_hoverDelay:function(){return this._hoverDelay},set_hoverDelay:function(n){this._hoverDelay!=n&&(this._hoverDelay=n,this.raisePropertyChanged("hoverDelay"))},get_HoverDelay:function(){return Sys.Extended.Deprecated("get_HoverDelay","get_hoverDelay"),this.get_hoverDelay()},set_HoverDelay:function(n){Sys.Extended.Deprecated("set_HoverDelay","set_hoverDelay");this.set_hoverDelay(n)},add_showing:function(n){this.get_events().addHandler("showing",n)},remove_showing:function(n){this.get_events().removeHandler("showing",n)},raise_showing:function(n){var t=this.get_events().getHandler("showing");t&&t(this,n)},raiseShowing:function(n){Sys.Extended.Deprecated("raiseShowing(eventArgs)","raise_showing(eventArgs)");this.raise_showing(n)},add_shown:function(n){this.get_events().addHandler("shown",n)},remove_shown:function(n){this.get_events().removeHandler("shown",n)},raise_shown:function(n){var t=this.get_events().getHandler("shown");t&&t(this,n)},raiseShown:function(n){Sys.Extended.Deprecated("raiseShown(eventArgs)","raise_shown(eventArgs)");this.raise_shown(n)},add_hiding:function(n){this.get_events().addHandler("hiding",n)},remove_hiding:function(n){this.get_events().removeHandler("hiding",n)},raise_hiding:function(n){var t=this.get_events().getHandler("hiding");t&&t(this,n)},raiseHiding:function(n){Sys.Extended.Deprecated("raiseHiding(eventArgs)","raise_hiding(eventArgs)");this.raise_hiding(n)},add_hidden:function(n){this.get_events().addHandler("hidden",n)},remove_hidden:function(n){this.get_events().removeHandler("hidden",n)},raise_hidden:function(n){var t=this.get_events().getHandler("hidden");t&&t(this,n)},raiseHidden:function(n){Sys.Extended.Deprecated("raiseHidden(eventArgs)","raise_hidden(eventArgs)");this.raise_hidden(n)}};Sys.Extended.UI.HoverMenuBehavior.registerClass("Sys.Extended.UI.HoverMenuBehavior",Sys.Extended.UI.DynamicPopulateBehaviorBase);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");