base.js 19.5 KB
Newer Older
NoSubject's avatar
NoSubject 已提交
1 2 3 4
layout = window.layout || {};
layout.desktop = layout;
var locate = window.location;
layout.protocol = locate.protocol;
R
roo00 已提交
5
layout.inBrowser = true;
NoSubject's avatar
NoSubject 已提交
6
layout.session = layout.session || {};
R
roo00 已提交
7 8
layout.debugger = (locate.href.toString().indexOf("debugger") !== -1);
layout.anonymous = (locate.href.toString().indexOf("anonymous") !== -1);
NoSubject's avatar
NoSubject 已提交
9 10 11
o2.xApplication = o2.xApplication || {};

o2.xDesktop = o2.xDesktop || {};
R
roo00 已提交
12
o2.xDesktop.requireApp = function (module, clazz, callback, async) {
NoSubject's avatar
NoSubject 已提交
13 14
    o2.requireApp(module, clazz, callback, async);
};
R
roo00 已提交
15
o2.addReady(function () {
NoSubject's avatar
NoSubject 已提交
16 17
    //兼容方法
    Element.implement({
R
roo00 已提交
18
        "makeLnk": function (options) { }
NoSubject's avatar
NoSubject 已提交
19
    });
NoSubject's avatar
NoSubject 已提交
20 21 22 23 24

    var loadingNode = $("loaddingArea");
    var loadeds = 0;
    var loadCount = 15;
    var size = document.body.getSize();
R
roo00 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    var _closeLoadingNode = function () {
        if (loadingNode) {
            loadingNode.destroy();
            loadingNode = null;
        }

    };
    var _loadProgressBar = function (complete) {
        if (loadingNode) {
            if (complete) {
                loadingNode.setStyles({ "width": "" + size.x + "px" });
                //loadingNode.set('morph', {duration: 100}).morph({"width": ""+size.x+"px"});
                window.setTimeout(_closeLoadingNode, 500);
            } else {
                loadeds++;
                var p = (loadeds / loadCount) * size.x;
                loadingNode.setStyles({ "width": "" + p + "px" });
                //loadingNode.set('morph', {duration: 100}).morph({"width": ""+p+"px"});
                if (loadeds >= loadCount) window.setTimeout(_closeLoadingNode, 500);
            }
NoSubject's avatar
NoSubject 已提交
45 46 47
        }
    };

NoSubject's avatar
NoSubject 已提交
48 49
    //异步载入必要模块
    layout.config = null;
R
roo00 已提交
50 51 52 53 54 55 56
    var lp = o2.session.path + "/lp/" + o2.language + ".js";
    debugger;
    o2.load(lp, function () {
        _loadProgressBar();
        if (layout.config && o2.xDesktop.getServiceAddress) _getDistribute(function () { _load(); });
    });
    var modules = ["MWF.xDesktop.Common", "MWF.xAction.RestActions"];
NoSubject's avatar
NoSubject 已提交
57
    MWF.require(modules, {
R
roo00 已提交
58 59 60
        "onSuccess": function () {
            console.log("MWF.xDesktop.Common  MWF.xAction.RestActions");
            if (layout.config && o2.LP) _getDistribute(function () { _load(); });
NoSubject's avatar
NoSubject 已提交
61
        },
R
roo00 已提交
62
        "onEvery": function () {
NoSubject's avatar
NoSubject 已提交
63 64
            _loadProgressBar();
        }
NoSubject's avatar
NoSubject 已提交
65
    });
R
roo00 已提交
66
    o2.getJSON("/x_desktop/res/config/config.json", function (config) {
NoSubject's avatar
NoSubject 已提交
67
        _loadProgressBar();
NoSubject's avatar
NoSubject 已提交
68
        layout.config = config;
R
roo00 已提交
69
        if (o2.xDesktop.getServiceAddress && o2.LP) _getDistribute(function () { _load(); });
NoSubject's avatar
NoSubject 已提交
70 71
    });

R
roo00 已提交
72 73
    var _getDistribute = function (callback) {
        if (layout.config.app_protocol === "auto") {
NoSubject's avatar
NoSubject 已提交
74 75
            layout.config.app_protocol = window.location.protocol;
        }
R
roo00 已提交
76
        MWF.xDesktop.getServiceAddress(layout.config, function (service, center) {
NoSubject's avatar
NoSubject 已提交
77 78
            layout.serviceAddressList = service;
            layout.centerServer = center;
R
roo00 已提交
79
            _loadProgressBar();
NoSubject's avatar
NoSubject 已提交
80 81 82 83
            if (callback) callback();
        }.bind(this));
    };

R
roo00 已提交
84 85
    var _load = function () {
        var _loadApp = function (json) {
NoSubject's avatar
NoSubject 已提交
86 87 88 89
            //用户已经登录
            layout.user = json.data;
            layout.session = {};
            layout.session.user = json.data;
R
roo00 已提交
90 91
            (function (layout) {
                var _loadResource = function (callback) {
NoSubject's avatar
NoSubject 已提交
92
                    var isLoadedA = false;
NoSubject's avatar
NoSubject 已提交
93
                    var isLoadedB = false;
NoSubject's avatar
NoSubject 已提交
94 95 96 97 98 99 100 101 102 103 104
                    //var isLoadedC = false;

                    var modules = [
                        "o2.xDesktop.Dialog",
                        "MWF.xDesktop.UserData",
                        "MWF.xDesktop.Access",
                        "MWF.widget.UUID",
                        "MWF.xDesktop.Menu",
                        "MWF.xDesktop.shortcut",
                        "MWF.widget.PinYin",
                        "MWF.xDesktop.Access",
R
roo00 已提交
105
                        // "MWF.xDesktop.MessageMobile"
NoSubject's avatar
NoSubject 已提交
106 107
                    ];
                    //MWF.xDesktop.requireApp("Common", "", null, false);
R
roo00 已提交
108
                    var _check = function () { if (isLoadedA && isLoadedB) if (callback) callback(); };
NoSubject's avatar
NoSubject 已提交
109

R
roo00 已提交
110 111
                    o2.load(["/o2_lib/mootools/plugin/mBox.min.js"], function () { _loadProgressBar(); isLoadedA = true; _check(); });
                    o2.require("MWF.widget.Common", function () {
NoSubject's avatar
NoSubject 已提交
112 113
                        _loadProgressBar();
                        o2.require(modules, {
R
roo00 已提交
114 115
                            "onSuccess": function () {
                                o2.requireApp("Common", "", function () { _loadProgressBar(); isLoadedB = true; _check(); })
NoSubject's avatar
NoSubject 已提交
116
                            },
R
roo00 已提交
117
                            "onEvery": function () {
NoSubject's avatar
NoSubject 已提交
118 119
                                _loadProgressBar();
                            }
NoSubject's avatar
NoSubject 已提交
120 121 122 123
                        });
                    });
                };

R
roo00 已提交
124 125 126 127
                var _loadContent = function () {
                    _loadResource(function () {
                        _loadProgressBar(true);
                        while (layout.readys && layout.readys.length) {
NoSubject's avatar
NoSubject 已提交
128
                            layout.readys.shift().apply(window);
NoSubject's avatar
NoSubject 已提交
129
                        }
R
roo00 已提交
130

NoSubject's avatar
NoSubject 已提交
131 132 133 134 135
                    });
                };

                _loadContent();
            })(layout);
R
roo00 已提交
136 137
        };
        //先判断用户是否登录
R
roo00 已提交
138
        MWF.Actions.get("x_organization_assemble_authentication").getAuthentication(function (json) {
R
roo00 已提交
139
            //已经登录
R
roo00 已提交
140 141 142 143
            _loadProgressBar();
            _loadApp(json);
        }.bind(this), function (json) {
            _loadProgressBar();
R
roo00 已提交
144
            //允许匿名访问
R
roo00 已提交
145 146
            if (layout.anonymous) {
                _loadProgressBar(true);
R
roo00 已提交
147
                _loadApp({
R
roo00 已提交
148 149 150 151 152
                    user: "anonymous",
                    session: {
                        user: {
                            name: "anonymous",
                            roleList: []
R
roo00 已提交
153 154 155
                        }
                    }
                });
R
roo00 已提交
156
            } else {
R
roo00 已提交
157 158
                //用户未经登录
                //打开登录页面
R
roo00 已提交
159
                var _loadResource = function (callback) {
R
roo00 已提交
160 161 162
                    var isLoadedA = false;
                    var isLoadedB = false;
                    //var isLoadedC = false;
NoSubject's avatar
NoSubject 已提交
163

R
roo00 已提交
164
                    //var lp = o2.session.path+"/lp/"+o2.language+".js";
R
roo00 已提交
165 166 167 168 169 170 171 172 173 174 175 176
                    var modules = [
                        "o2.xDesktop.Dialog",
                        "MWF.xDesktop.UserData",
                        "MWF.xDesktop.Access",
                        "MWF.widget.UUID",
                        "MWF.xDesktop.Menu",
                        "MWF.xDesktop.shortcut",
                        "MWF.widget.PinYin",
                        "MWF.xDesktop.Access",
                        "MWF.xDesktop.MessageMobile"
                    ];
                    //MWF.xDesktop.requireApp("Common", "", null, false);
R
roo00 已提交
177
                    var _check = function () { if (isLoadedA && isLoadedB) if (callback) callback(); };
NoSubject's avatar
NoSubject 已提交
178

R
roo00 已提交
179 180
                    o2.load(["/o2_lib/mootools/plugin/mBox.min.js"], function () { _loadProgressBar(); isLoadedA = true; _check(); });
                    o2.require("MWF.widget.Common", function () {
R
roo00 已提交
181 182
                        _loadProgressBar();
                        o2.require(modules, {
R
roo00 已提交
183 184
                            "onSuccess": function () {
                                o2.requireApp("Common", "", function () { isLoadedB = true; _check(); })
R
roo00 已提交
185
                            },
R
roo00 已提交
186
                            "onEvery": function () {
R
roo00 已提交
187 188 189
                                _loadProgressBar();
                            }
                        });
NoSubject's avatar
NoSubject 已提交
190
                    });
R
roo00 已提交
191
                };
R
roo00 已提交
192 193
                _loadResource(function () {
                    _loadProgressBar(true);
R
roo00 已提交
194
                    layout.openLogin();
NoSubject's avatar
NoSubject 已提交
195
                });
R
roo00 已提交
196
            }
NoSubject's avatar
NoSubject 已提交
197 198
        });

R
roo00 已提交
199
        layout.openLogin = function () {
NoSubject's avatar
NoSubject 已提交
200
            MWF.require("MWF.widget.Common", null, false);
R
roo00 已提交
201
            MWF.require("MWF.xDesktop.Authentication", function () {
NoSubject's avatar
NoSubject 已提交
202 203 204 205 206 207 208 209 210
                var authentication = new MWF.xDesktop.Authentication({
                    "onLogin": _load.bind(layout)
                });
                authentication.loadLogin(document.body);
            });
        };
    };
});

