x.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. layout.addReady(function(){
  2. (function(layout){
  3. layout.inBrowser = false;
  4. layout.desktop.type = "layout";
  5. layout.app = false;
  6. layout.apps = [];
  7. var loadingNode = $("browser_loading");
  8. var _load = function(){
  9. MWF.xDesktop.getUserLayout(function(){
  10. layout.userLayout = layout.userLayout || {};
  11. if (!layout.userLayout.scale || isNaN(layout.userLayout.scale)){
  12. layout.userLayout.scale = 1;
  13. }
  14. var uri = new URI(window.location.href);
  15. var viewMode = uri.getData("view");
  16. var flatStyle = uri.getData("style");
  17. if (flatStyle) layout.userLayout.flatStyle = flatStyle;
  18. if (!viewMode) viewMode = (layout.userLayout && layout.userLayout.viewMode) ? layout.userLayout.viewMode : "homepage";
  19. viewMode = viewMode.toLowerCase();
  20. //viewMode = (["flat", "home", "homepage", "default"].indexOf(viewMode)!==-1) ? "Default" : "Layout";
  21. viewMode = (["layout", "desktop"].indexOf(viewMode)!==-1) ? "Layout" : "Default";
  22. layout.viewMode = viewMode.capitalize();
  23. //var layoutClass = "Homepage";
  24. $("appContent").destroy();
  25. MWF.require("MWF.xDesktop."+layout.viewMode, function(){
  26. layout.desktop = new MWF.xDesktop[layout.viewMode]("layout_main", {});
  27. layout.desktop.load();
  28. if (!layout.desktop.openApplication) layout.desktop.openApplication = layout.openApplication;
  29. if (!layout.desktop.refreshApp) layout.desktop.refreshApp = layout.refreshApp;
  30. });
  31. if (loadingNode){
  32. new Fx.Tween(loadingNode).start("opacity", 0).chain(function(){
  33. loadingNode.destroy();
  34. loadingNode = null;
  35. });
  36. }
  37. });
  38. };
  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. })(layout);
  49. });