// 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 dijit/_WidgetBase dijit/_TemplatedMixin dojo/_base/lang dojo/_base/array dojo/_base/html dojo/on dojo/query dojo/Evented".split(" "),function(k,l,m,d,g,b,e,f,n){return k([l,m,n],{baseClass:"jimu-dijit-dropdownmenu",declaredClass:"jimu.dijit.DropdownMenu",templateString:"\x3cdiv\x3e\x3c/div\x3e",itemHeight:24,iconSize:16,offsetY:5,shelter:null,paddingOffsetY:8,dropdownMenuClass:"",dropdownMenuItemClass:"dropdown-menu-item",items:null,highlightValue:"",highlightSelectedItemAfterClick:!0,
menuLeadingIcon:!0,maxDisplayItems:10,postCreate:function(){this.inherited(arguments);this.items||(this.items=[]);this.shelter=b.toDom('\x3cdiv class\x3d"jimu-dijit-dropdownmenu-shelter"\x3e\x3c/div\x3e');this.itemsContainer=b.toDom('\x3cdiv class\x3d"jimu-dijit-dropdownmenu-items-container '+this.dropdownMenuClass+'"\x3e\x3c/div\x3e');0>=this.maxDisplayItems&&(this.maxDisplayItems=20);this.itemsContainer.style.maxHeight=this.itemHeight*this.maxDisplayItems+2*this.paddingOffsetY+"px";g.forEach(this.items,
d.hitch(this,function(a){var c=b.toDom('\x3cdiv class\x3d"'+this.dropdownMenuItemClass+' jimu-ellipsis"\x3e'+a.label+"\x3c/div\x3e");c.itemInfo=a;c.title=a.label;b.place(c,this.itemsContainer)}));this.own(e(this.domNode,"click",d.hitch(this,this._onIconClick)));this.own(e(this.shelter,"click",d.hitch(this,this._onShelterClick)));this.own(e(this.itemsContainer,"click",d.hitch(this,this._onItemsContainerClick)));this.highlightValue&&this.setHighlightValue(this.highlightValue)},_onIconClick:function(a,
c){a.stopPropagation();this.isShowing()?this.hideMenu():(a=b.position(c||a.target||a.srcElement),this.showMenu(a))},_onShelterClick:function(){this.hideMenu()},_onItemsContainerClick:function(a){a.stopPropagation();a=a.target||a.srcElement;b.hasClass(a,this.dropdownMenuItemClass)&&(a=a.itemInfo.value,this.highlightSelectedItemAfterClick&&this.setHighlightValue(a),this.emit("click-item",a));this.hideMenu()},clearHighlightValue:function(){f("."+this.dropdownMenuItemClass,this.itemsContainer).removeClass("selected")},
setHighlightValue:function(a){this.clearHighlightValue();f("."+this.dropdownMenuItemClass,this.itemsContainer).some(d.hitch(this,function(c){return c.itemInfo.value===a?(b.addClass(c,"selected"),!0):!1}))},getHighlightValue:function(){var a=f("."+this.dropdownMenuItemClass+".selected",this.itemsContainer)[0];return a?a.itemInfo.value:null},getHighlightLabel:function(){var a=this.getHighlightValue(),c="";g.some(this.items,function(h){return h.value===a?(c=h.label,!0):!1},this);return c},isShowing:function(){return b.hasClass(this.domNode,
"showing")},showMenu:function(a){this.itemsContainer.style.top=a.y+this.iconSize+this.offsetY+"px";this.menuLeadingIcon===window.isRTL?(this.itemsContainer.style.left=a.x+"px",this.itemsContainer.style.right="auto"):(this.itemsContainer.style.right=window.innerWidth-(a.x+this.iconSize)+"px",this.itemsContainer.style.left="auto");b.place(this.shelter,document.body);b.place(this.itemsContainer,document.body);b.addClass(this.domNode,"showing")},hideMenu:function(){this.itemsContainer.parentNode&&this.itemsContainer.parentNode.removeChild(this.itemsContainer);
this.shelter.parentNode&&this.shelter.parentNode.removeChild(this.shelter);b.removeClass(this.domNode,"showing")},destroy:function(){this.hideMenu();b.destroy(this.itemsContainer);b.destroy(this.shelter);this.inherited(arguments)}})});