Class: UWA.Plugins.Abstract

UWA/Plugins/Abstract. UWA.Plugins.Abstract

new UWA.Plugins.Abstract(widget, options)

This object is made to implement widget custom plugins over widget events and widget content handling.

Examples of Plugins:

  • Auth Service with Form
  • Search Results Highlite into Widget body
  • Google Analitycs tracker
  • Google Ads
  • Resize Corner
  • Must be Online else widget is not availble
Examples

Using plugin in Widget Javascript:

<script type="text/javascript" src="http://cdn.uwa.preview.netvibes.com/lib/c/UWA/js/UWA_Plugins_GoogleAnalytics.js"></script>
<script type="text/javascript">
   var MyPlugin = new UWA.Plugins.MyPlugin(widget, {
       'myName': 'John'
   });
</script>

Using plugin in Widget Manifest:

<widget:plugins>
   <widget:plugin name="MyPluginClass">
       <widget:option name="myName" value="John">
   </widget:plugin>
</widget:plugins>

Or:

<widget:plugins>
   <widget:plugin name="MyPluginClass">
       <widget:options name="myData">
             <widget:option name="myName" value="John" />
             <widget:option name="mySex" value="male" />
             <widget:option name="myAge" value="18" />
       </widget:options>
   </widget:plugin>
</widget:plugins>

Plugin onLoad example:

this.addEvent('onLoad', function onLoad() {
   this.removeEvent('onLoad', onLoad);
   this.dispatchEvent('onLoad');
   return `false`;
});
Parameters
Name Type Description
widget Object
options Object

Options hash or a option/value pair.

Index

Methods

dispatchEvent(name, args, bind) → {Void}

Executes the listeners method associated with the given event name.

Internal or advanced use only.

Parameters
Name Type Description
name String

The event name (e.g. "onUpdateTitle");

args Array

Array of parameters that should be passed to each listener

bind Object

Context on which listener will be executed (object that should represent the this variable inside listener function)

Returns

Nothing but calls the listeners associated with the given event name.

Type
Void

addEvent(name, listener, bind, priority)

Add an listener method associated with the given event name.

Internal or advanced use only.

Parameters
Name Type Description
name String

The event name (e.g. "onUpdateTitle")

listener Function

Listener function that will be executed when event is triggered

bind Object

Context on which listener will be executed (object that should represent the this variable inside listener function)

priority Number

The priority level of the listener. Listeners with higher priority will be executed before listeners with lower priority Listeners with same priority level will be executed at the same order as they were added. (default = 0)

addEvents(events, bind, priority)

Add listeners methods associated with the given event name.

Internal or advanced use only.

Parameters
Name Type Description
events Object

The listeners methods indexed by name (e.g. {"onUpdateTitle", function() {}})

bind Object

Context on which listener will be executed (object that should represent the this variable inside listener function)

priority Number

The priority level of the listener. Listeners with higher priority will be executed before listeners with lower priority

removeEvent(name, listener)

Specified name ONLY: Remove ALL events of given name. Specified name AND listener function: Remove that given listener from this event name's stack.

Internal or advanced use only.

Parameters
Name Type Description
name String

event name (optional)

listener Function

function to remove (optional)