text: //>>built
  require({cache:{"url:esriviewer/ui/layers/template/LayersWidgetTemplate.html":"<div>\r\n    <div class=\"defaultTabContainer\" data-dojo-attach-point=\"layersTabContainer\">\r\n        <span data-dojo-attach-point=\"layersTab\"\r\n              data-bind=\"click:showLayersList, css: {selectedTab: layersListVisible}\">Layers</span>\r\n        <span data-dojo-attach-point=\"addLayersTab\"\r\n              data-bind=\"click:showAddLayers, css: {selectedTab: addLayersVisible}\">Add Layer</span>\r\n        <span data-dojo-attach-point=\"persistedLayersTab\"\r\n              data-bind=\"click:showUserPersistedLayers, css: {selectedTab: persistedLayersVisible}\">Saved Layers</span>\r\n    </div>\r\n    <div data-bind=\"visible:addLayersVisible\" class=\"addLayerContainer\" data-dojo-attach-point=\"addLayerContainer\">\r\n        <div class=\"addLayerContainerInner\">\r\n            <div class=\"viewerAddLayerWorkingWKIDContainer\" data-bind=\"visible:showWKIDInAddLayers\">\r\n                <span class=\"viewerAddLayerLabel \">Map WKID:</span>\r\n                <span class=\"viewerAddLayerWorkingWKIDLabel\" data-bind=\"text: viewerWKID\"></span>\r\n            </div>\r\n            <div class=\"viewerAddLayerLabel viewerAddLayerUrlLabel \">URL:</div>\r\n            <div data-dojo-type=\"dijit/form/TextBox\" style=\"width: 100%\" data-dojo-attach-point=\"addLayerTextInput\"\r\n                 data-dojo-attach-event=\"onKeyUp:handleLayerAddUrlKeyUp\"></div>\r\n            <div class=\"viewerAddLayerLabel viewerAddLayerUrlLabel \">Label:</div>\r\n            <div data-dojo-type=\"dijit/form/TextBox\" style=\"width: 100%\" data-dojo-attach-point=\"addLayerLabelInput\"\r\n                 value=\"Added Layer\"></div>\r\n            <div class=\"viewerAddLayerActions\">\r\n                <div class=\"layerTypeContainer\">\r\n                    <div class=\"viewerAddLayerLabel\">Type:</div>\r\n                    <select data-dojo-type=\"dijit/form/Select\" style=\"width: 100%\"\r\n                            data-dojo-attach-point=\"addLayerTypeSelect\"\r\n                            style=\"width: 15em\"></select>\r\n                </div>\r\n                <div class=\"viewerAddLayerButtonActions\">\r\n                    <div data-dojo-type=\"dijit/form/Button\" data-dojo-attach-event=\"onClick:addManualLayer\">Add Layer\r\n                    </div>\r\n                </div>\r\n            </div>\r\n\r\n        </div>\r\n    </div>\r\n    <div data-dojo-attach-point=\"layerTocContainer\" data-bind=\"visible:layersListVisible\">\r\n\r\n    </div>\r\n    <div data-bind=\"visible:persistedLayersVisible\" data-dojo-attach-point=\"userPersistedLayersContainer\">\r\n    </div>\r\n</div>"}});define("esriviewer/ui/layers/LayersWidget",["dojo/_base/declare","dojo/text!./template/LayersWidgetTemplate.html","dojo/topic","dojo/_base/lang","dojo/dom-style","dojo/dom-construct","../base/UITemplatedWidget","../tooltip/ConfirmTooltip","./base/LayersLocalStorageMixin","./model/LayersWidgetViewModel","./LayersTocWidget","./base/UserPersistedLayersListWidget","dijit/form/TextBox","dijit/form/Select","dijit/form/Button"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f){return _1([_7,_9],{showWKIDInAddLayers:true,firstAddLayerDisplay:true,errorMessageDelay:5000,successMessageDelay:2000,allowAddLayers:true,templateString:_2,constructor:function(_10){_4.mixin(this,_10||{});this.addedLayers={};},postCreate:function(){this.inherited(arguments);this.viewModel=new _a();this.viewModel.showWKIDInAddLayers(this.showWKIDInAddLayers);this.viewModel.showUserPersistedLayersIcon(this.localStoragePersistSupported);this.viewModel.layersListVisible.subscribe(_4.hitch(this,this.handleLayerListVisibilityChanged));this.viewModel.addLayersVisible.subscribe(_4.hitch(this,this.handleAddLayersVisibilityChanged));this.viewModel.persistedLayersVisible.subscribe(_4.hitch(this,this.handlePersistedLayersVisibilityChanged));this.viewModel.on(this.viewModel.ADD_LAYERS_VISIBLE,_4.hitch(this,this.handleAddLayersVisible));ko.applyBindings(this.viewModel,this.domNode);this.createLayersTocWidget();_5.set(this.domNode,"minHeight","250px");if(this.allowAddLayers){this.populateLayerTypesDropdown();}else{_5.set(this.layersTabContainer,"display","none");}this.manualLayerLoadedSuccessCallback=_4.hitch(this,this.handleManualLayerLoadedCallback);this.manualLayerLoadedErrCallback=_4.hitch(this,this.handleManualLayerLoadErrorCallback);if(this.localStoragePersistSupported){this.createUserPersistedLayerListWidget();}},handleLayerListVisibilityChanged:function(_11){this._handleContentAnimation(_11,this.layerTocContainer);},handleAddLayersVisibilityChanged:function(_12){this._handleContentAnimation(_12,this.addLayerContainer);},handlePersistedLayersVisibilityChanged:function(_13){this._handleContentAnimation(_13,this.userPersistedLayersContainer);},handleAddLayersVisible:function(){this.addLayerTextInput.set("value","");this.addLayerLabelInput.set("value","");this.addLayerTextInput.focus();},createLayersTocWidget:function(){this.layersTocWidget=new _b();_6.place(this.layersTocWidget.domNode,this.layerTocContainer);},createUserPersistedLayerListWidget:function(){if(this.userPersistedLayersListWidget==null){this.userPersistedLayersListWidget=new _c();this.userPersistedLayersListWidget.placeAt(this.userPersistedLayersContainer);this.userPersistedLayersListWidget.on("removeUserPersistedLayer",_4.hitch(this,this.handleRemoveUserPersistedLayer));this.userPersistedLayersListWidget.on("addUserPersistedLayerToMap",_4.hitch(this,this.handleAddUserPersistedLayerToMap));this.userPersistedLayersListWidget.on("removeAllUserPersistedLayers",_4.hitch(this,this.handleRemoveAllUserPersistedLayers));this.userPersistedLayersListWidget.addExistingPersistedLayerItems(this.persistedUserLayers);}},showLayerList:function(){this.viewModel.showLayersList();},handleRemoveAllUserPersistedLayers:function(){this.removeAllLayers();},handleRemoveUserPersistedLayer:function(_14){if(_14!=null&&_14!=""){this.deleteUserPersistedLayer(_14);}},handleAddUserPersistedLayerToMap:function(_15,_16){if(_15!=null&&_15!=""){this._addLayer(_15,_16);}},loadViewerConfigurationData:function(){var _17=null;_3.publish(VIEWER_GLOBALS.EVENTS.CONFIGURATION.GET_ENTRY,"layersWidget",function(_18){_17=_18;});if(_17){for(var key in _17){if(key==null||key.toString()==null){continue;}if(key.toString().toLowerCase()=="allowAddLayers".toLowerCase()){this.allowAddLayers=_17[key];}else{if(key.toString().toLowerCase()=="showWKIDInAddLayers".toLowerCase()){if(_17[key]==false){this.showWKIDInAddLayers=false;}}}}}},handleManualLayerLoadedCallback:function(){_3.publish(VIEWER_GLOBALS.EVENTS.MESSAGING.SHOW,"Layer Added");VIEWER_UTILS.log("Layer Added",VIEWER_GLOBALS.LOG_TYPE.INFO);},handleManualLayerLoadErrorCallback:function(msg){if(msg!=null&&_4.isString(msg)){VIEWER_UTILS.log("Could not add layer: "+msg,VIEWER_GLOBALS.LOG_TYPE.ERROR);}else{VIEWER_UTILS.log("Add Layer Failed",VIEWER_GLOBALS.LOG_TYPE.ERROR);}},initListeners:function(){this.inherited(arguments);_3.subscribe(VIEWER_GLOBALS.EVENTS.MAP.LAYERS.ADDED,_4.hitch(this,this.addLayer));_3.subscribe(VIEWER_GLOBALS.EVENTS.MAP.LAYERS.REMOVED,_4.hitch(this,this.handleLayerRemoved));_3.subscribe(VIEWER_GLOBALS.EVENTS.MAP.LAYERS.CLEAR_STORED_LAYERS,_4.hitch(this,this.handleRemoveAllUserPersistedLayers));},populateLayerTypesDropdown:function(){var _19;for(var key in VIEWER_GLOBALS.LAYER_TYPES){_19=VIEWER_GLOBALS.LAYER_TYPES[key];var _1a={label:_19.LABEL,value:_19.VALUE};this.addLayerTypeSelect.addOption(_1a);}},handleAddLayers:function(_1b){if(_1b!=null&&_4.isArray(_1b)){for(var i=0;i<_1b.length;i++){this.addLayer(_1b[i]);}}},addLayer:function(_1c){if(_1c==null){return;}var _1d=VIEWER_UTILS.getLayerUniqueId(_1c);if(_1d==null||this.addedLayers[_1d]!=null){return;}this.layersTocWidget.addLayer(_1c);this.addedLayers[_1d]={layer:_1c};if(_1c.url&&this.localStoragePersistSupported){this.saveLayer(_1c);}},saveLayer:function(_1e){var _1f=this.persistUserLayer(_1e);if(_1f&&_1f.url){this.userPersistedLayersListWidget.addPersistedLayer(_1f);}},handleToggleLayerVisibility:function(_20){if(_20.visible){_20.hide();}else{_20.show();}},handleZoomToLayer:function(_21){_3.publish(VIEWER_GLOBALS.EVENTS.MAP.EXTENT.SET_EXTENT,_21.fullExtent);},handleLayerAddUrlKeyUp:function(e){if(VIEWER_UTILS.isEnterKey(e)){this.addManualLayer();}else{var url=this.addLayerTextInput.get("value");if(url==""){return;}var _22=VIEWER_UTILS.getServiceTypeFromUrl(url);if(_22!=null){if(_22===VIEWER_GLOBALS.SERVICE_TYPES.IMAGE_SERVER){this.addLayerTypeSelect.set("value",VIEWER_GLOBALS.LAYER_TYPES.IMAGE_SERVER.VALUE);}else{if(_22===VIEWER_GLOBALS.SERVICE_TYPES.FEATURE_SERVER){this.addLayerTypeSelect.set("value",VIEWER_GLOBALS.LAYER_TYPES.FEATURE_LAYER.VALUE);}else{if(_22===VIEWER_GLOBALS.SERVICE_TYPES.KML){this.addLayerTypeSelect.set("value",VIEWER_GLOBALS.LAYER_TYPES.KML.VALUE);}else{if(_22===VIEWER_GLOBALS.SERVICE_TYPES.MAP_SERVER){var _23=REG_EXP_UTILS.featureLayerRegExp.test(url);if(_23){this.addLayerTypeSelect.set("value",VIEWER_GLOBALS.LAYER_TYPES.FEATURE_LAYER.VALUE);}else{this.addLayerTypeSelect.set("value",VIEWER_GLOBALS.LAYER_TYPES.MAP_SERVER.VALUE);}}}}}}}},addManualLayer:function(){var url=this.addLayerTextInput.get("value");if(url!=""){if(VIEWER_UTILS.endsWith(url,"/")){url=url.substring(0,url.length-1);}this._addLayer(url);}},_addLayer:function(_24,_25){var _26=_25;if(_26==null||_26==""){_26=this.addLayerLabelInput.get("value");}_3.publish(VIEWER_GLOBALS.EVENTS.MAP.LAYERS.ADD_FROM_URL,_24,{isOperationalLayer:true,canRemove:true,label:_26},this.manualLayerLoadedSuccessCallback,this.manualLayerLoadedErrCallback);},showConfirmDeleteLayerTooltip:function(_27,_28){this.deleteLayerConfirmedCallback=_4.hitch(this,this.handleRemoveLayerFromClick,_27);this.showDeleteLayerTooltip(_28);},handleRemoveLayerFromClick:function(_29){_3.publish(VIEWER_GLOBALS.EVENTS.MAP.LAYERS.REMOVE,_29);},createConfirmDeleteLayerTooltip:function(){this.confirmDeleteLayerTooltip=new _8({confirmCallback:_4.hitch(this,this.handleConfirmedLayerDelete)});this.confirmDeleteLayerTooltip.on("hide",_4.hitch(this,function(){this.deleteLayerConfirmedCallback=null;}));},handleConfirmedLayerDelete:function(){if(_4.isFunction(this.deleteLayerConfirmedCallback)){this.deleteLayerConfirmedCallback();}this.deleteLayerConfirmedCallback=null;},showDeleteLayerTooltip:function(_2a){if(_2a==null){return;}if(this.confirmDeleteLayerTooltip==null){this.createConfirmDeleteLayerTooltip();}if(this.confirmDeleteLayerTooltip){this.confirmDeleteLayerTooltip.setAroundNode(_2a);this.confirmDeleteLayerTooltip.show();}},handleLayerRemoved:function(_2b){if(_2b==null){return;}var _2c=VIEWER_UTILS.getLayerUniqueId(_2b);if(_2c==null){return;}if(this.addedLayers[_2c]!=null){this.layersTocWidget.removeLayer(_2b);delete this.addedLayers[_2c];}},hidePopups:function(){if(this.confirmDeleteLayerTooltip){this.confirmDeleteLayerTooltip.hide();}}});});