// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/ReportPlayer/playerSupports/_ZoomSupport","dojo/_base/declare dojo/aspect dojo/on dojo/dom-class dojo/when ../PlayerSelect ../PlayerZoomBehaviors esri/dijit/geoenrichment/utils/DomUtil dojo/i18n!../../../../nls/jsapi".split(" "),function(h,k,p,q,l,m,e,f,d){function n(a){var b=[];g.forEach(function(c){"number"===typeof c.value&&b.push({value:c.value,score:a<c.value?a/c.value:c.value/a})});b.sort(function(a,b){return b.score-a.score});return b[0].value}d=d.geoenrichment.dijit.ReportPlayer.ReportPlayer;
var g=[{value:"fitPage",label:d.fitPage},{value:"fitPageWidth",label:d.fitPageWidth},{value:150,label:"150%"},{value:100,label:"100%"},{value:80,label:"80%"},{value:75,label:"75%"},{value:60,label:"60%"},{value:50,label:"50%"}];return h(null,{_isFitPageFlag:!1,zoomSelect:null,postCreate:function(){this.inherited(arguments);this._initZoomControls();f.hide(this.zoomSelectDiv)},_initZoomControls:function(){var a=this;this.zoomSelect=(new (this._getZoomSelectClass())({onChange:function(){var b=a.zoomSelect.get("value");
"fitPage"===b?a.getCurrentReportContainer().zoomToFitPage():"fitPageWidth"===b?a.getCurrentReportContainer().zoomToFitPageWidth():a.getCurrentReportContainer().setZoomPercent(b)}})).placeAt(this.zoomSelectDiv);this.own(this.zoomSelect);this.zoomSelect.set("options",g);this.zoomSelect.set("value",100)},_getZoomSelectClass:function(){return m},setBestZoom:function(){this._callZoomMethod("setBestZoom")},zoomToFitPage:function(){this._callZoomMethod("zoomToFitPage")},zoomToFitPageWidth:function(){this._callZoomMethod("zoomToFitPageWidth")},
resetZoom:function(){this._callZoomMethod("resetZoom")},_applyDefaultZoomBehavior:function(a){a&&this.defaultZoomBehavior===e.FIT_PAGE?this.zoomToFitPage():a&&this.defaultZoomBehavior===e.FIT_PAGE_WIDTH?this.zoomToFitPage():this.resetZoom()},_callZoomMethod:function(a){if(!this.isSlidesView){var b=this.getCurrentReportContainer();b&&b[a]&&b[a]()}},_reportContainerZoomChangedHandle:null,resize:function(){var a=this;return l(this.inherited(arguments),function(){var b=a.getCurrentReportContainer();a._connectZoomToCurrentContainer();
b=!a.isSlidesView&&b&&!!b.zoomIn;f[b?"show":"hide"](a.zoomSelectDiv);a._applyDefaultZoomBehavior(b)})},_connectZoomToCurrentContainer:function(){var a=this.getCurrentReportContainer();this._reportContainerZoomChangedHandle&&this._reportContainerZoomChangedHandle.remove();this._reportContainerZoomChangedHandle=a&&k.after(a,"onZoomChanged",this._onZoomChanged.bind(this))},_onZoomChanged:function(){var a=this.getCurrentReportContainer();a&&a.getZoomInfo&&(a=this.getCurrentReportContainer().getZoomInfo(),
a=a.isFitPageScale?"fitPage":a.isFitPageWidthScale?"fitPageWidth":n(100*a.scale),a!==this.zoomSelect.get("value")&&this.zoomSelect.set("value",a))}})});