﻿// (c) 2010 CodePlex Foundation
(function(){var b="ExtendedCollapsiblePanel";function a(){var q="expandComplete",p="expanded",o="expanding",n="collapseComplete",m="collapsed",l="collapsing",k="TargetWidth",j="TargetHeight",c="auto",g="display",u="ExpandControlID",f="click",t="CollapseControlID",s="mouseout",r="mouseover",i="Collapsed",b="",h="SuppressPostBack",e="px",a=null,d=false;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",d);Sys.Extended.UI.CollapsiblePanelBehavior=function(c){var b=this;Sys.Extended.UI.CollapsiblePanelBehavior.initializeBase(b,[c]);b._collapsedSize=0;b._expandedSize=0;b._scrollContents=a;b._collapsed=d;b._expandControlID=a;b._collapseControlID=a;b._textLabelID=a;b._collapsedText=a;b._expandedText=a;b._imageControlID=a;b._expandedImage=a;b._collapsedImage=a;b._suppressPostBack=a;b._autoExpand=a;b._autoCollapse=a;b._expandDirection=Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical;b._collapseClickHandler=a;b._expandClickHandler=a;b._panelMouseEnterHandler=a;b._panelMouseLeaveHandler=a;b._childDiv=a;b._animation=a};Sys.Extended.UI.CollapsiblePanelBehavior.prototype={initialize:function(){var c=this;Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(c,"initialize");var g=c.get_element();c._animation=new Sys.Extended.UI.Animation.LengthAnimation(g,.25,10,"style",a,0,0,e);if(c._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical)c._animation.set_propertyKey("height");else c._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal&&c._animation.set_propertyKey("width");c._animation.add_ended(Function.createDelegate(c,c._onAnimateComplete));if(c._suppressPostBack==a)if(g.tagName=="INPUT"&&g.type=="checkbox"){c._suppressPostBack=d;c.raisePropertyChanged(h)}else if(g.tagName=="A"){c._suppressPostBack=true;c.raisePropertyChanged(h)}var j=Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(c,"get_ClientState");if(j&&j!=b){var m=Boolean.parse(j);if(c._collapsed!=m){c._collapsed=m;c.raisePropertyChanged(i)}}c._setupChildDiv();if(c._collapsed)c._setTargetSize(c._getCollapsedSize());else c._setTargetSize(c._getExpandedSize());c._setupState(c._collapsed);if(c._collapseControlID==c._expandControlID){c._collapseClickHandler=Function.createDelegate(c,c.togglePanel);c._expandClickHandler=a}else{c._collapseClickHandler=Function.createDelegate(c,c.collapsePanel);c._expandClickHandler=Function.createDelegate(c,c.expandPanel)}if(c._autoExpand){c._panelMouseEnterHandler=Function.createDelegate(c,c._onMouseEnter);$addHandler(g,r,c._panelMouseEnterHandler)}if(c._autoCollapse){c._panelMouseLeaveHandler=Function.createDelegate(c,c._onMouseLeave);$addHandler(g,s,c._panelMouseLeaveHandler)}if(c._collapseControlID){var k=$get(c._collapseControlID);if(!k)throw Error.argument(t,String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID,c._collapseControlID));else $addHandler(k,f,c._collapseClickHandler)}if(c._expandControlID)if(c._expandClickHandler){var l=$get(c._expandControlID);if(!l)throw Error.argument(u,String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID,c._expandControlID));else $addHandler(l,f,c._expandClickHandler)}},dispose:function(){var b=this,e=b.get_element();if(b._collapseClickHandler){var c=b._collapseControlID?$get(b._collapseControlID):a;c&&$removeHandler(c,f,b._collapseClickHandler);b._collapseClickHandler=a}if(b._expandClickHandler){var d=b._expandControlID?$get(b._expandControlID):a;d&&$removeHandler(d,f,b._expandClickHandler);b._expandClickHandler=a}b._panelMouseEnterHandler&&$removeHandler(e,r,b._panelMouseEnterHandler);b._panelMouseLeaveHandler&&$removeHandler(e,s,b._panelMouseLeaveHandler);if(b._animation){b._animation.dispose();b._animation=a}Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(b,"dispose")},togglePanel:function(a){this._toggle(a)},expandPanel:function(a){this._doOpen(a)},collapsePanel:function(a){this._doClose(a)},_checkCollapseHide:function(){if(this._collapsed&&this._getTargetSize()==0){var a=this.get_element(),b=$common.getCurrentStyle(a,g);if(!a.oldDisplay&&b!="none"){a.oldDisplay=b;a.style.display="none"}return true}return d},_doClose:function(b){var a=this,c=new Sys.CancelEventArgs;a.raiseCollapsing(c);if(c.get_cancel())return;if(a._animation){a._animation.stop();a._animation.set_startValue(a._getTargetSize());a._animation.set_endValue(a._getCollapsedSize());a._animation.play()}a._setupState(true);if(a._suppressPostBack)if(b&&b.preventDefault)b.preventDefault();else{if(b)b.returnValue=d;return d}},_doOpen:function(e){var b=this,f=new Sys.CancelEventArgs;b.raiseExpanding(f);if(f.get_cancel())return;if(b._animation){b._animation.stop();var c=b.get_element();if(b._checkCollapseHide()&&$common.getCurrentStyle(c,g,c.style.display)){if(c.oldDisplay)c.style.display=c.oldDisplay;else if(c.style.removeAttribute)c.style.removeAttribute(g);else c.style.removeProperty(g);c.oldDisplay=a}b._animation.set_startValue(b._getTargetSize());b._animation.set_endValue(b._getExpandedSize());b._animation.play()}b._setupState(d);if(b._suppressPostBack)if(e&&e.preventDefault)e.preventDefault();else{if(e)e.returnValue=d;return d}},_onAnimateComplete:function(){var a=this,b=a.get_element();if(!a._collapsed&&!a._expandedSize)if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical)if(a._childDiv.offsetHeight<=b.offsetHeight){b.style.height=c;a.raisePropertyChanged(j)}else a._checkCollapseHide();else if(a._childDiv.offsetWidth<=b.offsetWidth){b.style.width=c;a.raisePropertyChanged(k)}else a._checkCollapseHide();else a._checkCollapseHide();if(a._collapsed){a.raiseCollapseComplete();a.raiseCollapsed(Sys.EventArgs.Empty)}else{a.raiseExpandComplete();a.raiseExpanded(new Sys.EventArgs)}},_onMouseEnter:function(a){this._autoExpand&&this.expandPanel(a)},_onMouseLeave:function(a){this._autoCollapse&&this.collapsePanel(a)},_getExpandedSize:function(){var a=this;return a._expandedSize?a._expandedSize:a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical?a._childDiv.offsetHeight:a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal?a._childDiv.offsetWidth:void 0},_getCollapsedSize:function(){return this._collapsedSize?this._collapsedSize:0},_getTargetSize:function(){var b=this,a;if(b._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical)a=b.get_TargetHeight();else if(b._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal)a=b.get_TargetWidth();if(a===undefined)a=0;return a},_setTargetSize:function(b){var a=this,e=a._collapsed||a._expandedSize,d=a.get_element();if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical)if(e||b<d.offsetHeight)a.set_TargetHeight(b);else{d.style.height=c;a.raisePropertyChanged(j)}else if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal)if(e||b<d.offsetWidth)a.set_TargetWidth(b);else{d.style.width=c;a.raisePropertyChanged(k)}a._checkCollapseHide()},_setupChildDiv:function(){var h="hidden",g="scroll",a=this,i=a._getTargetSize(),f=a.get_element();a._childDiv=f.cloneNode(d);f.id=b;a._childDiv.style.visibility="visible";a._childDiv.style.display=b;while(f.hasChildNodes()){var j=f.childNodes[0];j=f.removeChild(j);a._childDiv.appendChild(j)}f.setAttribute("style",b);f.className=b;f.style.border="0px";f.style.margin="0px";f.style.padding="0px";if(a._scrollContents){if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical){f.style.overflowY=g;a._childDiv.style.overflowY=b}else{f.style.overflowX=g;a._childDiv.style.overflowX=b}if(Sys.Browser.agent==Sys.Browser.Safari||Sys.Browser.agent==Sys.Browser.Opera){f.style.overflow=g;a._childDiv.style.overflow=b}}else{if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical){f.style.overflowY=h;a._childDiv.style.overflowY=b}else{f.style.overflowX=h;a._childDiv.style.overflowX=b}if(Sys.Browser.Agent==Sys.Browser.Safari||Sys.Browser.Agent==Sys.Browser.Opera){f.style.overflow=h;a._childDiv.style.overflow=b}}a._childDiv.style.position=b;if(i==a._collapsedSize)if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical)a._childDiv.style.height=c;else if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal)a._childDiv.style.width=c;f.appendChild(a._childDiv);f.style.visibility="visible";f.style.display=b;if(a._collapsed)i=a._getCollapsedSize();else i=a._getExpandedSize();if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical){f.style.height=i+e;if(!a._expandedSize)f.style.height=c;else f.style.height=a._expandedSize+e;a._childDiv.style.height=c}else if(a._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Horizontal){f.style.width=i+e;if(!a._expandedSize)f.style.width=c;else f.style.width=a._expandedSize+e;a._childDiv.style.width=c}},_setupState:function(d){var a=this;if(d){if(a._textLabelID&&a._collapsedText){var c=$get(a._textLabelID);if(c)c.innerHTML=a._collapsedText}if(a._imageControlID&&a._collapsedImage){var b=$get(a._imageControlID);if(b&&b.src){b.src=a._collapsedImage;if(a._expandedText||a._collapsedText)b.title=a._collapsedText}}}else{if(a._textLabelID&&a._expandedText){var c=$get(a._textLabelID);if(c)c.innerHTML=a._expandedText}if(a._imageControlID&&a._expandedImage){var b=$get(a._imageControlID);if(b&&b.src){b.src=a._expandedImage;if(a._expandedText||a._collapsedText)b.title=a._expandedText}}}if(a._collapsed!=d){a._collapsed=d;a.raisePropertyChanged(i)}Sys.Extended.UI.CollapsiblePanelBehavior.callBaseMethod(a,"set_ClientState",[a._collapsed.toString()])},_toggle:function(a){return this.get_Collapsed()?this.expandPanel(a):this.collapsePanel(a)},add_collapsing:function(a){this.get_events().addHandler(l,a)},remove_collapsing:function(a){this.get_events().removeHandler(l,a)},raiseCollapsing:function(b){var a=this.get_events().getHandler(l);a&&a(this,b)},add_collapsed:function(a){this.get_events().addHandler(m,a)},remove_collapsed:function(a){this.get_events().removeHandler(m,a)},raiseCollapsed:function(b){var a=this.get_events().getHandler(m);a&&a(this,b)},add_collapseComplete:function(a){this.get_events().addHandler(n,a)},remove_collapseComplete:function(a){this.get_events().removeHandler(n,a)},raiseCollapseComplete:function(){var a=this.get_events().getHandler(n);a&&a(this,Sys.EventArgs.Empty)},add_expanding:function(a){this.get_events().addHandler(o,a)},remove_expanding:function(a){this.get_events().removeHandler(o,a)},raiseExpanding:function(b){var a=this.get_events().getHandler(o);a&&a(this,b)},add_expanded:function(a){this.get_events().addHandler(p,a)},remove_expanded:function(a){this.get_events().removeHandler(p,a)},raiseExpanded:function(b){var a=this.get_events().getHandler(p);a&&a(this,b)},add_expandComplete:function(a){this.get_events().addHandler(q,a)},remove_expandComplete:function(a){this.get_events().removeHandler(q,a)},raiseExpandComplete:function(){var a=this.get_events().getHandler(q);a&&a(this,Sys.EventArgs.Empty)},get_TargetHeight:function(){return this.get_element().offsetHeight},set_TargetHeight:function(a){this.get_element().style.height=a+e;this.raisePropertyChanged(j)},get_TargetWidth:function(){return this.get_element().offsetWidth},set_TargetWidth:function(a){this.get_element().style.width=a+e;this.raisePropertyChanged(k)},get_Collapsed:function(){return this._collapsed},set_Collapsed:function(b){var a=this;if(a.get_isInitialized()&&a.get_element()&&b!=a.get_Collapsed())a.togglePanel();else{a._collapsed=b;a.raisePropertyChanged(i)}},get_CollapsedSize:function(){return this._collapsedSize},set_CollapsedSize:function(a){if(this._collapsedSize!=a){this._collapsedSize=a;this.raisePropertyChanged("CollapsedSize")}},get_ExpandedSize:function(){return this._expandedSize},set_ExpandedSize:function(a){if(this._expandedSize!=a){this._expandedSize=a;this.raisePropertyChanged("ExpandedSize")}},get_CollapseControlID:function(){return this._collapseControlID},set_CollapseControlID:function(a){if(this._collapseControlID!=a){this._collapseControlID=a;this.raisePropertyChanged(t)}},get_ExpandControlID:function(){return this._expandControlID},set_ExpandControlID:function(a){if(this._expandControlID!=a){this._expandControlID=a;this.raisePropertyChanged(u)}},get_ScrollContents:function(){return this._scrollContents},set_ScrollContents:function(a){if(this._scrollContents!=a){this._scrollContents=a;this.raisePropertyChanged("ScrollContents")}},get_SuppressPostBack:function(){return this._suppressPostBack},set_SuppressPostBack:function(a){if(this._suppressPostBack!=a){this._suppressPostBack=a;this.raisePropertyChanged(h)}},get_TextLabelID:function(){return this._textLabelID},set_TextLabelID:function(a){if(this._textLabelID!=a){this._textLabelID=a;this.raisePropertyChanged("TextLabelID")}},get_ExpandedText:function(){return this._expandedText},set_ExpandedText:function(a){if(this._expandedText!=a){this._expandedText=a;this.raisePropertyChanged("ExpandedText")}},get_CollapsedText:function(){return this._collapsedText},set_CollapsedText:function(a){if(this._collapsedText!=a){this._collapsedText=a;this.raisePropertyChanged("CollapsedText")}},get_ImageControlID:function(){return this._imageControlID},set_ImageControlID:function(a){if(this._imageControlID!=a){this._imageControlID=a;this.raisePropertyChanged("ImageControlID")}},get_ExpandedImage:function(){return this._expandedImage},set_ExpandedImage:function(a){if(this._expandedImage!=a){this._expandedImage=a;this.raisePropertyChanged("ExpandedImage")}},get_CollapsedImage:function(){return this._collapsedImage},set_CollapsedImage:function(a){if(this._collapsedImage!=a){this._collapsedImage=a;this.raisePropertyChanged("CollapsedImage")}},get_AutoExpand:function(){return this._autoExpand},set_AutoExpand:function(a){if(this._autoExpand!=a){this._autoExpand=a;this.raisePropertyChanged("AutoExpand")}},get_AutoCollapse:function(){return this._autoCollapse},set_AutoCollapse:function(a){if(this._autoCollapse!=a){this._autoCollapse=a;this.raisePropertyChanged("AutoCollapse")}},get_ExpandDirection:function(){return this._expandDirection==Sys.Extended.UI.CollapsiblePanelExpandDirection.Vertical},set_ExpandDirection:function(a){if(this._expandDirection!=a){this._expandDirection=a;this.raisePropertyChanged("ExpandDirection")}}};Sys.Extended.UI.CollapsiblePanelBehavior.registerClass("Sys.Extended.UI.CollapsiblePanelBehavior",Sys.Extended.UI.BehaviorBase);Sys.registerComponent(Sys.Extended.UI.CollapsiblePanelBehavior,{name:"collapsiblePanel"})}if(window.Sys&&Sys.loader)Sys.loader.registerScript(b,["ExtendedBase","ExtendedCommon","ExtendedAnimations"],a);else a()})();