2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/client/desk/navbar.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-01-16 06:09:17 +00:00
const frappe = require('frappejs');
module.exports = class Navbar {
2018-01-23 08:00:29 +00:00
constructor({brand_label = 'Home'} = {}) {
2018-01-16 06:09:17 +00:00
Object.assign(this, arguments[0]);
2018-01-23 08:00:29 +00:00
this.items = {};
2018-02-09 12:55:55 +00:00
this.navbar = frappe.ui.add('div', 'navbar navbar-expand-md border-bottom navbar-dark bg-dark', document.querySelector('body'));
2018-01-23 08:00:29 +00:00
this.brand = frappe.ui.add('a', 'navbar-brand', this.navbar);
this.brand.href = '#';
this.brand.textContent = brand_label;
this.toggler = frappe.ui.add('button', 'navbar-toggler', this.navbar);
this.toggler.setAttribute('type', 'button');
this.toggler.setAttribute('data-toggle', 'collapse');
this.toggler.setAttribute('data-target', 'desk-navbar');
this.toggler.innerHTML = `<span class="navbar-toggler-icon"></span>`;
this.navbar_collapse = frappe.ui.add('div', 'collapse navbar-collapse', this.navbar);
this.navbar_collapse.setAttribute('id', 'desk-navbar');
this.nav = frappe.ui.add('ul', 'navbar-nav mr-auto', this.navbar_collapse);
}
2018-02-14 12:50:56 +00:00
addItem(label, route) {
2018-01-23 08:00:29 +00:00
let item = frappe.ui.add('li', 'nav-item', this.nav);
item.link = frappe.ui.add('a', 'nav-link', item);
item.link.textContent = label;
item.link.href = route;
this.items[label] = item;
return item;
}
add_dropdown(label) {
}
add_search() {
let form = frappe.ui.add('form', 'form-inline my-2 my-md-0', this.nav);
2018-01-16 06:09:17 +00:00
}
}