// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/html dojo/on dojo/keys dojo/dom-construct dojo/query dijit/_WidgetBase dijit/_TemplatedMixin jimu/dijit/ViewStack dojox/gesture/swipe dojox/gesture/tap jimu/utils".split(" "),function(u,h,v,g,l,k,m,p,w,x,y,z,A,t){var n=0;return u([w,x],{baseClass:"jimu-header-more-popup",templateString:'\x3cdiv\x3e\x3cdiv class\x3d"close" tabindex\x3d"0" data-dojo-attach-point\x3d"closeNode"\x3e\x3c/div\x3e\x3cdiv class\x3d"pages" data-dojo-attach-point\x3d"pagesNode"\x3e\x3c/div\x3e\x3cdiv class\x3d"points jimu-corner-bottom"\x3e\x3cdiv class\x3d"points-inner"data-dojo-attach-point\x3d"pointsNode"\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e',
margin:4,postCreate:function(){this.nodes=[];this.pages=[];this.createCloseBtn();this.own(l(this.domNode,"keydown",h.hitch(this,function(a){g.hasClass(a.target,"close-btn")||a.keyCode!==k.ESCAPE||this.closeNode.focus()})))},startup:function(){this.viewStack=new y({views:[],viewType:"dom"},this.pagesNode);this.viewStack.startup();l(this.pagesNode,z.end,h.hitch(this,function(a){n<this.maximumPages-1&&a.dx&&0>a.dx?(n++,this._selectPage(n)):a.dx&&0<a.dx&&0<n&&(n--,this._selectPage(n))}));this.resize();
this.nodes.length&&this.nodes[0].focus()},resize:function(){var a=this._calculateGridParam();if(null!==a){g.setStyle(this.domNode,t.getPositionStyle(a.position));this.nodeWidth=a.cellSize-this.margin;this.oldGridParam&&this.oldGridParam.rows===a.rows&&this.oldGridParam.cols===a.cols||(this.clearPages(),this.createPages(a));this.nodes.forEach(h.hitch(this,function(b,c){this.setItemNodePosition(b,c,a)}));this.oldGridParam=a;var d=p("div.close",this.domNode)[0];g.setStyle(d,{width:.25*this.nodeWidth+
"px",height:.25*this.nodeWidth+"px"})}else this.oldGridParam=null,g.setStyle(this.domNode,t.getPositionStyle({left:0,top:0,width:0,height:0,zIndex:111})),this.nodeWidth=0;!window.appInfo.isRunInMobile&&760<window.innerWidth&&this.numWidget&&8>=this.numWidget.length&&this.hide()},setItemNodePosition:function(a,d,b){var c=48,e=16;var f=0===d%b.cols?0:this.margin/2;var q=d%(b.rows*b.cols)<b.cols?0:this.margin/2;d={};"number"===typeof this.nodeWidth&&(d.width=this.nodeWidth+"px",d.height=this.nodeWidth+
"px");"number"===typeof f&&(window.isRTL?d.marginRight=f+"px":d.marginLeft=f+"px");"number"===typeof q&&(d.marginTop=q+"px");if(f=p("img",a)[0])b.iconScaled&&(c*=this.nodeWidth/120),g.setStyle(f,{width:c+"px",height:c+"px"});if(c=p("div.node-label",a)[0])b.showLabel?(b.iconScaled&&(e*=this.nodeWidth/120),g.setStyle(c,{"font-size":e+"px",display:"block"})):g.setStyle(c,{"font-size":e+"px",display:"none"});g.setStyle(a,d)},clearPages:function(){v.forEach(this.pages,function(a){this.viewStack.removeView(a.pageNode)},
this);m.empty(this.pointsNode);this.pages=[];this.nodes=[]},createPages:function(a){var d,b;this.maximumPages=d=Math.ceil(this.items.length/(a.rows*a.cols));for(b=0;b<d;b++){var c=m.create("div",{"class":"page"});this.createPageItems(b,c,a);this.viewStack.addView(c);if(1<d){var e=b===d-1;var f=m.create("div",{"class":"point",role:"button",tabindex:0},this.pointsNode);this.own(l(f,"click",h.hitch(this,this._onPageNodeClick,b)));this.own(l(f,"keydown",h.hitch(this,function(q,B,r){r.keyCode===k.ENTER||
r.keyCode===k.SPACE?(this._onPageNodeClick(q),p(".page.view",this.viewStack.domNode)[q].children[0].focus()):B&&!r.shiftKey&&r.keyCode===k.TAB&&r.preventDefault()},b,e)))}this.pages.push({pageNode:c,pointNode:f})}0<this.viewStack.views.length&&this._selectPage(0)},_onPageNodeClick:function(a){this._selectPage(a)},_selectPage:function(a){1<this.pages.length&&(p(".point",this.domNode).removeClass("point-selected jimu-main-background"),g.addClass(this.pages[a].pointNode,"point-selected jimu-main-background"));
this.viewStack.switchView(this.pages[a].pageNode)},createPageItems:function(a,d,b){var c=this.items.length;var e=b.rows*b.cols;b=(a+1)*e;var f=b-c;b=Math.min(b,c);for(a*=e;a<b;a++)this.createItemNode(a,d);for(a=c;a<c+f;a++)this.createEmptyItemNode(d)},createItemNode:function(a,d){a=this.items[a];var b=m.create("div",{"class":"icon-node jimu-float-leading jimu-main-background",title:a.label,"aria-label":a.label,settingId:a.id,"data-widget-name":a.name,role:"button",tabindex:0},d);d=m.create("img",
{src:a.icon},b);window.isRTL&&a.mirrorIconForRTL&&g.addClass(d,"jimu-flipx");m.create("div",{"class":"node-label",title:a.label,innerHTML:t.stripHTML(a.label)},b);b.config=a;this.own(l(b,A,h.hitch(this,function(){this.onNodeClicked(b)})));this.own(l(b,"keydown",h.hitch(this,function(c){if(c.keyCode===k.ENTER||c.keyCode===k.SPACE)this.onNodeClicked(b)})));this.nodes.push(b)},createEmptyItemNode:function(a){a=m.create("div",{"class":"icon-node jimu-float-leading jimu-main-background",tabindex:0},a);
this.own(l(a,"focus",h.hitch(this,function(d){t.isInNavMode()&&(1===this.viewStack.domNode.children.length?d.target.parentNode.children[0].focus():p(".point-selected",this.pointsNode)[0].previousSibling.focus())})));this.nodes.push(a);return a},createCloseBtn:function(){m.create("div",{role:"button","class":"close-inner jimu-main-background"},this.closeNode);this.own(l(this.closeNode,"click",h.hitch(this,function(){this.hide()})));this.own(l(this.closeNode,"keydown",h.hitch(this,function(a){a.keyCode===
k.ENTER||a.keyCode===k.SPACE||a.keyCode===k.ESCAPE?this.hide():a.shiftKey&&a.keyCode===k.TAB&&a.preventDefault()})));return this.closeNode},hide:function(){n=0;g.setStyle(this.domNode,"display","none")},show:function(){g.setStyle(this.domNode,"display","block")},onNodeClicked:function(a){this.hide()},openNodebyId:function(a){for(var d=0,b=this.nodes.length;d<b;d++){var c=this.nodes[d];if(a&&a===g.getAttr(c,"settingId"))return this.onNodeClicked(c),c}},_calculateGridParam:function(){var a=!1,d=!0;
var b=g.getContentBox(jimuConfig.mapId);var c=Math.min(b.w,b.h)-40;if(360<=c)var e=120;else{e=Math.floor(c/3);if(10>e)return null;a=!0;80>e&&(d=!1)}c=Math.floor((b.h-40)/e);var f=Math.floor((b.w-40)/e);c=4<c?4:c;c=3>c?3:c;f=3>c?3:4<f?4:f;return{rows:c,cols:f,cellSize:e,iconScaled:a,showLabel:d,position:{top:(b.h-e*c)/2,bottom:(b.h-e*c)/2,left:(b.w-e*f)/2,right:(b.w-e*f)/2,width:e*f-this.margin*(f-1)/2,height:e*c-this.margin*(c-1)/2,zIndex:111}}}})});