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

Managing events and lastPageNumber #35

Closed
ghost opened this issue May 5, 2011 · 1 comment
Closed

Managing events and lastPageNumber #35

ghost opened this issue May 5, 2011 · 1 comment

Comments

@ghost
Copy link

ghost commented May 5, 2011

Hi,

I have a few questions regarding Monocle. I am new to Javascript so please forgive my newbie questions. Please let me know if these questions should be posted elsewhere.

1 – How can I get the value of lastPageNumber for the current chapter ? A code snippet would be appreciated. It seems it is not exposed through the API, but I could be wrong.

2 – My chapters have images alongside the text. When clicking on an image, a lightbox is displayed so that you can view the image in higher resolution using prettyphoto.
Basically, my img has a onclick function which calls the code to display the lightbox. The problem is of course that this also triggers a page change in Monocle.
I tried using the event from the onclick method and call stopPropagation and preventDefault, but this did not work. I believe the Monocle reader receives the event before my onclick.
Any suggestions?

3 – Similarly, I have an option to select a text quote from the book and email it to a friend. The Select Quote has a Boolean which is true when this mode is on, and false otherwise.
The problem again is that on the mouseup event, The Monocle change page occurs. Is there a way to temporarily turn off the listening of mouse events in the reader (while quotation mode is true) and re-enabling them after?
I have been scratching my head and I have no idea on how to accomplish this. A code snippet if possible would again be appreciated.

Thank you very much,

@joseph
Copy link
Owner

joseph commented May 6, 2011

  1. component.lastPageNumber()

If you don't already have a reference to the current component, you can use reader.getPlace().properties.component.

2/3) See Panels — they are described in the README. Marginal or IMode might do the job - otherwise you could roll your own. Also, take a look at the Stencil class. This detects interactions with <a> elements specifically, and passes through onclick events without triggering default click behaviour.

Please re-open if this answer doesn't address your question.

@joseph joseph closed this as completed May 6, 2011
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