R
roo00 已提交
211
(function (layout) {
NoSubject's avatar
NoSubject 已提交
212
    layout.readys = [];
R
roo00 已提交
213 214 215
    layout.addReady = function () {
        for (var i = 0; i < arguments.length; i++) {
            if (o2.typeOf(arguments[i]) === "function") layout.readys.push(arguments[i]);
NoSubject's avatar
NoSubject 已提交
216 217
        }
    };
R
roo00 已提交
218
    var _requireApp = function (appNames, callback, clazzName) {
NoSubject's avatar
NoSubject 已提交
219 220
        var appPath = appNames.split(".");
        var baseObject = o2.xApplication;
R
roo00 已提交
221 222
        appPath.each(function (path, i) {
            if (i < (appPath.length - 1)) {
NoSubject's avatar
NoSubject 已提交
223
                baseObject[path] = baseObject[path] || {};
R
roo00 已提交
224 225
            } else {
                baseObject[path] = baseObject[path] || { "options": Object.clone(MWF.xApplication.Common.options) };
NoSubject's avatar
NoSubject 已提交
226 227 228 229 230 231
            }
            baseObject = baseObject[path];
        }.bind(this));
        if (!baseObject.options) baseObject.options = Object.clone(MWF.xApplication.Common.options);

        var _lpLoaded = false;
R
roo00 已提交
232 233
        MWF.xDesktop.requireApp(appNames, "lp." + o2.language, {
            "failure": function () {
NoSubject's avatar
NoSubject 已提交
234 235 236
                MWF.xDesktop.requireApp(appNames, "lp.zh-cn", null, false);
            }.bind(this)
        }, false);
R
roo00 已提交
237 238

        MWF.xDesktop.requireApp(appNames, clazzName, function () {
NoSubject's avatar
NoSubject 已提交
239 240 241
            if (callback) callback(baseObject);
        });
    };
R
roo00 已提交
242
    var _createNewApplication = function (e, appNamespace, appName, options, statusObj) {
NoSubject's avatar
NoSubject 已提交
243 244 245 246
        var app = new appNamespace["Main"](this, options);
        app.desktop = layout;
        app.inBrowser = true;
        app.status = statusObj;
R
roo00 已提交
247

NoSubject's avatar
NoSubject 已提交
248 249 250
        app.load(true);

        var appId = appName;
R
roo00 已提交
251
        if (options.appId) {
NoSubject's avatar
NoSubject 已提交
252
            appId = options.appId;
R
roo00 已提交
253 254
        } else {
            if (appNamespace.options.multitask) appId = appId + "-" + (new MWF.widget.UUID());
NoSubject's avatar
NoSubject 已提交
255 256 257
        }
        app.appId = appId;
        layout.app = app;
NoSubject's avatar
NoSubject 已提交
258
        layout.desktop.currentApp = app;
NoSubject's avatar
NoSubject 已提交
259 260 261 262 263

        var mask = document.getElementById("appContentMask");
        if (mask) mask.destroy();
    };

R
roo00 已提交
264
    var _openWorkAndroid = function (options) {
NoSubject's avatar
NoSubject 已提交
265 266
        if (window.o2android && window.o2android.openO2Work) {
            if (options.workId) {
NoSubject's avatar
NoSubject 已提交
267
                window.o2android.openO2Work(options.workId, "", options.title || "");
NoSubject's avatar
NoSubject 已提交
268
            } else if (options.workCompletedId) {
NoSubject's avatar
NoSubject 已提交
269
                window.o2android.openO2Work("", options.workCompletedId, options.title || "");
NoSubject's avatar
NoSubject 已提交
270 271 272 273 274
            }
            return true;
        }
        return false;
    };
R
roo00 已提交
275
    var _openWorkIOS = function (options) {
NoSubject's avatar
NoSubject 已提交
276 277 278 279 280
        if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2Work) {
            if (options.workId) {
                window.webkit.messageHandlers.openO2Work.postMessage({
                    "work": options.workId,
                    "workCompleted": "",
NoSubject's avatar
NoSubject 已提交
281
                    "title": options.title || ""
NoSubject's avatar
NoSubject 已提交
282 283 284 285 286
                });
            } else if (options.workCompletedId) {
                window.webkit.messageHandlers.openO2Work.postMessage({
                    "work": "",
                    "workCompleted": options.workCompletedId,
NoSubject's avatar
NoSubject 已提交
287
                    "title": options.title || ""
NoSubject's avatar
NoSubject 已提交
288 289 290 291 292 293
                });
            }
            return true;
        }
        return false;
    };
R
roo00 已提交
294
    var _openWorkHTML = function (options) {
NoSubject's avatar
NoSubject 已提交
295 296 297 298 299 300 301 302
        var uri = new URI(window.location.href);
        var redirectlink = uri.getData("redirectlink");
        if (!redirectlink) {
            redirectlink = encodeURIComponent(locate.pathname + locate.search);
        } else {
            redirectlink = encodeURIComponent(redirectlink);
        }
        if (options.workId) {
R
roo00 已提交
303
            window.location = "workmobilewithaction.html?workid=" + options.workId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=" + redirectlink;
NoSubject's avatar
NoSubject 已提交
304
        } else if (options.workCompletedId) {
R
roo00 已提交
305
            window.location = "workmobilewithaction.html?workcompletedid=" + options.workCompletedId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=" + redirectlink;
NoSubject's avatar
NoSubject 已提交
306 307
        }
    };
R
roo00 已提交
308
    var _openWork = function (options) {
NoSubject's avatar
NoSubject 已提交
309 310
        if (!_openWorkAndroid(options)) if (!_openWorkIOS(options)) _openWorkHTML(options);
    };
R
roo00 已提交
311 312
    var _openDocument = function (appNames, options, statusObj) {
        var title = typeOf(options) === "object" ? (options.docTitle || options.title) : "";
NoSubject's avatar
NoSubject 已提交
313
        title = title || "";
R
roo00 已提交
314 315
        var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
        if (window.o2android && window.o2android.openO2CmsDocument) {
NoSubject's avatar
NoSubject 已提交
316
            window.o2android.openO2CmsDocument(options.documentId, title);
R
roo00 已提交
317 318 319 320
        } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2CmsDocument) {
            window.webkit.messageHandlers.openO2CmsDocument.postMessage({ "docId": options.documentId, "docTitle": title });
        } else {
            window.location = "appMobile.html?" + par + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
321 322
        }
    };
