YUI.add("aui-toggler-base",function(e,t){var n=e.Lang,r=n.isBoolean,i=n.isObject,s=n.isUndefined,o=n.toInt,u="animated",a="animating",f="bindDOMEvents",l="click",c="collapsed",h="content",p="cubic-bezier(0, 0.1, 0, 1.0)",d="down",v="enter",m="esc",g="expanded",y="expandedChange",b="getBoundingClientRect",w="header",E="keydown",S="left",x="marginTop",T="num_minus",N="num_plus",C="offsetHeight",k="px",L="right",A="space",O="toggler",M="transition",_="up",D="wrapper",P=e.getClassName,H=P(O,h),B=P(O,h,c),j=P(O,h,g),F=P(O,h,D),I=P(O,w),q=P(O,w,c),R=P(O,w,g),U={"false":B,"true":j},z={"false":q,"true":R},W='<div class="'+F+'"></div>',X=e.Component.create({NAME:O,ATTRS:{animated:{validator:r,value:!1,writeOnce:!0},animating:{validator:r,value:!1},bindDOMEvents:{validator:r,value:!0,writeOnce:!0},content:{setter:e.one},expanded:{validator:r,value:!0},header:{setter:e.one},transition:{validator:i,value:{duration:.4,easing:p}}},EXTENDS:e.Base,headerEventHandler:function(e,t){if(e.type===l||e.isKey(v)||e.isKey(A))return e.preventDefault(),t.toggle();if(e.isKey(d)||e.isKey(L)||e.isKey(N))return e.preventDefault(),t.expand();if(e.isKey(_)||e.isKey(S)||e.isKey(m)||e.isKey(T))return e.preventDefault(),t.collapse()},prototype:{initializer:function(){var e=this;e.bindUI(),e.syncUI(),e._uiSetExpanded(e.get(g))},bindUI:function(){var t=this,n=t.get(w);n.setData(O,t);var r=[t.on(y,e.bind(t._onExpandedChange,t))];t.get(f)&&r.push(n.on([l,E],e.rbind(X.headerEventHandler,null,t))),t._eventHandles=r},syncUI:function(){var e=this;e.get(h).addClass(H),e.get(w).addClass(I)},destructor:function(){var t=this;t.get(w).setData(O,null),(new e.EventHandle(t._eventHandles)).detach()},animate:function(t,n){var r=this;r._uiSetExpanded(!0);var i=e.merge(t,r.get(M));r.get(h).transition(i,e.bind(n,r))},collapse:function(e){var t=this;return t.toggle(!1,e)},expand:function(e){var t=this;return t.toggle(!0,e)},getContentHeight:function(){var e=this,t=e.get(h),n=e.get(g),r;n||e._uiSetExpanded(!0);if(t.hasMethod(b)){var i=t.invoke(b);i&&(r=i.bottom-i.top)}else r=t.get(C);return n||e._uiSetExpanded(!1),r},toggle:function(e,t){var n=this,r=n.get(w),i;if(!r.test(":visible"))return;i=n.get(g),s(e)&&(e=!i);if(e!==i)if(n.get(u)){if(n.get(a))return e;n._animation(e,t)}else n.set(g,e,t);return e},_animation:function(e,t){var n=this,r=n.get(h),i=n.contentGutter,u=n.getContentHeight();s(i)&&(i=n.contentGutter=o(r.getStyle(x))),n.wrapped||(r.wrap(W),e&&r.setStyle(x,-(u+i)),n.wrapped=!0),n.set(a,!0),n.animate({marginTop:(e?i:-(u+i))+k},function(){n.set(a,!1),n.set(g,e,t)})},_onExpandedChange:function(e){var t=this;t._uiSetExpanded(e.newVal)},_uiSetExpanded:function(e){var t=this;t.get(h).replaceClass(U[!e],U[e]),t.get(w).replaceClass(z[!e],z[e])}}});e.Toggler=X},"2.0.0",{requires:["transition","aui-selector","aui-event-base","aui-node","aui-component"],skinnable:!0});
