Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 219 deletions.
37 changes: 36 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
### 0.2.0

- custom services will have `error` invoked if the environment did not provide
the capability. For example:
```js
// environment
var conductor = new Conductor(),
// both services exist
conductor.services.fulfilledCapability = Conductor.Oasis.Service;
conductor.services.unfulfilledCapability = Conductor.Oasis.Service;
// but only one capability is provided to the card
conductor.load("unfulfilled_capability_card.js", 1, { capabilities: ['fulfilledCapability']});

// sandbox
var card = Conductor.card({
consumers: {
fulfilledCapability: Conductor.Oasis.Consumer.extend({
error: function () {
// not invoked
}
}),
unfulfilledCapability: Conductor.Oasis.Consumer.extend({
error: function () {
// invoked
}
})
}
});
```
- added partial support for IE8. `postMessage` is too slow for large messages
(eg transferring jQuery using xhr service) for IE8 to be considered fully
supported.
- added support for IE10, IE9, Firefox, Safari.
- rsvp upgraded to 2.0.0.
- oasis upgraded.

##### Breaking Changes

- Request handlers are no longer passed a resolver. Instead they may return
values directly or return promises if the values need to be retrieved
asynchronously. Returned promises may reject, which will cause promise
rejection to the corresponding service or consumer.
- cards are no longer promise entities, but they have a promise property that
is resolved on sandbox readiness. `card.then``card.promise.then`.
- iframe sandboxes are now started on `appendTo` and not on `load`. This means
Expand All @@ -17,6 +51,7 @@
This file does not need to end in `html` but it does need to be served with an
html content type.

### 0.1.0 / 15 June 2013
### 0.1.0
*15 July 2013*

Initial version.
46 changes: 24 additions & 22 deletions dist/conductor.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,18 +858,16 @@ define("conductor.js-0.2.0",
Conductor.metadataConsumer = function(card) {
var options = card.options;

options.requests.metadataFor = function(resolver, name) {
options.requests.metadataFor = function(name) {
if (name === '*') {
var promises = [], names = [], defered;
var values = [], names = [], defered;

for (var metadataName in options.metadata) {
defered = Conductor.Oasis.RSVP.defer();
card.metadata[metadataName].call(card, defered);
promises.push(defered.promise);
values.push(card.metadata[metadataName].call(card));
names.push(metadataName);
}

Conductor.Oasis.RSVP.all(promises).then(function(sources) {
return Conductor.Oasis.RSVP.all(values).then(function(sources) {
var metadata = {};

for (var i = 0; i < sources.length; i++) {
Expand All @@ -879,11 +877,11 @@ define("conductor.js-0.2.0",
}
}

resolver.resolve(metadata);
return metadata;
});

} else {
card.metadata[name].call(card, resolver);
return card.metadata[name].call(card);
}
};

Expand Down Expand Up @@ -1153,21 +1151,25 @@ define("conductor.js-0.2.0",

Conductor.XHRService = Conductor.Oasis.Service.extend({
requests: {
get: function(promise, url) {
var xhr = new XMLHttpRequest(),
resourceUrl = PathUtils.cardResourceUrl(this.sandbox.options.url, url);

xhr.onreadystatechange = function (a1, a2, a3, a4) {
if (this.readyState === 4) {
if (this.status === 200) {
promise.resolve(this.responseText);
} else {
promise.reject({status: this.status});
get: function(url) {
var service = this;

return new Conductor.Oasis.RSVP.Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest(),
resourceUrl = PathUtils.cardResourceUrl(service.sandbox.options.url, url);

xhr.onreadystatechange = function (a1, a2, a3, a4) {
if (this.readyState === 4) {
if (this.status === 200) {
resolve(this.responseText);
} else {
reject({status: this.status});
}
}
}
};
xhr.open("get", resourceUrl, true);
xhr.send();
};
xhr.open("get", resourceUrl, true);
xhr.send();
});
}
}
});
Expand Down
Loading

0 comments on commit 881ca7b

Please sign in to comment.