R
roo00 已提交
323 324 325
    var _openCms = function (appNames, options, statusObj) {
        var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
        if (window.o2android && window.o2android.openO2CmsApplication) {
NoSubject's avatar
NoSubject 已提交
326
            window.o2android.openO2CmsApplication(options.columnId, options.title || "");
R
roo00 已提交
327
        } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2CmsApplication) {
NoSubject's avatar
NoSubject 已提交
328
            window.webkit.messageHandlers.openO2CmsApplication.postMessage(options.columnId);
R
roo00 已提交
329 330
        } else {
            window.location = "appMobile.html?" + par + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
331 332
        }
    };
R
roo00 已提交
333 334 335
    var _openMeeting = function (appNames, options, statusObj) {
        var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
        if (window.o2android && window.o2android.openO2Meeting) {
NoSubject's avatar
NoSubject 已提交
336
            window.o2android.openO2Meeting("");
R
roo00 已提交
337
        } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2Meeting) {
NoSubject's avatar
NoSubject 已提交
338
            window.webkit.messageHandlers.openO2Meeting.postMessage("");
R
roo00 已提交
339 340
        } else {
            window.location = "appMobile.html?" + par + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
341 342 343
        }
    };

R
roo00 已提交
344 345 346
    var _openCalendar = function (appNames, options, statusObj) {
        var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
        if (window.o2android && window.o2android.openO2Calendar) {
NoSubject's avatar
NoSubject 已提交
347
            window.o2android.openO2Calendar("");
R
roo00 已提交
348
        } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2Calendar) {
NoSubject's avatar
NoSubject 已提交
349
            window.webkit.messageHandlers.openO2Calendar.postMessage("");
R
roo00 已提交
350 351
        } else {
            window.location = "appMobile.html?" + par + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
352 353
        }
    };
