Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pageX and pageY properties to tree.contextmenu #29

Closed
ghost opened this issue Jun 4, 2012 · 11 comments
Closed

add pageX and pageY properties to tree.contextmenu #29

ghost opened this issue Jun 4, 2012 · 11 comments

Comments

@ghost
Copy link

ghost commented Jun 4, 2012

Hi, I've implemented (quite easily) lightweight but flexible context menu builder based on A Simple Good Looking Context Menu by Joe Walnes,
https://github.com/joewalnes/jquery-simple-context-menu.
I'm beginner in JavaScript, nevertheless, the only problem was to get the mouse pointer coordinates within bind tree.contextmenu event. After series of unsuccessful attempts I finally added to the core script tree.jquery.js (from download package) 2 strings after string #1014:

event.page_x = e.pageX;
event.page_y = e.pageY;

and it works!

Is it possible to add these properties in future releases?

@mbraak
Copy link
Owner

mbraak commented Jun 4, 2012

This sounds like a good idea. I will look into it.

@ghost
Copy link
Author

ghost commented Jun 4, 2012

Thank you!
jqTree is the first solution after half of dozen attempted by, where I have no troubles except the subj.
It is really lightweight but powerful and clearly documented. And it's reliable!

@mbraak
Copy link
Owner

mbraak commented Jun 5, 2012

The tree.contextmenu event has a the property click_event, which is the original contextmenu event.

This property is not documented yet, but I think you could use it to get the mouse coordinates:
event.click_event.pageX; event.click_event.pageY;

Please let me know if this works.

@ghost
Copy link
Author

ghost commented Jun 5, 2012

Awesome! It works :)
Maybe you will add this in the docs?
Thank you again.

@ghost
Copy link
Author

ghost commented Jun 5, 2012

Quick test:

xubuntu 12.04 FF, Chromium, Opera - ok
Win 7 IE9, FF, Opera, Safari, Google Chrome - ok
Win XP FF, Google Chrome - ok
all browsers are up-to-date.
XP IE8 - context menu script fail... no comments

@mbraak
Copy link
Owner

mbraak commented Jun 6, 2012

This is now added to the docs in the dev branch.

@mbraak mbraak closed this as completed Jun 6, 2012
@ghost
Copy link
Author

ghost commented Jun 21, 2012

Hi, Marco! Eventually I've got Context Menu working with jqTree. It can create, edit and delete folders and works without significant bugs :). Unfortunately, at the moment I have no skills in AJAX, so it interacts with server with page reload. (Todo!)

I'm not sure whether my code ready to be published on GitHub, so may I ask you, if you'll find a time, have a look at it here:
http://dl.dropbox.com/u/21872445/jqtree_contextmenu.zip
There are 4 files in zip archive:

  • modified jquery.contextmenu.js
  • jqtree_contextmenu.php - piece of code from view file with initialization of jqTree and Context Menu. It's huge!
    I put the last one in view file to have easy access to PHP variables that passed to javascript.
  • 2 screenshots

I guess, documents tree + context menu is interested not just me.
Suggestions and criticism are welcome!

Eugene

@mbraak
Copy link
Owner

mbraak commented Jun 22, 2012

I will have a look at it.

@mbraak
Copy link
Owner

mbraak commented Jun 23, 2012

Hello Eugene,

It looks very nice.

I would certainly add an html example, because not everybody uses php.

Marco

@ghost
Copy link
Author

ghost commented Jun 23, 2012

Hi Marco,
I really satisfied that result of my work is quite acceptable :)

What about html, I was hurrying to share working ContextMenu and just copy-pasted an existing code, so I would appreciate if you'll write an html example.

One string that I've commented to access browser context menu (jquery.contextmenu.js, str ## 88, 89):

menu.css({zIndex:1000001, left:left, top:top});
//.bind('contextmenu', function() { return false; });

should be uncommented in production version:

menu.css({zIndex:1000001, left:left, top:top})
.bind('contextmenu', function() { return false; });

Eugene

@mbraak
Copy link
Owner

mbraak commented Jun 23, 2012

Eugene,

I can't possibly do that. I really don't have the time available.

Marco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant