Description
A Cytoscape.js extension to provide context menu around elements and core instance.
Dependencies
Usage instructions
Download the library:
- via npm:
npm install cytoscape-context-menus
, - via bower:
bower install cytoscape-context-menus
, or - via direct download in the repository (probably from a tag).
require()
the library as appropriate for your project:
CommonJS:
var cytoscape = require('cytoscape');
var context-menus = require('cytoscape-context-menus');
context-menus( cytoscape );
AMD:
require(['cytoscape', 'cytoscape-context-menus'], function( cytoscape, context-menus ){
context-menus( cytoscape );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
Default Options
var options = {
menuItems: [
],
menuItemClasses: [
],
contextMenuClasses: [
]
};
API
cy.contextMenus(options)
To initialize with options.
cy.appendMenuItem(item)
Appends given menu item to the menu items list.
cy.appendMenuItems(items)
Appends menu items in the given list to the menu items list.
cy.removeMenuItem(itemID)
Removes the menu item with given ID.
cy.setTrailingDivider(itemID, status)
Sets whether the menuItem with given ID will have a following divider.
cy.insertBeforeMenuItem(item, existingItemID)
Inserts given item before the existingitem.
cy.moveBeforeOtherMenuItem(itemID, existingItemID)
Moves the item with given ID before the existingitem.
cy.disableMenuItem(itemID)
Disables the menu item with given ID.
cy.enableMenuItem(itemID)
Enables the menu item with given ID.
cy.destroyContextMenus()
Destroys the extension instance
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Set the version number environment variable:
export VERSION=1.2.3
- Publish:
gulp publish
- If publishing to bower for the first time, you'll need to run
bower register cytoscape-context-menus https://github.com/iVis-at-Bilkent/cytoscape.js-context-menus.git
Team