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 |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 25 | $('#toolbar-user').append('<li><a href="#Form/Profile/'+user+'">' |
| 26 | +wn._("My Settings")+'...</a></li>'); |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 27 | |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 28 | $('.navbar .pull-right').append('\ |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 29 | <li><a href="#!messages" title="'+wn._('Unread Messages') |
| 30 | +'"><span class="navbar-new-comments"></span></a></li>'); |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 31 | |
| 32 | // help |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 33 | $('.navbar .pull-right').prepend('<li class="dropdown">\ |
Rushabh Mehta | 6e156c7 | 2012-02-21 11:19:24 +0530 | [diff] [blame] | 34 | <a class="dropdown-toggle" data-toggle="dropdown" href="#" \ |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 35 | onclick="return false;">'+wn._('Help')+'<b class="caret"></b></a>\ |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 36 | <ul class="dropdown-menu" id="toolbar-help">\ |
| 37 | </ul></li>') |
| 38 | |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 39 | $('#toolbar-help').append('<li><a href="https://erpnext.com/manual" target="_blank">' |
| 40 | +wn._('Documentation')+'</a></li>') |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 41 | |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 42 | $('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">' |
| 43 | +wn._('Forum')+'</a></li>') |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 44 | |
| 45 | $('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\ |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 46 | '+wn._('Live Chat')+'</a></li>') |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 47 | |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 48 | erpnext.toolbar.set_new_comments(); |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 49 | } |
| 50 | |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 51 | erpnext.toolbar.add_modules = function() { |
| 52 | $('<li class="dropdown">\ |
| 53 | <a class="dropdown-toggle" data-toggle="dropdown" href="#"\ |
Rushabh Mehta | eadedb5 | 2013-02-06 13:15:13 +0530 | [diff] [blame] | 54 | title="'+wn._("Modules")+'"\ |
Rushabh Mehta | 8c713e7 | 2013-02-06 16:10:48 +0530 | [diff] [blame] | 55 | onclick="return false;"><i class="icon-th"></i></a>\ |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 56 | <ul class="dropdown-menu modules">\ |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 57 | </ul>\ |
Anand Doshi | 5b1beeb | 2012-02-27 17:17:48 +0530 | [diff] [blame] | 58 | </li>').prependTo('.navbar .nav:first'); |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 59 | |
Rushabh Mehta | 8fbfbfb | 2013-02-13 22:02:09 +0530 | [diff] [blame] | 60 | var modules_list = wn.user.get_desktop_items().sort(); |
Anand Doshi | 0374169 | 2013-02-16 15:05:37 +0530 | [diff] [blame] | 61 | |
| 62 | var _get_list_item = function(m) { |
| 63 | args = { |
| 64 | module: m, |
| 65 | module_page: wn.modules[m].link, |
| 66 | module_label: wn._(wn.modules[m].label || m), |
| 67 | icon: wn.modules[m].icon |
| 68 | } |
| 69 | |
| 70 | return repl('<li><a href="#!%(module_page)s" \ |
| 71 | data-module="%(module)s"><i class="%(icon)s" style="display: inline-block; \ |
| 72 | width: 21px; margin-top: -2px; margin-left: -7px;"></i>\ |
| 73 | %(module_label)s</a></li>', args); |
| 74 | } |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 75 | |
| 76 | // add to dropdown |
Rushabh Mehta | 5ade7ca | 2012-12-21 21:40:19 +0530 | [diff] [blame] | 77 | for(var i in modules_list) { |
| 78 | var m = modules_list[i] |
Anand Doshi | 70a3db7 | 2012-12-24 18:07:35 +0530 | [diff] [blame] | 79 | if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1 && wn.modules[m]) { |
Anand Doshi | 0374169 | 2013-02-16 15:05:37 +0530 | [diff] [blame] | 80 | $('.navbar .modules').append(_get_list_item(m)); |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 81 | } |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // setup for system manager |
| 85 | if(user_roles.indexOf("System Manager")!=-1) { |
Anand Doshi | 0374169 | 2013-02-16 15:05:37 +0530 | [diff] [blame] | 86 | $('.navbar .modules').append('<li class="divider">' + _get_list_item("Setup")); |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 87 | } |
| 88 | |
Rushabh Mehta | d025133 | 2012-02-21 17:26:50 +0530 | [diff] [blame] | 89 | } |
| 90 | |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 91 | erpnext.toolbar.set_new_comments = function(new_comments) { |
| 92 | var navbar_nc = $('.navbar-new-comments'); |
Rushabh Mehta | 9d0569a | 2012-11-13 11:42:42 +0530 | [diff] [blame] | 93 | if(cint(new_comments)) { |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 94 | navbar_nc.addClass('navbar-new-comments-true') |
Rushabh Mehta | 9d0569a | 2012-11-13 11:42:42 +0530 | [diff] [blame] | 95 | navbar_nc.text(new_comments); |
Anand Doshi | 2aa9ba6 | 2012-04-30 15:43:34 +0530 | [diff] [blame] | 96 | } else { |
| 97 | navbar_nc.removeClass('navbar-new-comments-true'); |
| 98 | navbar_nc.text(0); |
| 99 | } |
Rushabh Mehta | 523aec4 | 2013-01-07 15:39:54 +0530 | [diff] [blame] | 100 | } |