Skip to content

Commit

Permalink
Merge pull request #42 from iVis-at-Bilkent/unstable
Browse files Browse the repository at this point in the history
Merge unstable to master
  • Loading branch information
hasanbalci authored Mar 29, 2020
2 parents 0ad0e07 + 591dca9 commit fcb9a4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ A Cytoscape.js extension to provide context menu around elements and core instan

![Image of extension](example.png)

Please cite the following paper when using this extension:

U. Dogrusoz , A. Karacelik, I. Safarli, H. Balci, L. Dervishi, and M.C. Siper, "[Efficient methods and readily customizable libraries for managing complexity of large networks](https://doi.org/10.1371/journal.pone.0197238)", PLoS ONE, 13(5): e0197238, 2018.

## Demo

Click [here](https://ivis-at-bilkent.github.io/cytoscape.js-context-menus/demo.html) (simple) or [here](https://ivis-at-bilkent.github.io/cytoscape.js-context-menus/demo-customized.html) (customized) or [here](https://ivis-at-bilkent.github.io/cytoscape.js-context-menus/demo-show-hide-menuitem.html) (with different menu items) for demos
Click [here](https://raw.githack.com/iVis-at-Bilkent/cytoscape.js-context-menus/unstable/demo.html) (simple) or [here](https://raw.githack.com/iVis-at-Bilkent/cytoscape.js-context-menus/unstable/demo-customized.html) (customized) or [here](https://raw.githack.com/iVis-at-Bilkent/cytoscape.js-context-menus/unstable/demo-show-hide-menuitem.html) (with different menu items) for demos

## Dependencies

Expand Down Expand Up @@ -62,6 +66,9 @@ Plain HTML/JS has the extension registered for you automatically, because no `re
## Default Options
```js
var options = {
// Customize event to bring up the context menu
// Possible options https://js.cytoscape.org/#events/user-input-device-events
evtType: 'cxttap',
// List of initial menu items
menuItems: [/*
{
Expand Down
15 changes: 9 additions & 6 deletions cytoscape-context-menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
if( !cytoscape ){ return; } // can't register if cytoscape unspecified

var defaults = {
// Customize event to bring up the context menu
// Possible options https://js.cytoscape.org/#events/user-input-device-events
evtType: 'cxttap',
// List of initial menu items
menuItems: [
/*
Expand Down Expand Up @@ -158,9 +161,9 @@

var cxtfcn;
var cxtCoreFcn;

if(coreAsWell) {
cy.on('cxttap', cxtCoreFcn = function(event) {

cy.on(options.evtType, cxtCoreFcn = function(event) {
var target = event.target || event.cyTarget;
if( target != cy ) {
return;
Expand All @@ -171,7 +174,7 @@
}

if(selector) {
cy.on('cxttap', selector, cxtfcn = function(event) {
cy.on(options.evtType, selector, cxtfcn = function(event) {
_cxtfcn(event);
});
}
Expand Down Expand Up @@ -361,13 +364,13 @@
var selector = $component.data('selector');
var callOnClickFcn = $component.data('call-on-click-function');
var cxtCoreFcn = $component.data('cy-context-menus-cxtcorefcn');

if(cxtfcn) {
cy.off('cxttap', selector, cxtfcn);
cy.off(options.evtType, selector, cxtfcn);
}

if(cxtCoreFcn) {
cy.off('cxttap', cxtCoreFcn);
cy.off(options.evtType, cxtCoreFcn);
}

if(callOnClickFcn) {
Expand Down

0 comments on commit fcb9a4b

Please sign in to comment.