Interactive interface for browsing global, full-resolution satellite imagery
created notify modal components #230
Benjamin90c8926fbe34
diff --git a/web/js/notifications/wv.notifications.model.js b/web/js/notifications/wv.notifications.model.jsdeleted file mode 100644index 6df610431..000000000--- a/web/js/notifications/wv.notifications.model.js+++ /dev/null@@ -1,18 +0,0 @@-var wv = wv || {};-wv.notifications = wv.notifications || {};--/*- * @Class- */-wv.notifications.model = wv.notifications.model || function(models) {- self.infoIconActive = false;- self.messageIconActive = false;- self.notifyIconActive = false;-- self.events = wv.util.events();-- var init = function() {- self.events.on('');- };--};\ No newline at end of filediff --git a/web/js/notifications/wv.notifications.ui.js b/web/js/notifications/wv.notifications.ui.jsindex 7e41610c6..7cd23e9fd 100644--- a/web/js/notifications/wv.notifications.ui.js+++ b/web/js/notifications/wv.notifications.ui.js@@ -17,17 +17,19 @@ wv.notifications = wv.notifications || {};/** @Class*/-wv.notifications.ui = wv.notifications.ui || function(models, url) {+wv.notifications.ui = wv.notifications.ui || function(models, config) {var self = {};var mainNotification;var mainIcon;var iconCase;var secondaryNotification;- var sortedNotifications;+ var sortedNotifications = {};var activeNotifications = {};var activeMessageId;+ var url;+ url = config.features.alert.url;self.events = wv.util.events();self.infoIconActive = false;self.notifyIconActive = false;@@ -61,15 +63,15 @@ wv.notifications.ui = wv.notifications.ui || function(models, url) {outage = sortedNotifications.outages[0];alert = sortedNotifications.alerts[0];- if(!objectAlreadySeen(message)) {+ if(message && !objectAlreadySeen(message)) {mainNotification = 'message';activeMessageId = message.id;}- if(!objectAlreadySeen(alert)) {+ if(alert && !objectAlreadySeen(alert)) {mainNotification = 'alert';activeNotifications.alert = alert.id;}- if(!objectAlreadySeen(outage)) {+ if(outage && !objectAlreadySeen(outage)) {mainNotification = 'outage';activeNotifications.outage = outage.id;}@@ -129,13 +131,20 @@ wv.notifications.ui = wv.notifications.ui || function(models, url) {};self.getMessages = function() {var $message;+ if(!sortedNotifications.messages) {+ return null;+ }if(activeMessageId) {- $message = $("<li class='gift'><a><i class='ui-icon fa fa-fw fa-gift active'></i>What's new</a></li>");+ $message = $("<li class='gift'><a><i class='ui-icon fa fa-fw fa-gift active'></i>What's New</a></li>");$message.on('click', deactivateMessage);self.messageIconActive = true;return $message;- } else {- return $("<li><a><i class='ui-icon fa fa-fw fa-gift'></i>What's New</a></li>");+ } else if(sortedNotifications.messages[0]) {+ $message = $("<li><a><i class='ui-icon fa fa-fw fa-gift'></i>What's New</a></li>");+ $message.on('click', deactivateMessage);+ return $message;+ } else{+ return null;}};@@ -148,17 +157,25 @@ wv.notifications.ui = wv.notifications.ui || function(models, url) {$notifyMenuItem.on('click', notify);return $notifyMenuItem;- } else {+ } else if(!_.isEmpty(sortedNotifications.alerts) || !_.isEmpty(sortedNotifications.outages)) {$notifyMenuItem = $("<li><a><i class='ui-icon fa fa-fw fa-bolt'></i>Notifications</a></li>");$notifyMenuItem.on('click', notify);return $notifyMenuItem;+ } else {+ return null;}};var deactivateMessage = function(e) {+ var messages;this.className = 'ui-icon fa fa-fw fa-gift';self.messageIconActive = false;wv.util.localStorage('message', activeMessageId);activeMessageId = null;++ messages = sortedNotifications.messages[0];+ if(messages) {+ create$whatsNew(messages, 'Latest Release');+ }if(mainNotification === 'message') {mainNotification = null;}@@ -183,16 +200,25 @@ wv.notifications.ui = wv.notifications.ui || function(models, url) {updateMainIcon();};var createNotifyDialog = function() {- var $dialog;+ var $dialog, width, height;var $notifyContent = $('<div class="wv-notify-modal"></div>');-+ if(!sortedNotifications.alerts && !sortedNotifications.outages) {+ return null;+ }+ width = 625;+ height = 525;+ if ( wv.util.browser.small || wv.util.browser.touchDevice ) {+ width = $(window).width();+ height = $(window).height();+ }$notifyContent.append(create$block(sortedNotifications.outages, 'Outage'));$notifyContent.append(create$block(sortedNotifications.alerts, 'Alert'));$dialog = wv.ui.getDialog().append($notifyContent);+$dialog.dialog({title: "Notifications",- width: 625,- height: 525,+ width: width,+ height: height,show: { effect: "fade" },hide: { effect: "fade" }});@@ -206,7 +232,27 @@ wv.notifications.ui = wv.notifications.ui || function(models, url) {}return $ul;};-+ var create$whatsNew = function(obj, title) {+ var $dialog, width, height, $notifyContent, releasePageUrl;+ releasePageUrl = config.features.alert.releases || "https://github.com/nasa-gibs/worldview/releases";+ width = 625;+ height = 525;+ if ( wv.util.browser.small || wv.util.browser.touchDevice ) {+ width = $(window).width();+ height = $(window).height();+ }+ $notifyContent = $("<div class='wv-notify-modal'><div><h2>" + title + "</h2><p>" + obj.message +"</p></div></div>");+ $footer = $('<div class="wv-notify-footer"><p> Check out our <a target="_blank" href="' + releasePageUrl + '">release page</a> for a complete list of new additions.</p></div>');+ $notifyContent.append($footer);+ $dialog = wv.ui.getDialog().append($notifyContent);+ $dialog.dialog({+ title: "What's New",+ width: width,+ height: height,+ show: { effect: "fade" },+ hide: { effect: "fade" }+ });+ };init();return self;diff --git a/web/js/ui/wv.ui.info.js b/web/js/ui/wv.ui.info.jsindex 52262dea6..bf98aeca5 100644--- a/web/js/ui/wv.ui.info.js+++ b/web/js/ui/wv.ui.info.js@@ -47,16 +47,23 @@ wv.ui.info = wv.ui.info || (function(ui, config) {var show = function() {var $menu = wv.ui.getMenu().attr("id", "wv-info-menu");- var $alerts;+ var $alerts, $new;+ var whatsNewUrl = "https://github.com/nasa-gibs/worldview/releases";var $menuItems = $("<ul></ul>");var $feedback = $("<li><a class='feedback'><i class='ui-icon fa fa-envelope fa-fw'></i>Send Feedback</a></li>");var $tour = $("<li><a><i class='ui-icon fa fa-truck fa-fw'></i>Start Tour</a></li>");- var $new = $("<li><a><i class='ui-icon fa fa-flag fa-fw'></i>What's New</a></li>");var $about = $("<li><a><i class='ui-icon fa fa-file fa-fw'></i>About</a></li>");var $source = $("<li><a><i class='ui-icon fa fa-code fa-fw'></i>Source</a></li>");+if(config.features.alert) {$alerts = ui.alert.getAlert();$new = ui.alert.getMessages();+ if(config.features.alert.releases) {+ whatsNewUrl = config.features.alert.releases;+ }+ }+ if(!$new) {+ $new = $("<li><a target='_blank' href='" + whatsNewUrl + "'><i class='ui-icon fa fa-flag fa-fw'></i>What's New</a></li>");}if ( config.features.feedback ) {$menuItems.append($feedback);@@ -78,49 +85,17 @@ wv.ui.info = wv.ui.info || (function(ui, config) {$menuItems.menu();wv.ui.positionMenu($menuItems, {my: "left top",- at: "left bottom+5",+ at: "left bottom + 5",of: $label});$menuItems.hide();- $about.click(function() {- if ( wv.util.browser.small || wv.util.browser.touchDevice ) {- window.open("brand/pages/about.html?v=@BUILD_NONCE@", "_blank");- } else {- wv.ui.getDialog().dialog({- title: "About",- width: 625,- height: 525,- show: { effect: "fade" },- hide: { effect: "fade" }- })- .load("brand/pages/about.html?v=@BUILD_NONCE@ #page")- .addClass("wv-opaque");- }- });-$source.click( function( e ){window.open("https://github.com/nasa-gibs/worldview", "_blank");});wv.feedback.decorate($feedback.find("a"));- $new.click(function() {- if ( wv.util.browser.small || wv.util.browser.touchDevice ) {- window.open("brand/pages/new.html?v=@BUILD_NONCE@", "_blank");- } else {- wv.ui.getDialog().dialog({- title: "What's New",- width: 625,- height: 525,- show: { effect: "fade" },- hide: { effect: "fade" }- })- .load("brand/pages/new.html?v=@BUILD_NONCE@ #page")- .addClass("wv-opaque");- }- });-$tour.click(function() {ui.tour.start();});diff --git a/web/js/wv.main.js b/web/js/wv.main.jsindex 22265116e..65d2570b8 100644--- a/web/js/wv.main.js+++ b/web/js/wv.main.js@@ -212,7 +212,7 @@ $(function() {ui.tour = wv.tour(models, ui, config);ui.info = wv.ui.info(ui, config);if(config.features.alert){- ui.alert = wv.notifications.ui(ui, config.features.alert.url);+ ui.alert = wv.notifications.ui(ui, config);}