// MooTools: the javascript framework.
// Load this file's selection again by visiting: http://mootools.net/more/144546de4e5d33717f588373f2597f63 
// Or build this file again with packager using: packager build More/More More/Fx.Accordion More/Fx.Slide
/*
---

script: More.js

name: More

description: MooTools More

license: MIT-style license
...
*/

MooTools.More={'version':'1.3.1.1','build':'0292a3af1eea242b817fecf9daa127417d10d4ce'};Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(a,b){this.elements=this.subject=$$(a);this.parent(b)},compute:function(a,b,c){var d={};for(var i in a){var e=a[i],iTo=b[i],iNow=d[i]={};for(var p in e)iNow[p]=this.parent(e[p],iTo[p],c)}return d},set:function(a){for(var i in a){if(!this.elements[i])continue;var b=a[i];for(var p in b)this.render(this.elements[i],p,b[p],this.options.unit)}return this},start:function(a){if(!this.check(a))return this;var b={},to={};for(var i in a){if(!this.elements[i])continue;var c=a[i],iFrom=b[i]={},iTo=to[i]={};for(var p in c){var d=this.prepare(this.elements[i],p,c[p]);iFrom[p]=d.from;iTo[p]=d.to}}return this.parent(b,to)}});Fx.Accordion=new Class({Extends:Fx.Elements,options:{fixedHeight:false,fixedWidth:false,display:0,show:false,height:true,width:false,opacity:true,alwaysHide:false,trigger:'click',initialDisplayFx:true,resetHeight:true},initialize:function(){var c=function(a){return a!=null};var d=Array.link(arguments,{'container':Type.isElement,'options':Type.isObject,'togglers':c,'elements':c});this.parent(d.elements,d.options);var e=this.options,togglers=this.togglers=$$(d.togglers);this.previous=-1;this.internalChain=new Chain();if(e.alwaysHide)this.options.link='chain';if(e.show||this.options.show===0){e.display=false;this.previous=e.show}if(e.start){e.display=false;e.show=false}var f=this.effects={};if(e.opacity)f.opacity='fullOpacity';if(e.width)f.width=e.fixedWidth?'fullWidth':'offsetWidth';if(e.height)f.height=e.fixedHeight?'fullHeight':'scrollHeight';for(var i=0,l=togglers.length;i<l;i++)this.addSection(togglers[i],this.elements[i]);this.elements.each(function(a,i){if(e.show===i){this.fireEvent('active',[togglers[i],a])}else{for(var b in f)a.setStyle(b,0)}},this);if(e.display||e.display===0||e.initialDisplayFx===false){this.display(e.display,e.initialDisplayFx)}if(e.fixedHeight!==false)e.resetHeight=false;this.addEvent('complete',this.internalChain.callChain.bind(this.internalChain))},addSection:function(a,b){a=document.id(a);b=document.id(b);this.togglers.include(a);this.elements.include(b);var c=this.togglers,options=this.options,test=c.contains(a),idx=c.indexOf(a),displayer=this.display.pass(idx,this);a.store('accordion:display',displayer).addEvent(options.trigger,displayer);if(options.height)b.setStyles({'padding-top':0,'border-top':'none','padding-bottom':0,'border-bottom':'none'});if(options.width)b.setStyles({'padding-left':0,'border-left':'none','padding-right':0,'border-right':'none'});b.fullOpacity=1;if(options.fixedWidth)b.fullWidth=options.fixedWidth;if(options.fixedHeight)b.fullHeight=options.fixedHeight;b.setStyle('overflow','hidden');if(!test)for(var d in this.effects){b.setStyle(d,0)}return this},removeSection:function(a,b){var c=this.togglers,idx=c.indexOf(a),element=this.elements[idx];var d=function(){c.erase(a);this.elements.erase(element);this.detach(a)}.bind(this);if(this.now==idx||b!=null){this.display(b!=null?b:(idx-1>=0?idx-1:0)).chain(d)}else{d()}return this},detach:function(b){var c=function(a){a.removeEvent(this.options.trigger,a.retrieve('accordion:display'))}.bind(this);if(!b)this.togglers.each(c);else c(b);return this},display:function(d,e){if(!this.check(d,e))return this;var f={},elements=this.elements,options=this.options,effects=this.effects;if(e==null)e=true;if(typeOf(d)=='element')d=elements.indexOf(d);if(d==this.previous&&!options.alwaysHide)return this;if(options.resetHeight){var g=elements[this.previous];if(g&&!this.selfHidden){for(var h in effects)g.setStyle(h,g[effects[h]])}}if((this.timer&&options.link=='chain')||(d===this.previous&&!options.alwaysHide))return this;this.previous=d;this.selfHidden=false;elements.each(function(a,i){f[i]={};var b;if(i!=d){b=true}else if(options.alwaysHide&&((a.offsetHeight>0&&options.height)||a.offsetWidth>0&&options.width)){b=true;this.selfHidden=true}this.fireEvent(b?'background':'active',[this.togglers[i],a]);if(d=='all')for(var c in effects)f[i][c]=a[effects[c]];else for(var c in effects)f[i][c]=b?0:a[effects[c]];if(!e&&!b&&options.resetHeight)f[i].height='auto'},this);this.internalChain.clearChain();this.internalChain.chain(function(){if(options.resetHeight&&!this.selfHidden){var a=elements[d];if(a)a.setStyle('height','auto')}}.bind(this));return e?this.start(f):this.set(f)}});var Accordion=new Class({Extends:Fx.Accordion,initialize:function(){this.parent.apply(this,arguments);var a=Array.link(arguments,{'container':Type.isElement});this.container=a.container},addSection:function(a,b,c){a=document.id(a);b=document.id(b);var d=this.togglers.contains(a);var e=this.togglers.length;if(e&&(!d||c)){c=c!=null?c:e-1;a.inject(this.togglers[c],'before');b.inject(a,'after')}else if(this.container&&!d){a.inject(this.container);b.inject(this.container)}return this.parent.apply(this,arguments)}});Fx.Slide=new Class({Extends:Fx,options:{mode:'vertical',wrapper:false,hideOverflow:true,resetHeight:false},initialize:function(a,b){a=this.element=this.subject=document.id(a);this.parent(b);b=this.options;var c=a.retrieve('wrapper'),styles=a.getStyles('margin','position','overflow');if(b.hideOverflow)styles=Object.append(styles,{overflow:'hidden'});if(b.wrapper)c=document.id(b.wrapper).setStyles(styles);if(!c)c=new Element('div',{styles:styles}).wraps(a);a.store('wrapper',c).setStyle('margin',0);if(a.getStyle('overflow')=='visible')a.setStyle('overflow','hidden');this.now=[];this.open=true;this.wrapper=c;this.addEvent('complete',function(){this.open=(c['offset'+this.layout.capitalize()]!=0);if(this.open&&b.resetHeight)c.setStyle('height','')},true)},vertical:function(){this.margin='margin-top';this.layout='height';this.offset=this.element.offsetHeight},horizontal:function(){this.margin='margin-left';this.layout='width';this.offset=this.element.offsetWidth},set:function(a){this.element.setStyle(this.margin,a[0]);this.wrapper.setStyle(this.layout,a[1]);return this},compute:function(a,b,c){return[0,1].map(function(i){return Fx.compute(a[i],b[i],c)})},start:function(a,b){if(!this.check(a,b))return this;this[b||this.options.mode]();var c=this.element.getStyle(this.margin).toInt(),layout=this.wrapper.getStyle(this.layout).toInt(),caseIn=[[c,layout],[0,this.offset]],caseOut=[[c,layout],[-this.offset,0]],start;switch(a){case'in':start=caseIn;break;case'out':start=caseOut;break;case'toggle':start=(layout==0)?caseIn:caseOut}return this.parent(start[0],start[1])},slideIn:function(a){return this.start('in',a)},slideOut:function(a){return this.start('out',a)},hide:function(a){this[a||this.options.mode]();this.open=false;return this.set([-this.offset,0])},show:function(a){this[a||this.options.mode]();this.open=true;return this.set([0,this.offset])},toggle:function(a){return this.start('toggle',a)}});Element.Properties.slide={set:function(a){this.get('slide').cancel().setOptions(a);return this},get:function(){var a=this.retrieve('slide');if(!a){a=new Fx.Slide(this,{link:'cancel'});this.store('slide',a)}return a}};Element.implement({slide:function(a,b){a=a||'toggle';var c=this.get('slide'),toggle;switch(a){case'hide':c.hide(b);break;case'show':c.show(b);break;case'toggle':var d=this.retrieve('slide:flag',c.open);c[d?'slideOut':'slideIn'](b);this.store('slide:flag',!d);toggle=true;break;default:c.start(a,b)}if(!toggle)this.eliminate('slide:flag');return this}});
