Skip to content

Commit

Permalink
Updated JSDoc and README
Browse files Browse the repository at this point in the history
  • Loading branch information
midstar committed Nov 27, 2021
1 parent cda711e commit 987b274
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
package-lock.json
package-lock.json
out
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ menu bar.

![screenshot](screenshot.jpg)

# How it works
# Examples

Checkout example.html
* [Standard example](https://midstar.github.io/jdmenubar/example.html) and
[source](https://github.com/midstar/jdmenubar/blob/main/example.html)
* [Customized example](https://midstar.github.io/jdmenubar/example_customized.html) and
[source](https://github.com/midstar/jdmenubar/blob/main/example_customized.html)

# Installation

Download jdmenubar.js and jdmenubar.css and include in your HTML or use
following lines in your HTML code:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/midstar/jdmenubar/jdmenubar.min.css" type="text/css">
<script src="https://cdn.jsdelivr.net/gh/midstar/jdmenubar/jdmenubar.min.js"></script>
```

# How to customize the look-and-feel

Expand Down
29 changes: 22 additions & 7 deletions jdmenubar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
/**
* @file jdmenubar javascript library.
* See {@link https://github.com/midstar/jdmenubar} for a full description.
* @copyright Joel Midstjärna 2021
* @license MIT
*/

// eslint-disable-next-line no-unused-vars
class MenuBar {
/** Class representing a menu bar.
*
*/
class MenuBar { // eslint-disable-line no-unused-vars

/**
* Create a menu bar.
* @param {Object} menuBarElement - HTML 'DIV' element where the menu bar shall be generated.
* @param {Object[]} menuItems - The items that represents the menu bar.
*/
constructor(menuBarElement, menuItems) {
this.menuBarElement = menuBarElement;
this.menuItems = menuItems;
Expand Down Expand Up @@ -168,10 +177,14 @@ class MenuBar {
myself.stateOpen = false;
}

// Get item with id (value if id property). Useful when updating items
// in the menu. Call the update() method afterwards to make the change
// have effect.
// Returns null if no such element exists.
/**
* Get item with id (value if id property). Useful when updating items
* in the menu. Call the update() method afterwards to make the change
* have effect in the menu bar.
*
* @param {string} id - Identity of the item
* @return {Object} - The menuItem object or null if not found
*/
getItemWithId(id) {
return this.getItemWithIdOf(id, this.menuItems);
}
Expand All @@ -193,7 +206,9 @@ class MenuBar {
return null;
}

// Update menu in case the item objects has changed
/**
* Update menu in case the menuItem objects has changed.
*/
update() {
// Remove all items
while (this.menuBarElement.firstChild) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.1"
"eslint-plugin-promise": "^5.1.1",
"jsdoc": "^3.6.7"
},
"devDependencies": {},
"scripts": {
Expand Down

0 comments on commit 987b274

Please sign in to comment.