Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add compare alert #1234

Benjamin King7bf667ffe003
diff --git a/web/js/app.js b/web/js/app.js
index 6f071e809..432124af2 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -91,6 +91,7 @@ import { projectionUi } from './projection/ui';
// A|B comparison
import { compareModel } from './compare/model';
+import { compareUi } from './compare/ui';
// Other
import { debugConfig, debugLayers } from './debug';
import Brand from './brand';
@@ -492,7 +493,9 @@ class App extends React.Component {
if (config.features.alert) {
ui.alert = notificationsUi(ui, config);
}
-
+ if (config.features.compare) {
+ ui.compare = compareUi(models, ui, config);
+ }
// FIXME: Old hack
$(window).resize(function() {
if (util.browser.small) {
diff --git a/web/js/compare/ui.js b/web/js/compare/ui.js
new file mode 100644
index 000000000..e1c4648a7
--- /dev/null
+++ b/web/js/compare/ui.js
@@ -0,0 +1,52 @@
+import util from '../util/util';
+import wvui from '../ui/ui';
+var compareAlertBody =
+ '<h3 class="compare-dialog-header">What can I compare?</h3>' +
+ '<ul>' +
+ '<li>The same imagery at different times.</li>' +
+ '<li>The same time with different imagery products</li>' +
+ '<li>A mix of different times and layers</li>' +
+ '</ul>' +
+ '<p>You can toggle between three different comparison modes found at the base of the sidebar</p>' +
+ '<ul>' +
+ '<li>Swipe</li>' +
+ '<li>Opacity</li>' +
+ '<li>Spy</li>' +
+ '</ul>';
+
+export function compareUi(models, ui, config) {
+ var self = {};
+ var alertDialog;
+
+ var alert = function() {
+ if (!alertDialog) {
+ alertDialog = wvui.alert(
+ compareAlertBody,
+ 'You are in comparison mode',
+ 800,
+ 'warning',
+ function() {
+ if (util.browser.localStorage) {
+ localStorage.setItem('dismissedCompareAlert', true);
+ }
+ alertDialog.dialog('close');
+ }
+ );
+ }
+ if (
+ util.browser.localStorage &&
+ !localStorage.getItem('dismissedCompareAlert')
+ ) {
+ alertDialog.dialog('open');
+ }
+ };
+ var init = function() {
+ var model = models.compare;
+ if (model.active) alert();
+ model.events.on('toggle', function() {
+ if (model.active) alert();
+ });
+ };
+ init();
+ return self;
+}