// 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
require({cache:{"url:jimu/dijit/templates/PopupConfig.html":'\x3cdiv style\x3d"width:560px;"\x3e\r\n\t\x3ctable class\x3d"popup-config-layout" style\x3d"width:100%;table-layout:fixed;"\x3e\r\n\t\t\x3ccolgroup\x3e\r\n\t\t\t\x3ccol width\x3d"auto"\x3e\x3c/col\x3e\r\n\t\t\t\x3ccol width\x3d"370px"\x3e\x3c/col\x3e\r\n\t\t\t\x3ccol width\x3d"70px"\x3e\x3c/col\x3e\r\n\t\t\x3c/colgroup\x3e\r\n\t\t\x3ctbody\x3e\r\n\t\t\t\x3ctr data-dojo-attach-point\x3d"titleTR"\x3e\r\n\t\t\t\t\x3ctd nowrap\x3e\r\n\t\t\t\t\t\x3cspan\x3e${nls.title}\x3c/span\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd\x3e\r\n\t\t\t\t\t\x3cinput data-dojo-attach-point\x3d"titleTextBox" data-dojo-type\x3d"dijit/form/TextBox" style\x3d"width:100%;" /\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"btnAdd" data-dojo-type\x3d"dijit/form/DropDownButton"\x3e\r\n\t\t\t\t\t\t\x3cspan\x3e${nls.add}\x3c/span\x3e\r\n\t\t\t\t\t\t\x3cdiv data-dojo-type\x3d"dijit/TooltipDialog"\x3e\r\n\t\t\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"menu" data-dojo-type\x3d"dijit/Menu"\x3e\x3c/div\x3e\r\n\t\t\t\t\t\t\x3c/div\x3e\r\n\t\t\t\t\t\x3c/div\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr data-dojo-attach-point\x3d"fieldsTR"\x3e\r\n\t\t\t\t\x3ctd nowrap\x3e\r\n\t\t\t\t\t\x3cspan\x3e${nls.fields}\x3c/span\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd colspan\x3d"2" data-dojo-attach-point\x3d"fieldsTableTd"\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\x3c/tbody\x3e\r\n\t\x3c/table\x3e\r\n\x3c/div\x3e\r\n'}});
define("dojo/_base/declare dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/text!./templates/PopupConfig.html dojo/_base/lang dojo/_base/html dojo/_base/array dojo/Evented esri/request dijit/MenuItem jimu/dijit/SimpleTable dijit/form/TextBox dijit/form/DropDownButton dijit/TooltipDialog dijit/Menu".split(" "),function(k,l,m,n,p,c,e,f,q,r,h,t){return k([l,m,n,q],{_def:null,declaredClass:"jimu.dijit.PopupConfig",baseClass:"jimu-dijit-popup-config",templateString:p,url:null,
title:null,fields:null,config:null,showTitle:!0,postMixInProperties:function(){this.nls=window.jimuNls.popupConfig},postCreate:function(){this.inherited(arguments);this._initFieldsTable();this.clear();this.showTitle?(e.setStyle(this.titleTR,"display",""),this.title&&this.titleTextBox.set("value",this.title)):e.setStyle(this.titleTR,"display","none");this.fields?this.setFields(this.fields):this.url&&this.setUrl(this.url)},getConfig:function(){var a={title:c.trim(this.titleTextBox.get("value")),fields:[]},
b=this.fieldsTable.getRows();f.forEach(b,c.hitch(this,function(d){var g=this.fieldsTable.getRowData(d);g.visibility&&a.fields.push({name:g.name,alias:g.alias,type:d.fieldType})}));return a},setUrl:function(a){if("string"===typeof a)return this.url=a=c.trim(a),this.clear(),this._requestLayerInfo(a)},setFields:function(a){a instanceof Array&&this._setFields(a)},clear:function(){this.fieldsTable.clear();this._resetMenu();this._addEmptyMenuItem()},_initFieldsTable:function(){e.empty(this.fieldsTableTd);
var a=[{name:"visibility",title:this.nls.visibility,type:"checkbox",onChange:c.hitch(this,this._onFieldVisibleChange)},{name:"name",title:this.nls.name,type:"text",editable:!1},{name:"alias",title:this.nls.alias,type:"text",editable:!0},{name:"actions",title:this.nls.actions,type:"actions",actions:["up","down"]}];this.fieldsTable=new t({fields:a});this.fieldsTable.placeAt(this.fieldsTableTd)},_onFieldVisibleChange:function(){var a=this.fieldsTable.getRows();f.every(a,function(b){return!1===this.fieldsTable.getRowData(b).visibility},
this)?this.emit("noVisibleField"):this.emit("hasVisibleField")},_resetMenu:function(){var a=this.menu.getChildren();f.forEach(a,c.hitch(this,function(b){this.menu.removeChild(b)}))},_addEmptyMenuItem:function(){var a=new h({label:this.nls.noField,onClick:c.hitch(this,function(){var b=this.menu.getParent();e.setStyle(b.domNode.parentNode,"display","none")})});this.menu.addChild(a)},_setFields:function(a){this._resetMenu();this.fields=f.filter(a,function(b){return"esriFieldTypeGeometry"!==b.type});
0<this.fields.length?f.forEach(this.fields,c.hitch(this,function(b){this._addMenuItem(b);this._addRow(b)})):this._addEmptyMenuItem()},_requestLayerInfo:function(a){this._def&&this._def.cancel();this._def=r({url:a,content:{f:"json"},handleAs:"json",callbackParamName:"callback"});this._def.then(c.hitch(this,function(b){b&&b.fields&&this._setFields(b.fields)}),c.hitch(this,function(b){console.error("request layer info failed",b)}));return this._def},_addMenuItem:function(a){var b=new h({label:a.name+
" {"+a.name+"}",onClick:c.hitch(this,function(){var d=this.titleTextBox.get("value")+"${"+a.name+"}";this.titleTextBox.set("value",d);d=this.menu.getParent();e.setStyle(d.domNode.parentNode,"display","none")})});this.menu.addChild(b)},_addRow:function(a){var b=this.fieldsTable.addRow({visibility:!1!==a.visible,name:a.name,alias:a.alias||a.name});b.success&&(b.tr.fieldType=a.type)}})});