R
roo00 已提交
354 355
    var _openTaskCenter = function (appNames, options, statusObj) {
        var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
NoSubject's avatar
NoSubject 已提交
356
        var tab = ((options && options.navi) ? options.navi : "task").toLowerCase();
R
roo00 已提交
357 358
        if (tab === "done") tab = "taskCompleted";
        if (tab === "readed") tab = "readCompleted";
NoSubject's avatar
NoSubject 已提交
359

R
roo00 已提交
360
        if (window.o2android && window.o2android.openO2WorkSpace) {
NoSubject's avatar
NoSubject 已提交
361
            window.o2android.openO2WorkSpace(tab);
R
roo00 已提交
362
        } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openO2WorkSpace) {
NoSubject's avatar
NoSubject 已提交
363
            window.webkit.messageHandlers.openO2WorkSpace.postMessage(tab);
R
roo00 已提交
364 365
        } else {
            window.location = "appMobile.html?" + par + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
366 367 368
        }
    };

R
roo00 已提交
369
    var _openApplicationMobile = function (appNames, options, statusObj) {
NoSubject's avatar
NoSubject 已提交
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
        switch (appNames) {
            case "process.Work":
                _openWork(options);
                break;
            case "cms.Document":
                _openDocument(appNames, options, statusObj);
                break;
            case "cms.Module":
                _openCms(appNames, options, statusObj);
                break;
            case "Meeting":
                _openMeeting(appNames, options, statusObj);
                break;
            case "Calendar":
                _openCalendar(appNames, options, statusObj);
                break;
            case "process.TaskCenter":
                _openTaskCenter(appNames, options, statusObj);
                break;
            default:
R
roo00 已提交
390 391 392
                var uri = new URI(window.location.href);
                var optionsStr = uri.getData("option");
                var statusStr = uri.getData("status");
R
roo00 已提交
393
                window.location = "appMobile.html?app=" + appNames + "&option=" + (optionsStr || "") + "&status=" + (statusStr || "") + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
394
        }
NoSubject's avatar
NoSubject 已提交
395 396
    };

