AppSuite:Writing a notification area plugin (7.6.x)

From Open-Xchange
Revision as of 09:07, 11 April 2013 by D.haus (talk | contribs) (Created page with "How to: Write a plugin for the notification area. 1. Preparations To start a new plugin for the notification area you have to add a new folder at apps.plugins/notifications/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to: Write a plugin for the notification area.

1. Preparations

To start a new plugin for the notification area you have to add a new folder at apps.plugins/notifications/ . For this tutorial we will create plugins/notifications/tutorial/ .

Now add a new file to your folder and name it register.js . Now add the basic markup such as copyright define, use strict and so on. Our tutorial result should look similar to this.

CODE /**

* your copyright here
* @author Mister Test <mister.test@test.test>
*/

define('plugins/notifications/tutorial/register',

   ['io.ox/core/extensions'], function (ext) {
   'use strict';
   
   //just to give something back
   return true;

}); CODE

Note: We need to use extensions so require the needed resources with ...['io.ox/core/extensions'], function (ext)... as seen above.

2. Registering our plugin

Now we need to register our plugin by extending the right extension point, which is io.ox/core/notifications/register. Give your plugin a unique id and indexnumber and a register function. Inside this register function we register our notification plugin at the controller and also giving it an id and our view, we create later on We do so by adding:

CODE

   //register our notification plugin
   ext.point('io.ox/core/notifications/register').extend({
       id: 'tutorial',//unique id
       index: 500, //unused index
       register: function (controller) {
           //give our plugin a name and send it to the controller together with our view
           var notifications = controller.get('io.ox/tutorial', NotificationsView);
       }
   });

CODE

io.ox/tutorial is the id the controlelr should use to refer to our plugin and NotificationsView is the view we will create now to display it.

3. Creating the View