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

1 line
20 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI");Sys.Extended.UI.CollapsiblePanelExpandDirection=function(){throw Error.invalidOperation();};Sys.Extended.UI.CollapsiblePanelExpandDirection.prototype={Horizontal:0,Vertical:1};Sys.Extended.UI.CollapsiblePanelExpandDirection.registerEnum("Sys.Extended.UI.CollapsiblePanelExpandDirection",!1);Sys.Extended.UI.CollapsiblePanelBehavior=function(n){Sys.Extended.UI.CollapsiblePanelBehavior.initializeBase(this,[n]);this._collapsedSize=0;this._expandedSize=0;this._scrollContents=null;this._collapsed=!1;this._expandControlID=null;this._collapseControlID=null;this._textLabelID=null;this._collapsedText=null;this._expandedText=null;this._imageControlID=null;this._expandedImage=null;this._collapsedImage=null;this._suppressPostBack=null;this._autoExpand=null;this._autoCollapse=null;this._expandDirection=Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical;this._collapseClickHandler=null;this._expandClickHandler=null;this._panelMouseEnterHandler=null;this._panelMouseLeaveHandler=null;this._childDiv=null;this._animation=null};Sys.Extended.UI.CollapsiblePanelBehavior.prototype={initialize:function(){var n,t,i,r,u;if(Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(this,"initialize"),n=this.get_element(),this._animation=new Sys.Extended.UI.Animation.LengthAnimation(n,.25,10,"style",null,0,0,"px"),this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?this._animation.set_propertyKey("height"):this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&this._animation.set_propertyKey("width"),this._animation.add_ended(Function.createDelegate(this,this._onAnimateComplete)),this._suppressPostBack==null&&(n.tagName=="INPUT"&&n.type=="checkbox"?(this._suppressPostBack=!1,this.raisePropertyChanged("SuppressPostBack")):n.tagName=="A"&&(this._suppressPostBack=!0,this.raisePropertyChanged("SuppressPostBack"))),t=Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(this,"get_ClientState"),t&&t!=""&&(i=Boolean.parse(t),this._collapsed!=i&&(this._collapsed=i,this.raisePropertyChanged("Collapsed"))),this._setupChildDiv(),this._collapsed?this._setTargetSize(this._getCollapsedSize()):this._setTargetSize(this._getExpandedSize()),this._setupState(this._collapsed),this._collapseControlID==this._expandControlID?(this._collapseClickHandler=Function.createDelegate(this,this.togglePanel),this._expandClickHandler=null):(this._collapseClickHandler=Function.createDelegate(this,this.collapsePanel),this._expandClickHandler=Function.createDelegate(this,this.expandPanel)),this._autoExpand&&(this._panelMouseEnterHandler=Function.createDelegate(this,this._onMouseEnter),$addHandler(n,"mouseover",this._panelMouseEnterHandler)),this._autoCollapse&&(this._panelMouseLeaveHandler=Function.createDelegate(this,this._onMouseLeave),$addHandler(n,"mouseout",this._panelMouseLeaveHandler)),this._collapseControlID)if(r=$get(this._collapseControlID),r)$addHandler(r,"click",this._collapseClickHandler);else throw Error.argument("CollapseControlID",String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID,this._collapseControlID));if(this._expandControlID&&this._expandClickHandler)if(u=$get(this._expandControlID),u)$addHandler(u,"click",this._expandClickHandler);else throw Error.argument("ExpandControlID",String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID,this._expandControlID));},dispose:function(){var i=this.get_element(),n,t;this._collapseClickHandler&&(n=this._collapseControlID?$get(this._collapseControlID):null,n&&$removeHandler(n,"click",this._collapseClickHandler),this._collapseClickHandler=null);this._expandClickHandler&&(t=this._expandControlID?$get(this._expandControlID):null,t&&$removeHandler(t,"click",this._expandClickHandler),this._expandClickHandler=null);this._panelMouseEnterHandler&&$removeHandler(i,"mouseover",this._panelMouseEnterHandler);this._panelMouseLeaveHandler&&$removeHandler(i,"mouseout",this._panelMouseLeaveHandler);this._animation&&(this._animation.dispose(),this._animation=null);Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(this,"dispose")},togglePanel:function(n){this._toggle(n)},expandPanel:function(n){this._doOpen(n)},collapsePanel:function(n){this._doClose(n)},_checkCollapseHide:function(){if(this._collapsed&&this._getTargetSize()==0){var n=this.get_element(),t=$common.getCurrentStyle(n,"display");return n.oldDisplay||t=="none"||(n.oldDisplay=t,n.style.display="none"),!0}return!1},_doClose:function(n){var t=new Sys.CancelEventArgs;if((this.raise_collapsing(t),!t.get_cancel())&&(this._animation&&(this._animation.stop(),this._animation.set_startValue(this._getTargetSize()),this._animation.set_endValue(this._getCollapsedSize()),this._animation.play()),this._setupState(!0),this._suppressPostBack))if(n&&n.preventDefault)n.preventDefault();else return n&&(n.returnValue=!1),!1},_doOpen:function(n){var i=new Sys.CancelEventArgs,t;if((this.raise_expanding(i),!i.get_cancel())&&(this._animation&&(this._animation.stop(),t=this.get_element(),this._checkCollapseHide()&&$common.getCurrentStyle(t,"display",t.style.display)&&(t.oldDisplay?t.style.display=t.oldDisplay:t.style.removeAttribute?t.style.removeAttribute("display"):t.style.removeProperty("display"),t.oldDisplay=null),this._animation.set_startValue(this._getTargetSize()),this._animation.set_endValue(this._getExpandedSize()),this._animation.play()),this._setupState(!1),this._suppressPostBack))if(n&&n.preventDefault)n.preventDefault();else return n&&(n.returnValue=!1),!1},_onAnimateComplete:function(){var n=this.get_element();this._collapsed||this._expandedSize?this._checkCollapseHide():this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?this._childDiv.offsetHeight<=n.offsetHeight?(n.style.height="auto",this.raisePropertyChanged("TargetHeight")):this._checkCollapseHide():this._childDiv.offsetWidth<=n.offsetWidth?(n.style.width="auto",this.raisePropertyChanged("TargetWidth")):this._checkCollapseHide();this._collapsed?(this.raise_collapseComplete(),this.raise_collapsed(Sys.EventArgs.Empty)):(this.raise_expandComplete(),this.raise_expanded(new Sys.EventArgs))},_onMouseEnter:function(n){this._autoExpand&&this.expandPanel(n)},_onMouseLeave:function(n){this._autoCollapse&&this.collapsePanel(n)},_getExpandedSize:function(){return this._expandedSize?this._expandedSize:this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?this._childDiv.offsetHeight:this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal?this._childDiv.offsetWidth:void 0},_getCollapsedSize:function(){return this._collapsedSize?this._collapsedSize:0},_getTargetSize:function(){var n;return this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?n=this.get_targetHeight():this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&(n=this.get_targetWidth()),n===undefined&&(n=0),n},_setTargetSize:function(n){var i=this._collapsed||this._expandedSize,t=this.get_element();this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?i||n<t.offsetHeight?this.set_targetHeight(n):(t.style.height="auto",this.raisePropertyChanged("TargetHeight")):this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&(i||n<t.offsetWidth?this.set_targetWidth(n):(t.style.width="auto",this.raisePropertyChanged("TargetWidth")));this._checkCollapseHide()},_setupChildDiv:function(){var t=this._getTargetSize(),n=this.get_element(),i;for(this._childDiv=n.cloneNode(!1),n.id="",this._childDiv.style.visibility="visible",this._childDiv.style.display="";n.hasChildNodes();)i=n.childNodes[0],i=n.removeChild(i),this._childDiv.appendChild(i);n.setAttribute("style","");n.className="";n.style.border="0px";n.style.margin="0px";n.style.padding="0px";this._scrollContents?(this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?(n.style.overflowY="scroll",this._childDiv.style.overflowY=""):(n.style.overflowX="scroll",this._childDiv.style.overflowX=""),(Sys.Browser.agent==Sys.Browser.Safari||Sys.Browser.agent==Sys.Browser.Opera)&&(n.style.overflow="scroll",this._childDiv.style.overflow="")):(this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?(n.style.overflowY="hidden",this._childDiv.style.overflowY=""):(n.style.overflowX="hidden",this._childDiv.style.overflowX=""),(Sys.Browser.Agent==Sys.Browser.Safari||Sys.Browser.Agent==Sys.Browser.Opera)&&(n.style.overflow="hidden",this._childDiv.style.overflow=""));this._childDiv.style.position="";t==this._collapsedSize&&(this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?this._childDiv.style.height="auto":this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&(this._childDiv.style.width="auto"));n.appendChild(this._childDiv);n.style.visibility="visible";n.style.display="";t=this._collapsed?this._getCollapsedSize():this._getExpandedSize();this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?(n.style.height=t+"px",n.style.height=this._expandedSize?this._expandedSize+"px":"auto",this._childDiv.style.height="auto"):this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&(n.style.width=t+"px",n.style.width=this._expandedSize?this._expandedSize+"px":"auto",this._childDiv.style.width="auto")},_setupState:function(n){var i,t;n?(this._textLabelID&&this._collapsedText&&(i=$get(this._textLabelID),i&&(i.innerHTML=this._collapsedText)),this._imageControlID&&this._collapsedImage&&(t=$get(this._imageControlID),t&&t.src&&(t.src=this._collapsedImage,(this._expandedText||this._collapsedText)&&(t.title=this._collapsedText)))):(this._textLabelID&&this._expandedText&&(i=$get(this._textLabelID),i&&(i.innerHTML=this._expandedText)),this._imageControlID&&this._expandedImage&&(t=$get(this._imageControlID),t&&t.src&&(t.src=this._expandedImage,(this._expandedText||this._collapsedText)&&(t.title=this._expandedText))));this._collapsed!=n&&(this._collapsed=n,this.raisePropertyChanged("Collapsed"));Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(this,"set_ClientState",[this._collapsed.toString()])},_toggle:function(n){return this.get_collapsed()?this.expandPanel(n):this.collapsePanel(n)},add_collapsing:function(n){this.get_events().addHandler("collapsing",n)},remove_collapsing:function(n){this.get_events().removeHandler("collapsing",n)},raise_collapsing:function(n){var t=this.get_events().getHandler("collapsing");t&&t(this,n)},raiseCollapsing:function(n){Sys.Extended.Deprecated("raiseCollapsing","raise_collapsing");this.raise_collapsing(n)},add_collapsed:function(n){this.get_events().addHandler("collapsed",n)},remove_collapsed:function(n){this.get_events().removeHandler("collapsed",n)},raise_collapsed:function(n){var t=this.get_events().getHandler("collapsed");t&&t(this,n)},raiseCollapsed:function(n){Sys.Extended.Deprecated("raiseCollapsed","raise_collapsed");this.raise_collapsed(n)},add_collapseComplete:function(n){this.get_events().addHandler("collapseComplete",n)},remove_collapseComplete:function(n){this.get_events().removeHandler("collapseComplete",n)},raise_collapseComplete:function(){var n=this.get_events().getHandler("collapseComplete");n&&n(this,Sys.EventArgs.Empty)},raiseCollapseComplete:function(){Sys.Extended.Deprecated("raiseCollapseComplete","raise_collapseComplete");this.raise_collapseComplete()},add_expanding:function(n){this.get_events().addHandler("expanding",n)},remove_expanding:function(n){this.get_events().removeHandler("expanding",n)},raise_expanding:function(n){var t=this.get_events().getHandler("expanding");t&&t(this,n)},raiseExpanding:function(n){Sys.Extended.Deprecated("raiseExpanding","raise_expanding");this.raise_expanding(n)},add_expanded:function(n){this.get_events().addHandler("expanded",n)},remove_expanded:function(n){this.get_events().removeHandler("expanded",n)},raise_expanded:function(n){var t=this.get_events().getHandler("expanded");t&&t(this,n)},raiseExpanded:function(n){Sys.Extended.Deprecated("raiseExpanded","raise_expanded");this.raise_expanded(n)},add_expandComplete:function(n){this.get_events().addHandler("expandComplete",n)},remove_expandComplete:function(n){this.get_events().removeHandler("expandComplete",n)},raise_expandComplete:function(){var n=this.get_events().getHandler("expandComplete");n&&n(this,Sys.EventArgs.Empty)},raiseExpandComplete:function(){Sys.Extended.Deprecated("raiseExpandComplete","raise_expandComplete");this.raise_expandComplete()},get_targetHeight:function(){return this.get_element().offsetHeight},set_targetHeight:function(n){this.get_element().style.height=n+"px";this.raisePropertyChanged("targetHeight")},get_TargetHeight:function(){return Sys.Extended.Deprecated("get_TargetHeight","get_targetHeight"),this.get_targetHeight()},set_TargetHeight:function(n){Sys.Extended.Deprecated("set_TargetHeight","set_targetHeight");this.set_targetHeight(n)},get_targetWidth:function(){return this.get_element().offsetWidth},set_targetWidth:function(n){this.get_element().style.width=n+"px";this.raisePropertyChanged("targetWidth")},get_TargetWidth:function(){return Sys.Extended.Deprecated("get_TargetWidth","get_targetWidth"),this.get_targetWidth()},set_TargetWidth:function(n){Sys.Extended.Deprecated("set_TargetWidth","set_targetWidth");this.set_targetWidth(n)},get_collapsed:function(){return this._collapsed},set_collapsed:function(n){this.get_isInitialized()&&this.get_element()&&n!=this.get_collapsed()?this.togglePanel():(this._collapsed=n,this.raisePropertyChanged("collapsed"))},get_Collapsed:function(){return Sys.Extended.Deprecated("get_Collapsed","get_collapsed"),this.get_collapsed()},set_Collapsed:function(n){Sys.Extended.Deprecated("set_Collapsed","set_collapsed");this.set_collapsed(n)},get_collapsedSize:function(){return this._collapsedSize},set_collapsedSize:function(n){this._collapsedSize!=n&&(this._collapsedSize=n,this.raisePropertyChanged("collapsedSize"))},get_CollapsedSize:function(){return Sys.Extended.Deprecated("get_CollapsedSize","get_collapsedSize"),this.get_collapsedSize()},set_CollapsedSize:function(n){Sys.Extended.Deprecated("set_CollapsedSize","set_collapsedSize");this.set_collapsedSize(n)},get_expandedSize:function(){return this._expandedSize},set_expandedSize:function(n){this._expandedSize!=n&&(this._expandedSize=n,this.raisePropertyChanged("expandedSize"))},get_ExpandedSize:function(){return Sys.Extended.Deprecated("get_ExpandedSize","get_expandedSize"),this.get_expandedSize()},set_ExpandedSize:function(n){Sys.Extended.Deprecated("set_ExpandedSize","set_expandedSize");this.set_expandedSize(n)},get_collapseControlID:function(){return this._collapseControlID},set_collapseControlID:function(n){this._collapseControlID!=n&&(this._collapseControlID=n,this.raisePropertyChanged("collapseControlID"))},get_CollapseControlID:function(){return Sys.Extended.Deprecated("get_CollapseControlID","get_collapseControlID"),this.get_collapseControlID()},set_CollapseControlID:function(n){Sys.Extended.Deprecated("set_CollapseControlID","set_collapseControlID");this.set_collapseControlID(n)},get_expandControlID:function(){return this._expandControlID},set_expandControlID:function(n){this._expandControlID!=n&&(this._expandControlID=n,this.raisePropertyChanged("expandControlID"))},get_ExpandControlID:function(){return Sys.Extended.Deprecated("get_ExpandControlID","get_expandControlID"),this.get_expandControlID()},set_ExpandControlID:function(n){Sys.Extended.Deprecated("set_ExpandControlID","set_expandControlID");this.set_expandControlID(n)},get_scrollContents:function(){return this._scrollContents},set_scrollContents:function(n){this._scrollContents!=n&&(this._scrollContents=n,this.raisePropertyChanged("scrollContents"))},get_ScrollContents:function(){return Sys.Extended.Deprecated("get_ScrollContents","get_scrollContents"),this.get_scrollContents()},set_ScrollContents:function(n){Sys.Extended.Deprecated("set_ScrollContents","set_scrollContents");this.set_scrollContents(n)},get_suppressPostBack:function(){return this._suppressPostBack},set_suppressPostBack:function(n){this._suppressPostBack!=n&&(this._suppressPostBack=n,this.raisePropertyChanged("suppressPostBack"))},get_SuppressPostBack:function(){return Sys.Extended.Deprecated("get_SuppressPostBack","get_suppressPostBack"),this.get_suppressPostBack()},set_SuppressPostBack:function(n){Sys.Extended.Deprecated("set_SuppressPostBack","set_suppressPostBack");this.set_suppressPostBack(n)},get_textLabelID:function(){return this._textLabelID},set_textLabelID:function(n){this._textLabelID!=n&&(this._textLabelID=n,this.raisePropertyChanged("textLabelID"))},get_TextLabelID:function(){return Sys.Extended.Deprecated("get_TextLabelID","get_textLabelID"),this.get_textLabelID()},set_TextLabelID:function(n){Sys.Extended.Deprecated("set_TextLabelID","set_textLabelID");this.set_textLabelID(n)},get_expandedText:function(){return this._expandedText},set_expandedText:function(n){this._expandedText!=n&&(this._expandedText=n,this.raisePropertyChanged("expandedText"))},get_ExpandedText:function(){return Sys.Extended.Deprecated("get_ExpandedText","get_expandedText"),this.get_expandedText()},set_ExpandedText:function(n){Sys.Extended.Deprecated("set_ExpandedText","set_expandedText");this.set_expandedText(n)},get_collapsedText:function(){return this._collapsedText},set_collapsedText:function(n){this._collapsedText!=n&&(this._collapsedText=n,this.raisePropertyChanged("collapsedText"))},get_CollapsedText:function(){return Sys.Extended.Deprecated("get_CollapsedText","get_collapsedText"),this.get_collapsedText()},set_CollapsedText:function(n){Sys.Extended.Deprecated("set_CollapsedText","set_collapsedText");this.set_collapsedText(n)},get_imageControlID:function(){return this._imageControlID},set_imageControlID:function(n){this._imageControlID!=n&&(this._imageControlID=n,this.raisePropertyChanged("imageControlID"))},get_ImageControlID:function(){return Sys.Extended.Deprecated("get_ImageControlID","get_imageControlID"),this.get_imageControlID()},set_ImageControlID:function(){Sys.Extended.Deprecated("set_ImageControlID","set_imageControlID");this.set_imageControlID()},get_expandedImage:function(){return this._expandedImage},set_expandedImage:function(n){this._expandedImage!=n&&(this._expandedImage=n,this.raisePropertyChanged("expandedImage"))},get_ExpandedImage:function(){return Sys.Extended.Deprecated("get_ExpandedImage","get_expandedImage"),this.get_expandedImage()},set_ExpandedImage:function(n){Sys.Extended.Deprecated("set_ExpandedImage","set_expandedImage");this.set_expandedImage(n)},get_collapsedImage:function(){return this._collapsedImage},set_collapsedImage:function(n){this._collapsedImage!=n&&(this._collapsedImage=n,this.raisePropertyChanged("collapsedImage"))},get_CollapsedImage:function(){return Sys.Extended.Deprecated("get_CollapsedImage","get_collapsedImage"),this.get_collapsedImage()},set_CollapsedImage:function(){Sys.Extended.Deprecated("set_CollapsedImage","set_collapsedImage");this.set_collapsedImage()},get_autoExpand:function(){return this._autoExpand},set_autoExpand:function(n){this._autoExpand!=n&&(this._autoExpand=n,this.raisePropertyChanged("autoExpand"))},get_AutoExpand:function(){return Sys.Extended.Deprecated("get_AutoExpand","get_autoExpand"),this.get_autoExpand()},set_AutoExpand:function(n){Sys.Extended.Deprecated("set_AutoExpand","set_autoExpand");this.set_autoExpand(n)},get_autoCollapse:function(){return this._autoCollapse},set_autoCollapse:function(n){this._autoCollapse!=n&&(this._autoCollapse=n,this.raisePropertyChanged("autoCollapse"))},get_AutoCollapse:function(){return Sys.Extended.Deprecated("get_AutoCollapse","get_autoCollapse"),this.get_autoCollapse()},set_AutoCollapse:function(n){Sys.Extended.Deprecated("set_AutoCollapse","set_autoCollapse");this.set_autoCollapse(n)},get_expandDirection:function(){return this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical},set_expandDirection:function(n){this._expandDirection!=n&&(this._expandDirection=n,this.raisePropertyChanged("expandDirection"))},get_ExpandDirection:function(){return Sys.Extended.Deprecated("get_ExpandDirection","get_expandDirection"),this.get_expandDirection()},set_ExpandDirection:function(n){Sys.Extended.Deprecated("set_ExpandDirection","set_expandDirection");this.set_expandDirection(n)}};Sys.Extended.UI.CollapsiblePanelBehavior.registerClass("Sys.Extended.UI.CollapsiblePanelBehavior",Sys.Extended.UI.BehaviorBase);