AppSuite:Writing a notification area plugin: Difference between revisions

From Open-Xchange
mNo edit summary
No edit summary
Line 6: Line 6:
__TOC__
__TOC__


Lorem ipsum ...
==Basic Notification==
 
This is the most basic code for a notification plugin, it doesn't have api suppport or other things but should work:
 
<pre class="language-javascript">
define('plugins/notifications/tutorial/register', [
    'io.ox/core/extensions',
    'io.ox/core/notifications/subview'
], function (ext, Subview) {
 
    'use strict';
 
    ext.point('io.ox/core/notifications/tutorial/item').extend({
        draw: function (baton) {
            this.append( $('<span>').text('hello world'));
        }
    });
 
    ext.point('io.ox/core/notifications/register').extend({
        id: 'tutorialplugin',
        index: 300,
        register: function () {
            var options = {
                    id: 'io.ox/tutorialplugin',
                    //#. Invitations (notifications) about appointments
                    title: 'Test Notifications',
                    extensionPoints: {
                        item: 'io.ox/core/notifications/tutorial/item'
                    },
                },
                subview  = new Subview(options);
 
            subview.resetNotifications({id: myNotification1});
        }
    });
 
    return true;
});
</pre>

Revision as of 08:58, 10 September 2015

Writing a plugin for the notification area

Abstract: This article is a step by step tutorial to build your own notification plugin. These plugins can be used for various purposes, for example reminding the user of something or showing him new invitations.

Basic Notification

This is the most basic code for a notification plugin, it doesn't have api suppport or other things but should work:

define('plugins/notifications/tutorial/register', [
    'io.ox/core/extensions',
    'io.ox/core/notifications/subview'
], function (ext, Subview) {

    'use strict';

    ext.point('io.ox/core/notifications/tutorial/item').extend({
        draw: function (baton) {
            this.append( $('<span>').text('hello world'));
        }
    });

    ext.point('io.ox/core/notifications/register').extend({
        id: 'tutorialplugin',
        index: 300,
        register: function () {
            var options = {
                    id: 'io.ox/tutorialplugin',
                    //#. Invitations (notifications) about appointments
                    title: 'Test Notifications',
                    extensionPoints: {
                        item: 'io.ox/core/notifications/tutorial/item'
                    },
                },
                subview  = new Subview(options);

            subview.resetNotifications({id: myNotification1});
        }
    });

    return true;
});