aboutsummaryrefslogtreecommitdiffstats
path: root/view
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-06-25 10:53:37 +0000
committerMario <mario@mariovavti.com>2021-06-25 10:53:37 +0000
commit4f328740dc5f2492b33ee2953e8bad2b84b98243 (patch)
tree7371e71618477164895830f702f4a6f504d8fc4a /view
parent2f1c2f42b1e27e5ae7fc7f82f6118517d087fdba (diff)
downloadvolse-hubzilla-4f328740dc5f2492b33ee2953e8bad2b84b98243.tar.gz
volse-hubzilla-4f328740dc5f2492b33ee2953e8bad2b84b98243.tar.bz2
volse-hubzilla-4f328740dc5f2492b33ee2953e8bad2b84b98243.zip
more work on notifications
Diffstat (limited to 'view')
-rw-r--r--view/js/main.js9
-rw-r--r--view/js/mod_hq.js6
-rw-r--r--view/js/mod_settings.js8
-rw-r--r--view/tpl/settings.tpl7
4 files changed, 23 insertions, 7 deletions
diff --git a/view/js/main.js b/view/js/main.js
index a286d53bf..9ab66833c 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1737,22 +1737,23 @@ function push_notification_request(e) {
else if (Notification.permission !== 'granted') {
Notification.requestPermission(function(permission) {
if(permission === 'granted') {
- $(e.target).closest('button').hide();
+ $(e.target).closest('div').hide();
}
});
}
}
-function push_notification(body, title) {
+function push_notification(title, body, href) {
let options = {
body: body,
+ data: href,
icon: '/images/hz-64.png',
silent: false
}
let n = new Notification(title, options);
- n.onclick = function (event) {
- setTimeout(n.close.bind(n), 300);
+ n.onclick = function (e) {
+ window.location.href = e.target.data;
}
}
diff --git a/view/js/mod_hq.js b/view/js/mod_hq.js
index 87d9f1ef3..48fbf1f9b 100644
--- a/view/js/mod_hq.js
+++ b/view/js/mod_hq.js
@@ -13,7 +13,11 @@ $(document).ready(function() {
});
$(document).on('hz:handleNetworkNotificationsItems', function(e, obj) {
- push_notification($('<p>' + obj.message + '</p>').text(), obj.name);
+ push_notification(
+ obj.name,
+ $('<p>' + obj.message + '</p>').text(),
+ baseurl + '/hq/' + obj.b64mid
+ );
});
});
diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js
index d3392c748..3e91dac9a 100644
--- a/view/js/mod_settings.js
+++ b/view/js/mod_settings.js
@@ -24,8 +24,14 @@ $(document).ready(function() {
loadPermcat(permName);
});
+ if (Notification.permission !== 'granted') {
+ $('#desktop-notifications-info').show();
+ }
-
+ $('#desktop-notifications-request').on('click', function(e) {
+ e.preventDefault();
+ push_notification_request(e);
+ });
});
diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl
index c0808272d..e185707a8 100644
--- a/view/tpl/settings.tpl
+++ b/view/tpl/settings.tpl
@@ -106,7 +106,12 @@
<div class="section-content-tools-wrapper">
<div id="settings-notifications">
- {{include file="field_input.tpl" field=$mailhost}}
+ <div id="desktop-notifications-info" class="section-content-warning-wrapper" style="display: none;">
+ {{$desktop_notifications_info}}<br>
+ <a id="desktop-notifications-request" href="#">{{$desktop_notifications_request}}</a>
+ </div>
+
+ {{include file="field_input.tpl" field=$mailhost}}
<h3>{{$activity_options}}</h3>
<div class="group">