website css cleanups + dropdown in top toolbar

This commit is contained in:
Rushabh Mehta
2012-02-17 12:06:33 +05:30
parent 9670292543
commit aa848bee28
11 changed files with 82 additions and 28 deletions

View File

@@ -13,6 +13,7 @@ erpnext.topbar.TopBar = Class.extend({
this.make();
$('.brand').html(wn.boot.website_settings.brand_html);
this.make_items();
$('.topbar').dropdown();
},
make: function() {
$('header').append('<div class="topbar">\
@@ -31,13 +32,32 @@ erpnext.topbar.TopBar = Class.extend({
$('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page'))
},
make_items: function() {
var items = wn.boot.website_menus
var items = wn.boot.website_menus;
// parent labels
for(var i=0;i<items.length;i++) {
var item = items[i];
if(!item.parent_label && item.parentfield=='top_bar_items') {
item.route = item.url || item.custom_page;
$('header .nav:first').append(repl('<li><a href="#!%(route)s" \
data-label="%(label)s">%(label)s</a></li>', item))
$('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');
$parent_li.find('a:first').addClass('dropdown-toggle');
$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))
}
}
}