您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. //
  3. // MIT License (MIT)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a
  6. // copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the
  10. // Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. //
  22. wn.Application = Class.extend({
  23. init: function() {
  24. // load boot info
  25. this.load_bootinfo();
  26. // page container
  27. this.make_page_container();
  28. // navbar
  29. this.make_nav_bar();
  30. // favicon
  31. this.set_favicon();
  32. // trigger app startup
  33. $(document).trigger('startup');
  34. // route to home page
  35. wn.route();
  36. },
  37. load_bootinfo: function() {
  38. LocalDB.sync(wn.boot.docs);
  39. wn.control_panel = wn.boot.control_panel;
  40. if(wn.boot.error_messages)
  41. console.log(wn.boot.error_messages)
  42. if(wn.boot.server_messages)
  43. msgprint(wn.boot.server_messages);
  44. this.set_globals();
  45. },
  46. set_globals: function() {
  47. // for backward compatibility
  48. profile = wn.boot.profile;
  49. user = wn.boot.profile.name;
  50. user_fullname = wn.user_info(user).fullname;
  51. user_defaults = profile.defaults;
  52. user_roles = profile.roles;
  53. user_email = profile.email;
  54. sys_defaults = wn.boot.sysdefaults;
  55. },
  56. make_page_container: function() {
  57. wn.container = new wn.views.Container();
  58. wn.views.make_403();
  59. wn.views.make_404();
  60. },
  61. make_nav_bar: function() {
  62. // toolbar
  63. if(wn.user.name !='Guest') {
  64. wn.container.wntoolbar = new wn.ui.toolbar.Toolbar();
  65. }
  66. },
  67. logout: function() {
  68. var me = this;
  69. wn.call({
  70. method:'logout',
  71. callback: function(r) {
  72. if(r.exc) {
  73. console.log(r.exc); return;
  74. }
  75. me.redirect_to_login();
  76. }
  77. })
  78. },
  79. redirect_to_login: function() {
  80. window.location.hash = '';
  81. window.location.reload();
  82. },
  83. set_favicon: function() {
  84. var link = $('link[type="image/x-icon"]').remove().attr("href");
  85. var favicon ='\
  86. <link rel="shortcut icon" href="' + link + '" type="image/x-icon"> \
  87. <link rel="icon" href="' + link + '" type="image/x-icon">'
  88. $(favicon).appendTo('head');
  89. }
  90. })