summaryrefslogtreecommitdiffstats
path: root/0.4.6/xohtml/xohtml.js
blob: 9e3d836d23ab52ff1014a07c4cb54e6e99d364f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
jQuery(function($) {
    setTimeout(function() {
        var $top = $("html body");
        $top.find('[class~="data"]').each(function() {
            var help = $(this).attr('data-help'),
                type = $(this).attr('data-type'),
                xpath = $(this).attr('data-xpath'),
                tag = $(this).attr('data-tag'),
                output = "";
            if (help) {
                output += "<b>Help</b>: " + help  + "<br/>";
            }
            if (type) {
                output += "<b>Type</b>: " + type  + "<br/>";
            }
            if (xpath) {
                output += "<div class='xpath-wrapper'>"
                    + "<a class='xpath-link' href='#'>"
                    + "show xpath</a><div class='xpath'>" 
                    + xpath + "</div></div><br/>";
            }
            if (output.length > 0) {
                output = "<div>" + output + "</div>";
            }

            $(this).qtip({
                content: {
                    title: "<b>" + tag + "</b>",
                    text: function () {
                        var div = $(output);
                        div.find(".xpath-link")
                        .click(function() {
                            var xpath = $(this).next();
                            if (xpath.is(":hidden")) {
                                xpath.show();
                                $(this).text("hide xpath");
                            } else {
                                xpath.hide();
                                $(this).text("show xpath");
                            }
                            return false;
                        });
                        return div;
                    }
                },
                hide: {
                    fixed: true,
                    delay: 300
                },
                style: "qtip-tipped"
            });
        });
    }, 0);
});
OpenPOWER on IntegriCloud