before and target javascript options

Option to specify a "before" function to be called before the context menu is displayed (possibly aborting display or changing the menu.) 
"target" option to allow context menu target to be specified in javascript
Moved functions to class members