R
roo00 已提交
397 398 399
    layout.openApplication = function (e, appNames, options, statusObj) {
        if (layout.app) {
            if (layout.mobile) {
NoSubject's avatar
NoSubject 已提交
400
                _openApplicationMobile(appNames, options, statusObj);
R
roo00 已提交
401 402 403 404 405 406 407 408
            } else {
                var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");

                if (layout.app.$openWithSelf) {
                    return window.location = "app.html?" + par + ((layout.debugger) ? "&debugger" : "");
                } else {
                    return window.open("app.html?" + par + ((layout.debugger) ? "&debugger" : ""), par);
                }
NoSubject's avatar
NoSubject 已提交
409
            }
R
roo00 已提交
410
        } else {
NoSubject's avatar
NoSubject 已提交
411
            var appPath = appNames.split(".");
R
roo00 已提交
412
            var appName = appPath[appPath.length - 1];
NoSubject's avatar
NoSubject 已提交
413

R
roo00 已提交
414
            _requireApp(appNames, function (appNamespace) {
NoSubject's avatar
NoSubject 已提交
415 416 417 418 419
                _createNewApplication(e, appNamespace, appName, options, statusObj);
            }.bind(this));
        }
    };

R
roo00 已提交
420
    layout.refreshApp = function (app) {
NoSubject's avatar
NoSubject 已提交
421 422 423 424 425 426 427 428 429
        var status = app.recordStatus();

        var uri = new URI(window.location.href);
        var appNames = uri.getData("app");
        var optionsStr = uri.getData("option");
        var statusStr = uri.getData("status");
        if (status) statusStr = JSON.encode(status);

        var port = uri.get("port");
R
roo00 已提交
430
        window.location = uri.get("scheme") + "://" + uri.get("host") + ((port) ? ":" + port + "/" : "") + uri.get("directory ") + "?app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent(statusStr) + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "") + ((layout.debugger) ? "&debugger" : "");
NoSubject's avatar
NoSubject 已提交
431 432
    };

R
roo00 已提交
433
    layout.load = function (appNames, options, statusObj) {
NoSubject's avatar
NoSubject 已提交
434 435 436 437 438
        layout.message = new MWF.xDesktop.MessageMobile();
        layout.message.load();

        layout.apps = [];
        layout.node = $("layout");
R
roo00 已提交
439
        var appName = appNames, m_status = statusObj, option = options;
NoSubject's avatar
NoSubject 已提交
440 441

        var topWindow = window.opener;
R
roo00 已提交
442 443
        if (topWindow) {
            try {
NoSubject's avatar
NoSubject 已提交
444 445
                if (!appName) appName = topWindow.layout.desktop.openBrowserApp;
                if (!m_status) m_status = topWindow.layout.desktop.openBrowserStatus;
R
roo00 已提交
446 447
                if (!option) option = topWindow.layout.desktop.openBrowserOption;
            } catch (e) { }
NoSubject's avatar
NoSubject 已提交
448
        }
R
roo00 已提交
449
        layout.openApplication(null, appName, option || {}, m_status);
NoSubject's avatar
NoSubject 已提交
450 451
    }

R
roo00 已提交
452
})(layout);