Search in sources :

Example 1 with HelpNavigateEvent

use of org.rstudio.studio.client.workbench.views.help.events.HelpNavigateEvent in project rstudio by rstudio.

the class HelpPane method helpNavigated.

private void helpNavigated(Document doc) {
    NodeList<Element> elements = doc.getElementsByTagName("a");
    for (int i = 0; i < elements.getLength(); i++) {
        ElementEx a = (ElementEx) elements.getItem(i);
        String href = a.getAttribute("href", 2);
        if (href == null)
            continue;
        if (href.contains(":") || href.endsWith(".pdf")) {
            // external links
            AnchorElement aElement = a.cast();
            aElement.setTarget("_blank");
        } else {
            // Internal links need to be handled in JavaScript so that
            // they can participate in virtual session history. This
            // won't have any effect for right-click > Show in New Window
            // but that's a good thing.
            a.setAttribute("onclick", "window.parent.helpNavigate(this.href, " + (BrowseCap.isLinuxDesktop() || BrowseCap.isWindowsDesktop() ? "true" : "false") + "); return false");
        }
    }
    String effectiveTitle = getDocTitle(doc);
    title_.setText(effectiveTitle);
    this.fireEvent(new HelpNavigateEvent(doc.getURL(), effectiveTitle));
}
Also used : HelpNavigateEvent(org.rstudio.studio.client.workbench.views.help.events.HelpNavigateEvent) IFrameElementEx(org.rstudio.core.client.dom.IFrameElementEx) ElementEx(org.rstudio.core.client.dom.ElementEx)

Aggregations

ElementEx (org.rstudio.core.client.dom.ElementEx)1 IFrameElementEx (org.rstudio.core.client.dom.IFrameElementEx)1 HelpNavigateEvent (org.rstudio.studio.client.workbench.views.help.events.HelpNavigateEvent)1