﻿// (c) 2010 CodePlex Foundation
(function(){var b="ExtendedPopupBehavior";function a(){var b="click",c=false,a=null;Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.PopupControlBehavior=function(d){var b=this;Sys.Extended.UI.PopupControlBehavior.initializeBase(b,[d]);b._popupControlID=a;b._commitProperty=a;b._commitScript=a;b._position=a;b._offsetX=0;b._offsetY=0;b._extenderControlID=a;b._popupElement=a;b._popupBehavior=a;b._popupVisible=c;b._focusHandler=a;b._popupKeyDownHandler=a;b._popupClickHandler=a;b._bodyClickHandler=a;b._onShowJson=a;b._onHideJson=a};Sys.Extended.UI.PopupControlBehavior.prototype={initialize:function(){var c=this;Sys.Extended.UI.PopupControlBehavior.callBaseMethod(c,"initialize");var d=c.get_element();c._popupElement=$get(c._popupControlID);c._popupBehavior=$create(Sys.Extended.UI.PopupBehavior,{id:c.get_id()+"PopupBehavior",parentElement:d},a,a,c._popupElement);c._onShowJson&&c._popupBehavior.set_onShow(c._onShowJson);c._onHideJson&&c._popupBehavior.set_onHide(c._onHideJson);c._focusHandler=Function.createDelegate(c,c._onFocus);c._popupClickHandler=Function.createDelegate(c,c._onPopupClick);c._bodyClickHandler=Function.createDelegate(c,c._onBodyClick);c._popupKeyDownHandler=Function.createDelegate(c,c._onPopupKeyDown);$addHandler(d,"focus",c._focusHandler);$addHandler(d,b,c._focusHandler);$addHandler(document.body,b,c._bodyClickHandler);$addHandler(c._popupElement,b,c._popupClickHandler);$addHandler(c._popupElement,"keydown",c._popupKeyDownHandler);c.registerPartialUpdateEvents();Sys.Extended.UI.PopupControlBehavior.__VisiblePopup&&c.get_id()==Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id()&&c._onFocus(a)},dispose:function(){var c=this,d=c.get_element();c._onShowJson=a;c._onHideJson=a;if(c._popupBehavior){c._popupBehavior.dispose();c._popupBehavior=a}if(c._focusHandler){$removeHandler(d,"focus",c._focusHandler);$removeHandler(d,b,c._focusHandler);c._focusHandler=a}if(c._bodyClickHandler){$removeHandler(document.body,b,c._bodyClickHandler);c._bodyClickHandler=a}if(c._popupClickHandler){$removeHandler(c._popupElement,b,c._popupClickHandler);c._popupClickHandler=a}if(c._popupKeyDownHandler){$removeHandler(c._popupElement,"keydown",c._popupKeyDownHandler);c._popupKeyDownHandler=a}Sys.Extended.UI.PopupControlBehavior.callBaseMethod(c,"dispose")},showPopup:function(){var a=this,b=Sys.Extended.UI.PopupControlBehavior.__VisiblePopup;b&&b._popupBehavior&&b.hidePopup();Sys.Extended.UI.PopupControlBehavior.callBaseMethod(a,"populate");a._popupBehavior.set_x(a._getLeftOffset());a._popupBehavior.set_y(a._getTopOffset());a._popupBehavior.show();a._popupVisible=true;Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=a},hidePopup:function(){this._popupBehavior.hide();this._popupVisible=c;Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=a},_onFocus:function(a){!this._popupVisible&&this.showPopup();a&&a.stopPropagation()},_onPopupKeyDown:function(a){this._popupVisible&&a.keyCode==27&&this.get_element().focus()},_onPopupClick:function(a){a.stopPropagation()},_onBodyClick:function(){this._popupVisible&&this.hidePopup()},_close:function(e){var b=this,d=b.get_element();if(a!=e){if("$$CANCEL$$"!=e){if(b._commitProperty)d[b._commitProperty]=e;else if("text"==d.type)d.value=e;else Sys.Debug.assert(c,String.format(Sys.Extended.UI.Resources.PopupControl_NoDefaultProperty,d.id,d.type));if(b._commitScript)eval(b._commitScript)}b.hidePopup()}},_partialUpdateEndRequest:function(d,c){var a=this;Sys.Extended.UI.PopupControlBehavior.callBaseMethod(a,"_partialUpdateEndRequest",[d,c]);if(a.get_element()){var b=c.get_dataItems()[a.get_element().id];if(undefined===b&&Sys.Extended.UI.PopupControlBehavior.__VisiblePopup&&a.get_id()==Sys.Extended.UI.PopupControlBehavior.__VisiblePopup.get_id())b=c.get_dataItems()._PopupControl_Proxy_ID_;undefined!==b&&a._close(b)}},_onPopulated:function(b,a){Sys.Extended.UI.PopupControlBehavior.callBaseMethod(this,"_onPopulated",[b,a]);this._popupVisible&&this._popupBehavior.show()},_getLeftOffset:function(){var a=this;return Sys.Extended.UI.PopupControlPopupPosition.Left==a._position?-1*a.get_element().offsetWidth+a._offsetX:Sys.Extended.UI.PopupControlPopupPosition.Right==a._position?a.get_element().offsetWidth+a._offsetX:a._offsetX},_getTopOffset:function(){var a=this,b;if(Sys.Extended.UI.PopupControlPopupPosition.Top==a._position)b=-1*a.get_element().offsetHeight+a._offsetY;else if(Sys.Extended.UI.PopupControlPopupPosition.Bottom==a._position)b=a.get_element().offsetHeight+a._offsetY;else b=a._offsetY;return b},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_PopupControlID:function(){return this._popupControlID},set_PopupControlID:function(a){if(this._popupControlID!=a){this._popupControlID=a;this.raisePropertyChanged("PopupControlID")}},get_CommitProperty:function(){return this._commitProperty},set_CommitProperty:function(a){if(this._commitProperty!=a){this._commitProperty=a;this.raisePropertyChanged("CommitProperty")}},get_CommitScript:function(){return this._commitScript},set_CommitScript:function(a){if(this._commitScript!=a){this._commitScript=a;this.raisePropertyChanged("CommitScript")}},get_Position:function(){return this._position},set_Position:function(a){if(this._position!=a){this._position=a;this.raisePropertyChanged("Position")}},get_ExtenderControlID:function(){return this._extenderControlID},set_ExtenderControlID:function(a){if(this._extenderControlID!=a){this._extenderControlID=a;this.raisePropertyChanged("ExtenderControlID")}},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_PopupVisible:function(){return this._popupVisible},add_showing:function(a){this._popupBehavior&&this._popupBehavior.add_showing(a)},remove_showing:function(a){this._popupBehavior&&this._popupBehavior.remove_showing(a)},raiseShowing:function(a){this._popupBehavior&&this._popupBehavior.raiseShowing(a)},add_shown:function(a){this._popupBehavior&&this._popupBehavior.add_shown(a)},remove_shown:function(a){this._popupBehavior&&this._popupBehavior.remove_shown(a)},raiseShown:function(a){this._popupBehavior&&this._popupBehavior.raiseShown(a)},add_hiding:function(a){this._popupBehavior&&this._popupBehavior.add_hiding(a)},remove_hiding:function(a){this._popupBehavior&&this._popupBehavior.remove_hiding(a)},raiseHiding:function(a){this._popupBehavior&&this._popupBehavior.raiseHiding(a)},add_hidden:function(a){this._popupBehavior&&this._popupBehavior.add_hidden(a)},remove_hidden:function(a){this._popupBehavior&&this._popupBehavior.remove_hidden(a)},raiseHidden:function(a){this._popupBehavior&&this._popupBehavior.raiseHidden(a)}};Sys.Extended.UI.PopupControlBehavior.registerClass("Sys.Extended.UI.PopupControlBehavior",Sys.Extended.UI.DynamicPopulateBehaviorBase);Sys.registerComponent(Sys.Extended.UI.PopupControlBehavior,{name:"popupBehavior"});Sys.Extended.UI.PopupControlBehavior.__VisiblePopup=a;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",c)}if(window.Sys&&Sys.loader)Sys.loader.registerScript(b,["ExtendedDynamicPopulate","ExtendedPopup","ExtendedAnimationBehavior"],a);else a()})();