1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.BalloonPopupControlBehavior=function(n){Sys.Extended.UI.BalloonPopupControlBehavior.initializeBase(this,[n]);this._balloonPopupControlID=null;this._position=Sys.Extended.UI.BalloonPopupPosition.Auto;this._balloonStyle=Sys.Extended.UI.BalloonPopupStyle.Rectangle;this._offsetX=0;this._offsetY=0;this._extenderControlID=null;this._displayOnMouseOver=!1;this._displayOnFocus=!1;this._displayOnClick=!0;this._balloonSize="small";this._shadow=!0;this._scrollBars=Sys.Extended.UI.ScrollBars.Auto;this._popupElement=null;this._styleElement=null;this._sizeElement=null;this._shadowElement=null;this._directionElement=null;this._contentElement=null;this._popupBehavior=null;this._popupVisible=!1;this._focusHandler=null;this._mouseOverHandler=null;this._clickHandler=null;this._popupClickHandler=null;this._bodyClickHandler=null;this._onShowJson=null;this._onHideJson=null;this._popupWidth=0;this._popupHeight=0;this._AutoPosition=null;this._directionClassName=null};Sys.Extended.UI.BalloonPopupControlBehavior.prototype={initialize:function(){Sys.Extended.UI.BalloonPopupControlBehavior.callBaseMethod(this,"initialize");var n=this.get_element();this.createPopupElement();this._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:this.get_id()+"BalloonPopupBehavior",parentElement:n},null,null,this._popupElement);this._onShowJson&&this._popupBehavior.set_onShow(this._onShowJson);this._onHideJson&&this._popupBehavior.set_onHide(this._onHideJson);this._displayOnFocus&&(this._focusHandler=Function.createDelegate(this,this._onFocus));this._displayOnMouseOver&&(this._mouseOverHandler=Function.createDelegate(this,this._onMouseOver));this._displayOnClick&&(this._clickHandler=Function.createDelegate(this,this._onFocus));this._popupClickHandler=Function.createDelegate(this,this._onPopupClick);this._bodyClickHandler=Function.createDelegate(this,this._onBodyClick);this._displayOnFocus&&$addHandler(n,"focus",this._focusHandler);this._displayOnMouseOver&&$addHandler(n,"mouseover",this._mouseOverHandler);this._displayOnClick&&$addHandler(n,"click",this._clickHandler);$addHandler(document,"click",this._bodyClickHandler);$addHandler(this._popupElement,"click",this._popupClickHandler)},dispose:function(){var n=this.get_element();this._onShowJson=null;this._onHideJson=null;this._popupBehavior&&(this._popupBehavior.dispose(),this._popupBehavior=null);this._focusHandler&&($removeHandler(n,"focus",this._focusHandler),this._focusHandler=null);this._mouseOverHandler&&($removeHandler(n,"mouseover",this._mouseOverHandler),this._mouseOverHandler=null);this._clickHandler&&($removeHandler(n,"click",this._clickHandler),this._clickHandler=null);this._bodyClickHandler&&($removeHandler(document,"click",this._bodyClickHandler),this._bodyClickHandler=null);this._popupClickHandler&&($removeHandler(this._popupElement,"click",this._popupClickHandler),this._popupClickHandler=null);Sys.Extended.UI.BalloonPopupControlBehavior.callBaseMethod(this,"dispose")},createPopupElement:function(){var n=this.get_element();if(this._popupElement=$common.createElementFromTemplate({nodeName:"div",properties:{id:this.get_id()+"_balloonPopup",style:{display:"block",position:"absolute"}},cssClasses:["ajax__balloon_popup"]},n.parentNode),this._styleElement=$common.createElementFromTemplate({nodeName:"span",Properties:{id:"ajax__style_wrapper"}},this._popupElement),this._sizeElement=$common.createElementFromTemplate({nodeName:"span",Properties:{id:"ajax__size_wrapper"}},this._styleElement),this._shadowElement=$common.createElementFromTemplate({nodeName:"div",Properties:{id:"ajax__shadow_wrapper"}},this._sizeElement),this._directionElement=$common.createElementFromTemplate({nodeName:"div",Properties:{id:"ajax__direction_wrapper"}},this._shadowElement),this._contentElement=$common.createElementFromTemplate({nodeName:"div",Properties:{id:"ajax__content"},cssClasses:["ajax__content"]},this._directionElement),$get(this._balloonPopupControlID)==null)throw"Referred BalloonPopupControlId did not find.";$get(this._balloonPopupControlID).style.display="none";this.setStyle();this.setSize();this._directionElement.className=this._directionClassName;this._popupWidth=this._directionElement.offsetWidth;this._popupHeight=this._directionElement.offsetHeight;this.get_balloonPopupPosition()!=Sys.Extended.UI.BalloonPopupPosition.Auto&&(this.setPosition(),this.setContentPadding(),this.setScrollBar())},setStyle:function(){switch(this.get_balloonPopupStyle()){case Sys.Extended.UI.BalloonPopupStyle.Rectangle:this._styleElement.className="rect";this._directionClassName="rect";break;case Sys.Extended.UI.BalloonPopupStyle.Cloud:this._styleElement.className="cloud";this._directionClassName="cloud";break;case Sys.Extended.UI.BalloonPopupStyle.Custom:this._styleElement.className=this.get_customClassName();this._directionClassName=this.get_customClassName();break;default:this._styleElement.className="rect";this._directionClassName="rect"}},setSize:function(){switch(this.get_balloonSize()){case Sys.Extended.UI.BalloonPopupSize.Small:this._sizeElement.className+=" small";this._directionClassName+=" small";break;case Sys.Extended.UI.BalloonPopupSize.Medium:this._sizeElement.className+=" medium";this._directionClassName+=" medium";break;case Sys.Extended.UI.BalloonPopupSize.Large:this._sizeElement.className+=" large";this._directionClassName+=" large";break;default:this._sizeElement.className+=" small";this._directionClassName+=" small"}},setPosition:function(){var n=this.get_balloonPopupPosition()==Sys.Extended.UI.BalloonPopupPosition.Auto?this._autoPosition:this.get_balloonPopupPosition();switch(n){case Sys.Extended.UI.BalloonPopupPosition.TopLeft:this._directionElement.className=this._directionClassName+" top_left";this._shadowElement.className=this._directionClassName+" top_left_shadow";break;case Sys.Extended.UI.BalloonPopupPosition.TopRight:this._directionElement.className=this._directionClassName+" top_right";this._shadowElement.className=this._directionClassName+" top_right_shadow";break;case Sys.Extended.UI.BalloonPopupPosition.BottomLeft:this._directionElement.className=this._directionClassName+" bottom_left";this._shadowElement.className=this._directionClassName+" bottom_left_shadow";break;case Sys.Extended.UI.BalloonPopupPosition.BottomRight:this._directionElement.className=this._directionClassName+" bottom_right";this._shadowElement.className=this._directionClassName+" bottom_right_shadow";break;default:this._directionElement.className=this._directionClassName+" top_right";this._shadowElement.className=this._directionClassName+" top_right_shadow"}},setContentPadding:function(){var n=$common.getPaddingBox(this._contentElement),t=$get(this._balloonPopupControlID);$common.setBounds(t,{x:this._offsetX+n.left,y:this._offsetY+n.top,width:this._popupWidth-n.left-n.right,height:this._popupHeight-n.top-n.bottom})},setScrollBar:function(){var n=$get(this._balloonPopupControlID);switch(this.get_scrollBars()){case Sys.Extended.UI.ScrollBars.Horizontal:$common.setStyle(n,{overflowX:"scroll",overflowY:"hidden"});break;case Sys.Extended.UI.ScrollBars.Vertical:$common.setStyle(n,{overflowY:"scroll",overflowX:"hidden"});break;case Sys.Extended.UI.ScrollBars.Both:$common.setStyle(n,{overflow:"scroll"});break;case Sys.Extended.UI.ScrollBars.None:$common.setStyle(n,{overflow:"hidden"});break;default:$common.setStyle(n,{overflow:"auto"})}},showPopup:function(){var n,t,i;this._contentElement.appendChild($get(this._balloonPopupControlID));$get(this._balloonPopupControlID).style.display="block";Sys.Extended.UI.BalloonPopupPosition.Auto==this._position&&(this._setAutoPosition(),this.setPosition(),this.setContentPadding(),this.setScrollBar());this._shadow||(this._shadowElement.className="");n=Sys.Extended.UI.BalloonPopupControlBehavior.__VisiblePopup;n&&n._popupBehavior&&n.hidePopup();Sys.Extended.UI.BalloonPopupControlBehavior.callBaseMethod(this,"populate");this._popupBehavior.set_x(this._getLeftOffset());this._popupBehavior.set_y(this._getTopOffset());this._popupBehavior.show();this._popupVisible=!0;Sys.Extended.UI.BalloonPopupControlBehavior.__VisiblePopup=this;t=$common.getCurrentStyle(this._directionElement,"backgroundPositionX");i=$common.getCurrentStyle(this._directionElement,"backgroundPositionY");$common.setStyle(this._styleElement,{backgroundPositionX:t,backgroundPositionY:i})},hidePopup:function(){this._popupBehavior.hide();this._popupVisible=!1;Sys.Extended.UI.BalloonPopupControlBehavior.__VisiblePopup=null},_onFocus:function(n){this._popupVisible||this.showPopup();n&&n.stopPropagation()},_onMouseOver:function(n){this._popupVisible||this.showPopup();n&&n.stopPropagation()},_onPopupClick:function(n){n.stopPropagation()},_onBodyClick:function(){this._popupVisible&&this.hidePopup()},_onPopulated:function(n,t){Sys.Extended.UI.BalloonPopupControlBehavior.callBaseMethod(this,"_onPopulated",[n,t]);this._popupVisible&&this._popupBehavior.show()},_getLeftOffset:function(){var n=Sys.Extended.UI.BalloonPopupPosition.Auto==this._position?this._autoPosition:this._position;return Sys.Extended.UI.BalloonPopupPosition.BottomLeft==n||Sys.Extended.UI.BalloonPopupPosition.TopLeft==n?-1*this._popupWidth+this._offsetX:Sys.Extended.UI.BalloonPopupPosition.BottomRight==n||Sys.Extended.UI.BalloonPopupPosition.TopRight==n?this.get_element().offsetWidth+this._offsetX:this._offsetX},_getTopOffset:function(){var n=Sys.Extended.UI.BalloonPopupPosition.Auto==this._position?this._autoPosition:this._position;return Sys.Extended.UI.BalloonPopupPosition.TopLeft==n||Sys.Extended.UI.BalloonPopupPosition.TopRight==n?-1*this._popupHeight+this._offsetY:Sys.Extended.UI.BalloonPopupPosition.BottomLeft==n||Sys.Extended.UI.BalloonPopupPosition.BottomRight==n?this.get_element().offsetHeight+this._offsetY:this._offsetY},_setAutoPosition:function(){var t=0,i=0,n=this.get_element();if(n.offsetParent)do i+=n.offsetLeft,t+=n.offsetTop;while(n=n.offsetParent);var r=this.posTop(),o=this.posLeft(),s=this.pageWidth(),h=this.pageHeight(),c=r+h,u=o+s,f=t-this._popupHeight,a=i-this._popupWidth,l=t+this.get_element().offsetHeight+this._popupHeight,e=i+this.get_element().offsetWidth+this._popupWidth;this._autoPosition=f-r>0&&f-r>c-l?u<e?Sys.Extended.UI.BalloonPopupPosition.TopLeft:Sys.Extended.UI.BalloonPopupPosition.TopRight:u<e?Sys.Extended.UI.BalloonPopupPosition.BottomLeft:Sys.Extended.UI.BalloonPopupPosition.BottomRight},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_balloonPopupControlID:function(){return this._balloonPopupControlID},set_balloonPopupControlID:function(n){this._balloonPopupControlID!=n&&(this._balloonPopupControlID=n,this.raisePropertyChanged("balloonPopupControlID"))},get_BalloonPopupControlID:function(){return Sys.Extended.Deprecated("get_BalloonPopupControlID","get_balloonPopupControlID"),this.get_balloonPopupControlID()},set_BalloonPopupControlID:function(n){Sys.Extended.Deprecated("set_BalloonPopupControlID","set_balloonPopupControlID");this.set_balloonPopupControlID(n)},get_balloonPopupPosition:function(){return this._position},set_balloonPopupPosition:function(n){this._position!=n&&(this._position=n,this.raisePropertyChanged("Position"))},get_balloonPopupStyle:function(){return this._balloonStyle},set_balloonPopupStyle:function(n){this._balloonStyle!=n&&(this._balloonStyle=n,this.raisePropertyChanged("balloonStyle"))},get_extenderControlID:function(){return this._extenderControlID},set_extenderControlID:function(n){this._extenderControlID!=n&&(this._extenderControlID=n,this.raisePropertyChanged("extenderControlID"))},get_ExtenderControlID:function(){return Sys.Extended.Deprecated("get_ExtenderControlID","get_extenderControlID"),this.get_extenderControlID()},set_ExtenderControlID:function(n){Sys.Extended.Deprecated("set_ExtenderControlID","set_extenderControlID");this.set_extenderControlID(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","set_offsetX");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","set_offsetY");this.set_offsetY(n)},get_displayOnMouseOver:function(){return this._displayOnMouseOver},set_displayOnMouseOver:function(n){this._displayOnMouseOver!=n&&(this._displayOnMouseOver=n,this.raisePropertyChanged("displayOnMouseOver"))},get_displayOnFocus:function(){return this._displayOnFocus},set_displayOnFocus:function(n){this._displayOnFocus!=n&&(this._displayOnFocus=n,this.raisePropertyChanged("displayOnFocus"))},get_displayOnClick:function(){return this._displayOnClick},set_displayOnClick:function(n){this._displayOnClick!=n&&(this._displayOnClick=n,this.raisePropertyChanged("displayOnClick"))},get_balloonSize:function(){return this._balloonSize},set_balloonSize:function(n){this._balloonSize!=n&&(this._balloonSize=n,this.raisePropertyChanged("balloonSize"))},get_useShadow:function(){return this._shadow},set_useShadow:function(n){this._shadow!=n&&(this._shadow=n,this.raisePropertyChanged("useShadow"))},get_scrollBars:function(){return this._scrollBars},set_scrollBars:function(n){this._scrollBars!=n&&(this._scrollBars=n,this.raisePropertyChanged("scrollBars"))},get_popupVisible:function(){return this._popupVisible},get_PopupVisible:function(){return Sys.Extended.Deprecated("get_PopupVisible","get_popupVisible"),this.get_popupVisible()},get_customClassName:function(){return this._customClassName},set_customClassName:function(n){this._customClassName!=n&&(this._customClassName=n,this.raisePropertyChanged("customClassName"))},add_showing:function(n){this._popupBehavior&&this._popupBehavior.add_showing(n)},remove_showing:function(n){this._popupBehavior&&this._popupBehavior.remove_showing(n)},raise_showing:function(n){this._popupBehavior&&this._popupBehavior.raise_showing(n)},raiseShowing:function(n){Sys.Extended.Deprecated("raiseShowing(eventArgs)","raise_showing(eventArgs)");this.raise_showing(n)},add_shown:function(n){this._popupBehavior&&this._popupBehavior.add_shown(n)},remove_shown:function(n){this._popupBehavior&&this._popupBehavior.remove_shown(n)},raise_shown:function(n){this._popupBehavior&&this._popupBehavior.raise_shown(n)},raiseShown:function(n){Sys.Extended.Deprecated("raiseShown(eventArgs)","raise_shown(eventArgs)");this.raise_shown(n)},add_hiding:function(n){this._popupBehavior&&this._popupBehavior.add_hiding(n)},remove_hiding:function(n){this._popupBehavior&&this._popupBehavior.remove_hiding(n)},raise_hiding:function(n){this._popupBehavior&&this._popupBehavior.raise_hiding(n)},raiseHiding:function(n){Sys.Extended.Deprecated("raiseHiding(eventArgs)","raise_hiding(eventArgs)");this.raise_hiding(n)},add_hidden:function(n){this._popupBehavior&&this._popupBehavior.add_hidden(n)},remove_hidden:function(n){this._popupBehavior&&this._popupBehavior.remove_hidden(n)},raise_hidden:function(n){this._popupBehavior&&this._popupBehavior.raise_hidden(n)},raiseHidden:function(n){Sys.Extended.Deprecated("raiseHidden(eventArgs)","raise_hidden(eventArgs)");this.raise_hidden(n)},posTop:function(){var n=0;return typeof pageYOffset!="undefined"?n=window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?n=document.documentElement.scrollTop:document.body.scrollTop&&(n=document.body.scrollTop),n},posLeft:function(){var n=0;return typeof pageXOffset!="undefined"?n=window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?n=document.documentElement.scrollLeft:document.body.scrollLeft&&(n=document.body.scrollLeft),n},pageHeight:function(){var n=null;return window.innerHeight!=null?n=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?n=document.documentElement.clientHeight:document.body!=null&&(n=document.body.clientHeight),n},pageWidth:function(){var n=null;return window.innerWidth!=null?n=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?n=document.documentElement.clientWidth:document.body!=null&&(n=document.body.clientWidth),n}};Sys.Extended.UI.BalloonPopupControlBehavior.registerClass("Sys.Extended.UI.BalloonPopupControlBehavior",Sys.Extended.UI.DynamicPopulateBehaviorBase);Sys.Extended.UI.BalloonPopupControlBehavior.__VisiblePopup=null;Sys.Extended.UI.BalloonPopupPosition=function(){throw Error.invalidOperation();};Sys.Extended.UI.BalloonPopupPosition.prototype={Auto:0,TopRight:1,TopLeft:2,BottomRight:3,BottomLeft:4};Sys.Extended.UI.BalloonPopupPosition.registerEnum("Sys.Extended.UI.BalloonPopupPosition",!1);Sys.Extended.UI.BalloonPopupStyle=function(){throw Error.invalidOperation();};Sys.Extended.UI.BalloonPopupStyle.prototype={Rectangle:0,Cloud:1,Custom:2};Sys.Extended.UI.BalloonPopupStyle.registerEnum("Sys.Extended.UI.BalloonPopupStyle",!1);Sys.Extended.UI.BalloonPopupSize=function(){throw Error.invalidOperation();};Sys.Extended.UI.BalloonPopupSize.prototype={Small:0,Medium:1,Large:2};Sys.Extended.UI.BalloonPopupSize.registerEnum("Sys.Extended.UI.BalloonPopupSize",!1); |