Przeglądaj źródła

better modularized appstart.js

Herbert Vojčík 14 lat temu
rodzic
commit
29a8e96b90
1 zmienionych plików z 30 dodań i 24 usunięć
  1. 30 24
      lib-app/appstart.js

+ 30 - 24
lib-app/appstart.js

@@ -13,10 +13,8 @@ appjet._native.runLibrary = function () {
 };
 try { import({}, "storage"); } finally { appjet._native.runLibrary = old; }
 
-import("lib-app/globals");
-
 var _hdrWrite = page.body.write,
-  _dir;
+  _dir, _fb = false;
 
 function appRun (dir, callback) {
   setupAppDir(dir);
@@ -30,6 +28,22 @@ function appRun (dir, callback) {
 function setupAppDir (dir) { _dir = dir; }
 
 function setupAppPresenter () {
+  import(_dir + "presenter");
+  import("lib-app/dispatch-plus");
+  page.setPresenter(dispatchPlus);
+}
+
+function setupAppView () {
+  import(_dir + "view");
+  page.setView(getView());
+}
+
+function setupAppModel () {
+  import(_dir + "model");
+  page.setModel(getModel());
+}
+
+function setupFacebook () {
   if (request.isGet && request.path !== '/') {
     var _oldFbInit = fb.init;
     fb.init = function() {
@@ -42,30 +56,22 @@ function setupAppPresenter () {
     };
   }
   fb.init();
-  import(_dir + "presenter");
-  import("lib-app/dispatch-plus");
-  page.setPresenter(dispatchPlus);
+  _fb = true;
 }
 
-function setupAppView () {
-  dispatchInject(function post_callback_ui_ () {
-    import({}, _dir + "view-gallery").show(true);
-  });
-
-  dispatchInject(function get_callback_ui_ () {
-    page.setMode("html");
-    _hdrWrite = page.head.write;
-    request.method = "POST";
-    import({}, _dir + "view-gallery").show();
-  });
-
-  import(_dir + "view");
-  page.setView(getView());
-}
+function setupAppUiGallery () {
+  if (_fb) {
+    dispatchInject(function post_callback_ui_ () {
+      import({}, _dir + "view-gallery").show(true);
+    });
 
-function setupAppModel () {
-  import(_dir + "model");
-  page.setModel(getModel());
+    dispatchInject(function get_callback_ui_ () {
+      page.setMode("html");
+      _hdrWrite = page.head.write;
+      request.method = "POST";
+      import({}, _dir + "view-gallery").show();
+    });
+  } else throw "not yet implemented";
 }
 
 function appGo () {