1273562SmarceljQuery(function($) {
2273562Smarcel    setTimeout(function() {
3273562Smarcel        var $top = $("html body");
4273562Smarcel        $top.find('[class~="data"]').each(function() {
5273562Smarcel            var help = $(this).attr('data-help'),
6273562Smarcel                type = $(this).attr('data-type'),
7273562Smarcel                xpath = $(this).attr('data-xpath'),
8273562Smarcel                tag = $(this).attr('data-tag'),
9273562Smarcel                output = "";
10273562Smarcel            if (help) {
11273562Smarcel                output += "<b>Help</b>: " + help  + "<br/>";
12273562Smarcel            }
13273562Smarcel            if (type) {
14273562Smarcel                output += "<b>Type</b>: " + type  + "<br/>";
15273562Smarcel            }
16273562Smarcel            if (xpath) {
17273562Smarcel                output += "<div class='xpath-wrapper'>"
18273562Smarcel                    + "<a class='xpath-link' href='#'>"
19273562Smarcel                    + "show xpath</a><div class='xpath'>"
20273562Smarcel                    + xpath + "</div></div><br/>";
21273562Smarcel            }
22273562Smarcel            if (output.length > 0) {
23273562Smarcel                output = "<div>" + output + "</div>";
24273562Smarcel            }
25273562Smarcel
26273562Smarcel            $(this).qtip({
27273562Smarcel                content: {
28273562Smarcel                    title: "<b>" + tag + "</b>",
29273562Smarcel                    text: function () {
30273562Smarcel                        var div = $(output);
31273562Smarcel                        div.find(".xpath-link")
32273562Smarcel                        .click(function() {
33273562Smarcel                            var xpath = $(this).next();
34273562Smarcel                            if (xpath.is(":hidden")) {
35273562Smarcel                                xpath.show();
36273562Smarcel                                $(this).text("hide xpath");
37273562Smarcel                            } else {
38273562Smarcel                                xpath.hide();
39273562Smarcel                                $(this).text("show xpath");
40273562Smarcel                            }
41273562Smarcel                            return false;
42273562Smarcel                        });
43273562Smarcel                        return div;
44273562Smarcel                    }
45273562Smarcel                },
46273562Smarcel                hide: {
47273562Smarcel                    fixed: true,
48273562Smarcel                    delay: 300
49273562Smarcel                },
50273562Smarcel                style: "qtip-tipped"
51273562Smarcel            });
52273562Smarcel        });
53273562Smarcel    }, 0);
54273562Smarcel});