// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) // // MIT License (MIT) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // wn.ui.toolbar.Toolbar = Class.extend({ init: function() { this.make(); this.make_home(); this.make_document(); this.make_apps(); wn.ui.toolbar.recent = new wn.ui.toolbar.RecentDocs(); this.make_tools(); this.set_user_name(); this.make_logout(); $('.dropdown-toggle').dropdown(); $(document).trigger('toolbar_setup'); }, make: function() { $('header').append(''); }, make_home: function() { $('.navbar .nav:first').append('
  • \ Home
  • '); $('.navbar .brand').attr('href', "#!" + home_page); }, make_document: function() { wn.ui.toolbar.new_dialog = new wn.ui.toolbar.NewDialog(); wn.ui.toolbar.search = new wn.ui.toolbar.Search(); wn.ui.toolbar.report = new wn.ui.toolbar.Report(); $('.navbar .nav:first').append(''); }, make_tools: function() { $('.navbar .nav:first').append(''); if(has_common(user_roles,['Administrator','System Manager'])) { $('#toolbar-tools').append('
  • \ Download Backup
  • '); } }, make_apps: function() { $('.navbar .nav:first').append(''); }, set_user_name: function() { var fn = user_fullname; if(fn.length > 15) fn = fn.substr(0,12) + '...'; $('#toolbar-user-link').html(fn + ''); }, make_logout: function() { // logout $('#toolbar-user').append('
  • Logout
  • '); } }); wn.ui.toolbar.clear_cache = function() { localStorage && localStorage.clear(); $c('webnotes.session_cache.clear',{},function(r,rt){ show_alert(r.message); }); return false; } wn.ui.toolbar.download_backup = function() { $c('webnotes.utils.backups.get_backup',{},function(r,rt) {}); return false; } wn.ui.toolbar.show_about = function() { try { wn.require('lib/js/wn/misc/about.js'); wn.ui.misc.about(); } catch(e) { console.log(e); } return false; }