From 4c0d7bf8e869ef5772838a31656902b5a6da6d11 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 21 Apr 2017 16:51:32 +0200 Subject: [PATCH] support multiple calls to cryptpad.ready --- www/common/cryptpad-common.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 68d2745d2..fce8b58e6 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1129,13 +1129,22 @@ define([ }; - common.ready = function (f) { - var block = 0; + common.ready = (function () { var env = {}; + var initialized = false; + + return function (f) { + if (initialized) { + return void window.setTimeout(function () { + f(void 0, env); + }); + } + var block = 0; var cb = function () { block--; if (!block) { + initialized = true; f(void 0, env); } }; @@ -1229,6 +1238,8 @@ define([ }, common); }; + }()); + $(function () { Messages._applyTranslation(); });