text: /*! ramp-pcar 12-11-2014 15:03:54 : v. 3.0.1 
   * 
   * RAMP GIS viewer - Canada Goose; Sample of an implementation of RAMP 
   **/
  define(["dojo/_base/declare","require","dojo/dom-construct","dojo/io-query","dojo/_base/lang","dojo/dom","dojo/_base/array","dojo/topic","dijit/form/TextBox","dijit/TitlePane","esri/geometry/Extent","ramp/globalStorage","ramp/map","ramp/eventManager","ramp/ramp","utils/url","utils/util","utils/dictionary","utils/array","utils/popupManager"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){"use strict";function u(a,b){V[a]=null===b?null:d.objectToQuery(b)}function v(a,b){W[a]=b}function w(a){var b=String.format(S,i18n.t("bookmarkLink.emailUrlSubject"),i18n.t("bookmarkLink.emailUrlBody"),encodeURIComponent(a));C.val(a),J.attr("href",b)}function x(){var a=L;r.forEachEntry(V,function(b,c){c&&(a+="&"+c)}),r.isEmpty(W)||(a+="&"),r.forEachEntry(W,function(b,c){a+="#"+c}),U?C.is(":visible")&&(K.show(),jQuery.urlShortener({longUrl:a,success:function(a){w(a),K.hide()},error:function(a){K.hide()}})):w(a)}function y(a){var b;U=a===!0?!0:a===!1?!1:!U,b=i18n.t(U?"bookmarkLink.longLink":"bookmarkLink.shortLink"),I.text(b),x()}function z(a){var c,e=new p(b.toUrl(document.location));A=l.config,L=e.uri,B=d.queryToObject(e.query),-1===L.indexOf(a)&&(L+=a),L+="?lang="+A.lang,jQuery.urlShortener.settings.apiKey="AIzaSyB52ByjsXrOYlXxc2Q9GVpClLDwt0Lw6pc",B.panelVisible&&(c={visible:q.parseBool(B.panelVisible)},u(O,c),A.ui.sidePanelOpened=c.visible),B.fullscreen&&(c={fullscreen:q.parseBool(B.fullscreen)},u(N,c),A.ui.fullscreen=c.fullscreen),B.xmin&&(c={xmin:parseFloat(B.xmin.replace(/,/g,"")),ymin:parseFloat(B.ymin.replace(/,/g,"")),xmax:parseFloat(B.xmax.replace(/,/g,"")),ymax:parseFloat(B.ymax.replace(/,/g,"")),sr:B.sr},u(M,c),A.extents.defaultExtent=c,A.spatialReference=JSON.parse(B.sr)),B.baseMap&&(c={baseMap:B.baseMap},u(Q,c),g.forEach(A.basemaps,function(a){a.showOnInit=a.id===c.baseMap})),B.layerTransparency&&(u(n.FilterManager.LAYER_TRANSPARENCY_CHANGED,{layerTransparency:B.layerTransparency}),r.forEachEntry(JSON.parse(B.layerTransparency),function(a,b){var c=s.find(A.featureLayers.concat(A.wmsLayers),function(b){return b.id===a});c.settings.opacity.default=b})),B.selectedTab&&u(P,{index:B.selectedTab});var f;B.visibleLayers&&(f=B.visibleLayers.split("+"),f.forEach(function(a){var b=o.getLayerConfigWithId(a);null!==b&&(b.layerVisible=!0,X[a]=!0)}),u(R.FILTER.VISIBLE_LAYERS,{visibleLayers:B.visibleLayers})),B.hiddenLayers&&(f=B.hiddenLayers.split("+"),f.forEach(function(a){var b=o.getLayerConfigWithId(a);null!==b&&(b.layerVisible=!1,X[a]=!1)}),u(R.FILTER.HIDDEN_LAYERS,{hiddenLayers:B.hiddenLayers})),B.visibleBoxes&&(f=B.visibleBoxes.split("+"),f.forEach(function(a){var b=o.getLayerConfigWithId(a);null!==b&&(b.boundingBoxVisible=!0,Y[a]=!0)}),u(R.FILTER.VISIBLE_BOXES,{visibleBoxes:B.visibleBoxes})),B.hiddenBoxes&&(f=B.hiddenBoxes.split("+"),f.forEach(function(a){var b=o.getLayerConfigWithId(a);null!==b&&(b.boundingBoxVisible=!1,Y[a]=!1)}),u(R.FILTER.HIDDEN_BOXES,{hiddenBoxes:B.hiddenBoxes}))}var A,B,C,D,E,F,G,H,I,J,K,L,M="extentChange",N="fullscreen",O="panelChange",P="selectedTab",Q="basemapChange",R={FILTER:{VISIBLE_LAYERS:"visibleLayers",HIDDEN_LAYERS:"hiddenLayers",VISIBLE_BOXES:"visibleBoxes",HIDDEN_BOXES:"hiddenBoxes"}},S="mailto:?subject={0}&body={1}%0D%0A%0D%0A{2}",T="button-pressed",U=!1,V={},W={},X={},Y={},Z={},_={init:function(){K=$("#getlink-section .loadingAnimation"),J=$(".getlink-email-button"),E=$("#getlink-toggle"),F=$("#getlink-section-container"),G=$("#getlink-section"),C=$("#getlink-input").on("focus",function(){var a=$(this).one("mouseup.mouseupSelect",function(){return a.select(),!1}).one("mousedown",function(){a.off("mouseup.mouseupSelect")}).select()}),H=$(".getlink-shorten-button").on("click",y),I=H.find("span.on-right"),D=t.registerPopup(E,"click",function(a){h.publish(n.BookmarkLink.GETLINK_PANEL_CHANGED,{visible:!0}),h.publish(n.GUI.TOOLBAR_SECTION_OPEN,{id:"get-link-section"}),q.subscribeOnce(n.GUI.TOOLBAR_SECTION_OPEN,e.hitch(this,function(){this.isOpen()&&this.close()})),F.slideDown("fast",function(){a.resolve()})},{activeClass:T,target:F,closeHandler:function(a){h.publish(n.BookmarkLink.GETLINK_PANEL_CHANGED,{visible:!1}),h.publish(n.GUI.TOOLBAR_SECTION_CLOSE,{id:"get-link-section"}),F.slideUp("fast",function(){y(!1),a.resolve()})},resetFocusOnClose:!0})}};return{createUI:function(){_.init()},updateConfig:z,subscribeAndUpdate:function(){h.subscribe(n.Map.EXTENT_CHANGE,function(a){u(M,{xmin:a.extent.xmin,ymin:a.extent.ymin,xmax:a.extent.xmax,ymax:a.extent.ymax,sr:JSON.stringify(a.extent.spatialReference)}),x()}),h.subscribe(n.GUI.FULLSCREEN_CHANGE,function(a){u(N,{fullscreen:a.visible}),x()}),h.subscribe(n.GUI.TAB_SELECTED,function(a){v(P,a.id.replace("-link","")),x()}),h.subscribe(n.GUI.PANEL_CHANGE,function(a){u(O,{panelVisible:a.visible}),x()}),h.subscribe(n.BasemapSelector.BASEMAP_CHANGED,function(a){u(Q,{baseMap:a.id}),x()}),h.subscribe(n.FilterManager.LAYER_VISIBILITY_TOGGLED,function(a){var b=a.id;X[b]=a.state;var c=r.filter(X,function(a,b){return b&&!o.getLayerConfigWithId(a).layerVisible}),d=r.filter(X,function(a,b){return!b&&o.getLayerConfigWithId(a).layerVisible});u(R.FILTER.HIDDEN_LAYERS,r.isEmpty(d)?null:{hiddenLayers:Object.keys(d).join("+")}),u(R.FILTER.VISIBLE_LAYERS,r.isEmpty(c)?null:{visibleLayers:Object.keys(c).join("+")}),x()}),h.subscribe(n.FilterManager.BOX_VISIBILITY_TOGGLED,function(a){var b=a.id;Y[b]=a.state;var c=r.filter(Y,function(a,b){return b&&!o.getLayerConfigWithId(a).boundingBoxVisible}),d=r.filter(Y,function(a,b){return!b&&o.getLayerConfigWithId(a).boundingBoxVisible});u(R.FILTER.HIDDEN_BOXES,r.isEmpty(d)?null:{hiddenBoxes:Object.keys(d).join("+")}),u(R.FILTER.VISIBLE_BOXES,r.isEmpty(c)?null:{visibleBoxes:Object.keys(c).join("+")}),x()}),h.subscribe(n.FilterManager.LAYER_TRANSPARENCY_CHANGED,function(a){u(n.FilterManager.LAYER_TRANSPARENCY_CHANGED,a),Z[a.layerId]=a.value,u(n.FilterManager.LAYER_TRANSPARENCY_CHANGED,{layerTransparency:JSON.stringify(Z)}),x()}),x()}}});