//>>built
define("dijit/layout/StackController","dojo/_base/array,dojo/_base/declare,dojo/dom-class,dojo/_base/event,dojo/keys,dojo/_base/lang,dojo/on,../focus,../registry,../_Widget,../_TemplatedMixin,../_Container,../form/ToggleButton,dojo/i18n!../nls/common".split(","),function(k,i,n,g,f,l,o,m,h,p,q,r,j){j=i("dijit.layout._StackButton",j,{tabIndex:"-1",closeButton:!1,_aria_attr:"aria-selected",buildRendering:function(a){this.inherited(arguments);(this.focusNode||this.domNode).setAttribute("role","tab")}});
i=i("dijit.layout.StackController",[p,q,r],{baseClass:"dijitStackController",templateString:"<span role='tablist' data-dojo-attach-event='onkeypress'></span>",containerId:"",buttonWidget:j,buttonWidgetCloseClass:"dijitStackCloseButton",constructor:function(){this.pane2button={}},postCreate:function(){this.inherited(arguments);this.subscribe(this.containerId+"-startup","onStartup");this.subscribe(this.containerId+"-addChild","onAddChild");this.subscribe(this.containerId+"-removeChild","onRemoveChild");
this.subscribe(this.containerId+"-selectChild","onSelectChild");this.subscribe(this.containerId+"-containerKeyPress","onContainerKeyPress");this.connect(this.containerNode,"click",function(a){var b=h.getEnclosingWidget(a.target);if(b!=this.containerNode&&!b.disabled&&b.page)for(a=a.target;a!==this.containerNode;a=a.parentNode)if(n.contains(a,this.buttonWidgetCloseClass)){this.onCloseButtonClick(b.page);break}else if(a==b.domNode){this.onButtonClick(b.page);break}})},onStartup:function(a){k.forEach(a.children,
this.onAddChild,this);if(a.selected)this.onSelectChild(a.selected);var b=h.byId(this.containerId).containerNode,c=this.pane2button,a={title:"label",showtitle:"showLabel",iconclass:"iconClass",closable:"closeButton",tooltip:"title",disabled:"disabled"},e=function(a,d){return o(b,"attrmodified-"+a,function(a){var b=c[a.detail&&a.detail.widget&&a.detail.widget.id];b&&b.set(d,a.detail.newValue)})},d;for(d in a)this.own(e(d,a[d]))},destroy:function(){for(var a in this.pane2button)this.onRemoveChild(h.byId(a));
this.inherited(arguments)},onAddChild:function(a,b){var c=new (l.isString(this.buttonWidget)?l.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,showLabel:a.showTitle,iconClass:a.iconClass,closeButton:a.closable,title:a.tooltip,page:a});this.addChild(c,b);this.pane2button[a.id]=c;a.controlButton=c;if(!this._currentChild)this.onSelectChild(a)},onRemoveChild:function(a){if(this._currentChild===
a)this._currentChild=null;var b=this.pane2button[a.id];b&&(this.removeChild(b),delete this.pane2button[a.id],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");h.byId(this.containerId)}},onButtonClick:function(a){var b=this.pane2button[a.id];m.focus(b.focusNode);
this._currentChild&&this._currentChild.id===a.id&&b.set("checked",!0);h.byId(this.containerId).selectChild(a)},onCloseButtonClick:function(a){h.byId(this.containerId).closeChild(a);this._currentChild&&(a=this.pane2button[this._currentChild.id])&&m.focus(a.focusNode||a.domNode)},adjacent:function(a){if(!this.isLeftToRight()&&(!this.tabPosition||/top|bottom/.test(this.tabPosition)))a=!a;var b=this.getChildren(),c=k.indexOf(b,this.pane2button[this._currentChild.id]),e=b[c],d;do c=(c+(a?1:b.length-1))%
b.length,d=b[c];while(d.disabled&&d!=e);return d},onkeypress:function(a){if(!this.disabled&&!a.altKey){var b=null;if(a.ctrlKey||!a._djpage){switch(a.charOrCode){case f.LEFT_ARROW:case f.UP_ARROW:a._djpage||(b=!1);break;case f.PAGE_UP:a.ctrlKey&&(b=!1);break;case f.RIGHT_ARROW:case f.DOWN_ARROW:a._djpage||(b=!0);break;case f.PAGE_DOWN:a.ctrlKey&&(b=!0);break;case f.HOME:for(var c=this.getChildren(),e=0;e<c.length;e++){var d=c[e];if(!d.disabled){this.onButtonClick(d.page);break}}g.stop(a);break;case f.END:c=
this.getChildren();for(e=c.length-1;0<=e;e--)if(d=c[e],!d.disabled){this.onButtonClick(d.page);break}g.stop(a);break;case f.DELETE:if(this._currentChild.closable)this.onCloseButtonClick(this._currentChild);g.stop(a);break;default:if(a.ctrlKey)if(a.charOrCode===f.TAB)this.onButtonClick(this.adjacent(!a.shiftKey).page),g.stop(a);else if("w"==a.charOrCode){if(this._currentChild.closable)this.onCloseButtonClick(this._currentChild);g.stop(a)}}null!==b&&(this.onButtonClick(this.adjacent(b).page),g.stop(a))}}},
onContainerKeyPress:function(a){a.e._djpage=a.page;this.onkeypress(a.e)}});i.StackButton=j;return i});