portal.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. layout.addReady(function(){
  2. (function(layout){
  3. var uri = new URI(window.location.href);
  4. var appNames = "portal.Portal";
  5. var id = uri.getData("id");
  6. var page = uri.getData("page");
  7. var widget = uri.getData("widget");
  8. var parameters = uri.getData("parameters");
  9. var statusObj = null;
  10. var options = {"portalId": id, "pageId": page, "parameters": parameters, "widgetId":widget };
  11. var _load = function(){
  12. //o2.require("MWF.xDesktop.MessageMobile", function(){
  13. // layout.message = new MWF.xDesktop.MessageMobile();
  14. // layout.message.load();
  15. //}.bind(this));
  16. layout.apps = [];
  17. //layout.node = $("layout");
  18. layout.node = $("layout") || $("appContent") || document.body;
  19. var appName=appNames, m_status=statusObj, option=options;
  20. var topWindow = window.opener;
  21. if (topWindow){
  22. try{
  23. if (!appName) appName = topWindow.layout.desktop.openBrowserApp;
  24. if (!m_status && !option) m_status = topWindow.layout.desktop.openBrowserStatus;
  25. if (!option && !m_status) option = topWindow.layout.desktop.openBrowserOption;
  26. }catch(e){}
  27. }
  28. layout.openApplication(null, appName, option||{}, m_status);
  29. if (!layout.session.user || layout.session.user.name === "anonymous"){
  30. o2.loadCss("../o2_core/o2/xDesktop/$Default/blue/style-skin.css");
  31. }else{
  32. o2.xDesktop.getUserLayout(function(){
  33. var style = layout.userLayout.flatStyle;
  34. o2.loadCss("../o2_core/o2/xDesktop/$Default/"+style+"/style-skin.css");
  35. });
  36. }
  37. };
  38. _load();
  39. // if (layout.session && layout.session.user){
  40. // _load();
  41. // }else{
  42. // if (layout.sessionPromise){
  43. // layout.sessionPromise.then(function(){
  44. // _load();
  45. // },function(){});
  46. // }
  47. // }
  48. window.addEventListener('popstate', function (event) {
  49. uri = new URI(document.location.href);
  50. id = uri.getData("id");
  51. page = uri.getData("page");
  52. if (event.state){
  53. id = event.state.id;
  54. page = event.state.page;
  55. }
  56. // var appName = "portal.Portal";
  57. // var option = {"portalId": id, "pageId": page, "widgetId":widget };
  58. layout.app.toPortal(id, page, null, true);
  59. }.bind(this));
  60. })(layout);
  61. });