diff --git a/assets/script/calculator.js b/assets/script/calculator.js index 1fe07e9..20e9fc3 100644 --- a/assets/script/calculator.js +++ b/assets/script/calculator.js @@ -57,6 +57,14 @@ class Element { static getCartButton() { return document.querySelector('button.cart-value'); } + + /** + * Get the navbar brand element + * @returns {Element} + */ + static getNavbarBrand() { + return document.querySelector('nav a.navbar-brand'); + } } /** @@ -200,6 +208,11 @@ class Base64Image { }); } + /** + * Resize an image from a base64 string to a smaller size + * @param base64 + * @returns {Promise} + */ static imageResize(base64) { return new Promise((resolve, reject) => { const img = new Image(); @@ -244,6 +257,16 @@ class ProductManager { this.setExportFieldJsonValue(); this.registerSettingsFormEvents(); this.registerImportFormEvents(); + this.registerNavbarBrandToProductEvent(); + } + + /** + * Register the event for the navbar brand to switch to the products tab when clicked. + */ + registerNavbarBrandToProductEvent() { + Element.getNavbarBrand().addEventListener('click', () => { + TabManager.switchTab('products'); + }) } /**