Preview tiddler on hover not hiding until I left-click

87 views
Skip to first unread message

kebi

unread,
Aug 11, 2020, 9:36:42 AM8/11/20
to tiddl...@googlegroups.com
Hello guys, today I installed the following plugin to my tiddlywiki file:

Whenever I hover a link it shows me a popup with the preview of the tiddler and works as expected.
The problem is that when I stop hovering a link it continues to show me the popup until I left-click.

Does anybody know what lines to add/change in order to hide the popup once the hovering is over?

Here's the current javascript code:

/*\
title: $:/plugins/tobibeer/preview/link.js
type: application/javascript
module-type: startup

Enhances the link widget for on-hover previews

@preserve
\*/
(function() {
    var e, t = require("$:/core/modules/widgets/link.js").link,
        i = t.prototype.render,
        o = t.prototype.handleClickEvent;
    t.prototype.render = function() {
        i.apply(this, arguments);
        var t = this,
            o = this.wiki,
            p = this.domNodes[0],
            r = o.getTiddler(t.to),
            n = "$:/plugins/tobibeer/preview/defaults/",
            u = "$:/temp/tobibeer/preview-",
            l = $tw.utils.parseKeyDescriptorTB(o.getTextReference(n + "keys", "").toUpperCase()),
            s = o.getTextReference(n + "delay").toUpperCase(),
            a = function(e) {
                var i = $tw.popup.popupInfo(e),
                    p = i.popupLevel;
                return o.getTextReference(u + p) && o.getTextReference(u + p + "-tiddler") === t.to ? null : i
            },
            f = function() {
                var i, r = a(p);
                if (r) {
                    i = r.popupLevel;
                    clearTimeout(t.previewTimeout);
                    $tw.popup.cancel(i);
                    i++;
                    o.setText(u + i + "-tiddler", "text", null, t.to);
                    if ($tw.popup.findPopup(u + i) === -1) {
                        setTimeout(function() {
                            $tw.popup.triggerPopup({
                                domNode: p,
                                title: u + i,
                                wiki: o
                            });
                            e = 0
                        }, 50)
                    }
                }
            },
            d = function() {
                var e, i, r = 1,
                    u = o.getTextReference(n + "not", "");
                if (u) {
                    $tw.utils.each(u.split(" "), function(e) {
                        var t = p;
                        while (t && r) {
                            if ($tw.utils.hasClass(t, e)) {
                                r = 0;
                                return false
                            }
                            t = t.parentNode
                        }
                    })
                }
                if (r) {
                    i = o.getTextReference(n + "exclude", "");
                    e = i ? o.filterTiddlers(i) : [];
                    if (e.indexOf(t.to) >= 0) {
                        r = 0
                    }
                }
                return r
            };
        s = s !== undefined ? parseInt(s) : null;
        if (s !== null && isNaN(s)) {
            s = 0
        }
        if (r) {
            $tw.utils.addClass(p, "tc-popup-handle");
            $tw.utils.addClass(p, "tc-popup-absolute");
            ["mouseover", "mouseout"].forEach(function(i) {
                p.addEventListener(i, function(o) {
                    var p = o || window.event;
                    if (i === "mouseover") {
                        if (d()) {
                            if (!p.keyCode) {
                                p.keyCode = 0
                            }
                            if ($tw.utils.checkKeyDescriptorTB(p, l)) {
                                if (!e) {
                                    e = 1;
                                    f()
                                }
                            } else if (s !== null) {
                                e = 0;
                                t.previewTimeout = setTimeout(f, s)
                            }
                        }
                    } else {
                        e = 0;
                        clearTimeout(t.previewTimeout)
                    }
                })
            })
        }
    };
    t.prototype.handleClickEvent = function() {
        o.apply(this, arguments);
        clearTimeout(this.previewTimeout);
        $tw.popup.cancel(Math.max(0, $tw.popup.popupInfo(this.domNodes[0]).popupLevel))
    }
})();

林东吴

unread,
Aug 11, 2020, 10:38:39 AM8/11/20
to tiddl...@googlegroups.com
Hi

This is a known error mentioned in the issue 

We proposed a fix in the issue and there is a PR for it 

Lin Onetwo

kebi <harut...@gmail.com> 于2020年8月11日周二 下午9:36写道:
Hello guys, today I installed the following plugin to my tiddlywiki file:

Whenever I hover a link it shows me a popun with the preview of the tiddler and works as expected.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1360bf91-b66a-4903-8aad-b7d9c8b22849o%40googlegroups.com.

harut...@gmail.com

unread,
Aug 11, 2020, 7:09:45 PM8/11/20
to TiddlyWiki
This is exactly what I was looking for, thank you so much Lin!
Message has been deleted

harut...@gmail.com

unread,
Aug 11, 2020, 8:25:44 PM8/11/20
to TiddlyWiki
Is there also a way to make the position of the popup fixed
When using the plugin Stories the popup only sticks to the story river on the left, so when I use the mouse wheel it disconnects from the link in the story river on the right.

Screen-Recording-0002-08-12-at-9.gif
Reply all
Reply to author
Forward
0 new messages