Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wejs/we-plugin-menu
We.js plugin with menu feature
https://github.com/wejs/we-plugin-menu
nodejs wejs
Last synced: about 1 month ago
JSON representation
We.js plugin with menu feature
- Host: GitHub
- URL: https://github.com/wejs/we-plugin-menu
- Owner: wejs
- Created: 2014-11-17T19:43:04.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-09-21T02:23:28.000Z (over 4 years ago)
- Last Synced: 2024-11-10T01:55:07.485Z (about 1 month ago)
- Topics: nodejs, wejs
- Language: JavaScript
- Size: 70.3 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# We.js menu and links plugin
Add menu features to your project
[![Dependency Status](https://david-dm.org/wejs/we-plugin-menu.png)](https://david-dm.org/wejs/we-plugin-menu)
## Installation
```sh
we i we-plugin-menu
```## Menu class / prototype:
```js
// first create one menu
var menu = new we.class.Menu({
id: 'anOptionalId',
class: 'your-menu-class',
name: 'menuName',
// access is check if menu is rendered with we-menu helper
roles: ['authenticated'],
// show this menu only for users with the permission:
permission: 'can_do_something', // default: null
// add active class in partent links if curent page?
setParentLinkActiveClass: false // default false
});// Then add links:
//// Add links for add multiple links
menu.addLinks([
{
id: 'edit',
text: ' '+req.__('menu.user.edit'),
href: '/user/'+res.locals.user.id+'/edit',
class: null,
weight: 4,
name: 'menu.user.edit'
},
{
id: 'create',
text: ' '+req.__('menu.user.create'),
href: '/user/'+res.locals.user.id+'/criate',
class: null,
weight: 5,
name: 'menu.user.create'
},
);// or add one linke
menu.addLink({
id: 'edit',
text: ' '+req.__('menu.user.edit'),
href: '/user/'+res.locals.user.id+'/edit',
class: null,
weight: 4,
name: 'menu.user.edit'
});```
### For render your menu use:
```hbs
{{we-menu menu locals=this}}
```## Hooks and events:
Hooks and events avaible in this plugin
##### EVENT we-plugin-menu:after:set:menu:class
This event run in we.js bootstrap after load all plugins```sh
we.events.on('we-plugin-menu:after:set:menu:class', function (we){
// your code here ...
});
```##### HOOK we-plugin-menu:after:set:core:menus
This hook run in load context step of request/response```sh
we.hooks.on('we-plugin-menu:after:set:core:menus', function (data, done){
var req = data.req;
var res = data.res;// your code here ...
done();
});
```## How to install:
In one we.js project:
```sh
npm install we-plugin-menu --save
```#### NPM Info:
[![NPM](https://nodei.co/npm/we-plugin-menu.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/we-plugin-menu/)## License
Under [the MIT license](https://github.com/wejs/we/blob/master/LICENSE.md).