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
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2015-09-02 12:55:14 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2015-09-14 16:50:24 +0300
commit2fd55c1886dffb1c017a5492d3ff73ac8101530e (patch)
tree0395e80eefb4964852b9245f6573138044a6a5f7 /js/notification.js
parented1baac6b61a1148170ac5ca2122ba9f834e60f2 (diff)
First attempt at frontend
Diffstat (limited to 'js/notification.js')
-rw-r--r--js/notification.js119
1 files changed, 119 insertions, 0 deletions
diff --git a/js/notification.js b/js/notification.js
new file mode 100644
index 0000000..1ea3c28
--- /dev/null
+++ b/js/notification.js
@@ -0,0 +1,119 @@
+/**
+ * ownCloud - Notifications
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Tom Needham <tom@owncloud.com>
+ * @copyright Tom Needham 2015
+ */
+
+ (function() {
+
+ /**
+ * Initialise the notification
+ */
+ var Notif = function(jsonData){
+ // TODO handle defaults
+ this.app = jsonData.app;
+ this.user = jsonData.user;
+ this.timestamp = jsonData.timestamp;
+ this.object_type = jsonData.object_type;
+ this.object_id = jsonData.object_id;
+ this.subject = jsonData.subject;
+ this.message = jsonData.message;
+ this.link = jsonData.link;
+ this.icon = jsonData.icon;
+ this.actions = jsonData.actions; // TODO some parsing here?
+ this.notification_id = jsonData.notification_id;
+ };
+
+ Notif.prototype = {
+
+ app: null,
+
+ user: null,
+
+ timestamp: null,
+
+ object_type: null,
+
+ object_id: null,
+
+ subject: null,
+
+ message: null,
+
+ link: null,
+
+ icon: null,
+
+ actions: [],
+
+ notification_id: null,
+
+ getActions: function() {
+ return this.actions;
+ },
+
+ getSubject: function() {
+ return this.subject;
+ },
+
+ getTimestamp: function() {
+ return this.timestamp;
+ },
+
+ getObjectId: function() {
+ return this.object_id;
+ },
+
+ getActions: function() {
+ return this.actions;
+ },
+
+ getId: function() {
+ return this.notification_id;
+ },
+
+ getMessage: function() {
+ return this.message;
+ },
+
+ getEl: function() {
+ return $('div.notification[data-id='+this.getId()+']');
+ },
+
+ /**
+ * Generates the HTML for the notification
+ */
+ renderElement: function() {
+ var el = $('<div class="notification"></div>');
+ el.attr('data-id', this.getId());
+ el.attr('data-timestamp', this.getTimestamp());
+ el.append('<div class="notification-subject">'+this.getSubject()+'</div>');
+ el.append('<div class="notification-message">'+this.getMessage()+'</div>');
+ // Add actions
+ var actions = $('<div class="actions"></div>');
+ var actionsData = this.getActions();
+ $.each(actionsData, function(index) {
+ actions.append('<a class="button" href="'+actionsData[index].link+'">'+actionsData[index].label+'</a>');
+ // TODO create event handler on click for given action type
+ });
+ el.append(actions);
+ el.append('<div style="display: none;" class="notification-delete"><img class="svg" alt="Dismiss" src="/core/img/actions/close.svg"></div>');
+ return el;
+ },
+
+ /**
+ * Register notification Binds
+ */
+ bindNotificationEvents: function() {
+
+ }
+
+ }
+
+ OCA.Notifications.Notif = Notif;
+
+})();