You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

toolbar.js 4.4 KiB

13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
13 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.ui.toolbar.Toolbar = Class.extend({
  23. init: function() {
  24. this.make();
  25. this.make_home();
  26. this.make_document();
  27. wn.ui.toolbar.recent = new wn.ui.toolbar.RecentDocs();
  28. this.make_tools();
  29. this.set_user_name();
  30. this.make_logout();
  31. $('.dropdown-toggle').dropdown();
  32. $(document).trigger('toolbar_setup');
  33. },
  34. make: function() {
  35. $('header').append('<div class="navbar navbar-fixed-top">\
  36. <div class="navbar-inner">\
  37. <div class="container">\
  38. <a class="brand"></a>\
  39. <ul class="nav">\
  40. </ul>\
  41. <img src="lib/images/ui/spinner.gif" id="spinner"/>\
  42. <ul class="nav pull-right">\
  43. <li class="dropdown">\
  44. <a class="dropdown-toggle" data-toggle="dropdown" href="#" \
  45. onclick="return false;" id="toolbar-user-link"></a>\
  46. <ul class="dropdown-menu" id="toolbar-user">\
  47. </ul>\
  48. </li>\
  49. </ul>\
  50. </div>\
  51. </div>\
  52. </div>');
  53. },
  54. make_home: function() {
  55. $('.navbar .brand').attr('href', "#");
  56. },
  57. make_document: function() {
  58. wn.ui.toolbar.new_dialog = new wn.ui.toolbar.NewDialog();
  59. wn.ui.toolbar.search = new wn.ui.toolbar.Search();
  60. wn.ui.toolbar.report = new wn.ui.toolbar.Report();
  61. $('.navbar .nav:first').append('<li class="dropdown">\
  62. <a class="dropdown-toggle" href="#" data-toggle="dropdown"\
  63. onclick="return false;">Document<b class="caret"></b></a>\
  64. <ul class="dropdown-menu" id="toolbar-document">\
  65. <li><a href="#" onclick="return wn.ui.toolbar.new_dialog.show();">\
  66. <i class="icon-plus"></i> New</a></li>\
  67. <li><a href="#" onclick="return wn.ui.toolbar.search.show();">\
  68. <i class="icon-search"></i> Search</a></li>\
  69. <li><a href="#" onclick="return wn.ui.toolbar.report.show();">\
  70. <i class="icon-list"></i> Report</a></li>\
  71. </ul>\
  72. </li>');
  73. },
  74. make_tools: function() {
  75. $('.navbar .nav:first').append('<li class="dropdown">\
  76. <a class="dropdown-toggle" data-toggle="dropdown" href="#" \
  77. onclick="return false;">Tools<b class="caret"></b></a>\
  78. <ul class="dropdown-menu" id="toolbar-tools">\
  79. <li><a href="#" onclick="return err_console.show();">Error Console</a></li>\
  80. <li><a href="#" onclick="return wn.ui.toolbar.clear_cache();">Clear Cache & Refresh</a></li>\
  81. <li><a href="#" onclick="return wn.ui.toolbar.show_about();">About</a></li>\
  82. </ul>\
  83. </li>');
  84. if(has_common(user_roles,['Administrator','System Manager'])) {
  85. $('#toolbar-tools').append('<li><a href="#" \
  86. onclick="return wn.ui.toolbar.download_backup();">\
  87. Download Backup</a></li>');
  88. }
  89. },
  90. set_user_name: function() {
  91. var fn = user_fullname;
  92. if(fn.length > 15) fn = fn.substr(0,12) + '...';
  93. $('#toolbar-user-link').html(fn + '<b class="caret"></b>');
  94. },
  95. make_logout: function() {
  96. // logout
  97. $('#toolbar-user').append('<li><a href="#" onclick="return wn.app.logout();">Logout</a></li>');
  98. }
  99. });
  100. wn.ui.toolbar.clear_cache = function() {
  101. localStorage && localStorage.clear();
  102. $c('webnotes.session_cache.clear',{},function(r,rt){
  103. if(!r.exc) {
  104. show_alert(r.message);
  105. location.reload();
  106. }
  107. });
  108. return false;
  109. }
  110. wn.ui.toolbar.download_backup = function() {
  111. $c('webnotes.utils.backups.get_backup',{},function(r,rt) {});
  112. return false;
  113. }
  114. wn.ui.toolbar.show_about = function() {
  115. try {
  116. wn.require('lib/js/wn/misc/about.js');
  117. wn.ui.misc.about();
  118. } catch(e) {
  119. console.log(e);
  120. }
  121. return false;
  122. }