ShiftForward/mucuchies — pull request #6 by ruippeixotog (2014-06-13 11:41:58+00:00)
Title: Composite widget

This pull request adds an abstract widget class which allows the allocation of more than one widget to the same position in the grid. It incorporates an embedded rotation logic which rotates between the various widgets in a round-robin manner every 10 seconds. A usage example is:

```javascript
{
pos: [1, 3],
widget: 'Dashboard.CompositeWidget',
args: {
widgets: [
{
widget: 'Dashboard.ClockWidget',
source: 'Dashboard.TimeSource'
},
{
widget: 'Dashboard.WeatherWidget',
source: 'Dashboard.WeatherSource',
sourceArgs: { woeId: 742676 }
}
]
}
}
```

The widget does not require an attached source. However, if a source is attached, it is used to change the widget shown at any given time, being expected data in the form of widget numeric indices:

```javascript
rotateSource: {
className: 'Dashboard.PeriodicSource',
args: {
period: 2000,
dataUpdate: function(callback) {
callback(Math.floor(Math.random() * 2));
}
}
}

(...)

{
pos: [1, 3],
widget: 'Dashboard.CompositeWidget',
source: 'rotateSource',
args: {
autoRotate: false,
widgets: [
{
widget: 'Dashboard.ClockWidget',
source: 'Dashboard.TimeSource'
},
{
widget: 'Dashboard.WeatherWidget',
source: 'Dashboard.WeatherSource',
sourceArgs: { woeId: 742676 }
}
]
}
}
```