blob: 8b70d1ee7bb28f5d27e0234faee7b84dd940562e [file] [log] [blame]
Rushabh Mehta865c00a2012-01-24 14:33:21 +05301wn.provide('erpnext.topbar');
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
11erpnext.topbar.TopBar = Class.extend({
12 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 Mehtaaa848be2012-02-17 12:06:33 +053016 $('.topbar').dropdown();
Rushabh Mehta865c00a2012-01-24 14:33:21 +053017 },
18 make: function() {
19 $('header').append('<div class="topbar">\
20 <div class="topbar-inner">\
21 <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"/>\
26 <ul class="nav secondary-nav">\
27 <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');
55 $parent_li.find('a:first').addClass('dropdown-toggle');
56 $parent_li.append('<ul class="dropdown-menu"></ul>');
57 }
58 item.route = item.url || item.custom_page;
59 $parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
60 <a href="#!%(route)s">%(label)s</a></li>', item))
Rushabh Mehta865c00a2012-01-24 14:33:21 +053061 }
62 }
63 }
64});
65
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053066
67// footer
68erpnext.Footer = Class.extend({
69 init: function() {
70 $('footer').html(repl('<div class="web-footer">\
71 <div class="web-footer-menu"><ul></ul></div>\
72 <div class="web-footer-address">%(address)s</div>\
73 <div class="web-footer-copyright">&copy; %(copyright)s</div>\
74 <div class="web-footer-powered">Powered by \
75 <a href="https://erpnext.com">erpnext.com</a></div>\
Rushabh Mehta7018b192012-02-02 13:42:28 +053076 </div>', wn.boot.website_settings));
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053077 this.make_items();
78 },
79 make_items: function() {
Rushabh Mehta7018b192012-02-02 13:42:28 +053080 var items = wn.boot.website_menus
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053081 for(var i=0;i<items.length;i++) {
82 var item = items[i];
83 if(!item.parent_label && item.parentfield=='footer_items') {
Rushabh Mehtaf35992f2012-02-07 10:39:17 +053084 item.route = item.url || item.custom_page;
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053085 $('.web-footer-menu ul').append(repl('<li><a href="#!%(route)s" \
86 data-label="%(label)s">%(label)s</a></li>', item))
87 }
88 }
89 }
90});
91
Rushabh Mehtaafaac602012-02-14 11:44:13 +053092$(document).bind('startup', function() {
93 erpnext.footer = new erpnext.Footer();
94 erpnext.topbar.topbar = new erpnext.topbar.TopBar();
95})