var Spry;
if(!Spry){
Spry={};
}
if(!Spry.Widget){
Spry.Widget={};
}
Spry.Widget.CollapsiblePanel=function(_1,_2){
this.element=this.getElement(_1);
this.focusElement=null;
this.hoverClass="CollapsiblePanelTabHover";
this.openClass="CollapsiblePanelOpen";
this.closedClass="CollapsiblePanelClosed";
this.focusedClass="CollapsiblePanelFocused";
this.enableAnimation=true;
this.enableKeyboardNavigation=true;
this.animator=null;
this.hasFocus=false;
this.contentIsOpen=true;
this.openPanelKeyCode=Spry.Widget.CollapsiblePanel.KEY_DOWN;
this.closePanelKeyCode=Spry.Widget.CollapsiblePanel.KEY_UP;
Spry.Widget.CollapsiblePanel.setOptions(this,_2);
this.attachBehaviors();
};
Spry.Widget.CollapsiblePanel.prototype.getElement=function(_3){
if(_3&&typeof _3=="string"){
return document.getElementById(_3);
}
return _3;
};
Spry.Widget.CollapsiblePanel.prototype.addClassName=function(_4,_5){
if(!_4||!_5||(_4.className&&_4.className.search(new RegExp("\\b"+_5+"\\b"))!=-1)){
return;
}
_4.className+=(_4.className?" ":"")+_5;
};
Spry.Widget.CollapsiblePanel.prototype.removeClassName=function(_6,_7){
if(!_6||!_7||(_6.className&&_6.className.search(new RegExp("\\b"+_7+"\\b"))==-1)){
return;
}
_6.className=_6.className.replace(new RegExp("\\s*\\b"+_7+"\\b","g"),"");
};
Spry.Widget.CollapsiblePanel.prototype.hasClassName=function(_8,_9){
if(!_8||!_9||!_8.className||_8.className.search(new RegExp("\\b"+_9+"\\b"))==-1){
return false;
}
return true;
};
Spry.Widget.CollapsiblePanel.prototype.setDisplay=function(_a,_b){
if(_a){
_a.style.display=_b;
}
};
Spry.Widget.CollapsiblePanel.setOptions=function(_c,_d,_e){
if(!_d){
return;
}
for(var _f in _d){
if(_e&&_d[_f]==undefined){
continue;
}
_c[_f]=_d[_f];
}
};
Spry.Widget.CollapsiblePanel.prototype.onTabMouseOver=function(e){
this.addClassName(this.getTab(),this.hoverClass);
return false;
};
Spry.Widget.CollapsiblePanel.prototype.onTabMouseOut=function(e){
this.removeClassName(this.getTab(),this.hoverClass);
return false;
};
Spry.Widget.CollapsiblePanel.prototype.open=function(){
this.contentIsOpen=true;
if(this.enableAnimation){
if(this.animator){
this.animator.stop();
}
this.animator=new Spry.Widget.CollapsiblePanel.PanelAnimator(this,true,{duration:this.duration,fps:this.fps,transition:this.transition});
this.animator.start();
}else{
this.setDisplay(this.getContent(),"block");
}
this.removeClassName(this.element,this.closedClass);
this.addClassName(this.element,this.openClass);
};
Spry.Widget.CollapsiblePanel.prototype.close=function(){
this.contentIsOpen=false;
if(this.enableAnimation){
if(this.animator){
this.animator.stop();
}
this.animator=new Spry.Widget.CollapsiblePanel.PanelAnimator(this,false,{duration:this.duration,fps:this.fps,transition:this.transition});
this.animator.start();
}else{
this.setDisplay(this.getContent(),"none");
}
this.removeClassName(this.element,this.openClass);
this.addClassName(this.element,this.closedClass);
};
Spry.Widget.CollapsiblePanel.prototype.onTabClick=function(e){
if(this.isOpen()){
this.close();
}else{
this.open();
}
this.focus();
return this.stopPropagation(e);
};
Spry.Widget.CollapsiblePanel.prototype.onFocus=function(e){
this.hasFocus=true;
this.addClassName(this.element,this.focusedClass);
return false;
};
Spry.Widget.CollapsiblePanel.prototype.onBlur=function(e){
this.hasFocus=false;
this.removeClassName(this.element,this.focusedClass);
return false;
};
Spry.Widget.CollapsiblePanel.KEY_UP=38;
Spry.Widget.CollapsiblePanel.KEY_DOWN=40;
Spry.Widget.CollapsiblePanel.prototype.onKeyDown=function(e){
var key=e.keyCode;
if(!this.hasFocus||(key!=this.openPanelKeyCode&&key!=this.closePanelKeyCode)){
return true;
}
if(this.isOpen()&&key==this.closePanelKeyCode){
this.close();
}else{
if(key==this.openPanelKeyCode){
this.open();
}
}
return this.stopPropagation(e);
};
Spry.Widget.CollapsiblePanel.prototype.stopPropagation=function(e){
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue=false;
}
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble=true;
}
return false;
};
Spry.Widget.CollapsiblePanel.prototype.attachPanelHandlers=function(){
var tab=this.getTab();
if(!tab){
return;
}
var _10=this;
Spry.Widget.CollapsiblePanel.addEventListener(tab,"click",function(e){
return _10.onTabClick(e);
},false);
Spry.Widget.CollapsiblePanel.addEventListener(tab,"mouseover",function(e){
return _10.onTabMouseOver(e);
},false);
Spry.Widget.CollapsiblePanel.addEventListener(tab,"mouseout",function(e){
return _10.onTabMouseOut(e);
},false);
if(this.enableKeyboardNavigation){
var _11=null;
var _12=null;
this.preorderTraversal(tab,function(_13){
if(_13.nodeType==1){
var _14=tab.attributes.getNamedItem("tabindex");
if(_14){
_11=_13;
return true;
}
if(!_12&&_13.nodeName.toLowerCase()=="a"){
_12=_13;
}
}
return false;
});
if(_11){
this.focusElement=_11;
}else{
if(_12){
this.focusElement=_12;
}
}
if(this.focusElement){
Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement,"focus",function(e){
return _10.onFocus(e);
},false);
Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement,"blur",function(e){
return _10.onBlur(e);
},false);
Spry.Widget.CollapsiblePanel.addEventListener(this.focusElement,"keydown",function(e){
return _10.onKeyDown(e);
},false);
}
}
};
Spry.Widget.CollapsiblePanel.addEventListener=function(_15,_16,_17,_18){
try{
if(_15.addEventListener){
_15.addEventListener(_16,_17,_18);
}else{
if(_15.attachEvent){
_15.attachEvent("on"+_16,_17);
}
}
}
catch(e){
}
};
Spry.Widget.CollapsiblePanel.prototype.preorderTraversal=function(_19,_1a){
var _1b=false;
if(_19){
_1b=_1a(_19);
if(_19.hasChildNodes()){
var _1c=_19.firstChild;
while(!_1b&&_1c){
_1b=this.preorderTraversal(_1c,_1a);
try{
_1c=_1c.nextSibling;
}
catch(e){
_1c=null;
}
}
}
}
return _1b;
};
Spry.Widget.CollapsiblePanel.prototype.attachBehaviors=function(){
var _1d=this.element;
var tab=this.getTab();
var _1e=this.getContent();
if(this.contentIsOpen||this.hasClassName(_1d,this.openClass)){
this.addClassName(_1d,this.openClass);
this.removeClassName(_1d,this.closedClass);
this.setDisplay(_1e,"block");
this.contentIsOpen=true;
}else{
this.removeClassName(_1d,this.openClass);
this.addClassName(_1d,this.closedClass);
this.setDisplay(_1e,"none");
this.contentIsOpen=false;
}
this.attachPanelHandlers();
};
Spry.Widget.CollapsiblePanel.prototype.getTab=function(){
return this.getElementChildren(this.element)[0];
};
Spry.Widget.CollapsiblePanel.prototype.getContent=function(){
return this.getElementChildren(this.element)[1];
};
Spry.Widget.CollapsiblePanel.prototype.isOpen=function(){
return this.contentIsOpen;
};
Spry.Widget.CollapsiblePanel.prototype.getElementChildren=function(_1f){
var _20=[];
var _21=_1f.firstChild;
while(_21){
if(_21.nodeType==1){
_20.push(_21);
}
_21=_21.nextSibling;
}
return _20;
};
Spry.Widget.CollapsiblePanel.prototype.focus=function(){
if(this.focusElement&&this.focusElement.focus){
this.focusElement.focus();
}
};
Spry.Widget.CollapsiblePanel.PanelAnimator=function(_22,_23,_24){
this.timer=null;
this.interval=0;
this.fps=60;
this.duration=500;
this.startTime=0;
this.transition=Spry.Widget.CollapsiblePanel.PanelAnimator.defaultTransition;
this.onComplete=null;
this.panel=_22;
this.content=_22.getContent();
this.doOpen=_23;
Spry.Widget.CollapsiblePanel.setOptions(this,_24,true);
this.interval=Math.floor(1000/this.fps);
var c=this.content;
var _25=c.offsetHeight?c.offsetHeight:0;
this.fromHeight=(_23&&c.style.display=="none")?0:_25;
if(!_23){
this.toHeight=0;
}else{
if(c.style.display=="none"){
c.style.visibility="hidden";
c.style.display="block";
}
c.style.height="";
this.toHeight=c.offsetHeight;
}
this.distance=this.toHeight-this.fromHeight;
this.overflow=c.style.overflow;
c.style.height=this.fromHeight+"px";
c.style.visibility="visible";
c.style.overflow="hidden";
c.style.display="block";
};
Spry.Widget.CollapsiblePanel.PanelAnimator.defaultTransition=function(_26,_27,_28,_29){
_26/=_29;
return _27+((2-_26)*_26*_28);
};
Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.start=function(){
var _2a=this;
this.startTime=(new Date).getTime();
this.timer=setTimeout(function(){
_2a.stepAnimation();
},this.interval);
};
Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stop=function(){
if(this.timer){
clearTimeout(this.timer);
this.content.style.overflow=this.overflow;
}
this.timer=null;
};
Spry.Widget.CollapsiblePanel.PanelAnimator.prototype.stepAnimation=function(){
var _2b=(new Date).getTime();
var _2c=_2b-this.startTime;
if(_2c>=this.duration){
if(!this.doOpen){
this.content.style.display="none";
}
this.content.style.overflow=this.overflow;
this.content.style.height=this.toHeight+"px";
if(this.onComplete){
this.onComplete();
}
return;
}
var ht=this.transition(_2c,this.fromHeight,this.distance,this.duration);
this.content.style.height=((ht<0)?0:ht)+"px";
var _2d=this;
this.timer=setTimeout(function(){
_2d.stepAnimation();
},this.interval);
};
Spry.Widget.CollapsiblePanelGroup=function(_2e,_2f){
this.element=this.getElement(_2e);
this.opts=_2f;
this.attachBehaviors();
};
Spry.Widget.CollapsiblePanelGroup.prototype.setOptions=Spry.Widget.CollapsiblePanel.prototype.setOptions;
Spry.Widget.CollapsiblePanelGroup.prototype.getElement=Spry.Widget.CollapsiblePanel.prototype.getElement;
Spry.Widget.CollapsiblePanelGroup.prototype.getElementChildren=Spry.Widget.CollapsiblePanel.prototype.getElementChildren;
Spry.Widget.CollapsiblePanelGroup.prototype.setElementWidget=function(_30,_31){
if(!_30||!_31){
return;
}
if(!_30.spry){
_30.spry=new Object;
}
_30.spry.collapsiblePanel=_31;
};
Spry.Widget.CollapsiblePanelGroup.prototype.getElementWidget=function(_32){
return (_32&&_32.spry&&_32.spry.collapsiblePanel)?_32.spry.collapsiblePanel:null;
};
Spry.Widget.CollapsiblePanelGroup.prototype.getPanels=function(){
if(!this.element){
return [];
}
return this.getElementChildren(this.element);
};
Spry.Widget.CollapsiblePanelGroup.prototype.getPanel=function(_33){
return this.getPanels()[_33];
};
Spry.Widget.CollapsiblePanelGroup.prototype.attachBehaviors=function(){
if(!this.element){
return;
}
var _34=this.getPanels();
var _35=_34.length;
for(var i=0;i<_35;i++){
var _36=_34[i];
this.setElementWidget(_36,new Spry.Widget.CollapsiblePanel(_36,this.opts));
}
};
Spry.Widget.CollapsiblePanelGroup.prototype.openPanel=function(_37){
var w=this.getElementWidget(this.getPanel(_37));
if(w&&!w.isOpen()){
w.open();
}
};
Spry.Widget.CollapsiblePanelGroup.prototype.closePanel=function(_38){
var w=this.getElementWidget(this.getPanel(_38));
if(w&&w.isOpen()){
w.close();
}
};
Spry.Widget.CollapsiblePanelGroup.prototype.openAllPanels=function(){
var _39=this.getPanels();
var _3a=_39.length;
for(var i=0;i<_3a;i++){
var w=this.getElementWidget(_39[i]);
if(w&&!w.isOpen()){
w.open();
}
}
};
Spry.Widget.CollapsiblePanelGroup.prototype.closeAllPanels=function(){
var _3b=this.getPanels();
var _3c=_3b.length;
for(var i=0;i<_3c;i++){
var w=this.getElementWidget(_3b[i]);
if(w&&w.isOpen()){
w.close();
}
}
};


