Commit c6f8315c authored by Romain Courteaud's avatar Romain Courteaud

Release version 0.15.0

Add onLoop service.
Allow manualBootstrap.
parent 14dbf92c
This diff is collapsed.
This diff is collapsed.
......@@ -749,6 +749,19 @@ if (typeof document.contains !== 'function') {
return new RSVP.Promise(itsANonResolvableTrap, canceller);
}
function promiseAnimationFrame() {
var request_id;
function canceller() {
window.cancelAnimationFrame(request_id);
}
function resolver(resolve) {
request_id = window.requestAnimationFrame(resolve);
}
return new RSVP.Promise(resolver, canceller);
}
function ajax(url) {
var xhr;
function resolver(resolve, reject) {
......@@ -799,7 +812,8 @@ if (typeof document.contains !== 'function') {
scope_increment = 0,
isAbsoluteOrDataURL = new RegExp('^(?:[a-z]+:)?//|data:', 'i'),
is_page_unloaded = false,
error_list = [];
error_list = [],
bootstrap_deferred_object = new RSVP.defer();
window.addEventListener('error', function (error) {
error_list.push(error);
......@@ -1160,6 +1174,34 @@ if (typeof document.contains !== 'function') {
return this;
};
RenderJSGadget.onLoop = function (callback, delay) {
if (delay === undefined) {
delay = 0;
}
this.__service_list.push(function () {
var queue_loop = new RSVP.Queue(),
wait = function () {
queue_loop
.push(function () {
return RSVP.delay(delay);
})
.push(function () {
// Only loop when the app has the focus
return promiseAnimationFrame();
})
.push(function () {
return callback.apply(this, []);
})
.push(function () {
wait();
});
};
wait();
return queue_loop;
});
return this;
};
function runJob(gadget, name, callback, argument_list) {
var job_promise = new RSVP.Queue()
.push(function () {
......@@ -1410,6 +1452,8 @@ if (typeof document.contains !== 'function') {
RenderJSGadget.declareService;
RenderJSEmbeddedGadget.onEvent =
RenderJSGadget.onEvent;
RenderJSEmbeddedGadget.onLoop =
RenderJSGadget.onLoop;
RenderJSEmbeddedGadget.prototype = new RenderJSGadget();
RenderJSEmbeddedGadget.prototype.constructor = RenderJSEmbeddedGadget;
......@@ -1473,6 +1517,8 @@ if (typeof document.contains !== 'function') {
RenderJSGadget.declareService;
RenderJSIframeGadget.onEvent =
RenderJSGadget.onEvent;
RenderJSIframeGadget.onLoop =
RenderJSGadget.onLoop;
RenderJSIframeGadget.prototype = new RenderJSGadget();
RenderJSIframeGadget.prototype.constructor = RenderJSIframeGadget;
......@@ -1842,6 +1888,8 @@ if (typeof document.contains !== 'function') {
RenderJSGadget.declareService;
tmp_constructor.onEvent =
RenderJSGadget.onEvent;
tmp_constructor.onLoop =
RenderJSGadget.onLoop;
tmp_constructor.prototype = new RenderJSGadget();
tmp_constructor.prototype.constructor = tmp_constructor;
tmp_constructor.prototype.__path = url;
......@@ -1989,6 +2037,16 @@ if (typeof document.contains !== 'function') {
// Bootstrap process. Register the self gadget.
///////////////////////////////////////////////////
// Manually initializes the self gadget if the DOMContentLoaded event
// is triggered before everything was ready.
// (For instance, the HTML-tag for the self gadget gets inserted after
// page load)
renderJS.manualBootstrap = function () {
bootstrap_deferred_object.resolve();
};
function bootstrap() {
var url = removeHash(window.location.href),
TmpConstructor,
......@@ -2054,6 +2112,8 @@ if (typeof document.contains !== 'function') {
RenderJSGadget.declareService;
TmpConstructor.onEvent =
RenderJSGadget.onEvent;
TmpConstructor.onLoop =
RenderJSGadget.onLoop;
TmpConstructor.prototype = new RenderJSGadget();
TmpConstructor.prototype.constructor = TmpConstructor;
TmpConstructor.prototype.__path = url;
......@@ -2182,6 +2242,8 @@ if (typeof document.contains !== 'function') {
RenderJSGadget.declareJob;
TmpConstructor.onEvent =
RenderJSGadget.onEvent;
TmpConstructor.onLoop =
RenderJSGadget.onLoop;
TmpConstructor.declareAcquiredMethod =
RenderJSGadget.declareAcquiredMethod;
TmpConstructor.allowPublicAcquisition =
......@@ -2301,7 +2363,16 @@ if (typeof document.contains !== 'function') {
throw e;
});
}
document.addEventListener('DOMContentLoaded', init, false);
document.addEventListener('DOMContentLoaded',
bootstrap_deferred_object.resolve, false);
// Return Promies/Queue here instead of directly calling init()
return new RSVP.Queue()
.push(function () {
return bootstrap_deferred_object.promise;
})
.push(function () {
return init();
});
});
loading_gadget_promise
......
This diff is collapsed.
{
"name": "renderjs",
"version": "0.14.1",
"version": "0.15.0",
"description": "RenderJs provides HTML5 gadgets",
"main": "dist/renderjs-latest.js",
"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