Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 1 | // ERPNext - web based ERP (http://erpnext.com) |
| 2 | // Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 17 | /* toolbar settings */ |
| 18 | wn.provide('erpnext.toolbar'); |
| 19 | |
| 20 | erpnext.toolbar.setup = function() { |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 21 | // modules |
| 22 | erpnext.toolbar.add_modules(); |
| 23 | |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 24 | // profile |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 25 | $('#toolbar-user').append('<li><a href="#profile-settings">Profile Settings</a></li>'); |
| 26 | |
| 27 | $('#toolbar-user').append('<li><a href="#My Company">Team / Messages</a></li>'); |
| 28 | |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 29 | |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 30 | $('.navbar .pull-right').append('\ |
| 31 | <li><a href="#!My%20Company" title="Unread Messages"><span class="navbar-new-comments"></span></a></li>'); |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 32 | |
| 33 | // help |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 34 | $('.navbar .pull-right').prepend('<li class="dropdown">\ |
Rushabh Mehta | 6e156c7 | 2012-02-21 11:19:24 +0530 | [diff] [blame] | 35 | <a class="dropdown-toggle" data-toggle="dropdown" href="#" \ |
| 36 | onclick="return false;">Help<b class="caret"></b></a>\ |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 37 | <ul class="dropdown-menu" id="toolbar-help">\ |
| 38 | </ul></li>') |
| 39 | |
| 40 | $('#toolbar-help').append('<li><a href="http://erpnext.blogspot.com/2011/03/erpnext-help.html" target="_blank">\ |
| 41 | Documentation</a></li>') |
| 42 | |
| 43 | $('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">\ |
| 44 | Forum</a></li>') |
| 45 | |
| 46 | $('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\ |
| 47 | Live Chat (Office Hours)</a></li>') |
| 48 | |
| 49 | // billing |
| 50 | if(pscript.is_erpnext_saas && is_system_manager) { |
| 51 | $('#toolbar-user').append('<li><a href="#billing">Billing</a></li>') |
| 52 | } |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 53 | |
| 54 | $.extend(page_body.wntoolbar, { |
| 55 | set_new_comments: function(new_comments) { |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 56 | var navbar_nc = $('.navbar-new-comments'); |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 57 | if(new_comments && new_comments.length>0) { |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 58 | navbar_nc.text(new_comments.length); |
| 59 | navbar_nc.addClass('navbar-new-comments-true') |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 60 | $.each(new_comments, function(i, v) { |
| 61 | var msg = 'New Message: ' + (v[1].length<=100 ? v[1] : (v[1].substr(0, 100) + "...")); |
| 62 | var id = v[0].replace('/', '-'); |
| 63 | if(!$('#' + id)[0]) { show_alert(msg, id); } |
| 64 | }) |
| 65 | } else { |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 66 | navbar_nc.removeClass('navbar-new-comments-true'); |
| 67 | navbar_nc.text(0); |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | page_body.wntoolbar.set_new_comments(); |
| 73 | } |
| 74 | |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 75 | erpnext.toolbar.add_modules = function() { |
| 76 | $('<li class="dropdown">\ |
| 77 | <a class="dropdown-toggle" data-toggle="dropdown" href="#"\ |
| 78 | onclick="return false;">Modules<b class="caret"></b></a>\ |
| 79 | <ul class="dropdown-menu">\ |
| 80 | <li><a href="#!accounts-home" data-module="Accounts">Accounts</a></li>\ |
| 81 | <li><a href="#!selling-home" data-module="Selling">Selling</a></li>\ |
| 82 | <li><a href="#!stock-home" data-module="Stock">Stock</a></li>\ |
| 83 | <li><a href="#!buying-home" data-module="Buying">Buying</a></li>\ |
| 84 | <li><a href="#!support-home" data-module="Support">Support</a></li>\ |
| 85 | <li><a href="#!hr-home" data-module="HR">Human Resources</a></li>\ |
| 86 | <li><a href="#!projects-home" data-module="Projects">Projects</a></li>\ |
| 87 | <li><a href="#!production-home" data-module="Production">Production</a></li>\ |
| 88 | <li><a href="#!website-home" data-module="Website">Website</a></li>\ |
| 89 | <li class="divider"></li>\ |
| 90 | <li><a href="#!Setup" data-module="Setup">Setup</a></li>\ |
| 91 | </ul>\ |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 92 | </li>').prependTo('.navbar .nav:first'); |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 93 | $('.navbar .nav:first') |
| 94 | } |
| 95 | |