/*
 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
 */

if(!dojo._hasResource["esri.dijit.editing.Editor"]){dojo._hasResource["esri.dijit.editing.Editor"]=true;dojo.provide("esri.dijit.editing.Editor");dojo.require("dijit.ProgressBar");dojo.require("dijit._Widget");dojo.require("dijit._Templated");dojo.require("esri.toolbars.edit");dojo.require("esri.toolbars.draw");dojo.require("esri.layers.FeatureLayer");dojo.require("esri.dijit.editing.Util");dojo.require("esri.dijit.editing.toolbars.Drawing");dojo.require("esri.dijit.editing.TemplatePicker");dojo.require("esri.dijit.AttributeInspector");dojo.require("esri.dijit.editing.SelectionHelper");dojo.require("esri.undoManager");dojo.require("esri.dijit.editing.editOperation");(function(){var _1=[dojo.moduleUrl("esri.dijit.editing","css/editor.css")];var _2=document.getElementsByTagName("head").item(0),_3;for(var i=0,il=_1.length;i<il;i++){_3=document.createElement("link");_3.type="text/css";_3.rel="stylesheet";_3.href=_1[i].toString();_2.appendChild(_3);}}());dojo.declare("esri.dijit.editing.Editor",[dijit._Widget,dijit._Templated],{widgetsInTemplate:true,templateString:"<div class=\"esriEditor\">\r\n    <div class=\"esriTemplatePicker\" dojoAttachPoint=\"templatePickerDiv\"></div>\r\n    <div class=\"esriDrawingToolbar\" dojoAttachPoint=\"drawingToolbarDiv\"></div>\r\n    <div class=\"progressBar\" dojoAttachPoint=\"progressBar\" indeterminate=\"true\" dojoType=\"dijit.ProgressBar\" />\r\n</div>\r\n",constructor:function(_4,_5){_4=_4||{};if(!_4.settings){console.error("Editor: please provide 'settings' parameter in the constructor");}if(!_4.settings.layerInfos){console.error("Editor: please provide 'layerInfos' parameter in the constructor");}this._settings=_4.settings;this._eConnects=[];},postCreate:function(){this._setDefaultOptions();this._initLayers();this._connectEvents();this._createWidgets();this._reset();this._enableMapClickHandler();},destroy:function(){if(this.drawingToolbar){this.drawingToolbar.destroy();}if(this.attributeInspector){this.attributeInspector.destroy();}if(this.templatePicker){this.templatePicker.destroy();}if(this._selectionHelper){this._selectionHelper.destroy();}if(this._drawToolbar){this._drawToolbar.deactivate();}this._reset();this._disableMapClickHandler();dojo.forEach(this._eConnects,"dojo.disconnect(item);");dojo.disconnect(this._dtConnect);dojo.disconnect(this._templatePickerOnSelectionChangeEvent);this._layer=this._currentGraphic=this._activeType=this._activeTemplate=this._drawingTool=this._drawToolbar=this._editToolbar=this.drawingToolbar=this.attributeInspector=this.templatePicker=this.undoManager=null;if(this._settings.map.infoWindow&&this._settings.map.infoWindow.clearFeatures){this._settings.map.infoWindow.clearFeatures();}this.inherited(arguments);},_setDefaultOptions:function(){this._drawToolbar=this._settings.drawToolbar||new esri.toolbars.Draw(this._settings.map);this._settings.drawToolbar=this._drawToolbar;this._editToolbar=this._settings.editToolbar||new esri.toolbars.Edit(this._settings.map);this._settings.editToolbar=this._editToolbar;this._settings.toolbarVisible=this._settings.toolbarVisible||false;this._settings.toolbarOptions=dojo.mixin({reshapeVisible:false,cutVisible:false,mergeVisible:false},this._settings.toolbarOptions);this._settings.createOptions=dojo.mixin({polylineDrawTools:[esri.dijit.editing.Editor.CREATE_TOOL_POLYLINE],polygonDrawTools:[esri.dijit.editing.Editor.CREATE_TOOL_POLYGON],editAttributesImmediately:true},this._settings.createOptions);this._settings.singleSelectionTolerance=this._settings.singleSelectionTolerance||3;this._settings.maxUndoRedoOperations=this._settings.maxUndoRedoOperations||10;this._settings.editor=this;this._usePopup=this._settings.usePopup=this._settings.map.infoWindow._setPagerCallbacks?true:false;this._datePackage=this._settings.datePackage;var _6=esri.config.defaults;this._settings.geometryService=this._settings.geometryService||_6.geometryService;_6.geometryService=_6.geometryService||this._settings.geometryService;},_initLayers:function(){this._settings.layers=[];this._settings.userIds={};this._settings.createOnlyLayer={};var _7=this._settings.layerInfos;dojo.forEach(_7,function(_8){if(_8.featureLayer&&_8.featureLayer.loaded){this._settings.layers.push(_8.featureLayer);var _9=_8.featureLayer.id;if(_8.featureLayer.credential){this._settings.userIds[_9]=_8.featureLayer.credential.userId;}if(_8.userId){this._settings.userIds[_9]=_8.userId;}var _a=_8.featureLayer.getEditCapabilities();if(_a.canCreate&&!_a.canUpdate){this._settings.createOnlyLayer[_9]=true;}else{this._settings.createOnlyLayer[_9]=false;}}},this);},_reset:function(){this._hideAttributeInspector();this._editToolbar.deactivate();this._editVertices=true;this._layer=null;this._currentGraphic=null;this._activeType=null;this._activeTemplate=null;this._drawingTool=null;this._attributeChanged=false;},_saveFeatureOnClient:function(_b){var _c=this.templatePicker.getSelected();var _d;if(_c.template){_d=_c.featureLayer.renderer.getSymbol(_c.template.prototype);}else{_d=_c.symbolInfo.symbol;}var _e=_c.featureLayer.fields;var _f={};dojo.forEach(_e,function(_10,idx){_f[_10.name]=null;});this._tempGraphic=new esri.Graphic(_b,_d,_f,null);var map=this._settings.map;map.graphics.add(this._tempGraphic);var _11=this._findCenterPoint(_b);this._createAttributeInspector(true);map.infoWindow.setTitle(_c.featureLayer?_c.featureLayer.name:esri.bundle.widgets.attributeInspector.NLS_title);this.attributeInspector.showFeature(this._tempGraphic,_c.featureLayer);map.infoWindow.show(_11,map.getInfoWindowAnchor(_11));if(this._settings.createOnlyLayer[_c.featureLayer.id]){this._infoWindowHideEvent=dojo.connect(map.infoWindow,"onHide",this,"_infoWindowHide");}dojo.disconnect(this._templatePickerOnSelectionChangeEvent);this.templatePicker.clearSelection();this._drawToolbar.deactivate();this._enableMapClickHandler();if(this.drawingToolbar){this.drawingToolbar.deactivate();}this._templatePickerOnSelectionChangeEvent=dojo.connect(this.templatePicker,"onSelectionChange",dojo.hitch(this,"_onCreateFeature"));},_saveAttributesOnClient:function(_12,_13,_14){this._tempGraphic.attributes[_13]=(typeof (_14)==="number"&&isNaN(_14))?null:_14;},_infoWindowHide:function(){this._createFeature(this._tempGraphic.geometry,this._tempGraphic.attributes);dojo.disconnect(this._infoWindowHideEvent);},_createFeature:function(_15,_16){this._editClickPoint=this._findCenterPoint(_15);if(!_15.rings){this._applyEdits([{layer:this._layer,adds:[this._createGraphic(_15,_16)]}]);return;}this._simplify(_15,dojo.hitch(this,function(_17){if(this._drawingTool!==esri.layers.FeatureTemplate.TOOL_AUTO_COMPLETE_POLYGON){this._applyEdits([{layer:this._layer,adds:[this._createGraphic(_17,_16)]}]);}else{this._autoComplete(_17,dojo.hitch(this,function(_18){if(_18&&_18.length){this._applyEdits([{layer:this._layer,adds:dojo.map(_18,dojo.hitch(this,function(_19){return this._createGraphic(_19,_16);}))}]);}}));}}));},_updateCurrentFeature:function(_1a){var _1b=this._isModified();if(_1b){this._updateFeature(_1b,_1a);}else{if(_1a){_1a(false);}}},_updateFeature:function(_1c,_1d){var _1e=_1c.geometry;if(!_1e.rings){this._applyEdits([{layer:_1c.getLayer(),updates:[_1c]}],_1d);}else{this._simplify(_1e,dojo.hitch(this,function(_1f){this._applyEdits([{layer:_1c.getLayer(),updates:[dojo.mixin(_1c,{geometry:_1f})]}],_1d);}));}},_deleteFeature:function(_20,_21){var _22=[];if(!_20){var _23=this._settings.layers;_22=dojo.map(dojo.filter(_23,function(_24){return _24.getSelectedFeatures().length>0;}),"return {layer:item, deletes: item.getSelectedFeatures()}");if((!_22||!_22.length)&&this._currentGraphic){_22.push({layer:this._layer,deletes:[this._currentGraphic]});}}else{_22.push({layer:_20.getLayer(),deletes:[_20]});}this._applyEdits(_22,(_21));},_stopEditing:function(_25,_26,_27,_28){esri.hide(this.progressBar.domNode);this._undoRedoAdd();var _29;if(_25._isSelOnly===true){if(_26&&_26.length){this.templatePicker.clearSelection();var _2a=new esri.tasks.Query();_2a.objectIds=[_26[0].objectId];if(!this._settings.createOnlyLayer[_25.id]){this._selectFeatures([_25],_2a,dojo.hitch(this,"_onEditFeature"));}else{this._settings.map.graphics.remove(this._tempGraphic);}}}else{_29=this._selectionHelper.findMapService(this._settings.map,_25);if(_29){_29.refresh();}if(_26&&_26.length){this.templatePicker.clearSelection();if(!this._settings.createOnlyLayer[_25.id]){esri.dijit.editing.Util.LayerHelper.findFeatures(_26,_25,dojo.hitch(this,"_onEditFeature"));}else{this._settings.map.graphics.remove(this._tempGraphic);}}}if(_28&&_28.length){this._clearSelection(true);if(this._undoRedo){_29=this._selectionHelper.findMapService(_25,this._settings.map);if(_29){_29.refresh();}}}if(this._undoRedo&&_27&&_27.length){_29=this._selectionHelper.findMapService(_25,this._settings.map);if(_29){_29.refresh();}this.attributeInspector.refresh();this._undoRedo=false;}if(this.drawingToolbar){this.drawingToolbar._updateUI();}this._undoRedo=false;},_undoRedoAdd:function(){this._settings._isApplyEditsCall=false;if(!this._settings.undoManager){return;}if(this._activeTool==="CUT"||this._activeTool==="UNION"){return;}var _2b=(this._edits&&this._edits.length)?this._edits[0]:null;if(!_2b){return;}var _2c=_2b.adds||[];var _2d=_2b.updates||[];var _2e=_2b.deletes||[];var _2f={featureLayer:_2b.layer};if(_2c.length){this.undoManager.add(new esri.dijit.editing.Add(dojo.mixin(_2f,{addedGraphics:_2c})));}else{if(_2e.length){this.undoManager.add(new esri.dijit.editing.Delete(dojo.mixin(_2f,{deletedGraphics:_2e})));}else{if(_2d.length){this.undoManager.add(new esri.dijit.editing.Update(dojo.mixin(_2f,{preUpdatedGraphics:[this._preUpdates],postUpdatedGraphics:_2d})));}}}this._edits=null;this._preUpdates=null;},_activateDrawToolbar:function(_30){this._layer=_30.featureLayer;this._activeType=_30.type;this._activeTemplate=_30.template;this._drawingTool=this._activeTemplate?this._activeTemplate.drawingTool:null;this._drawTool=this._toDrawTool(this._drawingTool,_30.featureLayer);dojo.disconnect(this._dtConnect);if(this._settings.createOnlyLayer[_30.featureLayer.id]){this._dtConnect=dojo.connect(this._drawToolbar,"onDrawEnd",this,"_saveFeatureOnClient");}else{this._dtConnect=dojo.connect(this._drawToolbar,"onDrawEnd",this,"_createFeature");}this._editToolbar.deactivate();this._disableMapClickHandler();if(!this.drawingToolbar){this._drawToolbar.activate(this._drawTool);}else{this.drawingToolbar.activateEditing(this._drawTool,this._layer);}},_activateEditToolbar:function(_31,_32){var _33=_31.getLayer();var _34=_33?_33.geometryType:null;var _35=esri.toolbars.Edit.MOVE;if(_34!=="esriGeometryPoint"&&this._isNotesFeature(_31)===true){_35=_35|esri.toolbars.Edit.ROTATE|esri.toolbars.Edit.SCALE;this._editVertices=false;}else{if(_34!=="esriGeometryPoint"&&this._editVertices===true){_35=_35|esri.toolbars.Edit.ROTATE|esri.toolbars.Edit.SCALE;this._editVertices=false;}else{_35=_35|esri.toolbars.Edit.EDIT_VERTICES;this._editVertices=true;}}this._attributeChanged=this._isModified();this._preUpdates=new esri.Graphic(dojo.clone(_31.toJson()));var _36=_33.getEditCapabilities({feature:_31,userId:this._settings.userIds[_33.id]});var _37=dojo.filter(this._settings.layerInfos,function(_38){return _38.featureLayer["layerId"]===_33.layerId;})[0];if(_36.canUpdate&&!_37.disableGeometryUpdate&&_33.allowGeometryUpdates){this._editToolbar.activate(_35,_31);}if(!this._settings.map.infoWindow.isShowing){var _39=(_32&&_32.screenPoint)||this._findCenterPoint(_31);this._settings.map.infoWindow.show(_39,this._settings.map.getInfoWindowAnchor(_39));}},_createGraphic:function(_3a,_3b){var _3c=(this._activeType&&this._activeType.symbol)||this._layer.defaultSymbol;var _3d=new esri.Graphic(_3a,_3c,_3b);if(this._activeTemplate||_3b){_3d.attributes=_3b||dojo.mixin({},this._activeTemplate.prototype.attributes);}else{_3d.attributes=_3d.attributes||[];dojo.forEach(this._layer.fields,function(_3e){_3d.attributes[_3e.name]=null;},this);}return _3d;},_connectEvents:function(){var _3f=this._settings.layers;dojo.forEach(_3f,"this._connect(item, 'onEditsComplete', dojo.hitch(this, '_stopEditing', item))",this);dojo.forEach(_3f,"this._connect(item, 'onBeforeApplyEdits', dojo.hitch(this, function() { esri.show(this.progressBar.domNode); this._settings._isApplyEditsCall = true;  }))",this);this._connect(this._editToolbar,"onGraphicClick",dojo.hitch(this,"_activateEditToolbar"));this._connect(this._editToolbar,"onGraphicFirstMove",dojo.hitch(this,"_hideAttributeInspector"));this._connect(this._editToolbar,"onVertexFirstMove",dojo.hitch(this,"_hideAttributeInspector"));this._connect(this._editToolbar,"onScaleStart",dojo.hitch(this,"_hideAttributeInspector"));this._connect(this._editToolbar,"onRotateStart",dojo.hitch(this,"_hideAttributeInspector"));},_connect:function(_40,evt,_41){this._eConnects.push(dojo.connect(_40,evt,_41));},_createWidgets:function(){this._selectionHelper=new esri.dijit.editing.SelectionHelper(this._settings);this._createTemplatePicker();this._createAttributeInspector();this._createDrawingToolbar();this._createUndoRedoManager();},_createTemplatePicker:function(){if(!this._settings.templatePicker){var _42=dojo.filter(this._settings.layers,function(_43){return _43.getEditCapabilities().canCreate;});this.templatePicker=new esri.dijit.editing.TemplatePicker({"class":"esriTemplatePicker",featureLayers:_42,showTooltip:true,maxLabelLength:this._settings.typesCharacterLimit,columns:"auto",rows:"auto"},this.templatePickerDiv);this.templatePicker.startup();this._settings.templatePicker=this.templatePicker;}else{this.templatePicker=this._settings.templatePicker;esri.hide(this.templatePickerDiv);}this._templatePickerOnSelectionChangeEvent=dojo.connect(this.templatePicker,"onSelectionChange",dojo.hitch(this,"_onCreateFeature"));},_createAttributeInspector:function(_44){if(!this._settings.attributeInspector){this._customAttributeInspector=false;var map=this._settings.map;this.attributeInspector=new esri.dijit.AttributeInspector({layerInfos:this._settings.layerInfos,hideNavButtons:this._usePopup,datePackage:this._datePackage},dojo.create("div"));this.attributeInspector.startup();map.infoWindow.setContent(this.attributeInspector.domNode);map.infoWindow.setTitle(esri.bundle.widgets.attributeInspector.NLS_title);map.infoWindow.resize(350,375);dojo.query(".esriAttributeInspector .atiLayerName").style({display:"none"});}else{this._customAttributeInspector=true;this.attributeInspector=this._settings.attributeInspector;}this._connect(this.attributeInspector,"onDelete",dojo.hitch(this,"_deleteFeature"));this._connect(this.attributeInspector,"onNext",dojo.hitch(this,function(_45){this._updateCurrentFeature(dojo.hitch(this,function(){this._attributeChanged=false;this._onEditFeature(_45);}));}));if(this._usePopup){this._settings.map.infoWindow._setPagerCallbacks(this.attributeInspector,dojo.hitch(this.attributeInspector,"next"),dojo.hitch(this.attributeInspector,"previous"));}if(_44){this._connect(this.attributeInspector,"onAttributeChange",dojo.hitch(this,"_saveAttributesOnClient"));}else{this._connect(this.attributeInspector,"onAttributeChange",dojo.hitch(this,function(_46,_47,_48){this._preUpdates=new esri.Graphic(dojo.clone(_46.toJson()));this._currentGraphic.attributes[_47]=(typeof (_48)==="number"&&isNaN(_48))?null:_48;this._updateFeature(this._currentGraphic,null);this._attributeChanged=false;}));}},_createDrawingToolbar:function(){if(this._settings.toolbarVisible===true){this.drawingToolbar=new esri.dijit.editing.toolbars.Drawing({"class":"esriDrawingToolbar",drawToolbar:this._drawToolbar,editToolbar:this._editToolbar,settings:this._settings,onDelete:dojo.hitch(this,"_deleteFeature"),onApplyEdits:dojo.hitch(this,"_applyEdits"),onShowAttributeInspector:dojo.hitch(this,"_onEditFeature")},this.drawingToolbarDiv);}},_createUndoRedoManager:function(){if(!this._settings.enableUndoRedo&&!this._settings.undoManager){return;}this._settings.enableUndoRedo=true;this.undoManager=this._settings.undoManager;if(!this.undoManager){this.undoManager=this._settings.undoManager=new esri.UndoManager({maxOperations:this._settings.maxUndoRedoOperations});}this._connect(document,"onkeypress",dojo.hitch(this,function(evt){if(evt.metaKey||evt.ctrlKey){if(evt.charOrCode==="z"){this._undo();}if(evt.charOrCode==="y"){this._redo();}}}));},_enableMapClickHandler:function(){this._mapClickHandler=dojo.connect(this._settings.map,"onClick",dojo.hitch(this,function(evt){if(this._drawToolbar._geometryType){return;}if(this._activeTool==="SELECT"){this._activeTool="";return;}this._updateCurrentFeature(dojo.hitch(this,function(){this._reset();this._updateSelection(evt);}));}));},_disableMapClickHandler:function(){dojo.disconnect(this._mapClickHandler);},_onCreateFeature:function(){var _49=this.templatePicker.getSelected();if(_49){this._updateCurrentFeature(dojo.hitch(this,function(){if(this._currentGraphic){this._clearSelection(false);}this._reset();this._activateDrawToolbar(_49);}));}else{this._reset();dojo.disconnect(this._dtConnect);this._drawToolbar.deactivate();this._enableMapClickHandler();if(this.drawingToolbar){this.drawingToolbar.deactivate();}}},_onEditFeature:function(_4a,_4b){_4a=(dojo.isArray(_4a)?_4a[0]:_4a)||null;if(!_4a){return;}if(!this._customAttributeInspector){_4b=_4b||this._editClickPoint||this._findCenterPoint(_4a);var _4c=_4a.getLayer();this._settings.map.infoWindow.setTitle(_4c?_4c.name:esri.bundle.widgets.attributeInspector.NLS_title);if(this.drawingToolbar||!this._settings.map.infoWindow.isShowing){this._settings.map.infoWindow.show(_4b,this._settings.map.getInfoWindowAnchor(_4b));}this._editClickPoint=null;}if(_4a===this._currentGraphic){return;}this._editVertices=true;this._layer=_4a.getLayer();this._currentGraphic=_4a;if(_4a.getDojoShape()){_4a.getDojoShape().moveToFront();}this._activateEditToolbar(_4a);},_applyEdits:function(_4d,_4e){_4d=_4d||[];if(_4d.length<=0){return;}this._edits=_4d;var _4f=dojo.map(_4d,function(_50){return _50.layer.applyEdits(_50.adds,_50.updates,_50.deletes);});this._deferredsList=new dojo.DeferredList(_4f).addCallback(dojo.hitch(this,function(){esri.hide(this.progressBar.domNode);if(_4e){_4e();}var map=this._settings.map;if(map&&map.infoWindow.reposition&&map.infoWindow.isShowing){map.infoWindow.reposition();}}));},_undo:function(){if(this._settings.undoManager&&!this._settings._isApplyEditsCall){this._editToolbar.deactivate();this._undoRedo=true;this._settings.undoManager.undo();}},_redo:function(){if(this._settings.undoManager&&!this._settings._isApplyEditsCall){this._editToolbar.deactivate();this._undoRedo=true;this._settings.undoManager.redo();}},_simplify:function(_51,_52){if(esri.geometry.polygonSelfIntersecting(_51)){this._settings.geometryService.simplify([_51],function(_53){var _54=(_53&&_53.length)?_53[0]:_54;if(_52){_52(_54);}});}else{if(_52){_52(_51);}}},_autoComplete:function(_55,_56){var _57=this._getLayers("esriGeometryPolygon");var _58=new esri.tasks.Query();_58.geometry=_55;_58.returnGeometry=true;this._selectFeatures(_57,_58,dojo.hitch(this,function(_59){if(!_59||_59.length<=0){if(_56){_56([_55]);}}else{this._settings.geometryService.autoComplete(esri.getGeometries(_59),this._toPolylines([_58.geometry]),function(_5a){if(_56){_56(_5a);}});}}));},_getLayers:function(_5b){var _5c=this._settings.layers;return dojo.filter(_5c,function(_5d){return _5d.geometryType===_5b;});},_selectFeatures:function(_5e,_5f,_60,_61){this._selectionHelper.selectFeatures(_5e,_5f,_61||esri.layers.FeatureLayer.SELECTION_NEW,_60);},_updateSelection:function(evt){var _62=evt.mapPoint;var _63=evt.graphic;this._selectionHelper.selectFeaturesByGeometry(this._settings.layers,_62,esri.layers.FeatureLayer.SELECTION_NEW,dojo.hitch(this,function(_64){var _65=dojo.some(_64,dojo.hitch(this,function(_66){return _66==_63;}));if(_63&&!_65){var _67=_63.getLayer();if(this._isValidLayer(_67)){var _68=new esri.tasks.Query();_68.objectIds=[_63.attributes[_67.objectIdField]];this._selectionHelper.selectFeatures([_67],_68,esri.layers.FeatureLayer.SELECTION_ADD,dojo.hitch(this,function(_69){this._updatePopupButtons(_69);this._onEditFeature(_69,_62);}));}else{this._clearSelection();}}else{if(_64&&_64.length){this._updatePopupButtons(_64);this._onEditFeature(_64,_62);}else{this._clearSelection();}}}));},_updatePopupButtons:function(_6a){if(!this._usePopup||!_6a){return;}var _6b=_6a.length;var _6c=[this._settings.map.infoWindow._prevFeatureButton,this._settings.map.infoWindow._nextFeatureButton];dojo.forEach(_6c,dojo.hitch(this,function(_6d){(_6b>1)?dojo.removeClass(_6d,"hidden"):dojo.addClass(_6d,"hidden");}));},_clearSelection:function(_6e){this._selectionHelper.clearSelection(_6e||false);this._reset();},_findCenterPoint:function(_6f){var _70=_6f.geometry||_6f;var _71;switch(_70.type){case "point":_71=_70;break;case "polyline":var _72=_70.paths[0].length;_71=_70.getPoint(0,Math.ceil(_72/2));break;case "polygon":var _73=_70.rings.length-1;var _74=_70.rings[_73].length-1;_71=_70.getPoint(_73,_74);break;}return this._settings.map.toScreen(_71);},_hideAttributeInspector:function(){if(!this._customAttributeInspector&&this._settings.map.infoWindow){this._settings.map.infoWindow.hide();}},_toPolylines:function(_75){var _76=dojo.map(_75,function(_77){var _78=new esri.geometry.Polyline(_77.spatialReference);dojo.forEach(_77.rings,function(_79){_78.addPath(_79);});return _78;});return _76;},_isNotesFeature:function(_7a){var _7b=_7a.getLayer();var _7c=_7b?_7b.types||null:null;if(!_7c){return false;}var _7d=_7a.attributes[_7b.typeIdField];var _7e;dojo.some(_7c,function(_7f){if(_7f.id===_7d){_7e=_7f.templates;return true;}return false;});if(!_7e){return false;}var _80=_7e[0]||null;if(!_80){return false;}var _81=this._isShapeTool(_80.drawingTool)||null;return _81?true:false;},_isValidLayer:function(_82){var _83=this._settings.layerInfos;for(var i=0;i<_83.length;i++){var _84=_83[i];if(_82.id==_84.layerId){return true;}}return false;},_isShapeTool:function(_85){switch(_85){case esri.layers.FeatureTemplate.TOOL_ARROW:return esri.toolbars.Draw.ARROW;case esri.layers.FeatureTemplate.TOOL_LEFT_ARROW:return esri.toolbars.Draw.LEFT_ARROW;case esri.layers.FeatureTemplate.TOOL_RIGHT_ARROW:return esri.toolbars.Draw.RIGHT_ARROW;case esri.layers.FeatureTemplate.TOOL_UP_ARROW:return esri.toolbars.Draw.UP_ARROW;case esri.layers.FeatureTemplate.TOOL_DOWN_ARROW:return esri.toolbars.Draw.DOWN_ARROW;case esri.layers.FeatureTemplate.TOOL_CIRCLE:return esri.toolbars.Draw.CIRCLE;case esri.layers.FeatureTemplate.TOOL_ELLIPSE:return esri.toolbars.Draw.ELLIPSE;case esri.layers.FeatureTemplate.TOOL_TRIANGLE:return esri.toolbars.Draw.TRIANGLE;case esri.layers.FeatureTemplate.TOOL_RECTANGLE:return esri.toolbars.Draw.RECTANGLE;default:return null;}},_toDrawTool:function(_86,_87){var _88=_87.geometryType;switch(_86){case esri.layers.FeatureTemplate.TOOL_POINT:return esri.toolbars.Draw.POINT;case esri.layers.FeatureTemplate.TOOL_ARROW:return esri.toolbars.Draw.ARROW;case esri.layers.FeatureTemplate.TOOL_LEFT_ARROW:return esri.toolbars.Draw.LEFT_ARROW;case esri.layers.FeatureTemplate.TOOL_RIGHT_ARROW:return esri.toolbars.Draw.RIGHT_ARROW;case esri.layers.FeatureTemplate.TOOL_UP_ARROW:return esri.toolbars.Draw.UP_ARROW;case esri.layers.FeatureTemplate.TOOL_DOWN_ARROW:return esri.toolbars.Draw.DOWN_ARROW;case esri.layers.FeatureTemplate.TOOL_CIRCLE:return esri.toolbars.Draw.CIRCLE;case esri.layers.FeatureTemplate.TOOL_ELLIPSE:return esri.toolbars.Draw.ELLIPSE;case esri.layers.FeatureTemplate.TOOL_TRIANGLE:return esri.toolbars.Draw.TRIANGLE;case esri.layers.FeatureTemplate.TOOL_RECTANGLE:return esri.toolbars.Draw.RECTANGLE;case esri.layers.FeatureTemplate.TOOL_LINE:return esri.toolbars.Draw.POLYLINE;case esri.layers.FeatureTemplate.TOOL_POLYGON:return esri.toolbars.Draw.POLYGON;case esri.layers.FeatureTemplate.TOOL_FREEHAND:if(_88==="esriGeometryPolyline"){return esri.toolbars.Draw.FREEHAND_POLYLINE;}else{return esri.toolbars.Draw.FREEHAND_POLYGON;}break;default:var _89=esri.toolbars.Draw.POINT;if(_88==="esriGeometryPolyline"){_89=esri.toolbars.Draw.POLYLINE;if(this._settings.createOptions.polylineDrawTools[0]===esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYLINE){_89=esri.toolbars.Draw.FREEHAND_POLYLINE;}}else{if(_88==="esriGeometryPolygon"){_89=esri.toolbars.Draw.POLYGON;if(this._settings.createOptions.polygonDrawTools[0]===esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON){_89=esri.toolbars.Draw.FREEHAND_POLYGON;}}}return _89;}},_isModified:function(){var _8a=this._editToolbar.getCurrentState();return ((_8a.isModified||this._attributeChanged)&&_8a.graphic)?_8a.graphic:null;}});dojo.mixin(esri.dijit.editing.Editor,{CREATE_TOOL_POLYLINE:"polyline",CREATE_TOOL_FREEHAND_POLYLINE:"freehandpolyline",CREATE_TOOL_POLYGON:"polygon",CREATE_TOOL_FREEHAND_POLYGON:"freehandpolygon",CREATE_TOOL_AUTOCOMPLETE:"autocomplete",CREATE_TOOL_RECTANGLE:"rectangle",CREATE_TOOL_TRIANGLE:"triangle",CREATE_TOOL_CIRCLE:"circle",CREATE_TOOL_ELLIPSE:"ellipse",CREATE_TOOL_ARROW:"arrow",CREATE_TOOL_UP_ARROW:"uparrow",CREATE_TOOL_DOWN_ARROW:"downarrow",CREATE_TOOL_RIGHT_ARROW:"rightarrow",CREATE_TOOL_LEFT_ARROW:"leftarrow"});}