Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Placeholder data download button in

Mike McGann7539c95f08d7
diff --git a/src/index.html b/src/index.html
index 4495e0667..9bb9829f2 100644
--- a/src/index.html
+++ b/src/index.html
@@ -141,6 +141,8 @@
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Map/DailyProduct.js"></script>
<!-- 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/DataDownload/Model.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/Map.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/Palette.js"></script>
@@ -148,6 +150,7 @@
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/ArcticProjectionChangeNotification.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/Opacity.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/EPSG.js"></script>
+ <!-- link.dev --> <script type="text/javascript" src="js/Worldview/Widget/DataDownload.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/tour.js"></script>
@@ -163,6 +166,7 @@
<li class='toolbar-icon'><div id='camera'></div></li>
<li class='toolbar-icon'><div id="switch"></div></li>
<li class='toolbar-icon'><a id='perma_link' class='toolbar-link' title='Permalink' href='javascript:Worldview.Permalink.show();'><img src='images/permalink.png' /></a></li>
+ <li class='toolbar-icon'><div class='DataDownload_ModeButton'></div></li>
</ul>
</div>
diff --git a/src/js/Worldview/DataDownload.js b/src/js/Worldview/DataDownload.js
index 488c8ca35..c7bf2a649 100644
--- a/src/js/Worldview/DataDownload.js
+++ b/src/js/Worldview/DataDownload.js
@@ -12,6 +12,5 @@
/**
* Browse and select available granules for download.
*
- * @module Worldview.DataDownload
- * @main
+ * @namespace Worldview.DataDownload
*/
\ No newline at end of file
diff --git a/src/js/Worldview/DataDownload/Model.js b/src/js/Worldview/DataDownload/Model.js
index 2ee7bf076..321bb4fff 100644
--- a/src/js/Worldview/DataDownload/Model.js
+++ b/src/js/Worldview/DataDownload/Model.js
@@ -14,15 +14,33 @@ Worldview.namespace("DataDownload");
/**
* Data download model.
*
- * @module Worldview.DataDownload
+ * @namespace DataDownload
* @class Model
+ * @constructor
+ * @param config config
*/
Worldview.DataDownload.Model = function(config) {
var self = {};
/**
- * Indicates if data download mode is enabled.
+ * Fired when the data download mode is activated.
+ *
+ * @event ACTIVATE
+ * @final
+ */
+ self.ACTIVATE = "activate";
+
+ /**
+ * Fired when the data download mode is deactivated.
+ *
+ * @event DEACTIVATE
+ * @final
+ */
+ self.DEACTIVATE = "deactivate";
+
+ /**
+ * Indicates if data download mode is active.
*
* @property active
* @type boolean
@@ -31,32 +49,53 @@ Worldview.DataDownload.Model = function(config) {
*/
self.active = false;
-
/**
- * Enables data download mode. If the mode is already enabled, this method
+ * Handler for events fired by this class.
+ *
+ * @property events
+ * @type Events
+ */
+ self.events = Worldview.Events();
+
+ /**
+ * Activates data download mode. If the mode is already active, this method
* does nothing.
*
- * @method enable
+ * @method activate
*/
- self.enable = function() {
- if ( !active ) {
- console.log("Starting");
- active = true;
+ self.activate = function() {
+ if ( !self.active ) {
+ self.active = true;
+ self.events.fire(self.ACTIVATE);
}
- }
+ };
/**
- * Disables data download mode. If the mode is not already enabled, this
+ * Deactivates data download mode. If the mode is not already active, this
* method does nothing.
*
- * @method disable
+ * @method deactivate
+ */
+ self.deactivate = function() {
+ if ( self.active ) {
+ self.active = false;
+ self.events.fire(self.DEACTIVATE);
+ }
+ };
+
+ /**
+ * Toggles the current mode of data download. Deactivates if already
+ * active. Activates if already inactive.
+ *
+ * @method toggleMode
*/
- self.disable = function() {
- if ( active ) {
- console.log("Stopping");
- active = false;
+ self.toggleMode = function() {
+ if ( self.active ) {
+ self.deactivate();
+ } else {
+ self.activate();
}
- }
+ };
return self;
}
\ No newline at end of file
diff --git a/src/js/Worldview/Events.js b/src/js/Worldview/Events.js
index f37c3ed66..465429b03 100644
--- a/src/js/Worldview/Events.js
+++ b/src/js/Worldview/Events.js
@@ -25,7 +25,6 @@
*
* events.fire("answerReceived", 42);
*
- * @module Worldview
* @class Events
*/
Worldview.Events = function() {
@@ -45,6 +44,9 @@ Worldview.Events = function() {
* function.
*/
self.on = function(event, callback) {
+ if ( !event ) {
+ throw new Error("No event type specified");
+ }
var listeners = types[event];
if ( !listeners ) {
listeners = [];
diff --git a/src/js/Worldview/Widget/DataDownload.js b/src/js/Worldview/Widget/DataDownload.js
new file mode 100644
index 000000000..8e227c9b1
--- /dev/null
+++ b/src/js/Worldview/Widget/DataDownload.js
@@ -0,0 +1,56 @@
+/*
+ * 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("Widget");
+
+/**
+ * Handles UI interactions with the Data Download model.
+ *
+ * @module Worldview.Widget
+ * @class DataDownload
+ * @constructor
+ * @param model {Worldview.DataDownload.Model} model for which this widget
+ * will be a view for.
+ * @param config Worldview config
+ * @param spec.selector {string} jQuery selector for where the mode activation
+ * button should be rendered.
+ */
+Worldview.Widget.DataDownload = function(model, config, spec) {
+
+ var self = {};
+
+ var HTML_WIDGET_INACTIVE = "<img src='images/camera.png'></img>";
+ var HTML_WIDGET_ACTIVE = "<img src='images/cameraon.png'></img>";
+
+ var init = function() {
+ model.events.on("activate", onActivate);
+ model.events.on("deactivate", onDeactivate);
+
+ $(spec.selector).on("click", function() {
+ model.toggleMode();
+ });
+
+ onDeactivate();
+ }
+
+ var onActivate = function() {
+ $(spec.selector).html(HTML_WIDGET_ACTIVE);
+ };
+
+ var onDeactivate = function() {
+ $(spec.selector).html(HTML_WIDGET_INACTIVE);
+ }
+
+ init();
+ return self;
+
+};
+
diff --git a/src/js/main.js b/src/js/main.js
index a3a3a0d69..e501140b9 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -109,6 +109,12 @@ $(function() {// Initialize "static" vars
var opacity = new Worldview.Widget.Opacity(config);
var epsg = new Worldview.Widget.EPSG(config);
+ var dataDownloadModel = Worldview.DataDownload.Model();
+ var dataDownloadWidget =
+ Worldview.Widget.DataDownload(dataDownloadModel, config, {
+ selector: ".DataDownload_ModeButton"
+ });
+
// Get rid of address bar on iphone/ipod
var fixSize = function() {
window.scrollTo(0,0);