Procházet zdrojové kódy

Works with concatenated-for-node-js scenario.

Herbert Vojčík před 11 roky
rodič
revize
4293a7cd21
1 změnil soubory, kde provedl 15 přidání a 6 odebrání
  1. 15 6
      js/init.js

+ 15 - 6
js/init.js

@@ -1,9 +1,18 @@
-setTimeout(function () {
-    smalltalk.initialize();
+(function () {
+    var inBrowser = typeof amber !== "undefined" && typeof amber.load === "function";
+    function init() {
+        smalltalk.initialize();
 
-    /* Similar to jQuery(document).ready() */
+        /* Similar to jQuery(document).ready() */
 
-    if (this.amber && this.amber.smalltalkReady) {
-        this.amber.smalltalkReady();
+        if (inBrowser && amber.smalltalkReady) {
+            amber.smalltalkReady();
+        }
     }
-}, 0);
+
+    if (inBrowser) {
+        setTimeout(init, 0);
+    } else {
+        init();
+    }
+})();