Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-10-07 18:41:57 +0300
committerJoas Schilling <coding@schilljs.com>2016-10-07 18:41:57 +0300
commit06f251cd878b6f021ca5b8b84ecc22a0f0627b5a (patch)
tree66b39aff8bfc3f3204dde73bbc66eca02e379dc4 /js
parent106cf06f4dbd2fa3a24130d5162367a00d22634b (diff)
Add onclick handler when a link is given
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'js')
-rw-r--r--js/app.js17
-rw-r--r--js/notification.js5
2 files changed, 14 insertions, 8 deletions
diff --git a/js/app.js b/js/app.js
index b11e274..3c6e6a9 100644
--- a/js/app.js
+++ b/js/app.js
@@ -220,7 +220,7 @@
/**
* Handles removing the Notification from the UI when no longer in JSON
- * @param {OCA.Notifications.Notification} notification
+ * @param {OCA.Notifications.Notif} notification
*/
_onRemoveNotification: function(notification) {
$('div.notification[data-id='+escapeHTML(notification.getId())+']').remove();
@@ -229,7 +229,7 @@
/**
* Handle new notification received
- * @param {OCA.Notifications.Notification} notification
+ * @param {OCA.Notifications.Notif} notification
*/
_onNewNotification: function(notification) {
// Add it to the array
@@ -261,7 +261,7 @@
* Create a browser notification
*
* @see https://developer.mozilla.org/en/docs/Web/API/notification
- * @param {OCA.Notifications.Notification} notification
+ * @param {OCA.Notifications.Notif} notification
*/
createWebNotification: function (notification) {
var n = new Notification(notification.getSubject(), {
@@ -270,6 +270,14 @@
body: notification.getMessage(),
tag: notification.getId()
});
+
+ if (notification.getLink()) {
+ n.onclick = function(event) {
+ event.preventDefault();
+ window.location.href = notification.getLink();
+ }
+ }
+
setTimeout(n.close.bind(n), 5000);
},
@@ -282,7 +290,7 @@
/**
* Adds the notification to the UI
- * @param {OCA.Notifications.Notification} notification
+ * @param {OCA.Notifications.Notif} notification
*/
addToUI: function(notification) {
$('div.notification-wrapper').prepend(notification.renderElement());
@@ -335,7 +343,6 @@
type: 'GET'
});
-
request.done(function(data, statusText, xhr) {
if (xhr.status === 204 || data.ocs.meta.statuscode === 204) {
// 204 No Content - Intercept when no notifiers are there.
diff --git a/js/notification.js b/js/notification.js
index 6e5bc01..4cfb844 100644
--- a/js/notification.js
+++ b/js/notification.js
@@ -13,8 +13,7 @@
/**
* Initialise the notification
*/
- var Notif = function(jsonData){
- // TODO handle defaults
+ var Notif = function(jsonData) {
this.app = jsonData.app;
this.user = jsonData.user;
this.timestamp = moment(jsonData.datetime).format('X');
@@ -23,7 +22,7 @@
this.subject = jsonData.subject;
this.message = jsonData.message;
this.link = jsonData.link;
- this.actions = jsonData.actions; // TODO some parsing here?
+ this.actions = jsonData.actions;
this.notification_id = jsonData.notification_id;
};