2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +00:00
books/client/desk/navbar.js

40 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-01-16 06:09:17 +00:00
const frappe = require('frappejs');
module.exports = class Navbar {
2018-02-19 16:41:10 +00:00
constructor({brand_label = 'Home'} = {}) {
Object.assign(this, arguments[0]);
this.items = {};
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
2018-03-08 13:31:22 +00:00
this.brand = frappe.ui.add('a', 'navbar-brand', this.navbar, brand_label);
2018-02-19 16:41:10 +00:00
this.brand.href = '#';
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
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>`;
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
this.navbar_collapse = frappe.ui.add('div', 'collapse navbar-collapse', this.navbar);
this.navbar_collapse.setAttribute('id', 'desk-navbar');
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
this.nav = frappe.ui.add('ul', 'navbar-nav mr-auto', this.navbar_collapse);
}
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
addItem(label, route) {
let item = frappe.ui.add('li', 'nav-item', this.nav);
2018-03-08 13:31:22 +00:00
item.link = frappe.ui.add('a', 'nav-link', item, label);
2018-02-19 16:41:10 +00:00
item.link.href = route;
this.items[label] = item;
return item;
}
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
add_dropdown(label) {
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
}
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
add_search() {
let form = frappe.ui.add('form', 'form-inline my-2 my-md-0', this.nav);
2018-01-23 08:00:29 +00:00
2018-02-19 16:41:10 +00:00
}
2018-01-16 06:09:17 +00:00
}