Interactive interface for browsing global, full-resolution satellite imagery
Removed jQuery Mobile widgets in data selection list, panel hidden when going to data download
Mike McGann2a22b76986dd
diff --git a/src/css/dataDownload.css b/src/css/dataDownload.cssindex 1ecfe857e..8570bcbe2 100644--- a/src/css/dataDownload.css+++ b/src/css/dataDownload.css@@ -106,3 +106,12 @@padding: 10px;color: #FFFBE7;}++#DataDownload_GranuleList .button {+ width: 16px;+ height: 16px;+}++#DataDownload_GranuleList td {+ padding: 3px;+}\ No newline at end of filediff --git a/src/index.html b/src/index.htmlindex 304c1039b..28fcda4d6 100644--- a/src/index.html+++ b/src/index.html@@ -158,6 +158,8 @@<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Map/GraticuleLayer.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/Map/TWMSLayer.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/Map/HoverControl.js"></script>++ <!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/ECHO.js"></script><!-- link.dev --> <script type="text/javascript" src="js/Worldview/DataDownload/ECHO/Client.js"></script>diff --git a/src/js/Worldview/DataDownload.js b/src/js/Worldview/DataDownload.jsnew file mode 100644index 000000000..a58e2c58a--- /dev/null+++ b/src/js/Worldview/DataDownload.js@@ -0,0 +1,23 @@+/*+ * NASA Worldview+ *+ * This code was originally developed at NASA/Goddard Space Flight Center for+ * the Earth Science Data and Information System (ESDIS) project.+ *+ * Copyright (C) 2013 United States Government as represented by the+ * Administrator of the National Aeronautics and Space Administration.+ * All Rights Reserved.+ */+Worldview.namespace("DataDownload");++Worldview.DataDownload = (function() {++ var ns = {};++ ns.IMAGE_SELECT = "images/data-download-plus-button-orange.svg";+ ns.IMAGE_UNSELECT = "images/data-download-minus-button-red.svg";++ return ns;++}());+diff --git a/src/js/Worldview/DataDownload/DownloadListPanel.js b/src/js/Worldview/DataDownload/DownloadListPanel.jsindex 54b5b1087..f5c9ee978 100644--- a/src/js/Worldview/DataDownload/DownloadListPanel.js+++ b/src/js/Worldview/DataDownload/DownloadListPanel.js@@ -31,6 +31,7 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {var panel = null;var selection;var self = {};+ self.events = Worldview.Events();self.show = function() {selection = reformatSelection();@@ -51,23 +52,30 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {panel.show();panel.center();panel.hideEvent.subscribe(function() {- setTimeout(function() { panel.destroy(); panel = null; }, 25);+ setTimeout(dispose, 25);});- $("#DataDownload_DownloadListPanel a.wget").click(function() {- Worldview.DataDownload.WgetPage.show(selection);- });+ $("#DataDownload_DownloadListPanel a.wget").click(showWgetPage);}};self.hide = function() {- panel.hide();+ if ( panel ) {+ panel.hide();+ }};self.visible = function() {return panel !== null;};+ var dispose = function() {+ self.events.trigger("close");+ panel.destroy();+ panel = null;+ $("#DataDownload_DownloadListPanel a.wget").off("click", showWgetPage);+ };+var reformatSelection = function() {var selection = {};@@ -236,6 +244,10 @@ Worldview.DataDownload.DownloadListPanel = function(config, model) {return text;};+ var showWgetPage = function() {+ Worldview.DataDownload.WgetPage.show(selection);+ };+return self;};diff --git a/src/js/Worldview/DataDownload/Layers/Button.js b/src/js/Worldview/DataDownload/Layers/Button.jsindex e6bc0d2c3..edd8e8a47 100644--- a/src/js/Worldview/DataDownload/Layers/Button.js+++ b/src/js/Worldview/DataDownload/Layers/Button.js@@ -14,8 +14,8 @@ Worldview.DataDownload.Layers.Button = function(model, maps, config) {var LAYER_NAME = "DataDownload_Button";- var IMAGE_SELECT = "images/data-download-plus-button-orange.svg";- var IMAGE_UNSELECT = "images/data-download-minus-button-red.svg";+ var IMAGE_SELECT = Worldview.DataDownload.IMAGE_SELECT;+ var IMAGE_UNSELECT = Worldview.DataDownload.IMAGE_UNSELECT;var STYLE = {"default": {diff --git a/src/js/Worldview/DataDownload/MapController.js b/src/js/Worldview/DataDownload/MapController.jsindex dfa51434c..36a3e4a54 100644--- a/src/js/Worldview/DataDownload/MapController.js+++ b/src/js/Worldview/DataDownload/MapController.js@@ -17,7 +17,6 @@ Worldview.DataDownload.MapController = function(model, maps, config) {var self = {};var results = [];- var selectionListPanel = null;var selectionLayers = ns.Layers.Selection(model, maps, config);var swathLayers = ns.Layers.Swath(model, maps, config);@@ -54,17 +53,7 @@ Worldview.DataDownload.MapController = function(model, maps, config) {swathLayers.update(results);gridLayers.update(results);buttonLayers.update(results);-- if ( newResults.meta.showList ) {- selectionListPanel =- Worldview.DataDownload.SelectionListPanel(model, results);- selectionListPanel.show();- } else {- if ( selectionListPanel ) {- selectionListPanel.hide();- }- }-+// TODO: Remove if not used//maskLayers.update(results);};@@ -79,9 +68,6 @@ Worldview.DataDownload.MapController = function(model, maps, config) {gridLayers.dispose();hoverLayers.dispose();buttonLayers.dispose();- if ( selectionListPanel ) {- selectionListPanel.hide();- }// TODO: Remove if not used//maskLayers.dispose();};@@ -92,9 +78,6 @@ Worldview.DataDownload.MapController = function(model, maps, config) {gridLayers.clear();hoverLayers.clear();buttonLayers.clear();- if ( selectionListPanel ) {- selectionListPanel.hide();- }// TODO: Remove if not used//maskLayers.clear();};diff --git a/src/js/Worldview/DataDownload/Model.js b/src/js/Worldview/DataDownload/Model.jsindex d7a7bf097..e0b8f0dde 100644--- a/src/js/Worldview/DataDownload/Model.js+++ b/src/js/Worldview/DataDownload/Model.js@@ -227,6 +227,16 @@ Worldview.DataDownload.Model = function(config) {self.events.trigger(self.EVENT_GRANULE_UNSELECT, granule);};+ self.isSelected = function(granule) {+ var selected = false;+ $.each(self.selectedGranules, function(index, selection) {+ if ( granule.id === selection.id ) {+ selected = true;+ }+ });+ return selected;+ };+self.getSelectionSize = function() {var totalSize = 0;var sizeValid = true;diff --git a/src/js/Worldview/DataDownload/SelectionListPanel.js b/src/js/Worldview/DataDownload/SelectionListPanel.jsindex ee45cadf8..ebdd6a479 100644--- a/src/js/Worldview/DataDownload/SelectionListPanel.js+++ b/src/js/Worldview/DataDownload/SelectionListPanel.js@@ -13,21 +13,18 @@ Worldview.namespace("DataDownload");Worldview.DataDownload.SelectionListPanel = function(model, results) {var log = Logging.getLogger("Worldview.DataDownload");-- var NOTICE =- "These results cannot be displayed on the map. Select from the " +- "list below.";-+var panel = null;var self = {};var granules = {};self.show = function() {panel = new YAHOO.widget.Panel("DataDownload_SelectionListPanel", {- width: "600px",+ width: "400px",height: "400px",zIndex: 1020,- visible: false+ visible: false,+ close: false});panel.setHeader("Select data");@@ -36,15 +33,16 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {panel.show();panel.center();panel.hideEvent.subscribe(function() {- setTimeout(function() { panel.destroy(); panel = null; }, 25);+ setTimeout(dispose, 25);});$.each(results.granules, function(index, granule) {granules[granule.id] = granule;});- $("#DataDownload_GranuleList").trigger("create");- $("#DataDownload_GranuleList").on("change", updateSelection);+ $("#DataDownload_GranuleList img.button").on("click", toggleSelection);+ model.events.on("granuleSelect", onGranuleSelect);+ model.events.on("granuleUnselect", onGranuleUnselect);};self.hide = function() {@@ -56,12 +54,42 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {self.visible = function() {return panel !== null;};++ self.setVisible = function(value) {+ if ( !value ) {+ $("#DataDownload_SelectionListPanel").hide();+ } else {+ $("#DataDownload_SelectionListPanel").show();+ }+ };+ var dispose = function() {+ panel.destroy();+ panel = null;+ $("#DataDownload_GranuleList img.button").off("click", toggleSelection);+ model.events.off("granuleSelect", onGranuleSelect);+ model.events.off("granuleUnselect", onGranuleUnselect);+ };+var resultsText = function() {var elements = [];$.each(results.granules, function(index, granule) {- elements.push("<input type='checkbox' name='granule-list' id='" + granule.id + "' class='custom'/>");- elements.push("<label for='" + granule.id + "'>" + granule.label + "</label>");+ var selected = model.isSelected(granule);+ var button = ( selected )+ ? Worldview.DataDownload.IMAGE_UNSELECT+ : Worldview.DataDownload.IMAGE_SELECT;+ elements.push(+ "<tr>" ++ "<td>" ++ "<img " ++ "id='" + granule.id + "' " ++ "src='" + button + "' " ++ "data-selected='" + selected + "'" ++ "class='button'>" ++ "</td>" ++ "<td class='label'>" + granule.label + "</td>" ++ "</tr>"+ );});var text = elements.join("\n");return text;@@ -69,27 +97,40 @@ Worldview.DataDownload.SelectionListPanel = function(model, results) {var bodyText = function() {var elements = [- NOTICE,- "<div id='DataDownload_GranuleList' data-role='fieldcontain'>",- "<fieldset data-role='controlgroup'>",+ "<div id='DataDownload_GranuleList'>",+ "<table>",resultsText(),- "</fieldset>",+ "</table>","</div>"];- var text = elements.join("\n<br/>\n") + "<br/>";+ var text = elements.join("\n") + "<br/>";return text;};- var updateSelection = function(event, ui) {+ var toggleSelection = function(event, ui) {var granule = granules[event.target.id];- if ( event.target.checked ) {- log.debug(granule);- model.selectGranule(granule);- } else {+ var selected = $(this).attr("data-selected") === "true";+ if ( selected ) {model.unselectGranule(granule);+ } else {+ model.selectGranule(granule);}};+ var onGranuleSelect = function(granule) {+ log.debug(granule);+ $("#" + granule.id)+ .attr("src", Worldview.DataDownload.IMAGE_UNSELECT)+ .attr("data-selected", "true");+ };++ var onGranuleUnselect = function(granule) {+ log.debug(granule);+ $("#" + granule.id)+ .attr("src", Worldview.DataDownload.IMAGE_SELECT)+ .attr("data-selected", "false");+ };+return self;};\ No newline at end of filediff --git a/src/js/Worldview/Widget/DataDownload.js b/src/js/Worldview/Widget/DataDownload.jsindex 3d0fb5ca2..e847e6647 100644--- a/src/js/Worldview/Widget/DataDownload.js+++ b/src/js/Worldview/Widget/DataDownload.js@@ -130,6 +130,12 @@ Worldview.Widget.DataDownload = function(config, spec) {var onDeactivate = function() {log.debug("deactivate");Worldview.Indicator.hide();+ if ( selectionListPanel ) {+ selectionListPanel.hide();+ }+ if ( downloadListPanel ) {+ downloadListPanel.hide();+ }};var onProductSelect = function(product) {@@ -156,6 +162,17 @@ Worldview.Widget.DataDownload = function(config, spec) {Worldview.Indicator.hide();if ( results.granules.length === 0 ) {Worldview.Indicator.noData();+ } else {+ if ( results.meta.showList ) {+ selectionListPanel =+ Worldview.DataDownload.SelectionListPanel(model, results);+ selectionListPanel.show();+ } else {+ if ( selectionListPanel ) {+ selectionListPanel.hide();+ }+ selectionListPanel = null;+ }}};@@ -209,9 +226,17 @@ Worldview.Widget.DataDownload = function(config, spec) {};var showDownloadList = function() {+ if ( selectionListPanel ) {+ selectionListPanel.setVisible(false);+ }if ( !downloadListPanel ) {downloadListPanel =Worldview.DataDownload.DownloadListPanel(config, model);+ downloadListPanel.events.on("close", function() {+ if ( selectionListPanel ) {+ selectionListPanel.setVisible(true);+ }+ });}downloadListPanel.show();};