summaryrefslogtreecommitdiffstats
path: root/browser/src/map/handler
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2021-10-20 14:36:47 -0400
committerpedropintosilva <65948705+pedropintosilva@users.noreply.github.com>2022-01-26 16:46:06 +0100
commit9107ca8eff3cb2784f261ccacb1ea6c3158ee606 (patch)
treef0ae3714b5281c8719912a002a9e9495f9103869 /browser/src/map/handler
parentbrowser: send the git hashes to verify version (diff)
downloadonline-9107ca8eff3cb2784f261ccacb1ea6c3158ee606.tar.gz
online-9107ca8eff3cb2784f261ccacb1ea6c3158ee606.zip
browser: add initial welcome dialog
Change-Id: Ic42ad71fec286fe85e5130951fcab0e11b1563c0 Signed-off-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'browser/src/map/handler')
-rw-r--r--browser/src/map/handler/Map.Welcome.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/browser/src/map/handler/Map.Welcome.js b/browser/src/map/handler/Map.Welcome.js
new file mode 100644
index 0000000000..2c780e218d
--- /dev/null
+++ b/browser/src/map/handler/Map.Welcome.js
@@ -0,0 +1,51 @@
+/* -*- js-indent-level: 8 -*- */
+/*
+ * L.Map.Welcome.
+ */
+
+L.Map.mergeOptions({
+ welcome: true
+});
+
+L.Map.Welcome = L.Handler.extend({
+
+ initialize: function (map) {
+ L.Handler.prototype.initialize.call(this, map);
+
+ this._url = window.feedbackLocation.replace(/Rate\/feedback.html/g, 'Welcome/welcome.html');
+ },
+
+ addHooks: function () {
+ L.DomEvent.on(window, 'message', this.onMessage, this);
+ this.remove();
+
+ this._iframeWelcome = L.iframeDialog(this._url, null, null, { prefix: 'iframe-welcome' });
+ },
+
+ removeHooks: function () {
+ L.DomEvent.off(window, 'message', this.onMessage, this);
+ this.remove();
+ },
+
+ remove: function () {
+ if (this._iframeWelcome && this._iframeWelcome.hasLoaded()) {
+ this._iframeWelcome.remove();
+ delete this._iframeWelcome;
+ }
+ },
+
+ onMessage: function (e) {
+ var data = e.data;
+
+ if (data === 'welcome-show') {
+ this._iframeWelcome.show();
+ } else if (data === 'welcome-close') {
+ this.remove();
+ }
+ }
+});
+
+if (window.feedbackLocation && window.isLocalStorageAllowed) {
+ L.Map.addInitHook('addHandler', 'welcome', L.Map.Welcome);
+}
+