Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Splitting out old ui functionality; added in react widget file

ZachTRicea2a727245598
diff --git a/web/index.html b/web/index.html
index 45afdbdc8..3e944a600 100644
--- a/web/index.html
+++ b/web/index.html
@@ -262,7 +262,9 @@
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.animate.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.model.js"></script>
- <!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.ui.js"></script>
+ <!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.widget.js"></script>
+ <!-- link.dev -->
+ <!-- <script type="text/javascript" src="js/link/wv.link.ui.js"></script> -->
<!-- link.dev --> <script type="text/javascript" src="js/wv.feedback.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/wv.tour.js"></script>
diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.js
index 04f09a24d..e23398071 100644
--- a/web/js/link/wv.link.ui.js
+++ b/web/js/link/wv.link.ui.js
@@ -17,23 +17,11 @@ wv.link.ui = wv.link.ui || function(models, config) {
var self = {};
var id = "wv-link-button";
var selector = "#" + id;
- var widgetFactory = React.createFactory(WVC.Share);
- var widgetCreate = React.createElement(WVC.Share);
-
- var dialogCreate = React.createElement(WVC.Dialog);
var $button;
var $label;
var init = function() {
- self.reactComponent = ReactDOM.render(dialogCreate, $('#wv-dialog-button')[0]);
-
- var Widget;
- Widget = self.initWidget();
- //mount react component
- self.reactComponent = ReactDOM.render(widgetCreate, $('#wv-share-button')[0]);
-
-
$button = $("<input></input>")
.attr("type", "checkbox")
.attr("id", "wv-link-button-check");
@@ -62,12 +50,6 @@ wv.link.ui = wv.link.ui || function(models, config) {
models.link.events.on("update", replaceHistoryState);
};
- // NOTE: Not being used yet... until I set variables within react component
- self.initWidget = function() {
- return widgetFactory({
- });
- };
-
//Calls toQueryString to fetch updated state and returns URL
var replaceHistoryState = _.throttle(function() {
if ( wv.util.browser.history ) {
diff --git a/web/js/link/wv.link.widget.js b/web/js/link/wv.link.widget.js
new file mode 100644
index 000000000..12a655c3c
--- /dev/null
+++ b/web/js/link/wv.link.widget.js
@@ -0,0 +1,83 @@
+/*
+ * 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 - 2014 United States Government as represented by the
+ * Administrator of the National Aeronautics and Space Administration.
+ * All Rights Reserved.
+ */
+
+var wv = wv || {};
+wv.link = wv.link || {};
+
+wv.link.ui = wv.link.ui || function(models, config) {
+
+ var self = {};
+ var id = "wv-link-button";
+ var selector = "#" + id;
+ var widgetCreate = React.createElement(WVC.Share);
+
+ var widgetFactory = React.createFactory(WVC.Dialog);
+ // var dialogCreate = React.createElement(WVC.Dialog);
+ var init = function() {
+
+ // self.reactComponent = ReactDOM.render(dialogCreate, $('#wv-dialog-button')[0]);
+
+ var Widget;
+ Widget = self.initWidget();
+ //mount react component
+ self.reactComponent = ReactDOM.render(Widget, $('#wv-share-button')[0]);
+
+ $button = $("<input></input>")
+ .attr("type", "checkbox")
+ .attr("id", "wv-link-button-check");
+ $label = $("<label></label>")
+ .attr("for", "wv-link-button-check")
+ .attr("title", "Share this map");
+ var $icon = $("<i></i>")
+ .addClass("fa")
+ .addClass("fa-share-square-o")
+ .addClass("fa-2x");
+ $label.append($icon);
+ $(selector).append($label);
+ $(selector).append($button);
+ $button.button({
+ text: false
+ }).click(function() {
+ var checked = $("#wv-link-button-check").prop("checked");
+ WVC.GA.event('Link', 'Click', 'Share link Button');
+ if ( checked ) {
+ self.show();
+ } else {
+ wv.ui.closeDialog();
+ }
+ });
+
+ models.link.events.on("update", replaceHistoryState);
+ };
+
+ // NOTE: Not being used yet... until I set variables within react component
+ self.initWidget = function() {
+ return widgetFactory({
+ urlShortening: config.features.urlShortening,
+ config: config,
+ models: models,
+ getModelsLink: models.link.get(),
+ shortenModelsLink: models.link.shorten()
+ });
+ };
+
+ //Calls toQueryString to fetch updated state and returns URL
+ var replaceHistoryState = _.throttle(function() {
+ if ( wv.util.browser.history ) {
+ window.history.replaceState("", "@OFFICIAL_NAME@",
+ "?" + models.link.toQueryString());
+ }
+ }, 2000, {leading: true, trailing: true});
+
+ init();
+ return self;
+
+};