Interactive interface for browsing global, full-resolution satellite imagery
Selection links now update if changed while open
Mike McGanne9c9c20d66cd
diff --git a/src/js/Worldview/DataDownload/SelectionListPanel.js b/src/js/Worldview/DataDownload/SelectionListPanel.jsindex 17c281373..69885a651 100644--- a/src/js/Worldview/DataDownload/SelectionListPanel.js+++ b/src/js/Worldview/DataDownload/SelectionListPanel.js@@ -12,6 +12,8 @@ Worldview.namespace("DataDownload");Worldview.DataDownload.SelectionListPanel = function(config, model) {+ var log = Logging.getLogger("Worldview.DataDownload");+var echo = Worldview.DataDownload.ECHO;var NOTICE =@@ -26,39 +28,46 @@ Worldview.DataDownload.SelectionListPanel = function(config, model) {"</p>" +"</div>";- var panel;+ var panel = null;var selection;var self = {};self.show = function() {- if ( panel ) {- return;- }- panel = new YAHOO.widget.Panel("DataDownload_SelectionListPanel", {- width: "600px",- height: "400px",- zIndex: 1020,- visible: false- });- panel.setHeader("Download Links");selection = reformatSelection();+ var newPanel = false;+ if ( !panel ) {+ newPanel = true;+ panel = new YAHOO.widget.Panel("DataDownload_SelectionListPanel", {+ width: "600px",+ height: "400px",+ zIndex: 1020,+ visible: false+ });+ panel.setHeader("Download Links");+ }panel.setBody(bodyText(selection));- panel.render(document.body);- panel.show();- panel.center();- panel.hideEvent.subscribe(function() {- setTimeout(function() { panel.destroy(); }, 25);- });+ if ( newPanel ) {+ panel.render(document.body);+ panel.show();+ panel.center();+ panel.hideEvent.subscribe(function() {+ setTimeout(function() { panel.destroy(); panel = null; }, 25);+ });- $("#DataDownload_SelectionListPanel a.wget").click(function() {- Worldview.DataDownload.LinkPage.show(selection);- });+ $("#DataDownload_SelectionListPanel a.wget").click(function() {+ Worldview.DataDownload.LinkPage.show(selection);+ });+ }};self.hide = function() {panel.hide();};+ self.visible = function() {+ return panel !== null;+ };+var reformatSelection = function() {var selection = {};@@ -125,7 +134,7 @@ Worldview.DataDownload.SelectionListPanel = function(config, model) {});});- console.log(selection);+ log.debug(selection);return selection;};diff --git a/src/js/Worldview/Widget/DataDownload.js b/src/js/Worldview/Widget/DataDownload.jsindex cfd1ebfaf..769c69664 100644--- a/src/js/Worldview/Widget/DataDownload.js+++ b/src/js/Worldview/Widget/DataDownload.js@@ -50,8 +50,8 @@ Worldview.Widget.DataDownload = function(config, spec) {.on("queryCancel", onQueryCancel).on("queryError", onQueryError).on("queryTimeout", onQueryTimeout)- .on("granuleSelect", updateButton)- .on("granuleUnselect", updateButton);+ .on("granuleSelect", updateSelection)+ .on("granuleUnselect", updateSelection);REGISTRY.register(self.containerId, self);REGISTRY.markComponentReady(self.containerId);@@ -115,7 +115,7 @@ Worldview.Widget.DataDownload = function(config, spec) {mapController =Worldview.DataDownload.MapController(model, spec.maps, config);}- updateButton();+ updateSelection();};var onDeactivate = function() {@@ -160,7 +160,7 @@ Worldview.Widget.DataDownload = function(config, spec) {);};- var updateButton = function() {+ var updateSelection = function() {var selected = Worldview.size(model.selectedGranules);if ( selected > 0 ) {$("#DataDownload_Button input[type='button']").button("enable");@@ -168,12 +168,18 @@ Worldview.Widget.DataDownload = function(config, spec) {$("#DataDownload_Button input[type='button']").button("disable");}$("#DataDownload_Button .ui-btn .ui-btn-text")- .html("Download (" + selected + ")");+ .html("Download (" + selected + ")");++ if ( selectionListPanel && selectionListPanel.visible() ) {+ selectionListPanel.show();+ }};var showSelectionList = function() {- selectionListPanel =- Worldview.DataDownload.SelectionListPanel(config, model);+ if ( !selectionListPanel ) {+ selectionListPanel =+ Worldview.DataDownload.SelectionListPanel(config, model);+ }selectionListPanel.show();};