1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
Type.registerNamespace("Sys.Extended.UI"),Sys.Extended.UI.PopupControlBehavior=function(e){Sys.Extended.UI.PopupControlBehavior.initializeBase(this,[e]),this._popupControlID=null,this._commitProperty=null,this._commitScript=null,this._position=null,this._offsetX=0,this._offsetY=0,this._extenderControlID=null,this._popupElement=null,this._popupBehavior=null,this._popupVisible=!1,this._focusHandler=null,this._popupKeyDownHandler=null,this._popupClickHandler=null,this._bodyClickHandler=null,this._onShowJson=null,this._onHideJson=null},Sys.Extended.UI.PopupControlBehavior.prototype={initialize:function(){Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"initialize");var e=this.get_element();this._popupElement=$get(this._popupControlID),this._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:this.get_id()+"PopupBehavior",parentElement:e},null,null,this._popupElement),this._onShowJson&&this._popupBehavior.set_onShow(this._onShowJson),this._onHideJson&&this._popupBehavior.set_onHide(this._onHideJson),this._focusHandler=Function.createDelegate(this,this._onFocus),this._popupClickHandler=Function.createDelegate(this,this._onPopupClick),this._bodyClickHandler=Function.createDelegate(this,this._onBodyClick),this._popupKeyDownHandler=Function.createDelegate(this,this._onPopupKeyDown),$addHandler(e,"focus",this._focusHandler),$addHandler(e,"click",this._focusHandler),$addHandler(document.body,"click",this._bodyClickHandler),$addHandler(this._popupElement,"click",this._popupClickHandler),$addHandler(this._popupElement,"keydown",this._popupKeyDownHandler),this.registerPartialUpdateEvents(),Sys.Extended.UI.PopupControlBehavior.__VisiblePopup&&this.get_id()==Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id()&&this._onFocus(null)},dispose:function(){var e=this.get_element();this._onShowJson=null,this._onHideJson=null,this._popupBehavior&&(this._popupBehavior.dispose(),this._popupBehavior=null),this._focusHandler&&($removeHandler(e,"focus",this._focusHandler),$removeHandler(e,"click",this._focusHandler),this._focusHandler=null),this._bodyClickHandler&&($removeHandler(document.body,"click",this._bodyClickHandler),this._bodyClickHandler=null),this._popupClickHandler&&($removeHandler(this._popupElement,"click",this._popupClickHandler),this._popupClickHandler=null),this._popupKeyDownHandler&&($removeHandler(this._popupElement,"keydown",this._popupKeyDownHandler),this._popupKeyDownHandler=null),Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"dispose")},showPopup:function(){var e=Sys.Extended.UI.PopupControlBehavior.__VisiblePopup;e&&e._popupBehavior&&e.hidePopup(),Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"populate"),this._popupBehavior.set_x(this._getLeftOffset()),this._popupBehavior.set_y(this._getTopOffset()),this._popupBehavior.show(),this._popupVisible=!0,Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=this},hidePopup:function(){this._popupBehavior.hide(),this._popupVisible=!1,Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=null},_onFocus:function(e){this._popupVisible||this.showPopup(),e&&e.stopPropagation()},_onPopupKeyDown:function(e){this._popupVisible&&27==e.keyCode&&this.get_element().focus()},_onPopupClick:function(e){e.stopPropagation()},_onBodyClick:function(){this._popupVisible&&this.hidePopup()},_close:function(result){var e=this.get_element();null!=result&&("$$CANCEL$$"!=result&&(this._commitProperty?e[this._commitProperty]=result:"text"==e.type?e.value=result:Sys.Debug.assert(!1,String.format(Sys.Extended.UI.Resources.PopupControl_NoDefaultProperty,e.id,e.type)),this._commitScript&&eval(this._commitScript)),this.hidePopup())},_partialUpdateEndRequest:function(e,t){if(Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"_partialUpdateEndRequest",[e,t]),this.get_element()){var o=t.get_dataItems()[this.get_element().id];void 0===o&&Sys.Extended.UI.PopupControlBehavior.__VisiblePopup&&this.get_id()==Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id()&&(o=t.get_dataItems()._PopupControl_Proxy_ID_),void 0!==o&&this._close(o)}},_onPopulated:function(e,t){Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"_onPopulated",[e,t]),this._popupVisible&&this._popupBehavior.show()},_getLeftOffset:function(){return Sys.Extended.UI.PopupControlPopupPosition.Left==this._position?-1*this.get_element().offsetWidth+this._offsetX:Sys.Extended.UI.PopupControlPopupPosition.Right==this._position?this.get_element().offsetWidth+this._offsetX:this._offsetX},_getTopOffset:function(){var e;return e=Sys.Extended.UI.PopupControlPopupPosition.Top==this._position?-1*this.get_element().offsetHeight+this._offsetY:Sys.Extended.UI.PopupControlPopupPosition.Bottom==this._position?this.get_element().offsetHeight+this._offsetY:this._offsetY},get_onShow:function(){return this._popupBehavior?this._popupBehavior.get_onShow():this._onShowJson},set_onShow:function(e){this._popupBehavior?this._popupBehavior.set_onShow(e):this._onShowJson=e,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(e){this._popupBehavior?this._popupBehavior.set_onHide(e):this._onHideJson=e,this.raisePropertyChanged("onHide")},get_onHideBehavior:function(){return this._popupBehavior?this._popupBehavior.get_onHideBehavior():null},onHide:function(){this._popupBehavior&&this._popupBehavior.onHide()},get_popupControlID:function(){return this._popupControlID},set_popupControlID:function(e){this._popupControlID!=e&&(this._popupControlID=e,this.raisePropertyChanged("popupControlID"))},get_PopupControlID:function(){return Sys.Extended.Deprecated("get_PopupControlID()","get_popupControlID()"),this.get_popupControlID()},set_PopupControlID:function(e){Sys.Extended.Deprecated("set_PopupControlID(value)","set_popupControlID(value)"),this.set_popupControlID(e)},get_commitProperty:function(){return this._commitProperty},set_commitProperty:function(e){this._commitProperty!=e&&(this._commitProperty=e,this.raisePropertyChanged("commitProperty"))},get_CommitProperty:function(){return Sys.Extended.Deprecated("get_CommitProperty()","get_commitProperty()"),this.get_commitProperty()},set_CommitProperty:function(e){Sys.Extended.Deprecated("set_CommitProperty(value)","set_commitProperty(value)"),this.set_commitProperty(e)},get_commitScript:function(){return this._commitScript},set_commitScript:function(e){this._commitScript!=e&&(this._commitScript=e,this.raisePropertyChanged("commitScript"))},get_CommitScript:function(){return Sys.Extended.Deprecated("get_CommitScript()","get_commitScript()"),this.get_commitScript()},set_CommitScript:function(e){Sys.Extended.Deprecated("set_CommitScript(value)","set_commitScript(value)"),this.set_commitScript(e)},get_position:function(){return this._position},set_position:function(e){this._position!=e&&(this._position=e,this.raisePropertyChanged("position"))},get_Position:function(){return Sys.Extended.Deprecated("get_Position()","get_position()"),this.get_position()},set_Position:function(e){Sys.Extended.Deprecated("set_Position(value)","set_position(value)"),this.set_position(e)},get_extenderControlID:function(){return this._extenderControlID},set_extenderControlID:function(e){this._extenderControlID!=e&&(this._extenderControlID=e,this.raisePropertyChanged("extenderControlID"))},get_ExtenderControlID:function(){return Sys.Extended.Deprecated("get_ExtenderControlID()","get_extenderControlID()"),this.get_extenderControlID()},set_ExtenderControlID:function(e){Sys.Extended.Deprecated("set_ExtenderControlID(value)","set_extenderControlID(value)"),this.set_extenderControlID(e)},get_offsetX:function(){return this._offsetX},set_offsetX:function(e){this._offsetX!=e&&(this._offsetX=e,this.raisePropertyChanged("offsetX"))},get_OffsetX:function(){return Sys.Extended.Deprecated("get_OffsetX()","get_offsetX()"),this.get_offsetX()},set_OffsetX:function(e){Sys.Extended.Deprecated("set_OffsetX(value)","set_offsetX(value)"),this.set_offsetX(e)},get_offsetY:function(){return this._offsetY},set_offsetY:function(e){this._offsetY!=e&&(this._offsetY=e,this.raisePropertyChanged("offsetY"))},get_OffsetY:function(){return Sys.Extended.Deprecated("get_OffsetY()","get_offsetY()"),this.get_offsetY()},set_OffsetY:function(e){Sys.Extended.Deprecated("set_OffsetY(value)","set_offsetY(value)"),this.set_offsetY(e)},get_popupVisible:function(){return this._popupVisible},get_PopupVisible:function(){return Sys.Extended.Deprecated("get_PopupVisible()","get_popupVisible()"),this.get_popupVisible()},add_showing:function(e){this._popupBehavior&&this._popupBehavior.add_showing(e)},remove_showing:function(e){this._popupBehavior&&this._popupBehavior.remove_showing(e)},raise_showing:function(e){this._popupBehavior&&this._popupBehavior.raise_showing(e)},raiseShowing:function(e){Sys.Extended.Deprecated("raiseShowing(eventArgs)","raise_showing(eventArgs)"),this.raise_showing(e)},add_shown:function(e){this._popupBehavior&&this._popupBehavior.add_shown(e)},remove_shown:function(e){this._popupBehavior&&this._popupBehavior.remove_shown(e)},raise_shown:function(e){this._popupBehavior&&this._popupBehavior.raise_shown(e)},raiseShown:function(e){Sys.Extended.Deprecated("raiseShown(eventArgs)","raise_shown(eventArgs)"),this.raise_shown(e)},add_hiding:function(e){this._popupBehavior&&this._popupBehavior.add_hiding(e)},remove_hiding:function(e){this._popupBehavior&&this._popupBehavior.remove_hiding(e)},raise_hiding:function(){this._popupBehavior&&this._popupBehavior.raise_hiding(eventArgs)},raiseHiding:function(e){Sys.Extended.Deprecated("raiseHiding(eventArgs)","raise_hiding(eventArgs)"),this.raise_hiding(e)},add_hidden:function(e){this._popupBehavior&&this._popupBehavior.add_hidden(e)},remove_hidden:function(e){this._popupBehavior&&this._popupBehavior.remove_hidden(e)},raise_hidden:function(e){this._popupBehavior&&this._popupBehavior.raise_hidden(e)},raiseHidden:function(e){Sys.Extended.Deprecated("raiseHidden(eventArgs)","raise_hidden(eventArgs)"),this.raise_hidden(e)}},Sys.Extended.UI.PopupControlBehavior.registerClass("Sys.Extended.UI.PopupControlBehavior",Sys.Extended.UI.DynamicPopulateBehaviorBase),Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=null,Sys.Extended.UI.PopupControlPopupPosition=function(){throw Error.invalidOperation()},Sys.Extended.UI.PopupControlPopupPosition.prototype={Center:0,Top:1,Left:2,Bottom:3,Right:4},Sys.Extended.UI.PopupControlPopupPosition.registerEnum("Sys.Extended.UI.PopupControlPopupPosition",!1); |