Commit 3f1110c4 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style/erp5_web_renderjs_ui] Update renderJS 0.14.0

parent 7c8fc367
...@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') { ...@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') {
}); });
} }
function clearGadgetInternalParameters(g) { function clearGadgetInternalParameters() {
g.__sub_gadget_dict = {}; this.__sub_gadget_dict = {};
createMonitor(g); createMonitor(this);
} }
function loadSubGadgetDOMDeclaration(g) { function loadSubGadgetDOMDeclaration() {
var element_list = g.element.querySelectorAll('[data-gadget-url]'), var element_list = this.element.querySelectorAll('[data-gadget-url]'),
element, element,
promise_list = [], promise_list = [],
scope, scope,
url, url,
sandbox, sandbox,
i; i,
context = this;
function prepareReportGadgetDeclarationError(scope) {
return function (error) {
var aq_dict = context.__acquired_method_dict || {},
method_name = 'reportGadgetDeclarationError';
if (aq_dict.hasOwnProperty(method_name)) {
return aq_dict[method_name].apply(context,
[arguments, scope]);
}
throw error;
};
}
for (i = 0; i < element_list.length; i += 1) { for (i = 0; i < element_list.length; i += 1) {
element = element_list[i]; element = element_list[i];
...@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') { ...@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') {
url = element.getAttribute("data-gadget-url"); url = element.getAttribute("data-gadget-url");
sandbox = element.getAttribute("data-gadget-sandbox"); sandbox = element.getAttribute("data-gadget-sandbox");
if (url !== null) { if (url !== null) {
promise_list.push(g.declareGadget(url, { promise_list.push(
context.declareGadget(url, {
element: element, element: element,
scope: scope || undefined, scope: scope || undefined,
sandbox: sandbox || undefined sandbox: sandbox || undefined
})); })
.push(undefined, prepareReportGadgetDeclarationError(scope))
);
} }
} }
...@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') { ...@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.setState = function (state_dict) { RenderJSGadget.setState = function (state_dict) {
var json_state = JSON.stringify(state_dict); var json_state = JSON.stringify(state_dict);
return this.ready(function () { this.__ready_list.unshift(function () {
this.state = JSON.parse(json_state); this.state = JSON.parse(json_state);
}); });
return this;
}; };
RenderJSGadget.onStateChange = function (callback) { RenderJSGadget.onStateChange = function (callback) {
this.prototype.__state_change_callback = callback; this.prototype.__state_change_callback = callback;
...@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') { ...@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.declareAcquiredMethod("aq_reportServiceError", RenderJSGadget.declareAcquiredMethod("aq_reportServiceError",
"reportServiceError"); "reportServiceError");
RenderJSGadget.declareAcquiredMethod("aq_reportGadgetDeclarationError",
"reportGadgetDeclarationError");
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.allowPublicAcquisition // RenderJSGadget.allowPublicAcquisition
...@@ -1461,6 +1480,17 @@ if (typeof document.contains !== 'function') { ...@@ -1461,6 +1480,17 @@ if (typeof document.contains !== 'function') {
gadget_instance = new RenderJSIframeGadget(); gadget_instance = new RenderJSIframeGadget();
setAqParent(gadget_instance, parent_gadget); setAqParent(gadget_instance, parent_gadget);
iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
iframe.addEventListener('error', function (error) {
iframe_loading_deferred.reject(error);
});
iframe.addEventListener('load', function () {
return RSVP.timeout(5000)
.fail(function () {
iframe_loading_deferred.reject(
new Error('Timeout while loading: ' + url)
);
});
});
// gadget_instance.element.setAttribute("seamless", "seamless"); // gadget_instance.element.setAttribute("seamless", "seamless");
iframe.setAttribute("src", url); iframe.setAttribute("src", url);
gadget_instance.__path = url; gadget_instance.__path = url;
...@@ -1524,18 +1554,7 @@ if (typeof document.contains !== 'function') { ...@@ -1524,18 +1554,7 @@ if (typeof document.contains !== 'function') {
trans.delayReturn(true); trans.delayReturn(true);
}); });
return RSVP.any([ return iframe_loading_deferred.promise;
iframe_loading_deferred.promise,
// Timeout to prevent non renderJS embeddable gadget
// XXX Maybe using iframe.onload/onerror would be safer?
new RSVP.Queue()
.push(function () {
return RSVP.timeout(5000);
})
.push(undefined, function () {
throw new Error('Timeout while loading: ' + url);
})
]);
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -2283,8 +2302,8 @@ if (typeof document.contains !== 'function') { ...@@ -2283,8 +2302,8 @@ if (typeof document.contains !== 'function') {
return fct.call(g, g); return fct.call(g, g);
}; };
} }
TmpConstructor.ready(function (g) { TmpConstructor.ready(function () {
return startService(g); return startService(this);
}); });
loading_gadget_promise.push(ready_wrapper); loading_gadget_promise.push(ready_wrapper);
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.51226.25726.38263</string> </value> <value> <string>956.46086.45265.8004</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1481043805.03</float> <float>1484732189.17</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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