share-extras / media-viewers

Enhanced document previews for a range of different document and media types, plus a dashlet allowing any content item to be displayed on a site dashboard.
Apache License 2.0
29 stars 23 forks source link

Call to media viewers functions #45

Closed thbaymet closed 10 years ago

thbaymet commented 10 years ago

Hi,

I want to know how can I call to media viewers functions in my module to scroll the document to a specific page. Ex:

function myOwnEvent(pageNum) { Alfresco.WebPreview.prototype.Plugins.PdfJs.prototype._scrollToPage(pageNum); }

Is that possible ? Thanks,

wabson commented 10 years ago

You want the instance, not the prototype, so you you would want to do something like

Alfresco.util.ComponentManager.findFirst("Alfresco.WebPreview").plugin._scrollToPage(pageNum);

You'll probably want to wrap this with an if block which checks that the method is there before calling it, as other plugins used for other content types will not define it.

Also I should mention that _scrollToPage() is a private method, and so it is not guaranteed to be stable for you to use from outside. What exactly are you trying to achieve?

thbaymet commented 10 years ago

I've annotations on different pages that all of them are loaded while the document is not loaded totally. They are loaded in a sidebar. So I want to mediaviewer scroll to a specific page when I click on the annotation. For each annotation i ve it's page number; Which method of media-viewer will be nice to call it ?

wabson commented 10 years ago

It's not that you can't call that method, you can. Just that it's not intended to be called from outside. It's probably your only option.