/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
require({cache:{"url:esri/dijit/geoenrichment/templates/InfographicsCarousel.html":"<div style=\"display: inline-block;\">\r\n        <div data-dojo-attach-point=\"_loading\">\r\n            <div class=\"Browser_LoadingBackground\"></div>\r\n            <div class=\"Browser_Loading\"></div>\r\n        </div>\r\n        <table class=\"Browser_Table\" cellpadding=\"0\" cellspacing=\"0\">\r\n            <tr>\r\n                <td class=\"Browser_BackTd\">\r\n                    <div class=\"Browser_Back\" data-dojo-attach-event=\"click: _slideBack\"></div>\r\n                </td>\r\n                <td align=\"center\">\r\n\r\n                    <div data-dojo-type=\"dijit/layout/BorderContainer\" data-dojo-attach-point=\"_container\" data-dojo-props=\"gutters: false\" class=\"Browser_HostBorder\">\r\n                        <div data-dojo-type=\"dijit/layout/ContentPane\" data-dojo-attach-point=\"_titlePane\" data-dojo-props=\"region:'top'\" class=\"Browser_TitlePane\" style=\"visibility: hidden;\">\r\n                            <select data-dojo-type=\"dijit/form/Select\"\r\n                                data-dojo-attach-point=\"_select\"\r\n                                data-dojo-attach-event=\"onChange: _onSelectChange\">\r\n                            </select>\r\n                            <div data-dojo-attach-point=\"_subtitle\" class=\"Browser_Subtitle\"></div>\r\n                        </div>\r\n                        <div data-dojo-type=\"dijit/layout/ContentPane\" data-dojo-props=\"region:'center'\" style=\"padding: 0;\">\r\n                            <div data-dojo-type=\"esri/dijit/geoenrichment/Infographic\"\r\n                                data-dojo-attach-point=\"_infographic\"\r\n                                data-dojo-props=\"autoWidth: false, autoHeight: false, title: ''\"\r\n                                data-dojo-attach-event=\"onDataRequest: _onDataRequest, onDataLoad: _onDataLoad, onDataReady: _onDataReady, onDataError: _onDataError\"\r\n                                style=\"height: 100%\">\r\n                            </div>\r\n\r\n                        </div>\r\n                    </div>\r\n\r\n                </td>\r\n                <td class=\"Browser_ForwardTd\">\r\n                    <div class=\"Browser_Forward\" data-dojo-attach-event=\"click: _slideForward\"></div>\r\n                </td>\r\n            </tr>\r\n        </table>\r\n</div>\r\n"}});define("esri/dijit/geoenrichment/InfographicsCarousel",["../../declare","dojo/_base/lang","dojo/aspect","dojox/mvc/Templated","dojo/text!./templates/InfographicsCarousel.html","./dom","./Infographic","dojo/on","dojo/dom-class","./InfographicsOptions","./_Interop","./bufferTitle","./theme","../../tasks/geoenrichment/GeoenrichmentTask","../../tasks/geoenrichment/GeometryStudyArea","../../tasks/geoenrichment/studyAreaFromJson","./config","esri/dijit/_EventedWidget","./UserError","dijit/layout/BorderContainer","dijit/layout/ContentPane","dijit/form/Select"],function(_1,_2,_3,_4,_5,_6,_7,on,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12){var _13=_1("esri.dijit.geoenrichment.InfographicsCarousel",[_4,_11],{templateString:_5,studyArea:null,studyAreaTitle:null,selectedIndex:0,options:null,expanded:true,returnGeometry:false,_items:null,_loading:null,_infographic:null,_getCountryPromise:null,_countryForStudyArea:false,_eventMap:{"resize":["size"],"data-ready":["provider"],"data-error":["error"]},postCreate:function(){this.inherited(arguments);setTimeout(_2.hitch(this,this._onResize),0);},startup:function(){this.inherited(arguments);if(!this.options){this.set("options",new _9());}},_setReturnGeometryAttr:function(_14){this._set("returnGeometry",_14);this._infographic.set("returnGeometry",_14);},_setStudyAreaAttr:function(_15){if(!(_15 instanceof _e)){throw new Error("Not implemented yet");}this._countryForStudyArea=false;this._set("studyArea",_15);if(!this._getCountryPromise){if(this._infographic.get("countryID")){this._infographic.set("studyArea",_15);}else{this._getCountry();}}this._updateSubtitle();},_getCountry:function(){if(this._getCountryPromise){return;}var _16=new _d(_10.server);_16.token=_10.token;var _17=this.get("studyArea");this._getCountryPromise=_16.getCountries(_17.geometry);this._getCountryPromise.always(_2.hitch(this,function(){this._getCountryPromise=null;}));this._getCountryPromise.then(_2.hitch(this,this._onGetCountryComplete,_17),_2.hitch(this,this._onDataError));},_onGetCountryComplete:function(_18,_19){if(_19.length==0){this._onDataError(new _12("There is no data for the selected area"));return;}if(this.studyArea===_18){this._countryForStudyArea=true;}this._infographic.set("countryID",_19[0]);this._infographic.set("studyArea",this.studyArea);this._getReports();},_setStudyAreaTitleAttr:function(_1a){this._set("studyAreaTitle",_1a);this._updateSubtitle();},_updateSubtitle:function(){var _1b;if(this.studyArea){_1b=this.studyArea.geometry.type;}var _1c=_b(_1b,this.options&&this.options.studyAreaOptions);if(this.studyAreaTitle){this._subtitle.innerHTML=this.studyAreaTitle+" ("+_1c+")";}else{this._subtitle.innerHTML=_1c;}},_setOptionsAttr:function(_1d){this._set("options",_1d);this._getReports();this._infographic.set("studyAreaOptions",_1d.studyAreaOptions);this._updateSubtitle();_c.set(this.domNode,this.options.theme);},_getReports:function(){if(!this.options){return;}var _1e=this._infographic.get("countryID");if(!_1e){return;}this.options.getItems(_1e).then(_2.hitch(this,this._fillReports),_2.hitch(this,this._onDataError));},_fillReports:function(_1f){this._items=[];this._select.removeOption(this._select.getOptions());for(var i=0;i<_1f.length;i++){if(_1f[i].isVisible){var _20=_1f[i];this._items.push(_20);this._select.addOption({value:(this._items.length-1).toString(),label:_20.title});}}this._infographic.set("cacheLimit",this._items.length);this._titlePane.domNode.style.visibility="";this._updateSelection();},_setExpandedAttr:function(_21){this._set("expanded",_21);if(_21){_8.remove(this.domNode,"Collapsed");}else{_8.add(this.domNode,"Collapsed");}this._container.resize();this._infographic.set("expanded",_21);},_setSelectedIndexAttr:function(_22){if(this.selectedIndex==_22){return;}this._set("selectedIndex",_22);this._updateSelection();},_updateSelection:function(){if(!this._items){return;}var _23=this._items[this.selectedIndex];this._select.set("value",this.selectedIndex);this._infographic.set("type",_23.type);this._infographic.set("variables",_23.variables);this._infographic.set("datasetID",_23.datasetID);},_onDataRequest:function(){this._loading.style.display="block";},_onDataReady:function(_24){var _25=false;var _26=_24.getData();var _27=_26.getRowCount();if(_27>0){var row=_26.getRow(0);for(var i=0;i<row.length;i++){if(!_26.getCol(i).fullName){continue;}if(row[i]){_25=true;break;}}}if(_25){this.onDataReady(_24);}else{if(!this._countryForStudyArea){this._infographic.set("variables",null);_24.stop();this._getCountry();}}},onDataReady:function(_28){},_onDataLoad:function(){if(this._getCountryPromise){return;}this._loading.style.display="none";this.onDataLoad();},onDataLoad:function(){},_onDataError:function(_29){console.error(_29);this._loading.style.display="none";this.onDataError(_29);},onDataError:function(_2a){},_slideBack:function(){var _2b=this.get("selectedIndex")-1;if(_2b<0){_2b=this._items.length-1;}this.set("selectedIndex",_2b);},_slideForward:function(){var _2c=this.get("selectedIndex")+1;if(_2c>=this._items.length){_2c=0;}this.set("selectedIndex",_2c);},_onSelectChange:function(){this.set("selectedIndex",+this._select.get("value"));},_onResize:function(){this._container.resize();this.onResize([this.domNode.scrollWidth,this.domNode.scrollHeight]);},onResize:function(_2d){}});_13.Interop=_1([_13,_a],{postMixInProperties:function(){_3.after(this,"onResize",_2.hitch(this,function(_2e){this._onCommand("OnResize",_2e[0],_2e[1]);}),true);_3.after(this,"onDataError",_2.hitch(this,this._onCommand,"OnDataError"),true);this.inherited(arguments);},converters:{"studyArea":new _a.JsonConverter(_f),"options":new _a.CtorConverter(_9),"expanded":_a.BoolConverter},setValue:function(_2f,_30){if(_2f=="inGeom"){arguments[0]="studyArea";arguments[1]={geometry:_30};}this.inherited(arguments);}});return _13;});