concord-consortium/lab — pull request #59 by pjanik (2014-01-07 19:08:05+00:00)
Title: Iframe phone refactoring

This is refactoring and cleanup of IFramePhone and Parent Message API. I started work on [this story](https://www.pivotaltracker.com/s/projects/442903/stories/63248748) and then just did more changes to make APIs more consistent.

The main difference is that we used to send messages like:
```javascript
{
type: "someType",
prop1: "val1",
prop2: "val2"
}
```
and:
```javascript
{
type: "someType",
values: {
prop1: "val1",
prop2: "val2"
}
}
```
and sometimes mix of them:
```javascript
{
type: "someType",
prop1: "val1",
values: {
prop2: "val2"
}
}
```
On the one side of communication (in IFramePhone) only "values" property was passed to listeners, while on the other side (in Parent Message Controller), the whole message object pass passed to listeners. In general there was confusing mix of various patterns and none of them was used consequently. Sometimes it was causing problems like in the mentioned PT story.

This pull request unifies messages format to:
```javascript
{
type: "someType",
content: {
prop1: "val1",
prop2: "val2"
}
}
```
both in IFramePhone and Parent Message Controller / API.

Also API of IFramePhone.post() and ParentMessageController.post() was simplified and now looks like:
```javascript
.post(type, content)
.post("someType", { ... });
```
instead of:
```javascript
.post(messageObj);
.post({type: "someType", values: { ... } });
```
Part of API provided by IFramePhone was simplified too, e.g.:
```javascript
.post('get', 'timeStep');
// instead of:
.post({type: 'get', propertyName: 'timeStep'});

.post('observe', 'parameter1');
// instead of:
.post({type: 'observe', propertyName: 'parameter1'});
// etc.
```

The application.js, main consumer of IFramePhone in Lab repo, was updated and should work fine with new API.
Obviously these changes break backward compatibility (ITSI?).