//>>built
define("dijit/layout/StackController","dojo/_base/array dojo/_base/declare dojo/dom-class dojo/dom-construct dojo/keys dojo/_base/lang dojo/on dojo/topic ../focus ../registry ../_Widget ../_TemplatedMixin ../_Container ../form/ToggleButton dojo/touch".split(" "),function(q,l,v,p,e,f,r,m,t,k,w,x,y,z){p=l("dijit.layout._StackButton",z,{tabIndex:"-1",closeButton:!1,_aria_attr:"aria-selected",buildRendering:function(a){this.inherited(arguments);(this.focusNode||this.domNode).setAttribute("role","tab")}});
l=l("dijit.layout.StackController",[w,x,y],{baseClass:"dijitStackController",templateString:"\x3cspan role\x3d'tablist' data-dojo-attach-event\x3d'onkeydown'\x3e\x3c/span\x3e",containerId:"",buttonWidget:p,buttonWidgetCloseClass:"dijitStackCloseButton",pane2button:function(a){return k.byId(this.id+"_"+a)},postCreate:function(){this.inherited(arguments);this.own(m.subscribe(this.containerId+"-startup",f.hitch(this,"onStartup")),m.subscribe(this.containerId+"-addChild",f.hitch(this,"onAddChild")),m.subscribe(this.containerId+
"-removeChild",f.hitch(this,"onRemoveChild")),m.subscribe(this.containerId+"-selectChild",f.hitch(this,"onSelectChild")),m.subscribe(this.containerId+"-containerKeyDown",f.hitch(this,"onContainerKeyDown")));this.containerNode.dojoClick=!0;this.own(r(this.containerNode,"click",f.hitch(this,function(a){var b=k.getEnclosingWidget(a.target);if(b!=this.containerNode&&!b.disabled&&b.page)for(a=a.target;a!==this.containerNode;a=a.parentNode)if(v.contains(a,this.buttonWidgetCloseClass)){this.onCloseButtonClick(b.page);
break}else if(a==b.domNode){this.onButtonClick(b.page);break}})))},onStartup:function(a){this.textDir=a.textDir;q.forEach(a.children,this.onAddChild,this);if(a.selected)this.onSelectChild(a.selected);var b=k.byId(this.containerId).containerNode,c=f.hitch(this,"pane2button");a={title:"label",showtitle:"showLabel",iconclass:"iconClass",closable:"closeButton",tooltip:"title",disabled:"disabled",textdir:"textdir"};var g=function(h,A){return r(b,"attrmodified-"+h,function(n){var u=c(n.detail&&n.detail.widget&&
n.detail.widget.id);u&&u.set(A,n.detail.newValue)})},d;for(d in a)this.own(g(d,a[d]))},destroy:function(a){this.destroyDescendants(a);this.inherited(arguments)},onAddChild:function(a,b){var c=new (f.isString(this.buttonWidget)?f.getObject(this.buttonWidget):this.buttonWidget)({id:this.id+"_"+a.id,name:this.id+"_"+a.id,label:a.title,disabled:a.disabled,ownerDocument:this.ownerDocument,dir:a.dir,lang:a.lang,textDir:a.textDir||this.textDir,showLabel:a.showTitle,iconClass:a.iconClass,closeButton:a.closable,
title:a.tooltip,page:a});this.addChild(c,b);a.controlButton=c;if(!this._currentChild)this.onSelectChild(a);c=a._wrapper.getAttribute("aria-labelledby")?a._wrapper.getAttribute("aria-labelledby")+" "+c.id:c.id;a._wrapper.removeAttribute("aria-label");a._wrapper.setAttribute("aria-labelledby",c)},onRemoveChild:function(a){this._currentChild===a&&(this._currentChild=null);var b=this.pane2button(a.id);b&&(this.removeChild(b),b.destroy());delete a.controlButton},onSelectChild:function(a){if(a){if(this._currentChild){var b=
this.pane2button(this._currentChild.id);b.set("checked",!1);b.focusNode.setAttribute("tabIndex","-1")}b=this.pane2button(a.id);b.set("checked",!0);this._currentChild=a;b.focusNode.setAttribute("tabIndex","0");k.byId(this.containerId)}},onButtonClick:function(a){var b=this.pane2button(a.id);t.focus(b.focusNode);this._currentChild&&this._currentChild.id===a.id&&b.set("checked",!0);k.byId(this.containerId).selectChild(a)},onCloseButtonClick:function(a){k.byId(this.containerId).closeChild(a);this._currentChild&&
(a=this.pane2button(this._currentChild.id))&&t.focus(a.focusNode||a.domNode)},adjacent:function(a){this.isLeftToRight()||this.tabPosition&&!/top|bottom/.test(this.tabPosition)||(a=!a);var b=this.getChildren(),c=q.indexOf(b,this.pane2button(this._currentChild.id)),g=b[c];do{c=(c+(a?1:b.length-1))%b.length;var d=b[c]}while(d.disabled&&d!=g);return d},onkeydown:function(a,b){if(!this.disabled&&!a.altKey){var c=null;if(a.ctrlKey||!a._djpage){switch(a.keyCode){case e.LEFT_ARROW:case e.UP_ARROW:a._djpage||
(c=!1);break;case e.PAGE_UP:a.ctrlKey&&(c=!1);break;case e.RIGHT_ARROW:case e.DOWN_ARROW:a._djpage||(c=!0);break;case e.PAGE_DOWN:a.ctrlKey&&(c=!0);break;case e.HOME:for(var g=this.getChildren(),d=0;d<g.length;d++){var h=g[d];if(!h.disabled){this.onButtonClick(h.page);break}}a.stopPropagation();a.preventDefault();break;case e.END:g=this.getChildren();for(d=g.length-1;0<=d;d--)if(h=g[d],!h.disabled){this.onButtonClick(h.page);break}a.stopPropagation();a.preventDefault();break;case e.DELETE:case 87:this._currentChild.closable&&
(a.keyCode==e.DELETE||a.ctrlKey)&&(this.onCloseButtonClick(this._currentChild),a.stopPropagation(),a.preventDefault());break;case e.TAB:a.ctrlKey&&(this.onButtonClick(this.adjacent(!a.shiftKey).page),a.stopPropagation(),a.preventDefault())}null!==c&&(this.onButtonClick(this.adjacent(c).page),a.stopPropagation(),a.preventDefault())}}},onContainerKeyDown:function(a){a.e._djpage=a.page;this.onkeydown(a.e)}});l.StackButton=p;return l});