Interactive interface for browsing global, full-resolution satellite imagery
Now with download sizes and counts
Mike McGann26aaaa5c7d59
diff --git a/src/js/Worldview/DataDownload/Model.js b/src/js/Worldview/DataDownload/Model.jsindex 1578dbc98..38878c259 100644--- a/src/js/Worldview/DataDownload/Model.js+++ b/src/js/Worldview/DataDownload/Model.js@@ -227,6 +227,34 @@ Worldview.DataDownload.Model = function(config) {self.events.trigger(self.EVENT_GRANULE_UNSELECT, granule);};+ self.getSelectionSize = function() {+ var totalSize = 0;+ var sizeValid = true;+ $.each(self.selectedGranules, function(index, granule) {+ if ( sizeValid && granule.granule_size ) {+ totalSize += parseFloat(granule.granule_size);+ } else {+ sizeValid = false;+ }+ });+ if ( sizeValid ) {+ return totalSize;+ }+ };++ self.getSelectionCounts = function() {+ counts = {};+ $.each(self.layers, function(index, layer) {+ if ( layer.product ) {+ counts[layer.product] = 0;+ }+ });+ $.each(self.selectedGranules, function(index, granule) {+ counts[granule.product] ++;+ });+ return counts;+ };+self.setPreference = function(preference) {self.prefer = preference;query();diff --git a/src/js/Worldview/Widget/DataDownload.js b/src/js/Worldview/Widget/DataDownload.jsindex c8c7783a4..0f3c3eb1f 100644--- a/src/js/Worldview/Widget/DataDownload.js+++ b/src/js/Worldview/Widget/DataDownload.js@@ -99,7 +99,7 @@ Worldview.Widget.DataDownload = function(config, spec) {filter: true,search: false,action: {- text: "Download (~0GB)",+ text: "Download",callback: function() { showDownloadList(); }},selectableCategories: {@@ -182,12 +182,26 @@ Worldview.Widget.DataDownload = function(config, spec) {var selected = Worldview.size(model.selectedGranules);if ( selected > 0 ) {list.setButtonEnabled(true);+ var totalSize = model.getSelectionSize();+ if ( totalSize ) {+ var formattedSize = Math.round(totalSize * 100) / 100;+ list.setActionButtonText("Download (" + formattedSize + " MB)");+ } else {+ list.setActionButtonText("Download");+ }} else {list.setButtonEnabled(false);- }+ list.setActionButtonText("Download");+ }++ var counts = model.getSelectionCounts();+ $.each(counts, function(productId, count) {+ list.setCategoryDynamicText(productId, "" + count + " selected");+ });if ( downloadListPanel && downloadListPanel.visible() ) {downloadListPanel.show();}+};var showDownloadList = function() {diff --git a/src/js/list.js b/src/js/list.jsindex 570f154d4..268981a1c 100644--- a/src/js/list.js+++ b/src/js/list.js@@ -317,6 +317,14 @@ SOTE.widget.List.prototype.setButtonEnabled = function(enabled) {}};+SOTE.widget.List.prototype.setActionButtonText = function(text) {+ $("#" + this.id + "action").attr("value", text);+};++SOTE.widget.List.prototype.setCategoryDynamicText = function(id, text) {+ $("#" + id + "dynamictext").html(text);+};+SOTE.widget.List.act = function(e){var self = e.data.self;self.action.callback(self.args);