Example #1
0
def on_morph_hover(frame, href, url, element, x, y):
    tooltip_config = TextTooltipConfig("", mod=None)
    types = url.getHostName().split(":", 1)
    if types[0] not in ("robinson", "Greek"):
        tooltipdata = _("Don't know how to open this morphology type:")
        tooltipdata += "<br>%s" % type
    else:
        value = url.getPath()
        module = biblemgr.get_module("Robinson")
        if not value:
            return

        tooltip_config.mod = module
        if not module:
            tooltipdata = _(
                "Module %s is not installed, so you "
                "cannot view details for this morphological code") % type
        else:
            tooltipdata = biblemgr.dictionary.GetReferenceFromMod(
                module, value)

    tooltip_config.text = tooltipdata
    frame.show_tooltip(tooltip_config)
Example #2
0
def on_sword_hover(frame, href, url, element, x, y):
    tooltip_config = TextTooltipConfig("", mod=None)

    module = url.getHostName()
    key = SW.URL.decode(url.getPath()).c_str()

    f = find_frame(module)
    if f:
        mod = biblemgr.get_module(module)
        mod.KeyText(key)

        ref = to_unicode(mod.getKeyText(), mod)
        ref = f.format_ref(mod, ref)
        text = to_unicode(mod.RenderText(), mod)

        tooltip_config.module = mod
        tooltip_config.text = (u"%s (%s)<br>%s" % (ref, mod.Name(), text))
    else:
        tooltip_config.text = (_("The book '%s' is not installed, "
                                 "so you cannot view "
                                 "details for this entry (%s)") %
                               (module, key.decode("utf8")))

    frame.show_tooltip(tooltip_config)
Example #3
0
    def on_hover(frame, href, url, element, x, y):
        tooltip_config = TextTooltipConfig("", mod=frame.mod)

        def SetText(text):
            tooltip_config.text = text

        if url.getHostName() != "passagestudy.jsp":
            return
        action = url.getParameterValue("action")
        bible = biblemgr.bible
        dictionary = biblemgr.dictionary

        # set the tooltip's reference to this reference in case there is a
        # scripture note inside the note
        # e.g. first note in Matthew 2:1 in calvin's commentaries
        if not hasattr(frame, "reference"):
            dprint(WARNING, "Frame didn't have reference", frame)
            frame.reference = ""

        frame.tooltip.html.reference = frame.reference

        if action == "showStrongs":
            frame.tooltip.show_strongs_ref(frame, href, url, element, x, y)
            return

        elif action == "showMorph":
            type = url.getParameterValue("type")  #Hebrew or greek
            types = type.split(":", 1)
            if types[0] not in ("robinson", "Greek"):
                tooltipdata = _("Don't know how to open this morphology type:")
                tooltipdata += "<br>%s" % type
            else:
                value = url.getParameterValue("value")  #strongs number
                module = biblemgr.get_module("Robinson")
                if not value:
                    return

                tooltip_config.mod = module
                if not module:
                    tooltipdata = _(
                        "Module %s is not installed, so you "
                        "cannot view details for this morphological code"
                    ) % type
                else:
                    tooltipdata = dictionary.GetReferenceFromMod(module, value)

            SetText(tooltipdata)

        elif (action == "showNote"):
            type = url.getParameterValue("type")  #x or n
            value = url.getParameterValue("value")  #number footnote in verse
            if ((not type) or (not value)):
                dprint(WARNING, "Not type or value in showNote", href)
                return
            module = biblemgr.get_module(url.getParameterValue("module"))
            passage = url.getParameterValue("passage")
            if not passage or not module:
                return

            tooltip_config.mod = module

            if type == "n":
                data = bible.GetFootnoteData(module, passage, value, "body")
                data = data or ""
                SetText(data)

            elif type == "x":
                #find reference list
                reflist = bible.GetFootnoteData(module, passage, value,
                                                "refList")
                #it seems note may be as following -
                #ESV: John.3.1.xref_i "See Luke 24:20"
                #treat as footnote then. not sure if this is intended behaviour
                #could lead to weird things
                if (not reflist):
                    data = bible.GetFootnoteData(module, passage, value,
                                                 "body")
                    SetText(data)
                else:
                    reflist = reflist.split("; ")
                    tooltip_config = BibleTooltipConfig(reflist)

        elif action == "showRef":
            type = url.getParameterValue("type")
            if type != "scripRef":
                dprint(WARNING, "unknown type for showRef", type, href)
                return
            value = url.getParameterValue("value")  #passage
            module = biblemgr.get_module(url.getParameterValue("module"))
            if not module:
                module = biblemgr.bible.mod

            if not value:
                return

            refs = value.split("; ")
            tooltip_config = BibleTooltipConfig(refs)

        elif action == "showMultiRef":
            values = url.getParameterValue("values")
            if not values:
                return

            references = [
                url.getParameterValue("val%s" % value)
                for value in range(int(values))
            ]
            tooltip_config = BibleTooltipConfig(references)

        elif action == "showImage":
            return
        else:
            dprint(WARNING, "Unknown action", action, href)
            return

        frame.show_tooltip(tooltip_config)