1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /* appjet:version 0.1 */
- /* appjet:library */
- // Copyright (c) 2010, Herbert Vojčík
- // Licensed by MIT license (http://www.opensource.org/licenses/mit-license.php)
- // Fake 'storage' to point to 'storage[appjet.appName]'
- // Must be imported before storage (the best is to import it first).
- var old = appjet._native.runLibrary;
- appjet._native.runLibrary = function () {
- var lib = Function.prototype.apply.call(old, this, arguments);
- lib.storage = lib.storage[appjet.appName];
- return lib;
- };
- try { import({}, "storage"); } finally { appjet._native.runLibrary = old; }
- var _hdrWrite = page.body.write,
- _dir, _fb = false;
- function appRun (dir, callback) {
- setupAppDir(dir);
- setupAppPresenter();
- setupAppView();
- setupAppModel();
- if (callback) callback();
- appGo();
- }
- 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() {
- request.method = "POST";
- try {
- _oldFbInit.apply(this, arguments);
- } finally {
- request.method = "GET";
- }
- };
- }
- fb.init();
- _fb = true;
- }
- function setupAppUiGallery () {
- if (_fb) {
- dispatchInject(function post_callback_ui_ () {
- import({}, _dir + "view-gallery").show(true);
- });
- dispatchInject(function get_ui_ () {
- page.setMode("html");
- _hdrWrite = page.head.write;
- request.method = "POST";
- import({}, _dir + "view-gallery").show();
- });
- } else throw "not yet implemented";
- }
- function appGo () {
- mvp();
- _hdrWrite(["<style type='text/css'>", getCss(), "</style>", ""].join("\r\n"));
- }
|