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-02-21 05:00:43 +00:00
|
|
|
wn.provide('erpnext.navbar');
|
2012-01-24 09:03:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
<li class="dropdown">\
|
|
|
|
<a class="dropdown-toggle" href="#" onclick="return false;"></a>\
|
|
|
|
<ul class="dropdown-menu" id="toolbar-user">\
|
|
|
|
</ul>\
|
|
|
|
</li>\
|
|
|
|
*/
|
|
|
|
|
2012-02-21 05:00:43 +00:00
|
|
|
erpnext.navbar.navbar = Class.extend({
|
2012-01-24 09:03:21 +00:00
|
|
|
init: function() {
|
|
|
|
this.make();
|
2012-02-02 08:12:28 +00:00
|
|
|
$('.brand').html(wn.boot.website_settings.brand_html);
|
2012-01-24 09:03:21 +00:00
|
|
|
this.make_items();
|
2012-02-21 05:49:24 +00:00
|
|
|
$('.dropdown-toggle').dropdown();
|
2012-02-21 11:56:50 +00:00
|
|
|
},
|
2012-01-24 09:03:21 +00:00
|
|
|
make: function() {
|
2012-02-21 05:00:43 +00:00
|
|
|
$('header').append('<div class="navbar navbar-fixed-top">\
|
|
|
|
<div class="navbar-inner">\
|
2012-01-24 09:03:21 +00:00
|
|
|
<div class="container">\
|
2012-02-02 08:12:28 +00:00
|
|
|
<a class="brand">[brand]</a>\
|
2012-01-24 09:03:21 +00:00
|
|
|
<ul class="nav">\
|
|
|
|
</ul>\
|
|
|
|
<img src="lib/images/ui/spinner.gif" id="spinner"/>\
|
2012-02-21 05:49:24 +00:00
|
|
|
<ul class="nav pull-right">\
|
2012-01-24 09:03:21 +00:00
|
|
|
<li><a href="#!Login Page">Login</a></li>\
|
|
|
|
</ul>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
</div>');
|
2012-02-02 08:12:28 +00:00
|
|
|
$('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page'))
|
2012-01-24 09:03:21 +00:00
|
|
|
},
|
|
|
|
make_items: function() {
|
2012-02-17 06:36:33 +00:00
|
|
|
var items = wn.boot.website_menus;
|
|
|
|
|
|
|
|
// parent labels
|
2012-01-24 09:03:21 +00:00
|
|
|
for(var i=0;i<items.length;i++) {
|
|
|
|
var item = items[i];
|
2012-01-31 12:31:16 +00:00
|
|
|
if(!item.parent_label && item.parentfield=='top_bar_items') {
|
2012-02-07 05:09:17 +00:00
|
|
|
item.route = item.url || item.custom_page;
|
2012-02-17 06:36:33 +00:00
|
|
|
$('header .nav:first').append(repl('<li data-label="%(label)s">\
|
|
|
|
<a href="#!%(route)s">%(label)s</a></li>', item))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// child labels
|
|
|
|
for(var i=0;i<items.length;i++) {
|
|
|
|
var item = items[i];
|
|
|
|
if(item.parent_label && item.parentfield=='top_bar_items') {
|
|
|
|
// check if parent label has class "dropdown"
|
|
|
|
$parent_li = $(repl('header li[data-label="%(parent_label)s"]', item));
|
|
|
|
if(!$parent_li.hasClass('dropdown')) {
|
|
|
|
$parent_li.addClass('dropdown');
|
2012-02-21 05:00:43 +00:00
|
|
|
$parent_li.find('a:first').addClass('dropdown-toggle')
|
|
|
|
.attr('data-toggle', 'dropdown')
|
2012-02-21 11:56:50 +00:00
|
|
|
.attr('href', '')
|
|
|
|
.append('<b class="caret"></b>')
|
|
|
|
.click(function() {
|
|
|
|
return false;
|
|
|
|
});
|
2012-02-17 06:36:33 +00:00
|
|
|
$parent_li.append('<ul class="dropdown-menu"></ul>');
|
|
|
|
}
|
|
|
|
item.route = item.url || item.custom_page;
|
|
|
|
$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
|
|
|
|
<a href="#!%(route)s">%(label)s</a></li>', item))
|
2012-01-24 09:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-01-31 12:31:16 +00:00
|
|
|
|
|
|
|
// footer
|
|
|
|
erpnext.Footer = Class.extend({
|
|
|
|
init: function() {
|
|
|
|
$('footer').html(repl('<div class="web-footer">\
|
|
|
|
<div class="web-footer-menu"><ul></ul></div>\
|
|
|
|
<div class="web-footer-address">%(address)s</div>\
|
|
|
|
<div class="web-footer-copyright">© %(copyright)s</div>\
|
|
|
|
<div class="web-footer-powered">Powered by \
|
|
|
|
<a href="https://erpnext.com">erpnext.com</a></div>\
|
2012-02-02 08:12:28 +00:00
|
|
|
</div>', wn.boot.website_settings));
|
2012-01-31 12:31:16 +00:00
|
|
|
this.make_items();
|
|
|
|
},
|
|
|
|
make_items: function() {
|
2012-02-02 08:12:28 +00:00
|
|
|
var items = wn.boot.website_menus
|
2012-01-31 12:31:16 +00:00
|
|
|
for(var i=0;i<items.length;i++) {
|
|
|
|
var item = items[i];
|
|
|
|
if(!item.parent_label && item.parentfield=='footer_items') {
|
2012-02-07 05:09:17 +00:00
|
|
|
item.route = item.url || item.custom_page;
|
2012-01-31 12:31:16 +00:00
|
|
|
$('.web-footer-menu ul').append(repl('<li><a href="#!%(route)s" \
|
|
|
|
data-label="%(label)s">%(label)s</a></li>', item))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-02-14 06:14:13 +00:00
|
|
|
$(document).bind('startup', function() {
|
|
|
|
erpnext.footer = new erpnext.Footer();
|
2012-02-21 05:00:43 +00:00
|
|
|
erpnext.navbar.navbar = new erpnext.navbar.navbar();
|
2012-02-14 06:14:13 +00:00
|
|
|
})
|