// 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:widgets/Chart/setting/DataFields.html":'\x3cdiv\x3e\r\n\t\x3cdiv data-dojo-attach-point\x3d"fieldsContent" class\x3d"fields-content"\x3e\r\n\t\x3c/div\x3e\r\n\t\x3cdiv class\x3d"operation"\x3e\r\n\t\t\x3cdiv data-dojo-attach-point\x3d"btnUp" data-dojo-attach-event\x3d"onclick:_moveUp" class\x3d"up-icon" title\x3d"${nls.moveUp}"\x3e\x3c/div\x3e\r\n\t\t\x3cdiv data-dojo-attach-point\x3d"btnDown" data-dojo-attach-event\x3d"onclick:_moveDown" class\x3d"down-icon" title\x3d"${nls.moveDown}"\x3e\x3c/div\x3e\r\n\t\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/html dojo/_base/query dojo/on dijit/_WidgetBase dijit/_TemplatedMixin dojo/Evented dojo/text!./DataFields.html jimu/utils".split(" "),function(m,e,g,c,f,h,n,p,q,r,t){return m([n,q,p],{baseClass:"jimu-widget-chart-setting-data-fields",templateString:r,postCreate:function(){this.inherited(arguments);this.own(h(this.domNode,"click",e.hitch(this,this._onDomClicked)))},clear:function(){c.empty(this.fieldsContent);this.emit("change")},
setFields:function(a){this.clear();g.forEach(a,e.hitch(this,function(b){var d=c.toDom('\x3cdiv class\x3d"field-item"\x3e\x3cinput type\x3d"checkbox" /\x3e\x3cspan class\x3d"jimu-ellipsis" /\x3e\x3c/div\x3e'),k=f("input",d)[0],l=f("span",d)[0];k.checked=!!b.checked;l.innerHTML=t.sanitizeHTML(b.alias||b.name);l.title=b.alias||b.name;d.fieldName=b.name;c.place(d,this.fieldsContent);this.own(h(k,"change",e.hitch(this,function(){this.emit("change")})))}));this.emit("change")},selectFields:function(a){e.isArrayLike(a)&&
(a=e.clone(a),a.reverse(),g.forEach(a,e.hitch(this,function(b){if(b=this._getFieldItemDivByName(b))c.place(b,b.parentNode,"first"),f("input",b)[0].checked=!0})));this.emit("change")},getSelectedFieldNames:function(){var a=f(".field-item",this.fieldsContent),b=[];g.forEach(a,e.hitch(this,function(d){f("input",d)[0].checked&&b.push(d.fieldName)}));return b},_getFieldItemDivByName:function(a){var b=f(".field-item",this.fieldsContent);return g.filter(b,e.hitch(this,function(d){return d.fieldName===a}))[0]},
_onDomClicked:function(a){a=a.target||a.srcElement;if(c.isDescendant(a,this.fieldsContent)&&a!==this.fieldsContent){var b=a.tagName.toLowerCase(),d=null;c.hasClass(a,"field-item")?this._selectFieldItemDom(a):"span"===b?(d=a.parentNode,this._selectFieldItemDom(d)):"input"===b&&(d=a.parentNode,a.checked?this._selectFieldItemDom(d):c.removeClass(d,"selected"));this._updateHighLightIcons()}},_updateHighLightIcons:function(){var a=this._getSelectedFieldItemDiv();a&&c.hasClass(a,"selected")&&(a.previousSibling?
c.addClass(this.btnUp,"high-light"):c.removeClass(this.btnUp,"high-light"),a.nextSibling?c.addClass(this.btnDown,"high-light"):c.removeClass(this.btnDown,"high-light"))},_selectFieldItemDom:function(a){f(".field-item",this.fieldsContent).removeClass("selected");c.addClass(a,"selected")},_getSelectedFieldItemDiv:function(){var a=null,b=f(".field-item.selected",this.fieldsContent);0<b.length&&(a=b[0]);return a},_moveUp:function(){var a=this._getSelectedFieldItemDiv();a&&a.previousSibling&&c.place(a,
a.previousSibling,"before");this._updateHighLightIcons()},_moveDown:function(){var a=this._getSelectedFieldItemDiv();a&&a.nextSibling&&c.place(a,a.nextSibling,"after");this._updateHighLightIcons()}})});