jdhenke / celestrium

A javascript library to visualize graphs.
MIT License
2 stars 1 forks source link

Context menu #80

Closed jhelbert closed 10 years ago

jhelbert commented 10 years ago

@haosharon I am running into problems with circular dependencies, Joe said you were dealing with something similar?

For me, the ContextMenu plugin needs to access the DataProvider instance (which would mean the dataprovider would need to be listed first in main.coffee), but DataProvider calls a ContextMenu function as well.

jdhenke commented 10 years ago

Why does the context menu need access to the data provider? It seems like the data provider should depend on the context menu and use a function to add itself to the context menu.

jdhenke commented 10 years ago

@jhelbert status on this?

jhelbert commented 10 years ago

Press 'm' to toggle the context menu on and off.

Two Context Menu sections are visible by default:

Selected Node Count Expand Nodes Button

Adding a New Section To The Context Menu (in main.coffee plugin init callback):

call ContextMenu.addMenuOption: (menuText, itemFunction, that) menuText- text that will appear itemFunction- function to be executed when context menu section is clicked that- instance of class (needed due to binding issues)

dataProvider = instances["local/ExampleDataProvider"] ContextMenu.addMenuOption "Expand Nodes", dataProvider.addRelatedNodes, dataProvider

jdhenke commented 10 years ago

i tried putting this in with the latest on celestrium-example's random page and on page load it just appears like this

image

pressing m just changes the location of the "nodes selected" message, it doesn't turn it off.

@jhelbert can you point me to a working implementation using this code?

jhelbert commented 10 years ago

here is a working implementation https://github.com/jhelbert/github_collaborators

pulling celestrium-example now to see why it isn't working there...