blob: 29b2c51e62afc0c17abc544b8207b3f02a771d8c [file] [log] [blame]
Rushabh Mehta4dc2f432012-02-21 10:30:43 +05301wn.provide('erpnext.navbar');
Rushabh Mehta865c00a2012-01-24 14:33:21 +05302
3/*
4<li class="dropdown">\
5 <a class="dropdown-toggle" href="#" onclick="return false;"></a>\
6 <ul class="dropdown-menu" id="toolbar-user">\
7 </ul>\
8</li>\
9*/
10
Rushabh Mehta4dc2f432012-02-21 10:30:43 +053011erpnext.navbar.navbar = Class.extend({
Rushabh Mehta865c00a2012-01-24 14:33:21 +053012 init: function() {
13 this.make();
Rushabh Mehta7018b192012-02-02 13:42:28 +053014 $('.brand').html(wn.boot.website_settings.brand_html);
Rushabh Mehta865c00a2012-01-24 14:33:21 +053015 this.make_items();
Rushabh Mehta6e156c72012-02-21 11:19:24 +053016 $('.dropdown-toggle').dropdown();
Rushabh Mehtad0251332012-02-21 17:26:50 +053017 },
Rushabh Mehta865c00a2012-01-24 14:33:21 +053018 make: function() {
Rushabh Mehta4dc2f432012-02-21 10:30:43 +053019 $('header').append('<div class="navbar navbar-fixed-top">\
20 <div class="navbar-inner">\
Rushabh Mehta865c00a2012-01-24 14:33:21 +053021 <div class="container">\
Rushabh Mehta7018b192012-02-02 13:42:28 +053022 <a class="brand">[brand]</a>\
Rushabh Mehta865c00a2012-01-24 14:33:21 +053023 <ul class="nav">\
24 </ul>\
25 <img src="lib/images/ui/spinner.gif" id="spinner"/>\
Rushabh Mehta6e156c72012-02-21 11:19:24 +053026 <ul class="nav pull-right">\
Rushabh Mehta865c00a2012-01-24 14:33:21 +053027 <li><a href="#!Login Page">Login</a></li>\
28 </ul>\
29 </div>\
30 </div>\
31 </div>');
Rushabh Mehta7018b192012-02-02 13:42:28 +053032 $('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page'))
Rushabh Mehta865c00a2012-01-24 14:33:21 +053033 },
34 make_items: function() {
Rushabh Mehtaaa848be2012-02-17 12:06:33 +053035 var items = wn.boot.website_menus;
36
37 // parent labels
Rushabh Mehta865c00a2012-01-24 14:33:21 +053038 for(var i=0;i<items.length;i++) {
39 var item = items[i];
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053040 if(!item.parent_label && item.parentfield=='top_bar_items') {
Rushabh Mehtaf35992f2012-02-07 10:39:17 +053041 item.route = item.url || item.custom_page;
Rushabh Mehtaaa848be2012-02-17 12:06:33 +053042 $('header .nav:first').append(repl('<li data-label="%(label)s">\
43 <a href="#!%(route)s">%(label)s</a></li>', item))
44 }
45 }
46
47 // child labels
48 for(var i=0;i<items.length;i++) {
49 var item = items[i];
50 if(item.parent_label && item.parentfield=='top_bar_items') {
51 // check if parent label has class "dropdown"
52 $parent_li = $(repl('header li[data-label="%(parent_label)s"]', item));
53 if(!$parent_li.hasClass('dropdown')) {
54 $parent_li.addClass('dropdown');
Rushabh Mehta4dc2f432012-02-21 10:30:43 +053055 $parent_li.find('a:first').addClass('dropdown-toggle')
56 .attr('data-toggle', 'dropdown')
Rushabh Mehtad0251332012-02-21 17:26:50 +053057 .attr('href', '')
58 .append('<b class="caret"></b>')
59 .click(function() {
60 return false;
61 });
Rushabh Mehtaaa848be2012-02-17 12:06:33 +053062 $parent_li.append('<ul class="dropdown-menu"></ul>');
63 }
64 item.route = item.url || item.custom_page;
65 $parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
66 <a href="#!%(route)s">%(label)s</a></li>', item))
Rushabh Mehta865c00a2012-01-24 14:33:21 +053067 }
68 }
69 }
70});
71
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053072
73// footer
74erpnext.Footer = Class.extend({
75 init: function() {
76 $('footer').html(repl('<div class="web-footer">\
77 <div class="web-footer-menu"><ul></ul></div>\
78 <div class="web-footer-address">%(address)s</div>\
79 <div class="web-footer-copyright">&copy; %(copyright)s</div>\
80 <div class="web-footer-powered">Powered by \
81 <a href="https://erpnext.com">erpnext.com</a></div>\
Rushabh Mehta7018b192012-02-02 13:42:28 +053082 </div>', wn.boot.website_settings));
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053083 this.make_items();
84 },
85 make_items: function() {
Rushabh Mehta7018b192012-02-02 13:42:28 +053086 var items = wn.boot.website_menus
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053087 for(var i=0;i<items.length;i++) {
88 var item = items[i];
89 if(!item.parent_label && item.parentfield=='footer_items') {
Rushabh Mehtaf35992f2012-02-07 10:39:17 +053090 item.route = item.url || item.custom_page;
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053091 $('.web-footer-menu ul').append(repl('<li><a href="#!%(route)s" \
92 data-label="%(label)s">%(label)s</a></li>', item))
93 }
94 }
95 }
96});
97
Rushabh Mehtaafaac602012-02-14 11:44:13 +053098$(document).bind('startup', function() {
99 erpnext.footer = new erpnext.Footer();
Rushabh Mehta4dc2f432012-02-21 10:30:43 +0530100 erpnext.navbar.navbar = new erpnext.navbar.navbar();
Rushabh Mehtaafaac602012-02-14 11:44:13 +0530101})