2012-02-23 07:05:32 +00:00
|
|
|
// ERPNext - web based ERP (http://erpnext.com)
|
|
|
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-01-20 08:17:16 +00:00
|
|
|
/* toolbar settings */
|
|
|
|
wn.provide('erpnext.toolbar');
|
|
|
|
|
|
|
|
erpnext.toolbar.setup = function() {
|
2012-02-21 11:56:50 +00:00
|
|
|
// modules
|
|
|
|
erpnext.toolbar.add_modules();
|
|
|
|
|
2012-01-20 08:17:16 +00:00
|
|
|
// profile
|
2013-01-07 10:09:54 +00:00
|
|
|
$('#toolbar-user').append('<li><a href="#Form/Profile/'+user+'">'
|
|
|
|
+wn._("My Settings")+'...</a></li>');
|
2012-02-21 11:56:50 +00:00
|
|
|
|
2012-02-27 11:47:48 +00:00
|
|
|
$('.navbar .pull-right').append('\
|
2013-01-07 10:09:54 +00:00
|
|
|
<li><a href="#!messages" title="'+wn._('Unread Messages')
|
|
|
|
+'"><span class="navbar-new-comments"></span></a></li>');
|
2012-01-20 08:17:16 +00:00
|
|
|
|
|
|
|
// help
|
2012-02-27 11:47:48 +00:00
|
|
|
$('.navbar .pull-right').prepend('<li class="dropdown">\
|
2012-02-21 05:49:24 +00:00
|
|
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#" \
|
2013-01-07 10:09:54 +00:00
|
|
|
onclick="return false;">'+wn._('Help')+'<b class="caret"></b></a>\
|
2012-01-20 08:17:16 +00:00
|
|
|
<ul class="dropdown-menu" id="toolbar-help">\
|
|
|
|
</ul></li>')
|
|
|
|
|
2013-01-07 10:09:54 +00:00
|
|
|
$('#toolbar-help').append('<li><a href="https://erpnext.com/manual" target="_blank">'
|
|
|
|
+wn._('Documentation')+'</a></li>')
|
2012-01-20 08:17:16 +00:00
|
|
|
|
2013-01-07 10:09:54 +00:00
|
|
|
$('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">'
|
|
|
|
+wn._('Forum')+'</a></li>')
|
2012-01-20 08:17:16 +00:00
|
|
|
|
|
|
|
$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
|
2013-01-07 10:09:54 +00:00
|
|
|
'+wn._('Live Chat')+'</a></li>')
|
2012-01-20 08:17:16 +00:00
|
|
|
|
2012-04-30 10:13:34 +00:00
|
|
|
erpnext.toolbar.set_new_comments();
|
2012-02-20 11:01:55 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 11:56:50 +00:00
|
|
|
erpnext.toolbar.add_modules = function() {
|
|
|
|
$('<li class="dropdown">\
|
|
|
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
|
2013-02-06 07:45:13 +00:00
|
|
|
title="'+wn._("Modules")+'"\
|
2013-02-06 10:40:48 +00:00
|
|
|
onclick="return false;"><i class="icon-th"></i></a>\
|
2012-02-28 13:26:56 +00:00
|
|
|
<ul class="dropdown-menu modules">\
|
2012-02-21 11:56:50 +00:00
|
|
|
</ul>\
|
2012-02-27 11:47:48 +00:00
|
|
|
</li>').prependTo('.navbar .nav:first');
|
2012-02-28 13:26:56 +00:00
|
|
|
|
2013-02-13 16:32:09 +00:00
|
|
|
var modules_list = wn.user.get_desktop_items().sort();
|
2013-02-16 09:35:37 +00:00
|
|
|
|
|
|
|
var _get_list_item = function(m) {
|
|
|
|
args = {
|
|
|
|
module: m,
|
|
|
|
module_page: wn.modules[m].link,
|
|
|
|
module_label: wn._(wn.modules[m].label || m),
|
|
|
|
icon: wn.modules[m].icon
|
|
|
|
}
|
|
|
|
|
|
|
|
return repl('<li><a href="#!%(module_page)s" \
|
|
|
|
data-module="%(module)s"><i class="%(icon)s" style="display: inline-block; \
|
|
|
|
width: 21px; margin-top: -2px; margin-left: -7px;"></i>\
|
|
|
|
%(module_label)s</a></li>', args);
|
|
|
|
}
|
2012-02-28 13:26:56 +00:00
|
|
|
|
|
|
|
// add to dropdown
|
2013-04-03 09:51:44 +00:00
|
|
|
$.each(modules_list,function(i, m) {
|
|
|
|
if(m!='Setup') {
|
2013-02-16 09:35:37 +00:00
|
|
|
$('.navbar .modules').append(_get_list_item(m));
|
2012-02-28 13:26:56 +00:00
|
|
|
}
|
2013-04-03 09:51:44 +00:00
|
|
|
})
|
2012-02-28 13:26:56 +00:00
|
|
|
|
|
|
|
// setup for system manager
|
|
|
|
if(user_roles.indexOf("System Manager")!=-1) {
|
2013-02-16 09:35:37 +00:00
|
|
|
$('.navbar .modules').append('<li class="divider">' + _get_list_item("Setup"));
|
2012-02-28 13:26:56 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 11:56:50 +00:00
|
|
|
}
|
|
|
|
|
2012-04-30 10:13:34 +00:00
|
|
|
erpnext.toolbar.set_new_comments = function(new_comments) {
|
|
|
|
var navbar_nc = $('.navbar-new-comments');
|
2012-11-13 06:12:42 +00:00
|
|
|
if(cint(new_comments)) {
|
2012-04-30 10:13:34 +00:00
|
|
|
navbar_nc.addClass('navbar-new-comments-true')
|
2012-11-13 06:12:42 +00:00
|
|
|
navbar_nc.text(new_comments);
|
2012-04-30 10:13:34 +00:00
|
|
|
} else {
|
|
|
|
navbar_nc.removeClass('navbar-new-comments-true');
|
|
|
|
navbar_nc.text(0);
|
|
|
|
}
|
2013-01-07 10:09:54 +00:00
|
|
|
}
|