Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Moved WVC callback function into WV. Renamed methods to be more logical - Moved the updateLink method from WVC into WV. - Renamed methods to specify share so not to be confused with url link shortener methods

ZachTRice162f1fb0c04c
diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.js
index 9a4da35bd..0b0e139fa 100644
--- a/web/js/link/wv.link.ui.js
+++ b/web/js/link/wv.link.ui.js
@@ -19,7 +19,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
var selector = "#" + id;
var $button, $label;
var fbLink, twLink, rdLink, emailLink;
- var widgetFactory = React.createFactory(WVC.Link);
+ var widgetFactory = React.createFactory(WVC.Share);
var init = function() {
$button = $("<input></input>").attr("type", "checkbox").attr("id", "wv-link-button-check");
@@ -37,8 +37,13 @@ wv.link.ui = wv.link.ui || function(models, config) {
wv.ui.closeDialog();
}
});
-
models.link.events.on("update", replaceHistoryState);
+ WVC.Share.defaultProps = {
+ fbLink: '#',
+ twLink: '#',
+ rdLink: '#',
+ emailLink: '#',
+ };
};
//Calls toQueryString to fetch updated state and returns URL
@@ -71,7 +76,16 @@ wv.link.ui = wv.link.ui || function(models, config) {
return "mailto:?" + "subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body);
};
- self.setLink = function(fbLink, twLink, rdLink, emailLink, callback) {
+ self.updateShareLink = function(fbLink, twLink, rdLink, emailLink, callback) {
+ self.reactComponent.setState({
+ fbLink : fbLink,
+ twLink : twLink,
+ rdLink : rdLink,
+ emailLink : emailLink
+ });
+ };
+
+ self.setShareLinks = function(fbLink, twLink, rdLink, emailLink, callback) {
var fb, tw, rd, email;
var promise = models.link.shorten();
var shareMessage = 'Check out what I found in NASA Worldview!';
@@ -121,7 +135,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
self.reactComponent = ReactDOM.render(Widget, $dialog[0]);
// Update react link states when dialog is shown.
- self.setLink(fbLink, twLink, rdLink, emailLink, self.reactComponent.updateLinkState);
+ self.setShareLinks(fbLink, twLink, rdLink, emailLink, self.updateShareLink);
// If selected during the animation, the cursor will go to the
// end of the input box
@@ -214,7 +228,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
while (Date.now() < waitUntil) {
if (!linkReady) {
linkReady = true;
- self.setLink(fbLink, twLink, rdLink, emailLink, self.reactComponent.updateLinkState);
+ self.setShareLinks(fbLink, twLink, rdLink, emailLink, self.updateShareLink);
$('#permalink_content').val(models.link.get());
$("#wv-link-shorten-check").iCheck("uncheck");
$('#permalink_content').focus();