Commit 4f84be88 authored by Xiaowu Zhang's avatar Xiaowu Zhang

Release version 0.7.3

parent a289140e
This diff is collapsed.
This diff is collapsed.
...@@ -665,7 +665,7 @@ ...@@ -665,7 +665,7 @@
* http://www.renderjs.org/documentation * http://www.renderjs.org/documentation
*/ */
(function (document, window, RSVP, DOMParser, Channel, MutationObserver, (function (document, window, RSVP, DOMParser, Channel, MutationObserver,
Node, undefined) { Node) {
"use strict"; "use strict";
var gadget_model_dict = {}, var gadget_model_dict = {},
...@@ -822,7 +822,7 @@ ...@@ -822,7 +822,7 @@
}; };
}; };
Monitor.prototype = Object.create(Promise.prototype); Monitor.prototype = Object.create(RSVP.Promise.prototype);
Monitor.prototype.constructor = Monitor; Monitor.prototype.constructor = Monitor;
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -1614,6 +1614,7 @@ ...@@ -1614,6 +1614,7 @@
notifyReady, notifyReady,
notifyDeclareMethod, notifyDeclareMethod,
gadget_ready = false, gadget_ready = false,
iframe_top_gadget,
last_acquisition_gadget; last_acquisition_gadget;
// Create the gadget class for the current url // Create the gadget class for the current url
...@@ -1621,25 +1622,33 @@ ...@@ -1621,25 +1622,33 @@
throw new Error("bootstrap should not be called twice"); throw new Error("bootstrap should not be called twice");
} }
loading_klass_promise = new RSVP.Promise(function (resolve, reject) { loading_klass_promise = new RSVP.Promise(function (resolve, reject) {
if (window.self === window.top) {
last_acquisition_gadget = new RenderJSGadget(); last_acquisition_gadget = new RenderJSGadget();
last_acquisition_gadget.__acquired_method_dict = { last_acquisition_gadget.__acquired_method_dict = {
getTopURL: function () { getTopURL: function () {
return url; return url;
}, },
reportServiceError: function (param_list) { reportServiceError: function (param_list) {
letsCrash(param_list[0]); letsCrash(param_list[0]);
} }
}; };
// Stop acquisition on the last acquisition gadget // Stop acquisition on the last acquisition gadget
// Do not put this on the klass, as their could be multiple instances // Do not put this on the klass, as their could be multiple instances
last_acquisition_gadget.__aq_parent = function (method_name) { last_acquisition_gadget.__aq_parent = function (method_name) {
throw new renderJS.AcquisitionError( throw new renderJS.AcquisitionError(
"No gadget provides " + method_name "No gadget provides " + method_name
); );
}; };
//we need to determine tmp_constructor's value before exit bootstrap
//because of function : renderJS
//but since the channel checking is async,
//we can't use code structure like:
// if channel communication is ok
// tmp_constructor = RenderJSGadget
// else
// tmp_constructor = RenderJSEmbeddedGadget
if (window.self === window.top) {
// XXX Copy/Paste from declareGadgetKlass // XXX Copy/Paste from declareGadgetKlass
tmp_constructor = function () { tmp_constructor = function () {
RenderJSGadget.call(this); RenderJSGadget.call(this);
...@@ -1678,15 +1687,6 @@ ...@@ -1678,15 +1687,6 @@
tmp_constructor.prototype.__path = url; tmp_constructor.prototype.__path = url;
root_gadget = new RenderJSEmbeddedGadget(); root_gadget = new RenderJSEmbeddedGadget();
// Bind calls to renderJS method on the instance
embedded_channel.bind("methodCall", function (trans, v) {
root_gadget[v[0]].apply(root_gadget, v[1]).then(function (g) {
trans.complete(g);
}).fail(function (e) {
trans.error(e.toString());
});
trans.delayReturn(true);
});
// Notify parent about gadget instanciation // Notify parent about gadget instanciation
notifyReady = function () { notifyReady = function () {
...@@ -1734,9 +1734,9 @@ ...@@ -1734,9 +1734,9 @@
tmp_constructor.allowPublicAcquisition = tmp_constructor.allowPublicAcquisition =
RenderJSGadget.allowPublicAcquisition; RenderJSGadget.allowPublicAcquisition;
// Define __aq_parent to inform parent window //Default: Define __aq_parent to inform parent window
tmp_constructor.prototype.__aq_parent = function (method_name, tmp_constructor.prototype.__aq_parent = function (method_name,
argument_list) { argument_list, time_out) {
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
embedded_channel.call({ embedded_channel.call({
method: "acquire", method: "acquire",
...@@ -1749,7 +1749,8 @@ ...@@ -1749,7 +1749,8 @@
}, },
error: function (e) { error: function (e) {
reject(e); reject(e);
} },
timeout: time_out
}); });
}); });
}; };
...@@ -1878,13 +1879,40 @@ ...@@ -1878,13 +1879,40 @@
} }
if (window.top !== window.self) { if (window.top !== window.self) {
tmp_constructor.ready(function () { //checking channel should be done before sub gadget's declaration
var base = document.createElement('base'); //__ready_list:
return root_gadget.__aq_parent('getTopURL', []) //0: clearGadgetInternalParameters
//1: loadSubGadgetDOMDeclaration
//.....
tmp_constructor.__ready_list.splice(1, 0, function () {
return root_gadget.__aq_parent('getTopURL', [], 100)
.then(function (topURL) { .then(function (topURL) {
var base = document.createElement('base');
base.href = topURL; base.href = topURL;
base.target = "_top"; base.target = "_top";
document.head.appendChild(base); document.head.appendChild(base);
//the channel is ok
//so bind calls to renderJS method on the instance
embedded_channel.bind("methodCall", function (trans, v) {
root_gadget[v[0]].apply(root_gadget, v[1])
.then(function (g) {
trans.complete(g);
}).fail(function (e) {
trans.error(e.toString());
});
trans.delayReturn(true);
});
})
.fail(function (error) {
if (error === "timeout_error") {
//the channel fail
//we consider current gadget is parent gadget
//redifine last acquisition gadget
iframe_top_gadget = true;
setAqParent(root_gadget, last_acquisition_gadget);
} else {
throw error;
}
}); });
}); });
} }
...@@ -1916,7 +1944,12 @@ ...@@ -1916,7 +1944,12 @@
notifyReady(); notifyReady();
}) })
.fail(function (e) { .fail(function (e) {
embedded_channel.notify({method: "failed", params: e.toString()}); //top gadget in iframe
if (iframe_top_gadget) {
letsCrash(e);
} else {
embedded_channel.notify({method: "failed", params: e.toString()});
}
throw e; throw e;
}); });
} }
......
This diff is collapsed.
{ {
"name": "renderjs", "name": "renderjs",
"version": "0.7.2", "version": "0.7.3",
"description": "RenderJs provides HTML5 gadgets", "description": "RenderJs provides HTML5 gadgets",
"main": "dist/renderjs-latest.js", "main": "dist/renderjs-latest.js",
"dependencies": { "dependencies": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment