1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /* appjet:version 0.1 */
- /* appjet:library */
- // (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; }
- import("lib-app/globals");
- var _hdrWrite = page.body.write,
- _dir;
- function appRun (dir, callback) {
- setupAppDir(dir);
- setupAppPresenter();
- setupAppView();
- setupAppModel();
- if (callback) callback();
- appGo();
- }
- function setupAppDir (dir) { _dir = dir; }
- function setupAppPresenter () {
- 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();
- import(_dir + "presenter");
- import("lib-app/dispatch-plus");
- page.setPresenter(dispatchPlus);
- }
- 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 setupAppModel () {
- import(_dir + "model");
- page.setModel(getModel());
- }
- function appGo () {
- mvp();
- _hdrWrite(["<style type='text/css'>", getCss(), "</style>", ""].join("\r\n"));
- }
|